feffery_utils_components 0.2.0-rc19 → 0.2.0-rc20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESCRIPTION +1 -1
- package/NAMESPACE +3 -0
- package/Project.toml +2 -2
- package/README.md +1 -1
- package/feffery_utils_components/FefferyEventListener.py +65 -0
- package/feffery_utils_components/FefferyListenElementSize.py +59 -0
- package/feffery_utils_components/FefferyListenHover.py +56 -0
- package/feffery_utils_components/FefferyListenScroll.py +40 -5
- package/feffery_utils_components/_imports_.py +6 -0
- package/feffery_utils_components/alias.py +20 -8
- package/feffery_utils_components/async-feffery_animated_3d_background_p5.js +1 -1
- package/feffery_utils_components/async-feffery_animated_3d_background_three.js +1 -1
- package/feffery_utils_components/async-feffery_animated_image.js +1 -1
- package/feffery_utils_components/async-feffery_aplayer.js +1 -1
- package/feffery_utils_components/async-feffery_auto_animate.js +1 -1
- package/feffery_utils_components/async-feffery_auto_fit.js +2 -2
- package/feffery_utils_components/async-feffery_burger.js +1 -1
- package/feffery_utils_components/async-feffery_captcha.js +1 -1
- package/feffery_utils_components/async-feffery_color_pickers.js +1 -1
- package/feffery_utils_components/async-feffery_dom2image.js +1 -1
- package/feffery_utils_components/async-feffery_dplayer.js +1 -1
- package/feffery_utils_components/async-feffery_emoji_picker.js +1 -1
- package/feffery_utils_components/async-feffery_excel_preview.js +1 -1
- package/feffery_utils_components/async-feffery_extra_spinner.js +1 -1
- package/feffery_utils_components/async-feffery_fancy_button.js +1 -1
- package/feffery_utils_components/async-feffery_grid.js +1 -1
- package/feffery_utils_components/async-feffery_http_requests.js +1 -1
- package/feffery_utils_components/async-feffery_image_cropper.js +1 -1
- package/feffery_utils_components/async-feffery_json_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_local_large_storage.js +1 -1
- package/feffery_utils_components/async-feffery_markdown_editor.js +2 -2
- package/feffery_utils_components/async-feffery_motion.js +1 -1
- package/feffery_utils_components/async-feffery_music_player.js +1 -1
- package/feffery_utils_components/async-feffery_photo_sphere_viewer.js +1 -1
- package/feffery_utils_components/async-feffery_resizable.js +1 -1
- package/feffery_utils_components/async-feffery_rich_text_editor.js +2 -2
- package/feffery_utils_components/async-feffery_rnd.js +1 -1
- package/feffery_utils_components/async-feffery_seamless_scroll.js +1 -1
- package/feffery_utils_components/async-feffery_shortcut_panel.js +1 -1
- package/feffery_utils_components/async-feffery_slider_captcha.js +1 -1
- package/feffery_utils_components/async-feffery_sortable.js +1 -1
- package/feffery_utils_components/async-feffery_vditor.js +1 -1
- package/feffery_utils_components/async-feffery_word_preview.js +1 -1
- package/feffery_utils_components/async-fuc-shared.js +3 -3
- package/feffery_utils_components/feffery_utils_components.min.js +7 -7
- package/feffery_utils_components/metadata.json +302 -1
- package/feffery_utils_components/package-info.json +1 -1
- package/package.json +1 -1
- package/src/lib/components/FefferyEventSource.react.js +2 -0
- package/src/lib/components/listeners/FefferyEventListener.react.js +97 -0
- package/src/lib/components/listeners/FefferyListenElementSize.react.js +86 -0
- package/src/lib/components/listeners/FefferyListenHover.js +75 -0
- package/src/lib/components/listeners/FefferyListenScroll.react.js +91 -10
- package/src/lib/index.js +7 -1
- package/usage.py +17 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(window.webpackJsonpfeffery_utils_components=window.webpackJsonpfeffery_utils_components||[]).push([[0],{548:function(d,e,t){"use strict";t.r(e),t.d(e,"ACESFilmicToneMapping",function(){return Ee}),t.d(e,"AddEquation",function(){return ee}),t.d(e,"AddOperation",function(){return B}),t.d(e,"AdditiveAnimationBlendMode",function(){return br}),t.d(e,"AdditiveBlending",function(){return X}),t.d(e,"AlphaFormat",function(){return dt}),t.d(e,"AlwaysDepth",function(){return ve}),t.d(e,"AlwaysStencilFunc",function(){return Jr}),t.d(e,"AmbientLight",function(){return qc}),t.d(e,"AmbientLightProbe",function(){return cd}),t.d(e,"AnimationClip",function(){return _c}),t.d(e,"AnimationLoader",function(){return Ac}),t.d(e,"AnimationMixer",function(){return Gd}),t.d(e,"AnimationObjectGroup",function(){return Ud}),t.d(e,"AnimationUtils",function(){return p}),t.d(e,"ArcCurve",function(){return Jh}),t.d(e,"ArrayCamera",function(){return El}),t.d(e,"ArrowHelper",function(){return Af}),t.d(e,"Audio",function(){return Td}),t.d(e,"AudioAnalyser",function(){return Ld}),t.d(e,"AudioContext",function(){return ld}),t.d(e,"AudioListener",function(){return bd}),t.d(e,"AudioLoader",function(){return hd}),t.d(e,"AxesHelper",function(){return Lf}),t.d(e,"AxisHelper",function(){return ip}),t.d(e,"BackSide",function(){return Ae}),t.d(e,"BasicDepthPacking",function(){return Ir}),t.d(e,"BasicShadowMap",function(){return R}),t.d(e,"BinaryTextureLoader",function(){return lp}),t.d(e,"Bone",function(){return oh}),t.d(e,"BooleanKeyframeTrack",function(){return fc}),t.d(e,"BoundingBoxHelper",function(){return np}),t.d(e,"Box2",function(){return Xd}),t.d(e,"Box3",function(){return Ni}),t.d(e,"Box3Helper",function(){return Tf}),t.d(e,"BoxBufferGeometry",function(){return ks}),t.d(e,"BoxGeometry",function(){return ks}),t.d(e,"BoxHelper",function(){return bf}),t.d(e,"BufferAttribute",function(){return w}),t.d(e,"BufferGeometry",function(){return S}),t.d(e,"BufferGeometryLoader",function(){return td}),t.d(e,"ByteType",function(){return tt}),t.d(e,"Cache",function(){return bc}),t.d(e,"Camera",function(){return Bs}),t.d(e,"CameraHelper",function(){return xf}),t.d(e,"CanvasRenderer",function(){return up}),t.d(e,"CanvasTexture",function(){return Nh}),t.d(e,"CatmullRomCurve3",function(){return iu}),t.d(e,"CineonToneMapping",function(){return W}),t.d(e,"CircleBufferGeometry",function(){return Bh}),t.d(e,"CircleGeometry",function(){return Bh}),t.d(e,"ClampToEdgeWrapping",function(){return Le}),t.d(e,"Clock",function(){return md}),t.d(e,"Color",function(){return g}),t.d(e,"ColorKeyframeTrack",function(){return pc}),t.d(e,"CompressedTexture",function(){return Fh}),t.d(e,"CompressedTextureLoader",function(){return Lc}),t.d(e,"ConeBufferGeometry",function(){return Hh}),t.d(e,"ConeGeometry",function(){return Hh}),t.d(e,"CubeCamera",function(){return Gs}),t.d(e,"CubeReflectionMapping",function(){return Ue}),t.d(e,"CubeRefractionMapping",function(){return Be}),t.d(e,"CubeTexture",function(){return Hs}),t.d(e,"CubeTextureLoader",function(){return Cc}),t.d(e,"CubeUVReflectionMapping",function(){return ze}),t.d(e,"CubeUVRefractionMapping",function(){return Ve}),t.d(e,"CubicBezierCurve",function(){return ou}),t.d(e,"CubicBezierCurve3",function(){return lu}),t.d(e,"CubicInterpolant",function(){return hc}),t.d(e,"CullFaceBack",function(){return Y}),t.d(e,"CullFaceFront",function(){return $}),t.d(e,"CullFaceFrontBack",function(){return L}),t.d(e,"CullFaceNone",function(){return j}),t.d(e,"Curve",function(){return Kh}),t.d(e,"CurvePath",function(){return mu}),t.d(e,"CustomBlending",function(){return Q}),t.d(e,"CustomToneMapping",function(){return we}),t.d(e,"CylinderBufferGeometry",function(){return Gh}),t.d(e,"CylinderGeometry",function(){return Gh}),t.d(e,"Cylindrical",function(){return qd}),t.d(e,"DataTexture",function(){return lh}),t.d(e,"DataTexture2DArray",function(){return Pa}),t.d(e,"DataTexture3D",function(){return Ba}),t.d(e,"DataTextureLoader",function(){return Dc}),t.d(e,"DataUtils",function(){return If}),t.d(e,"DecrementStencilOp",function(){return Gr}),t.d(e,"DecrementWrapStencilOp",function(){return zr}),t.d(e,"DefaultLoadingManager",function(){return Sc}),t.d(e,"DepthFormat",function(){return vt}),t.d(e,"DepthStencilFormat",function(){return yt}),t.d(e,"DepthTexture",function(){return Uh}),t.d(e,"DirectionalLight",function(){return $c}),t.d(e,"DirectionalLightHelper",function(){return vf}),t.d(e,"DiscreteInterpolant",function(){return cc}),t.d(e,"DodecahedronBufferGeometry",function(){return Vh}),t.d(e,"DodecahedronGeometry",function(){return Vh}),t.d(e,"DoubleSide",function(){return Fe}),t.d(e,"DstAlphaFactor",function(){return ce}),t.d(e,"DstColorFactor",function(){return fe}),t.d(e,"DynamicBufferAttribute",function(){return $f}),t.d(e,"DynamicCopyUsage",function(){return si}),t.d(e,"DynamicDrawUsage",function(){return Qr}),t.d(e,"DynamicReadUsage",function(){return ri}),t.d(e,"EdgesGeometry",function(){return qh}),t.d(e,"EdgesHelper",function(){return sp}),t.d(e,"EllipseCurve",function(){return Xh}),t.d(e,"EqualDepth",function(){return _e}),t.d(e,"EqualStencilFunc",function(){return Yr}),t.d(e,"EquirectangularReflectionMapping",function(){return Ge}),t.d(e,"EquirectangularRefractionMapping",function(){return He}),t.d(e,"Euler",function(){return bn}),t.d(e,"EventDispatcher",function(){return hi}),t.d(e,"ExtrudeBufferGeometry",function(){return Nu}),t.d(e,"ExtrudeGeometry",function(){return Nu}),t.d(e,"FaceColors",function(){return Ff}),t.d(e,"FileLoader",function(){return Mc}),t.d(e,"FlatShading",function(){return P}),t.d(e,"Float16BufferAttribute",function(){return ls}),t.d(e,"Float32Attribute",function(){return tp}),t.d(e,"Float32BufferAttribute",function(){return V}),t.d(e,"Float64Attribute",function(){return rp}),t.d(e,"Float64BufferAttribute",function(){return hs}),t.d(e,"FloatType",function(){return at}),t.d(e,"Fog",function(){return Il}),t.d(e,"FogExp2",function(){return Dl}),t.d(e,"Font",function(){return vp}),t.d(e,"FontLoader",function(){return gp}),t.d(e,"FrontSide",function(){return Oe}),t.d(e,"Frustum",function(){return Ks}),t.d(e,"GLBufferAttribute",function(){return Vd}),t.d(e,"GLSL1",function(){return oi}),t.d(e,"GLSL3",function(){return li}),t.d(e,"GammaEncoding",function(){return Mr}),t.d(e,"GreaterDepth",function(){return Te}),t.d(e,"GreaterEqualDepth",function(){return be}),t.d(e,"GreaterEqualStencilFunc",function(){return Xr}),t.d(e,"GreaterStencilFunc",function(){return qr}),t.d(e,"GridHelper",function(){return df}),t.d(e,"Group",function(){return wl}),t.d(e,"HalfFloatType",function(){return ot}),t.d(e,"HemisphereLight",function(){return kc}),t.d(e,"HemisphereLightHelper",function(){return cf}),t.d(e,"HemisphereLightProbe",function(){return ud}),t.d(e,"IcosahedronBufferGeometry",function(){return Bu}),t.d(e,"IcosahedronGeometry",function(){return Bu}),t.d(e,"ImageBitmapLoader",function(){return ad}),t.d(e,"ImageLoader",function(){return Rc}),t.d(e,"ImageUtils",function(){return Li}),t.d(e,"ImmediateRenderObject",function(){return yp}),t.d(e,"IncrementStencilOp",function(){return Br}),t.d(e,"IncrementWrapStencilOp",function(){return Hr}),t.d(e,"InstancedBufferAttribute",function(){return dh}),t.d(e,"InstancedBufferGeometry",function(){return ed}),t.d(e,"InstancedInterleavedBuffer",function(){return zd}),t.d(e,"InstancedMesh",function(){return vh}),t.d(e,"Int16Attribute",function(){return Jf}),t.d(e,"Int16BufferAttribute",function(){return ns}),t.d(e,"Int32Attribute",function(){return Qf}),t.d(e,"Int32BufferAttribute",function(){return as}),t.d(e,"Int8Attribute",function(){return qf}),t.d(e,"Int8BufferAttribute",function(){return ts}),t.d(e,"IntType",function(){return nt}),t.d(e,"InterleavedBuffer",function(){return kl}),t.d(e,"InterleavedBufferAttribute",function(){return Ol}),t.d(e,"Interpolant",function(){return lc}),t.d(e,"InterpolateDiscrete",function(){return pr}),t.d(e,"InterpolateLinear",function(){return mr}),t.d(e,"InterpolateSmooth",function(){return gr}),t.d(e,"InvertStencilOp",function(){return Vr}),t.d(e,"JSONLoader",function(){return cp}),t.d(e,"KeepStencilOp",function(){return Nr}),t.d(e,"KeyframeTrack",function(){return dc}),t.d(e,"LOD",function(){return eh}),t.d(e,"LatheBufferGeometry",function(){return Gu}),t.d(e,"LatheGeometry",function(){return Gu}),t.d(e,"Layers",function(){return Tn}),t.d(e,"LensFlare",function(){return fp}),t.d(e,"LessDepth",function(){return ye}),t.d(e,"LessEqualDepth",function(){return xe}),t.d(e,"LessEqualStencilFunc",function(){return $r}),t.d(e,"LessStencilFunc",function(){return jr}),t.d(e,"Light",function(){return Pc}),t.d(e,"LightProbe",function(){return Jc}),t.d(e,"Line",function(){return Sh}),t.d(e,"Line3",function(){return Qd}),t.d(e,"LineBasicMaterial",function(){return y}),t.d(e,"LineCurve",function(){return hu}),t.d(e,"LineCurve3",function(){return uu}),t.d(e,"LineDashedMaterial",function(){return ac}),t.d(e,"LineLoop",function(){return Ah}),t.d(e,"LinePieces",function(){return kf}),t.d(e,"LineSegments",function(){return Mh}),t.d(e,"LineStrip",function(){return Pf}),t.d(e,"LinearEncoding",function(){return De}),t.d(e,"LinearFilter",function(){return U}),t.d(e,"LinearInterpolant",function(){return uc}),t.d(e,"LinearMipMapLinearFilter",function(){return Qe}),t.d(e,"LinearMipMapNearestFilter",function(){return Je}),t.d(e,"LinearMipmapLinearFilter",function(){return Ze}),t.d(e,"LinearMipmapNearestFilter",function(){return Xe}),t.d(e,"LinearToneMapping",function(){return G}),t.d(e,"Loader",function(){return Ec}),t.d(e,"LoaderUtils",function(){return Qc}),t.d(e,"LoadingManager",function(){return Tc}),t.d(e,"LogLuvEncoding",function(){return Lr}),t.d(e,"LoopOnce",function(){return cr}),t.d(e,"LoopPingPong",function(){return fr}),t.d(e,"LoopRepeat",function(){return dr}),t.d(e,"LuminanceAlphaFormat",function(){return mt}),t.d(e,"LuminanceFormat",function(){return pt}),t.d(e,"MOUSE",function(){return b}),t.d(e,"Material",function(){return r}),t.d(e,"MaterialLoader",function(){return Zc}),t.d(e,"Math",function(){return bi}),t.d(e,"MathUtils",function(){return bi}),t.d(e,"Matrix3",function(){return v}),t.d(e,"Matrix4",function(){return ke}),t.d(e,"MaxEquation",function(){return ne}),t.d(e,"Mesh",function(){return E}),t.d(e,"MeshBasicMaterial",function(){return Qn}),t.d(e,"MeshDepthMaterial",function(){return yl}),t.d(e,"MeshDistanceMaterial",function(){return xl}),t.d(e,"MeshFaceMaterial",function(){return Uf}),t.d(e,"MeshLambertMaterial",function(){return nc}),t.d(e,"MeshMatcapMaterial",function(){return sc}),t.d(e,"MeshNormalMaterial",function(){return ic}),t.d(e,"MeshPhongMaterial",function(){return tc}),t.d(e,"MeshPhysicalMaterial",function(){return ec}),t.d(e,"MeshStandardMaterial",function(){return Qu}),t.d(e,"MeshToonMaterial",function(){return rc}),t.d(e,"MinEquation",function(){return ie}),t.d(e,"MirroredRepeatWrapping",function(){return je}),t.d(e,"MixOperation",function(){return F}),t.d(e,"MultiMaterial",function(){return Bf}),t.d(e,"MultiplyBlending",function(){return Z}),t.d(e,"MultiplyOperation",function(){return O}),t.d(e,"NearestFilter",function(){return Re}),t.d(e,"NearestMipMapLinearFilter",function(){return Ke}),t.d(e,"NearestMipMapNearestFilter",function(){return $e}),t.d(e,"NearestMipmapLinearFilter",function(){return qe}),t.d(e,"NearestMipmapNearestFilter",function(){return Ye}),t.d(e,"NeverDepth",function(){return ge}),t.d(e,"NeverStencilFunc",function(){return Wr}),t.d(e,"NoBlending",function(){return q}),t.d(e,"NoColors",function(){return Of}),t.d(e,"NoToneMapping",function(){return Ne}),t.d(e,"NormalAnimationBlendMode",function(){return _r}),t.d(e,"NormalBlending",function(){return K}),t.d(e,"NotEqualDepth",function(){return Se}),t.d(e,"NotEqualStencilFunc",function(){return Kr}),t.d(e,"NumberKeyframeTrack",function(){return mc}),t.d(e,"Object3D",function(){return c}),t.d(e,"ObjectLoader",function(){return rd}),t.d(e,"ObjectSpaceNormalMap",function(){return Or}),t.d(e,"OctahedronBufferGeometry",function(){return Hu}),t.d(e,"OctahedronGeometry",function(){return Hu}),t.d(e,"OneFactor",function(){return ae}),t.d(e,"OneMinusDstAlphaFactor",function(){return de}),t.d(e,"OneMinusDstColorFactor",function(){return pe}),t.d(e,"OneMinusSrcAlphaFactor",function(){return ue}),t.d(e,"OneMinusSrcColorFactor",function(){return le}),t.d(e,"OrthographicCamera",function(){return aa}),t.d(e,"PCFShadowMap",function(){return C}),t.d(e,"PCFSoftShadowMap",function(){return D}),t.d(e,"PMREMGenerator",function(){return ba}),t.d(e,"ParametricGeometry",function(){return pp}),t.d(e,"Particle",function(){return Hf}),t.d(e,"ParticleBasicMaterial",function(){return Wf}),t.d(e,"ParticleSystem",function(){return zf}),t.d(e,"ParticleSystemMaterial",function(){return jf}),t.d(e,"Path",function(){return gu}),t.d(e,"PerspectiveCamera",function(){return N}),t.d(e,"Plane",function(){return Ys}),t.d(e,"PlaneBufferGeometry",function(){return Zs}),t.d(e,"PlaneGeometry",function(){return Zs}),t.d(e,"PlaneHelper",function(){return Sf}),t.d(e,"PointCloud",function(){return Gf}),t.d(e,"PointCloudMaterial",function(){return Vf}),t.d(e,"PointLight",function(){return jc}),t.d(e,"PointLightHelper",function(){return of}),t.d(e,"Points",function(){return Ph}),t.d(e,"PointsMaterial",function(){return Lh}),t.d(e,"PolarGridHelper",function(){return ff}),t.d(e,"PolyhedronBufferGeometry",function(){return zh}),t.d(e,"PolyhedronGeometry",function(){return zh}),t.d(e,"PositionalAudio",function(){return Ad}),t.d(e,"PropertyBinding",function(){return x}),t.d(e,"PropertyMixer",function(){return Rd}),t.d(e,"QuadraticBezierCurve",function(){return cu}),t.d(e,"QuadraticBezierCurve3",function(){return du}),t.d(e,"Quaternion",function(){return ki}),t.d(e,"QuaternionKeyframeTrack",function(){return vc}),t.d(e,"QuaternionLinearInterpolant",function(){return gc}),t.d(e,"REVISION",function(){return _}),t.d(e,"RGBADepthPacking",function(){return Pr}),t.d(e,"RGBAFormat",function(){return Ce}),t.d(e,"RGBAIntegerFormat",function(){return Et}),t.d(e,"RGBA_ASTC_10x10_Format",function(){return $t}),t.d(e,"RGBA_ASTC_10x5_Format",function(){return Wt}),t.d(e,"RGBA_ASTC_10x6_Format",function(){return jt}),t.d(e,"RGBA_ASTC_10x8_Format",function(){return Yt}),t.d(e,"RGBA_ASTC_12x10_Format",function(){return qt}),t.d(e,"RGBA_ASTC_12x12_Format",function(){return Kt}),t.d(e,"RGBA_ASTC_4x4_Format",function(){return Ft}),t.d(e,"RGBA_ASTC_5x4_Format",function(){return Nt}),t.d(e,"RGBA_ASTC_5x5_Format",function(){return Ut}),t.d(e,"RGBA_ASTC_6x5_Format",function(){return Bt}),t.d(e,"RGBA_ASTC_6x6_Format",function(){return Gt}),t.d(e,"RGBA_ASTC_8x5_Format",function(){return Ht}),t.d(e,"RGBA_ASTC_8x6_Format",function(){return zt}),t.d(e,"RGBA_ASTC_8x8_Format",function(){return Vt}),t.d(e,"RGBA_BPTC_Format",function(){return Xt}),t.d(e,"RGBA_ETC2_EAC_Format",function(){return Ot}),t.d(e,"RGBA_PVRTC_2BPPV1_Format",function(){return It}),t.d(e,"RGBA_PVRTC_4BPPV1_Format",function(){return Dt}),t.d(e,"RGBA_S3TC_DXT1_Format",function(){return Mt}),t.d(e,"RGBA_S3TC_DXT3_Format",function(){return At}),t.d(e,"RGBA_S3TC_DXT5_Format",function(){return Lt}),t.d(e,"RGBDEncoding",function(){return Dr}),t.d(e,"RGBEEncoding",function(){return Ar}),t.d(e,"RGBEFormat",function(){return gt}),t.d(e,"RGBFormat",function(){return ft}),t.d(e,"RGBIntegerFormat",function(){return St}),t.d(e,"RGBM16Encoding",function(){return Cr}),t.d(e,"RGBM7Encoding",function(){return Rr}),t.d(e,"RGB_ETC1_Format",function(){return Pt}),t.d(e,"RGB_ETC2_Format",function(){return kt}),t.d(e,"RGB_PVRTC_2BPPV1_Format",function(){return Ct}),t.d(e,"RGB_PVRTC_4BPPV1_Format",function(){return Rt}),t.d(e,"RGB_S3TC_DXT1_Format",function(){return wt}),t.d(e,"RGFormat",function(){return bt}),t.d(e,"RGIntegerFormat",function(){return Tt}),t.d(e,"RawShaderMaterial",function(){return oa}),t.d(e,"Ray",function(){return cn}),t.d(e,"Raycaster",function(){return Wd}),t.d(e,"RectAreaLight",function(){return Kc}),t.d(e,"RedFormat",function(){return xt}),t.d(e,"RedIntegerFormat",function(){return _t}),t.d(e,"ReinhardToneMapping",function(){return H}),t.d(e,"RepeatWrapping",function(){return We}),t.d(e,"ReplaceStencilOp",function(){return Ur}),t.d(e,"ReverseSubtractEquation",function(){return re}),t.d(e,"RingBufferGeometry",function(){return zu}),t.d(e,"RingGeometry",function(){return zu}),t.d(e,"SRGB8_ALPHA8_ASTC_10x10_Format",function(){return lr}),t.d(e,"SRGB8_ALPHA8_ASTC_10x5_Format",function(){return sr}),t.d(e,"SRGB8_ALPHA8_ASTC_10x6_Format",function(){return ar}),t.d(e,"SRGB8_ALPHA8_ASTC_10x8_Format",function(){return or}),t.d(e,"SRGB8_ALPHA8_ASTC_12x10_Format",function(){return hr}),t.d(e,"SRGB8_ALPHA8_ASTC_12x12_Format",function(){return ur}),t.d(e,"SRGB8_ALPHA8_ASTC_4x4_Format",function(){return Jt}),t.d(e,"SRGB8_ALPHA8_ASTC_5x4_Format",function(){return Zt}),t.d(e,"SRGB8_ALPHA8_ASTC_5x5_Format",function(){return Qt}),t.d(e,"SRGB8_ALPHA8_ASTC_6x5_Format",function(){return er}),t.d(e,"SRGB8_ALPHA8_ASTC_6x6_Format",function(){return tr}),t.d(e,"SRGB8_ALPHA8_ASTC_8x5_Format",function(){return rr}),t.d(e,"SRGB8_ALPHA8_ASTC_8x6_Format",function(){return ir}),t.d(e,"SRGB8_ALPHA8_ASTC_8x8_Format",function(){return nr}),t.d(e,"Scene",function(){return Pl}),t.d(e,"SceneUtils",function(){return dp}),t.d(e,"ShaderChunk",function(){return M}),t.d(e,"ShaderLib",function(){return Qs}),t.d(e,"ShaderMaterial",function(){return Us}),t.d(e,"ShadowMaterial",function(){return Zu}),t.d(e,"Shape",function(){return vu}),t.d(e,"ShapeBufferGeometry",function(){return Vu}),t.d(e,"ShapeGeometry",function(){return Vu}),t.d(e,"ShapePath",function(){return Rf}),t.d(e,"ShapeUtils",function(){return ku}),t.d(e,"ShortType",function(){return rt}),t.d(e,"Skeleton",function(){return ch}),t.d(e,"SkeletonHelper",function(){return af}),t.d(e,"SkinnedMesh",function(){return ah}),t.d(e,"SmoothShading",function(){return k}),t.d(e,"Sphere",function(){return rn}),t.d(e,"SphereBufferGeometry",function(){return Wu}),t.d(e,"SphereGeometry",function(){return Wu}),t.d(e,"Spherical",function(){return $d}),t.d(e,"SphericalHarmonics3",function(){return Xc}),t.d(e,"SplineCurve",function(){return fu}),t.d(e,"SpotLight",function(){return Gc}),t.d(e,"SpotLightHelper",function(){return tf}),t.d(e,"Sprite",function(){return Xl}),t.d(e,"SpriteMaterial",function(){return Fl}),t.d(e,"SrcAlphaFactor",function(){return he}),t.d(e,"SrcAlphaSaturateFactor",function(){return me}),t.d(e,"SrcColorFactor",function(){return oe}),t.d(e,"StaticCopyUsage",function(){return ni}),t.d(e,"StaticDrawUsage",function(){return Zr}),t.d(e,"StaticReadUsage",function(){return ti}),t.d(e,"StereoCamera",function(){return pd}),t.d(e,"StreamCopyUsage",function(){return ai}),t.d(e,"StreamDrawUsage",function(){return ei}),t.d(e,"StreamReadUsage",function(){return ii}),t.d(e,"StringKeyframeTrack",function(){return yc}),t.d(e,"SubtractEquation",function(){return te}),t.d(e,"SubtractiveBlending",function(){return J}),t.d(e,"TOUCH",function(){return T}),t.d(e,"TangentSpaceNormalMap",function(){return kr}),t.d(e,"TetrahedronBufferGeometry",function(){return ju}),t.d(e,"TetrahedronGeometry",function(){return ju}),t.d(e,"TextGeometry",function(){return mp}),t.d(e,"Texture",function(){return u}),t.d(e,"TextureLoader",function(){return Ic}),t.d(e,"TorusBufferGeometry",function(){return Yu}),t.d(e,"TorusGeometry",function(){return Yu}),t.d(e,"TorusKnotBufferGeometry",function(){return $u}),t.d(e,"TorusKnotGeometry",function(){return $u}),t.d(e,"Triangle",function(){return f}),t.d(e,"TriangleFanDrawMode",function(){return Er}),t.d(e,"TriangleStripDrawMode",function(){return Sr}),t.d(e,"TrianglesDrawMode",function(){return Tr}),t.d(e,"TubeBufferGeometry",function(){return qu}),t.d(e,"TubeGeometry",function(){return qu}),t.d(e,"UVMapping",function(){return Me}),t.d(e,"Uint16Attribute",function(){return Zf}),t.d(e,"Uint16BufferAttribute",function(){return ss}),t.d(e,"Uint32Attribute",function(){return ep}),t.d(e,"Uint32BufferAttribute",function(){return os}),t.d(e,"Uint8Attribute",function(){return Kf}),t.d(e,"Uint8BufferAttribute",function(){return rs}),t.d(e,"Uint8ClampedAttribute",function(){return Xf}),t.d(e,"Uint8ClampedBufferAttribute",function(){return is}),t.d(e,"Uniform",function(){return Hd}),t.d(e,"UniformsLib",function(){return A}),t.d(e,"UniformsUtils",function(){return Ns}),t.d(e,"UnsignedByteType",function(){return et}),t.d(e,"UnsignedInt248Type",function(){return ct}),t.d(e,"UnsignedIntType",function(){return st}),t.d(e,"UnsignedShort4444Type",function(){return lt}),t.d(e,"UnsignedShort5551Type",function(){return ht}),t.d(e,"UnsignedShort565Type",function(){return ut}),t.d(e,"UnsignedShortType",function(){return it}),t.d(e,"VSMShadowMap",function(){return I}),t.d(e,"Vector2",function(){return z}),t.d(e,"Vector3",function(){return Pe}),t.d(e,"Vector4",function(){return Ie}),t.d(e,"VectorKeyframeTrack",function(){return xc}),t.d(e,"Vertex",function(){return Yf}),t.d(e,"VertexColors",function(){return Nf}),t.d(e,"VideoTexture",function(){return Oh}),t.d(e,"WebGL1Renderer",function(){return Cl}),t.d(e,"WebGLCubeRenderTarget",function(){return zs}),t.d(e,"WebGLMultipleRenderTargets",function(){return Ii}),t.d(e,"WebGLMultisampleRenderTarget",function(){return Pi}),t.d(e,"WebGLRenderTarget",function(){return Di}),t.d(e,"WebGLRenderTargetCube",function(){return hp}),t.d(e,"WebGLRenderer",function(){return s}),t.d(e,"WebGLUtils",function(){return Sl}),t.d(e,"WireframeGeometry",function(){return Ku}),t.d(e,"WireframeHelper",function(){return ap}),t.d(e,"WrapAroundEnding",function(){return xr}),t.d(e,"XHRLoader",function(){return op}),t.d(e,"ZeroCurvatureEnding",function(){return vr}),t.d(e,"ZeroFactor",function(){return se}),t.d(e,"ZeroSlopeEnding",function(){return yr}),t.d(e,"ZeroStencilOp",function(){return Fr}),t.d(e,"sRGBEncoding",function(){return wr});const _="134",b={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},T={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},j=0,Y=1,$=2,L=3,R=0,C=1,D=2,I=3,Oe=0,Ae=1,Fe=2,P=1,k=2,q=0,K=1,X=2,J=3,Z=4,Q=5,ee=100,te=101,re=102,ie=103,ne=104,se=200,ae=201,oe=202,le=203,he=204,ue=205,ce=206,de=207,fe=208,pe=209,me=210,ge=0,ve=1,ye=2,xe=3,_e=4,be=5,Te=6,Se=7,O=0,F=1,B=2,Ne=0,G=1,H=2,W=3,Ee=4,we=5,Me=300,Ue=301,Be=302,Ge=303,He=304,ze=306,Ve=307,We=1e3,Le=1001,je=1002,Re=1003,Ye=1004,$e=1004,qe=1005,Ke=1005,U=1006,Xe=1007,Je=1007,Ze=1008,Qe=1008,et=1009,tt=1010,rt=1011,it=1012,nt=1013,st=1014,at=1015,ot=1016,lt=1017,ht=1018,ut=1019,ct=1020,dt=1021,ft=1022,Ce=1023,pt=1024,mt=1025,gt=Ce,vt=1026,yt=1027,xt=1028,_t=1029,bt=1030,Tt=1031,St=1032,Et=1033,wt=33776,Mt=33777,At=33778,Lt=33779,Rt=35840,Ct=35841,Dt=35842,It=35843,Pt=36196,kt=37492,Ot=37496,Ft=37808,Nt=37809,Ut=37810,Bt=37811,Gt=37812,Ht=37813,zt=37814,Vt=37815,Wt=37816,jt=37817,Yt=37818,$t=37819,qt=37820,Kt=37821,Xt=36492,Jt=37840,Zt=37841,Qt=37842,er=37843,tr=37844,rr=37845,ir=37846,nr=37847,sr=37848,ar=37849,or=37850,lr=37851,hr=37852,ur=37853,cr=2200,dr=2201,fr=2202,pr=2300,mr=2301,gr=2302,vr=2400,yr=2401,xr=2402,_r=2500,br=2501,Tr=0,Sr=1,Er=2,De=3e3,wr=3001,Mr=3007,Ar=3002,Lr=3003,Rr=3004,Cr=3005,Dr=3006,Ir=3200,Pr=3201,kr=0,Or=1,Fr=0,Nr=7680,Ur=7681,Br=7682,Gr=7683,Hr=34055,zr=34056,Vr=5386,Wr=512,jr=513,Yr=514,$r=515,qr=516,Kr=517,Xr=518,Jr=519,Zr=35044,Qr=35048,ei=35040,ti=35045,ri=35049,ii=35041,ni=35046,si=35050,ai=35042,oi="100",li="300 es";class hi{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){var r;return void 0!==this._listeners&&void 0!==(r=this._listeners)[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0!==this._listeners){var r=this._listeners[e];if(void 0!==r){const e=r.indexOf(t);-1!==e&&r.splice(e,1)}}}dispatchEvent(r){if(void 0!==this._listeners){var e=this._listeners[r.type];if(void 0!==e){r.target=this;var i=e.slice(0);for(let e=0,t=i.length;e<t;e++)i[e].call(this,r);r.target=null}}}}let ui=1234567;const ci=Math.PI/180,di=180/Math.PI,n=[];for(let e=0;e<256;e++)n[e]=(e<16?"0":"")+e.toString(16);const fi="undefined"!=typeof crypto&&"randomUUID"in crypto;function pi(){var e,t,r,i;return(fi?crypto.randomUUID():(e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n[255&e]+n[e>>8&255]+n[e>>16&255]+n[e>>24&255]+"-"+n[255&t]+n[t>>8&255]+"-"+n[t>>16&15|64]+n[t>>24&255]+"-"+n[63&r|128]+n[r>>8&255]+"-"+n[r>>16&255]+n[r>>24&255]+n[255&i]+n[i>>8&255]+n[i>>16&255]+n[i>>24&255])).toUpperCase()}function mi(e,t,r){return Math.max(t,Math.min(r,e))}function gi(e,t){return(e%t+t)%t}function vi(e,t,r){return(1-r)*e+r*t}function yi(e){return 0==(e&e-1)&&0!==e}function xi(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function _i(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var bi=Object.freeze({__proto__:null,DEG2RAD:ci,RAD2DEG:di,generateUUID:pi,clamp:mi,euclideanModulo:gi,mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},inverseLerp:function(e,t,r){return e!==t?(r-e)/(t-e):0},lerp:vi,damp:function(e,t,r,i){return vi(e,t,1-Math.exp(-r*i))},pingpong:function(e,t=1){return t-Math.abs(gi(e,2*t)-t)},smoothstep:function(e,t,r){return e<=t?0:r<=e?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:r<=e?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return((ui=16807*(ui=void 0!==e?e%2147483647:ui)%2147483647)-1)/2147483646},degToRad:function(e){return e*ci},radToDeg:function(e){return e*di},isPowerOfTwo:yi,ceilPowerOfTwo:xi,floorPowerOfTwo:_i,setQuaternionFromProperEuler:function(e,t,r,i,n){var s=Math.cos,a=Math.sin,o=s(r/2),l=a(r/2),h=s((t+i)/2),u=a((t+i)/2),c=s((t-i)/2),d=a((t-i)/2),f=s((i-t)/2),p=a((i-t)/2);switch(n){case"XYX":e.set(o*u,l*c,l*d,o*h);break;case"YZY":e.set(l*d,o*u,l*c,o*h);break;case"ZXZ":e.set(l*c,l*d,o*u,o*h);break;case"XZX":e.set(o*u,l*p,l*f,o*h);break;case"YXY":e.set(l*f,o*u,l*p,o*h);break;case"ZYZ":e.set(l*p,l*f,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}});class z{constructor(e=0,t=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,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){var t=this.x,r=this.y,e=e.elements;return this.x=e[0]*t+e[3]*r+e[6],this.y=e[1]*t+e[4]*r+e[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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,e=this.y-e.y;return t*t+e*e}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){var r=Math.cos(t),t=Math.sin(t),i=this.x-e.x,n=this.y-e.y;return this.x=i*r-n*t+e.x,this.y=i*t+n*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}z.prototype.isVector2=!0;class v{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,r,i,n,s,a,o,l){var h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=n,h[5]=o,h[6]=r,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){e=e.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){var e=e.elements,t=t.elements,r=this.elements,i=e[0],n=e[3],s=e[6],a=e[1],o=e[4],l=e[7],h=e[2],u=e[5],e=e[8],c=t[0],d=t[3],f=t[6],p=t[1],m=t[4],g=t[7],v=t[2],y=t[5],t=t[8];return r[0]=i*c+n*p+s*v,r[3]=i*d+n*m+s*y,r[6]=i*f+n*g+s*t,r[1]=a*c+o*p+l*v,r[4]=a*d+o*m+l*y,r[7]=a*f+o*g+l*t,r[2]=h*c+u*p+e*v,r[5]=h*d+u*m+e*y,r[8]=h*f+u*g+e*t,this}multiplyScalar(e){var 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(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],e=e[8];return t*s*e-t*a*l-r*n*e+r*a*o+i*n*l-i*s*o}invert(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],h=e[8],u=h*s-a*l,c=a*o-h*n,d=l*n-s*o,f=t*u+r*c+i*d;return 0==f?this.set(0,0,0,0,0,0,0,0,0):(e[0]=u*(u=1/f),e[1]=(i*l-h*r)*u,e[2]=(a*r-i*s)*u,e[3]=c*u,e[4]=(h*t-i*o)*u,e[5]=(i*n-a*t)*u,e[6]=d*u,e[7]=(r*o-l*t)*u,e[8]=(s*t-r*n)*u,this)}transpose(){var e=this.elements,t=e[1];return e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){var 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,r,i,n,s,a){var o=Math.cos(n),n=Math.sin(n);return this.set(r*o,r*n,-r*(o*s+n*a)+s+e,-i*n,i*o,-i*(-n*s+o*a)+a+t,0,0,1),this}scale(e,t){var r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this}rotate(e){var t=Math.cos(e),e=Math.sin(e),r=this.elements,i=r[0],n=r[3],s=r[6],a=r[1],o=r[4],l=r[7];return r[0]=t*i+e*a,r[3]=t*n+e*o,r[6]=t*s+e*l,r[1]=-e*i+t*a,r[4]=-e*n+t*o,r[7]=-e*s+t*l,this}translate(e,t){var r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this}equals(e){var t=this.elements,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(t,r=0){for(let e=0;e<9;e++)this.elements[e]=t[e+r];return this}toArray(e=[],t=0){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function Ti(r){if(0===r.length)return-1/0;let i=r[0];for(let e=1,t=r.length;e<t;++e)r[e]>i&&(i=r[e]);return i}v.prototype.isMatrix3=!0;const Si={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Ei(e,t){return new Si[e](t)}function wi(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Mi(r,e=0){let i=3735928559^e,n=1103547991^e;for(let e,t=0;t<r.length;t++)e=r.charCodeAt(t),i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909)))+(i>>>0)}let Ai;class Li{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;var r;return 2048<(t=e instanceof HTMLCanvasElement?e:((Ai=void 0===Ai?wi("canvas"):Ai).width=e.width,Ai.height=e.height,r=Ai.getContext("2d"),e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),Ai)).width||2048<t.height?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Ri=0;class u extends hi{constructor(e=u.DEFAULT_IMAGE,t=u.DEFAULT_MAPPING,r=Le,i=Le,n=U,s=Ze,a=Ce,o=et,l=1,h=De){super(),Object.defineProperty(this,"id",{value:Ri++}),this.uuid=pi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=r,this.wrapT=i,this.magFilter=n,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new z(0,0),this.repeat=new z(1,1),this.center=new z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new v,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}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.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,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.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=pi()),!t&&void 0===e.images[i.uuid]){let r;if(Array.isArray(i)){r=[];for(let e=0,t=i.length;e<t;e++)i[e].isDataTexture?r.push(Ci(i[e].image)):r.push(Ci(i[e]))}else r=Ci(i);e.images[i.uuid]={uuid:i.uuid,url:r}}r.image=i.uuid}return"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping===Me){if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case We:e.x=e.x-Math.floor(e.x);break;case Le:e.x=e.x<0?0:1;break;case je:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||1<e.y)switch(this.wrapT){case We:e.y=e.y-Math.floor(e.y);break;case Le:e.y=e.y<0?0:1;break;case je:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}return e}set needsUpdate(e){!0===e&&this.version++}}function Ci(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Li.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}u.DEFAULT_IMAGE=void 0,u.DEFAULT_MAPPING=Me,u.prototype.isTexture=!0;class Ie{constructor(e=0,t=0,r=0,i=1){this.x=e,this.y=t,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){var t=this.x,r=this.y,i=this.z,n=this.w,e=e.elements;return this.x=e[0]*t+e[4]*r+e[8]*i+e[12]*n,this.y=e[1]*t+e[5]*r+e[9]*i+e[13]*n,this.z=e[2]*t+e[6]*r+e[10]*i+e[14]*n,this.w=e[3]*t+e[7]*r+e[11]*i+e[15]*n,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var 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,r,i,n;const s=e.elements,a=s[0],o=s[4],l=s[8],h=s[1],u=s[5],c=s[9],d=s[2],f=s[6],p=s[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(c-f)<.01)if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(c+f)<.1&&Math.abs(a+u+p-3)<.1)this.set(1,0,0,0);else{t=Math.PI;const e=(a+1)/2,s=(u+1)/2,m=(p+1)/2,g=(o+h)/4,v=(l+d)/4,y=(c+f)/4;e>s&&e>m?n=e<.01?(r=0,i=.707106781):(r=Math.sqrt(e),i=g/r,v/r):s>m?n=s<.01?(r=.707106781,i=0,.707106781):(i=Math.sqrt(s),r=g/i,y/i):m<.01?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(m),r=v/n,i=y/n),this.set(r,i,n,t)}else{let e=Math.sqrt((f-c)*(f-c)+(l-d)*(l-d)+(h-o)*(h-o));Math.abs(e)<.001&&(e=1),this.x=(f-c)/e,this.y=(l-d)/e,this.z=(h-o)/e,this.w=Math.acos((a+u+p-1)/2)}return 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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),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}}Ie.prototype.isVector4=!0;class Di extends hi{constructor(e,t,r={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Ie(0,0,e,t),this.scissorTest=!1,this.viewport=new Ie(0,0,e,t),this.texture=new u(void 0,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==r.generateMipmaps&&r.generateMipmaps,this.texture.internalFormat=void 0!==r.internalFormat?r.internalFormat:null,this.texture.minFilter=void 0!==r.minFilter?r.minFilter:U,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0!==r.stencilBuffer&&r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,r=1){this.width===e&&this.height===t&&this.depth===r||(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,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){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Di.prototype.isWebGLRenderTarget=!0;class Ii extends Di{constructor(e,t,r){super(e,t);var i=this.texture;this.texture=[];for(let e=0;e<r;e++)this.texture[e]=i.clone()}setSize(r,i,n=1){if(this.width!==r||this.height!==i||this.depth!==n){this.width=r,this.height=i,this.depth=n;for(let e=0,t=this.texture.length;e<t;e++)this.texture[e].image.width=r,this.texture[e].image.height=i,this.texture[e].image.depth=n;this.dispose()}return this.viewport.set(0,0,r,i),this.scissor.set(0,0,r,i),this}copy(r){this.dispose(),this.width=r.width,this.height=r.height,this.depth=r.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture;for(let e=this.texture.length=0,t=r.texture.length;e<t;e++)this.texture[e]=r.texture[e].clone();return this}}Ii.prototype.isWebGLMultipleRenderTargets=!0;class Pi extends Di{constructor(e,t,r){super(e,t,r),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Pi.prototype.isWebGLMultisampleRenderTarget=!0;class ki{constructor(e=0,t=0,r=0,i=1){this._x=e,this._y=t,this._z=r,this._w=i}static slerp(e,t,r,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),r.slerpQuaternions(e,t,i)}static slerpFlat(t,r,i,n,s,a,o){let l=i[n+0],h=i[n+1],u=i[n+2],c=i[n+3];var d=s[a+0],f=s[a+1],p=s[a+2],a=s[a+3];if(0===o)t[r+0]=l,t[r+1]=h,t[r+2]=u,t[r+3]=c;else if(1===o)t[r+0]=d,t[r+1]=f,t[r+2]=p,t[r+3]=a;else{if(c!==a||l!==d||h!==f||u!==p){let e=1-o;const r=l*d+h*f+u*p+c*a,i=0<=r?1:-1,n=1-r*r;if(n>Number.EPSILON){const s=Math.sqrt(n),a=Math.atan2(s,r*i);e=Math.sin(e*a)/s,o=Math.sin(o*a)/s}const s=o*i;if(l=l*e+d*s,h=h*e+f*s,u=u*e+p*s,c=c*e+a*s,e===1-o){const t=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=t,h*=t,u*=t,c*=t}}t[r]=l,t[r+1]=h,t[r+2]=u,t[r+3]=c}}static multiplyQuaternionsFlat(e,t,r,i,n,s){var a=r[i],o=r[i+1],l=r[i+2],r=r[i+3],i=n[s],h=n[s+1],u=n[s+2],n=n[s+3];return e[t]=a*n+r*i+o*u-l*h,e[t+1]=o*n+r*h+l*i-a*u,e[t+2]=l*n+r*u+a*h-o*i,e[t+3]=r*n-a*i-o*h-l*u,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,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,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){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,i=e._y,n=e._z,s=e._order,e=Math.cos,a=Math.sin,o=e(r/2),l=e(i/2),h=e(n/2),u=a(r/2),c=a(i/2),d=a(n/2);switch(s){case"XYZ":this._x=u*l*h+o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h-u*c*d;break;case"YXZ":this._x=u*l*h+o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h+u*c*d;break;case"ZXY":this._x=u*l*h-o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h-u*c*d;break;case"ZYX":this._x=u*l*h-o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h+u*c*d;break;case"YZX":this._x=u*l*h+o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h-u*c*d;break;case"XZY":this._x=u*l*h-o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h+u*c*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){var t=t/2,r=Math.sin(t);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){var e=e.elements,t=e[0],r=e[4],i=e[8],n=e[1],s=e[5],a=e[9],o=e[2],l=e[6],h=e[10],u=t+s+h;if(0<u){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(l-a)*e,this._y=(i-o)*e,this._z=(n-r)*e}else if(s<t&&h<t){const e=2*Math.sqrt(1+t-s-h);this._w=(l-a)/e,this._x=.25*e,this._y=(r+n)/e,this._z=(i+o)/e}else if(h<s){const e=2*Math.sqrt(1+s-t-h);this._w=(i-o)/e,this._x=(r+n)/e,this._y=.25*e,this._z=(a+l)/e}else{const e=2*Math.sqrt(1+h-t-s);this._w=(n-r)/e,this._x=(i+o)/e,this._y=(a+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(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=r,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mi(this.dot(e),-1,1)))}rotateTowards(e,t){var r=this.angleTo(e);return 0!==r&&(t=Math.min(1,t/r),this.slerp(e,t)),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(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(this._x=this._x*(e=1/e),this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){var r=e._x,i=e._y,n=e._z,e=e._w,s=t._x,a=t._y,o=t._z,t=t._w;return this._x=r*t+e*s+i*o-n*a,this._y=i*t+e*a+n*s-r*o,this._z=n*t+e*o+r*a-i*s,this._w=e*t-r*s-i*a-n*o,this._onChangeCallback(),this}slerp(t,r){if(0!==r){if(1===r)return this.copy(t);var i=this._x,n=this._y,s=this._z,a=this._w;let e=a*t._w+i*t._x+n*t._y+s*t._z;if(e<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,e=-e):this.copy(t),1<=e)this._w=a,this._x=i,this._y=n,this._z=s;else{t=1-e*e;if(t<=Number.EPSILON){const t=1-r;this._w=t*a+r*this._w,this._x=t*i+r*this._x,this._y=t*n+r*this._y,this._z=t*s+r*this._z,this.normalize()}else{var t=Math.sqrt(t),o=Math.atan2(t,e),l=Math.sin((1-r)*o)/t,r=Math.sin(r*o)/t;this._w=a*l+this._w*r,this._x=i*l+this._x*r,this._y=n*l+this._y*r,this._z=s*l+this._z*r}this._onChangeCallback()}}return this}slerpQuaternions(e,t,r){this.copy(e).slerp(t,r)}random(){var e=Math.random(),t=Math.sqrt(1-e),e=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),e*Math.sin(i),e*Math.cos(i),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}ki.prototype.isQuaternion=!0;class Pe{constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,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,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(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 e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Fi.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Fi.setFromAxisAngle(e,t))}applyMatrix3(e){var t=this.x,r=this.y,i=this.z,e=e.elements;return this.x=e[0]*t+e[3]*r+e[6]*i,this.y=e[1]*t+e[4]*r+e[7]*i,this.z=e[2]*t+e[5]*r+e[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){var t=this.x,r=this.y,i=this.z,e=e.elements,n=1/(e[3]*t+e[7]*r+e[11]*i+e[15]);return this.x=(e[0]*t+e[4]*r+e[8]*i+e[12])*n,this.y=(e[1]*t+e[5]*r+e[9]*i+e[13])*n,this.z=(e[2]*t+e[6]*r+e[10]*i+e[14])*n,this}applyQuaternion(e){var t=this.x,r=this.y,i=this.z,n=e.x,s=e.y,a=e.z,e=e.w,o=e*t+s*i-a*r,l=e*r+a*t-n*i,h=e*i+n*r-s*t,t=-n*t-s*r-a*i;return this.x=o*e+t*-n+l*-a-h*-s,this.y=l*e+t*-s+h*-n-o*-a,this.z=h*e+t*-a+o*-s-l*-n,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){var t=this.x,r=this.y,i=this.z,e=e.elements;return this.x=e[0]*t+e[4]*r+e[8]*i,this.y=e[1]*t+e[5]*r+e[9]*i,this.z=e[2]*t+e[6]*r+e[10]*i,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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){var r=e.x,i=e.y,e=e.z,n=t.x,s=t.y,t=t.z;return this.x=i*t-e*s,this.y=e*n-r*t,this.z=r*s-i*n,this}projectOnVector(e){var t=e.lengthSq();return 0===t?this.set(0,0,0):(t=e.dot(this)/t,this.copy(e).multiplyScalar(t))}projectOnPlane(e){return Oi.copy(this).projectOnVector(e),this.sub(Oi)}reflect(e){return this.sub(Oi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:(e=this.dot(e)/t,Math.acos(mi(e,-1,1)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,r=this.y-e.y,e=this.z-e.z;return t*t+r*r+e*e}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,r){var i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){e=e.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),e=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=e,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Pe.prototype.isVector3=!0;const Oi=new Pe,Fi=new ki;class Ni{constructor(e=new Pe(1/0,1/0,1/0),t=new Pe(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(r){let i=1/0,n=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let e=0,t=r.length;e<t;e+=3){var h=r[e],u=r[e+1],c=r[e+2];h<i&&(i=h),u<n&&(n=u),c<s&&(s=c),h>a&&(a=h),u>o&&(o=u),c>l&&(l=c)}return this.min.set(i,n,s),this.max.set(a,o,l),this}setFromBufferAttribute(r){let i=1/0,n=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let e=0,t=r.count;e<t;e++){var h=r.getX(e),u=r.getY(e),c=r.getZ(e);h<i&&(i=h),u<n&&(n=u),c<s&&(s=c),h>a&&(a=h),u>o&&(o=u),c>l&&(l=c)}return this.min.set(i,n,s),this.max.set(a,o,l),this}setFromPoints(r){this.makeEmpty();for(let e=0,t=r.length;e<t;e++)this.expandByPoint(r[e]);return this}setFromCenterAndSize(e,t){t=Bi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}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){e.updateWorldMatrix(!1,!1);var t=e.geometry,r=(void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Gi.copy(t.boundingBox),Gi.applyMatrix4(e.matrixWorld),this.union(Gi)),e.children);for(let e=0,t=r.length;e<t;e++)this.expandByObject(r[e]);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,Bi),Bi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return r=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){return!this.isEmpty()&&(this.getCenter($i),qi.subVectors(this.max,$i),Hi.subVectors(e.a,$i),zi.subVectors(e.b,$i),Vi.subVectors(e.c,$i),Wi.subVectors(zi,Hi),ji.subVectors(Vi,zi),Yi.subVectors(Hi,Vi),!!Ji([0,-Wi.z,Wi.y,0,-ji.z,ji.y,0,-Yi.z,Yi.y,Wi.z,0,-Wi.x,ji.z,0,-ji.x,Yi.z,0,-Yi.x,-Wi.y,Wi.x,0,-ji.y,ji.x,0,-Yi.y,Yi.x,0],Hi,zi,Vi,qi))&&!!Ji([1,0,0,0,1,0,0,0,1],Hi,zi,Vi,qi)&&(Ki.crossVectors(Wi,ji),Ji([Ki.x,Ki.y,Ki.z],Hi,zi,Vi,qi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Bi.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Bi).length(),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()||(Ui[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ui[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ui[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ui[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ui[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ui[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ui[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ui[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ui)),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)}}Ni.prototype.isBox3=!0;const Ui=[new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe],Bi=new Pe,Gi=new Ni,Hi=new Pe,zi=new Pe,Vi=new Pe,Wi=new Pe,ji=new Pe,Yi=new Pe,$i=new Pe,qi=new Pe,Ki=new Pe,Xi=new Pe;function Ji(r,i,n,s,a){for(let e=0,t=r.length-3;e<=t;e+=3){Xi.fromArray(r,e);var o=a.x*Math.abs(Xi.x)+a.y*Math.abs(Xi.y)+a.z*Math.abs(Xi.z),l=i.dot(Xi),h=n.dot(Xi),u=s.dot(Xi);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const Zi=new Ni,Qi=new Pe,en=new Pe,tn=new Pe;class rn{constructor(e=new Pe,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(r,e){var i=this.center;void 0!==e?i.copy(e):Zi.setFromPoints(r).getCenter(i);let n=0;for(let e=0,t=r.length;e<t;e++)n=Math.max(n,i.distanceToSquared(r[e]));return this.radius=Math.sqrt(n),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){var 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){var r=this.center.distanceToSquared(e);return t.copy(e),r>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.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){tn.subVectors(e,this.center);var t=tn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.add(tn.multiplyScalar(r/e)),this.radius+=r}return this}union(e){return en.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Qi.copy(e.center).add(en)),this.expandByPoint(Qi.copy(e.center).sub(en)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const nn=new Pe,sn=new Pe,an=new Pe,on=new Pe,ln=new Pe,hn=new Pe,un=new Pe;class cn{constructor(e=new Pe,t=new Pe(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,nn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);e=t.dot(this.direction);return e<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(e).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){var t=nn.subVectors(e,this.origin).dot(this.direction);return(t<0?this.origin:(nn.copy(this.direction).multiplyScalar(t).add(this.origin),nn)).distanceToSquared(e)}distanceSqToSegment(e,t,r,i){sn.copy(e).add(t).multiplyScalar(.5),an.copy(t).sub(e).normalize(),on.copy(this.origin).sub(sn);var e=.5*e.distanceTo(t),t=-this.direction.dot(an),n=on.dot(this.direction),s=-on.dot(an),a=on.lengthSq(),o=Math.abs(1-t*t);let l,h,u,c;if(0<o)if(l=t*s-n,h=t*n-s,c=e*o,0<=l)if(h>=-c)if(h<=c){const e=1/o;l*=e,h*=e,u=l*(l+t*h+2*n)+h*(t*l+h+2*s)+a}else h=e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;else h=-e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;else u=h<=-c?(l=Math.max(0,-(-t*e+n)),h=0<l?-e:Math.min(Math.max(-e,-s),e),-l*l+h*(h+2*s)+a):h<=c?(l=0,(h=Math.min(Math.max(-e,-s),e))*(h+2*s)+a):(l=Math.max(0,-(t*e+n)),h=0<l?e:Math.min(Math.max(-e,-s),e),-l*l+h*(h+2*s)+a);else h=0<t?-e:e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;return r&&r.copy(this.direction).multiplyScalar(l).add(this.origin),i&&i.copy(an).multiplyScalar(h).add(sn),u}intersectSphere(e,t){nn.subVectors(e.center,this.origin);var r=nn.dot(this.direction),i=nn.dot(nn)-r*r,e=e.radius*e.radius;return e<i||(i=r+(e=Math.sqrt(e-i)),(r=r-e)<0&&i<0)?null:r<0?this.at(i,t):this.at(r,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){var t=e.normal.dot(this.direction);return 0===t?0===e.distanceToPoint(this.origin)?0:null:0<=(e=-(this.origin.dot(e.normal)+e.constant)/t)?e:null}intersectPlane(e,t){e=this.distanceToPlane(e);return null===e?null:this.at(e,t)}intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,n,s,a,o;var l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,c=this.origin;return i=0<=l?(r=(e.min.x-c.x)*l,(e.max.x-c.x)*l):(r=(e.max.x-c.x)*l,(e.min.x-c.x)*l),s=0<=h?(n=(e.min.y-c.y)*h,(e.max.y-c.y)*h):(n=(e.max.y-c.y)*h,(e.min.y-c.y)*h),r>s||n>i||((n>r||r!=r)&&(r=n),(s<i||i!=i)&&(i=s),o=0<=u?(a=(e.min.z-c.z)*u,(e.max.z-c.z)*u):(a=(e.max.z-c.z)*u,(e.min.z-c.z)*u),r>o)||a>i||((a>r||r!=r)&&(r=a),(i=o<i||i!=i?o:i)<0)?null:this.at(0<=r?r:i,t)}intersectsBox(e){return null!==this.intersectBox(e,nn)}intersectTriangle(e,t,r,i,n){ln.subVectors(t,e),hn.subVectors(r,e),un.crossVectors(ln,hn);let s,a=this.direction.dot(un);if(0<a){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}on.subVectors(this.origin,e);t=s*this.direction.dot(hn.crossVectors(on,hn));return t<0||(r=s*this.direction.dot(ln.cross(on)))<0||t+r>a||(i=-s*on.dot(un))<0?null:this.at(i/a,n)}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)}}class ke{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,r,i,n,s,a,o,l,h,u,c,d,f,p,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=n,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=u,g[14]=c,g[3]=d,g[7]=f,g[11]=p,g[15]=m,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 ke).fromArray(this.elements)}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}copyPosition(e){var t=this.elements,e=e.elements;return t[12]=e[12],t[13]=e[13],t[14]=e[14],this}setFromMatrix3(e){e=e.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){var t=this.elements,r=e.elements,i=1/dn.setFromMatrixColumn(e,0).length(),n=1/dn.setFromMatrixColumn(e,1).length(),e=1/dn.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*n,t[5]=r[5]*n,t[6]=r[6]*n,t[7]=0,t[8]=r[8]*e,t[9]=r[9]*e,t[10]=r[10]*e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,r=e.x,i=e.y,n=e.z,s=Math.cos(r),a=Math.sin(r),o=Math.cos(i),l=Math.sin(i),h=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){const e=s*h,r=s*u,i=a*h,n=a*u;t[0]=o*h,t[4]=-o*u,t[8]=l,t[1]=r+i*l,t[5]=e-n*l,t[9]=-a*o,t[2]=n-e*l,t[6]=i+r*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*h,r=o*u,i=l*h,n=l*u;t[0]=e+n*a,t[4]=i*a-r,t[8]=s*l,t[1]=s*u,t[5]=s*h,t[9]=-a,t[2]=r*a-i,t[6]=n+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*h,r=o*u,i=l*h,n=l*u;t[0]=e-n*a,t[4]=-s*u,t[8]=i+r*a,t[1]=r+i*a,t[5]=s*h,t[9]=n-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*h,r=s*u,i=a*h,n=a*u;t[0]=o*h,t[4]=i*l-r,t[8]=e*l+n,t[1]=o*u,t[5]=n*l+e,t[9]=r*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*h,t[4]=n-e*u,t[8]=i*u+r,t[1]=u,t[5]=s*h,t[9]=-a*h,t[2]=-l*h,t[6]=r*u+i,t[10]=e-n*u}else if("XZY"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*h,t[4]=-u,t[8]=l*h,t[1]=e*u+n,t[5]=s*h,t[9]=r*u-i,t[2]=i*u-r,t[6]=a*h,t[10]=n*u+e}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(pn,e,mn)}lookAt(e,t,r){var i=this.elements;return yn.subVectors(e,t),0===yn.lengthSq()&&(yn.z=1),yn.normalize(),gn.crossVectors(r,yn),0===gn.lengthSq()&&(1===Math.abs(r.z)?yn.x+=1e-4:yn.z+=1e-4,yn.normalize(),gn.crossVectors(r,yn)),gn.normalize(),vn.crossVectors(yn,gn),i[0]=gn.x,i[4]=vn.x,i[8]=yn.x,i[1]=gn.y,i[5]=vn.y,i[9]=yn.y,i[2]=gn.z,i[6]=vn.z,i[10]=yn.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){var e=e.elements,t=t.elements,r=this.elements,i=e[0],n=e[4],s=e[8],a=e[12],o=e[1],l=e[5],h=e[9],u=e[13],c=e[2],d=e[6],f=e[10],p=e[14],m=e[3],g=e[7],v=e[11],e=e[15],y=t[0],x=t[4],_=t[8],b=t[12],T=t[1],S=t[5],E=t[9],w=t[13],M=t[2],A=t[6],L=t[10],R=t[14],C=t[3],D=t[7],I=t[11],t=t[15];return r[0]=i*y+n*T+s*M+a*C,r[4]=i*x+n*S+s*A+a*D,r[8]=i*_+n*E+s*L+a*I,r[12]=i*b+n*w+s*R+a*t,r[1]=o*y+l*T+h*M+u*C,r[5]=o*x+l*S+h*A+u*D,r[9]=o*_+l*E+h*L+u*I,r[13]=o*b+l*w+h*R+u*t,r[2]=c*y+d*T+f*M+p*C,r[6]=c*x+d*S+f*A+p*D,r[10]=c*_+d*E+f*L+p*I,r[14]=c*b+d*w+f*R+p*t,r[3]=m*y+g*T+v*M+e*C,r[7]=m*x+g*S+v*A+e*D,r[11]=m*_+g*E+v*L+e*I,r[15]=m*b+g*w+v*R+e*t,this}multiplyScalar(e){var 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(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],s=e[1],a=e[5],o=e[9],l=e[13],h=e[2],u=e[6],c=e[10],d=e[14];return e[3]*(+n*o*u-i*l*u-n*a*c+r*l*c+i*a*d-r*o*d)+e[7]*(+t*o*d-t*l*c+n*s*c-i*s*d+i*l*h-n*o*h)+e[11]*(+t*l*u-t*a*d-n*s*u+r*s*d+n*a*h-r*l*h)+e[15]*(-i*a*h-t*o*u+t*a*c+i*s*u-r*s*c+r*o*h)}transpose(){var e=this.elements,t=e[1];return 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,r){var i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],h=e[8],u=e[9],c=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15],v=u*m*l-p*c*l+p*o*d-a*m*d-u*o*g+a*c*g,y=f*c*l-h*m*l-f*o*d+s*m*d+h*o*g-s*c*g,x=h*p*l-f*u*l+f*a*d-s*p*d-h*a*g+s*u*g,_=f*u*o-h*p*o-f*a*c+s*p*c+h*a*m-s*u*m,b=t*v+r*y+i*x+n*_;return 0==b?this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0):(e[0]=v*(v=1/b),e[1]=(p*c*n-u*m*n-p*i*d+r*m*d+u*i*g-r*c*g)*v,e[2]=(a*m*n-p*o*n+p*i*l-r*m*l-a*i*g+r*o*g)*v,e[3]=(u*o*n-a*c*n-u*i*l+r*c*l+a*i*d-r*o*d)*v,e[4]=y*v,e[5]=(h*m*n-f*c*n+f*i*d-t*m*d-h*i*g+t*c*g)*v,e[6]=(f*o*n-s*m*n-f*i*l+t*m*l+s*i*g-t*o*g)*v,e[7]=(s*c*n-h*o*n+h*i*l-t*c*l-s*i*d+t*o*d)*v,e[8]=x*v,e[9]=(f*u*n-h*p*n-f*r*d+t*p*d+h*r*g-t*u*g)*v,e[10]=(s*p*n-f*a*n+f*r*l-t*p*l-s*r*g+t*a*g)*v,e[11]=(h*a*n-s*u*n-h*r*l+t*u*l+s*r*d-t*a*d)*v,e[12]=_*v,e[13]=(h*p*i-f*u*i+f*r*c-t*p*c-h*r*m+t*u*m)*v,e[14]=(f*a*i-s*p*i-f*r*o+t*p*o+s*r*m-t*a*m)*v,e[15]=(s*u*i-h*a*i+h*r*o-t*u*o-s*r*c+t*a*c)*v,this)}scale(e){var t=this.elements,r=e.x,i=e.y,e=e.z;return t[0]*=r,t[4]*=i,t[8]*=e,t[1]*=r,t[5]*=i,t[9]*=e,t[2]*=r,t[6]*=i,t[10]*=e,t[3]*=r,t[7]*=i,t[11]*=e,this}getMaxScaleOnAxis(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,e))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){var t=Math.cos(e),e=Math.sin(e);return this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this}makeRotationY(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this}makeRotationZ(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){var r=Math.cos(t),t=Math.sin(t),i=1-r,n=e.x,s=e.y,e=e.z,a=i*n,o=i*s;return this.set(a*n+r,a*s-t*e,a*e+t*s,0,a*s+t*e,o*s+r,o*e-t*n,0,a*e-t*s,o*e+t*n,i*e*e+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,n,s){return this.set(1,r,n,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){var i=this.elements,n=t._x,s=t._y,a=t._z,t=t._w,o=n+n,l=s+s,h=a+a,u=n*o,c=n*l,n=n*h,d=s*l,s=s*h,a=a*h,o=t*o,l=t*l,t=t*h,h=r.x,f=r.y,r=r.z;return i[0]=(1-(d+a))*h,i[1]=(c+t)*h,i[2]=(n-l)*h,i[3]=0,i[4]=(c-t)*f,i[5]=(1-(u+a))*f,i[6]=(s+o)*f,i[7]=0,i[8]=(n+l)*r,i[9]=(s-o)*r,i[10]=(1-(u+d))*r,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){var i=this.elements;let n=dn.set(i[0],i[1],i[2]).length();var s=dn.set(i[4],i[5],i[6]).length(),a=dn.set(i[8],i[9],i[10]).length(),e=(this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],fn.copy(this),1/n),i=1/s,o=1/a;return fn.elements[0]*=e,fn.elements[1]*=e,fn.elements[2]*=e,fn.elements[4]*=i,fn.elements[5]*=i,fn.elements[6]*=i,fn.elements[8]*=o,fn.elements[9]*=o,fn.elements[10]*=o,t.setFromRotationMatrix(fn),r.x=n,r.y=s,r.z=a,this}makePerspective(e,t,r,i,n,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,o=2*n/(r-i),l=(t+e)/(t-e),r=(r+i)/(r-i),i=-(s+n)/(s-n),s=-2*s*n/(s-n);return a[0]=2*n/(t-e),a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=o,a[9]=r,a[13]=0,a[2]=0,a[6]=0,a[10]=i,a[14]=s,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,r,i,n,s){var a=this.elements,o=1/(t-e),l=1/(r-i),h=1/(s-n),t=(t+e)*o,e=(r+i)*l,r=(s+n)*h;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-t,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-e,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-r,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){var t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(t,r=0){for(let e=0;e<16;e++)this.elements[e]=t[e+r];return this}toArray(e=[],t=0){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}ke.prototype.isMatrix4=!0;const dn=new Pe,fn=new ke,pn=new Pe(0,0,0),mn=new Pe(1,1,1),gn=new Pe,vn=new Pe,yn=new Pe,xn=new ke,_n=new ki;class bn{constructor(e=0,t=0,r=0,i=bn.DefaultOrder){this._x=e,this._y=t,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,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,r=!0){var e=e.elements,i=e[0],n=e[4],s=e[8],a=e[1],o=e[5],l=e[9],h=e[2],u=e[6],c=e[10];switch(t){case"XYZ":this._y=Math.asin(mi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._z=Math.atan2(-n,i)):(this._x=Math.atan2(u,o),this._z=0);break;case"YXZ":this._x=Math.asin(-mi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(s,c),this._z=Math.atan2(a,o)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(mi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,c),this._z=Math.atan2(-n,o)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-mi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,c),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-n,o));break;case"YZX":this._z=Math.asin(mi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,o),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,c));break;case"XZY":this._z=Math.asin(-mi(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,o),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-l,c),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return xn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xn,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _n.setFromEuler(this),this.setFromQuaternion(_n,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],void 0!==e[3]&&(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}toVector3(e){return e?e.set(this._x,this._y,this._z):new Pe(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}bn.prototype.isEuler=!0,bn.DefaultOrder="XYZ",bn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Tn{constructor(){this.mask=1}set(e){this.mask=1<<e|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 0!=(this.mask&e.mask)}}let Sn=0;const En=new Pe,wn=new ki,Mn=new ke,An=new Pe,Ln=new Pe,Rn=new Pe,Cn=new ki,Dn=new Pe(1,0,0),In=new Pe(0,1,0),Pn=new Pe(0,0,1),kn={type:"added"},On={type:"removed"};class c extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:Sn++}),this.uuid=pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DefaultUp.clone();const e=new Pe,t=new bn,r=new ki,i=new Pe(1,1,1);t._onChange(function(){r.setFromEuler(t,!1)}),r._onChange(function(){t.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ke},normalMatrix:{value:new v}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=c.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Tn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 wn.setFromAxisAngle(e,t),this.quaternion.multiply(wn),this}rotateOnWorldAxis(e,t){return wn.setFromAxisAngle(e,t),this.quaternion.premultiply(wn),this}rotateX(e){return this.rotateOnAxis(Dn,e)}rotateY(e){return this.rotateOnAxis(In,e)}rotateZ(e){return this.rotateOnAxis(Pn,e)}translateOnAxis(e,t){return En.copy(e).applyQuaternion(this.quaternion),this.position.add(En.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dn,e)}translateY(e){return this.translateOnAxis(In,e)}translateZ(e){return this.translateOnAxis(Pn,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Mn.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?An.copy(e):An.set(e,t,r);e=this.parent;this.updateWorldMatrix(!0,!1),Ln.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mn.lookAt(Ln,An,this.up):Mn.lookAt(An,Ln,this.up),this.quaternion.setFromRotationMatrix(Mn),e&&(Mn.extractRotation(e.matrixWorld),wn.setFromRotationMatrix(Mn),this.quaternion.premultiply(wn.invert()))}add(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.add(arguments[e]);else e===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),(e.parent=this).children.push(e),e.dispatchEvent(kn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);else{var t=this.children.indexOf(e);-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(On))}return this}removeFromParent(){var e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){var t=this.children[e];t.parent=null,t.dispatchEvent(On)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Mn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Mn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Mn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(r,i){if(this[r]===i)return this;for(let e=0,t=this.children.length;e<t;e++){var n=this.children[e].getObjectByProperty(r,i);if(void 0!==n)return n}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ln,e,Rn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ln,Cn,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(r){r(this);var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].traverse(r)}traverseVisible(r){if(!1!==this.visible){r(this);var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].traverseVisible(r)}}traverseAncestors(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),r=!(this.matrixWorldNeedsUpdate=!1));var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(r)}updateWorldMatrix(r,e){var t=this.parent;if(!0===r&&null!==t&&t.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].updateWorldMatrix(!1,!0)}}toJSON(r){const i=void 0===r||"string"==typeof r,n={},s=(i&&(r={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"}),{});function a(e,t){return void 0===e[t.uuid]&&(e[t.uuid]=t.toJSON(r)),t.uuid}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),!0===this.castShadow&&(s.castShadow=!0),!0===this.receiveShadow&&(s.receiveShadow=!0),!1===this.visible&&(s.visible=!1),!1===this.frustumCulled&&(s.frustumCulled=!1),0!==this.renderOrder&&(s.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor)&&(s.instanceColor=this.instanceColor.toJSON()),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(r).uuid)),this.environment&&this.environment.isTexture&&(s.environment=this.environment.toJSON(r).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=a(r.geometries,this.geometry);const i=this.geometry.parameters;if(void 0!==i&&void 0!==i.shapes){const n=i.shapes;if(Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const s=n[e];a(r.shapes,s)}else a(r.shapes,n)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton)&&(a(r.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid),void 0!==this.material)if(Array.isArray(this.material)){const i=[];for(let e=0,t=this.material.length;e<t;e++)i.push(a(r.materials,this.material[e]));s.material=i}else s.material=a(r.materials,this.material);if(0<this.children.length){s.children=[];for(let e=0;e<this.children.length;e++)s.children.push(this.children[e].toJSON(r).object)}if(0<this.animations.length){s.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];s.animations.push(a(r.animations,n))}}if(i){const i=e(r.geometries),s=e(r.materials),a=e(r.textures),t=e(r.images),o=e(r.shapes),l=e(r.skeletons),h=e(r.animations);0<i.length&&(n.geometries=i),0<s.length&&(n.materials=s),0<a.length&&(n.textures=a),0<t.length&&(n.images=t),0<o.length&&(n.shapes=o),0<l.length&&(n.skeletons=l),0<h.length&&(n.animations=h)}return n.object=s,n;function e(e){var t=[];for(const i in e){var r=e[i];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){var r=t.children[e];this.add(r.clone())}return this}}c.DefaultUp=new Pe(0,1,0),c.DefaultMatrixAutoUpdate=!0,c.prototype.isObject3D=!0;const Fn=new Pe,Nn=new Pe,Un=new Pe,Bn=new Pe,Gn=new Pe,Hn=new Pe,zn=new Pe,Vn=new Pe,Wn=new Pe,jn=new Pe;class f{constructor(e=new Pe,t=new Pe,r=new Pe){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),Fn.subVectors(e,t),i.cross(Fn);r=i.lengthSq();return 0<r?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,r,i,n){Fn.subVectors(i,t),Nn.subVectors(r,t),Un.subVectors(e,t);var i=Fn.dot(Fn),r=Fn.dot(Nn),e=Fn.dot(Un),t=Nn.dot(Nn),s=Nn.dot(Un),a=i*t-r*r;return 0==a?n.set(-2,-1,-1):n.set(1-(t=(t*e-r*s)*(n=1/a))-(a=(i*s-r*e)*n),a,t)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,Bn),0<=Bn.x&&0<=Bn.y&&Bn.x+Bn.y<=1}static getUV(e,t,r,i,n,s,a,o){return this.getBarycoord(e,t,r,i,Bn),o.set(0,0),o.addScaledVector(n,Bn.x),o.addScaledVector(s,Bn.y),o.addScaledVector(a,Bn.z),o}static isFrontFacing(e,t,r,i){return Fn.subVectors(r,t),Nn.subVectors(e,t),Fn.cross(Nn).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 Fn.subVectors(this.c,this.b),Nn.subVectors(this.a,this.b),.5*Fn.cross(Nn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return f.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return f.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,i,n){return f.getUV(e,this.a,this.b,this.c,t,r,i,n)}containsPoint(e){return f.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return f.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){var r=this.a,i=this.b,n=this.c;let s,a;Gn.subVectors(i,r),Hn.subVectors(n,r),Vn.subVectors(e,r);var o=Gn.dot(Vn),l=Hn.dot(Vn);if(o<=0&&l<=0)return t.copy(r);Wn.subVectors(e,i);var h=Gn.dot(Wn),u=Hn.dot(Wn);if(0<=h&&u<=h)return t.copy(i);var c=o*u-h*l;if(c<=0&&0<=o&&h<=0)return s=o/(o-h),t.copy(r).addScaledVector(Gn,s);jn.subVectors(e,n);var e=Gn.dot(jn),d=Hn.dot(jn);return 0<=d&&e<=d?t.copy(n):(o=e*l-o*d)<=0&&0<=l&&d<=0?(a=l/(l-d),t.copy(r).addScaledVector(Hn,a)):(l=h*d-e*u)<=0&&0<=u-h&&0<=e-d?(zn.subVectors(n,i),a=(u-h)/(u-h+(e-d)),t.copy(i).addScaledVector(zn,a)):(n=1/(l+o+c),s=o*n,a=c*n,t.copy(r).addScaledVector(Gn,s).addScaledVector(Hn,a))}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Yn=0;class r extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:Yn++}),this.uuid=pi(),this.name="",this.type="Material",this.fog=!0,this.blending=K,this.side=Oe,this.vertexColors=!1,this.opacity=1,this.format=Ce,this.transparent=!1,this.blendSrc=he,this.blendDst=ue,this.blendEquation=ee,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=xe,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Jr,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Nr,this.stencilZFail=Nr,this.stencilZPass=Nr,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){0<this._alphaTest!=0<e&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const i in e){var t,r=e[i];void 0===r?console.warn("THREE.Material: '"+i+"' parameter is undefined."):"shading"===i?(console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=r===P):void 0!==(t=this[i])?t&&t.isColor?t.set(r):t&&t.isVector3&&r&&r.isVector3?t.copy(r):this[i]=r:console.warn("THREE."+this.type+": '"+i+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){var t=[];for(const i in e){var r=e[i];delete r.metadata,t.push(r)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine)&&(r.combine=this.combine),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==K&&(r.blending=this.blending),this.side!==Oe&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.format!==Ce&&(r.format=this.format),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),0<this.alphaTest&&(r.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(r.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),1<this.wireframeLinewidth&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=this.flatShading),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t){const t=i(e.textures),n=i(e.images);0<t.length&&(r.textures=t),0<n.length&&(r.images=n)}return r}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var r=t.clippingPlanes;let i=null;if(null!==r){const t=r.length;i=new Array(t);for(let e=0;e!==t;++e)i[e]=r[e].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}r.prototype.isMaterial=!0;const $n={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},qn={h:0,s:0,l:0},Kn={h:0,s:0,l:0};function Xn(e,t,r){return r<0&&(r+=1),1<r&&--r,r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}function Jn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Zn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class g{constructor(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,r){return this.r=e,this.g=t,this.b=r,this}setHSL(e,t,r){return e=gi(e,1),t=mi(t,0,1),r=mi(r,0,1),0===t?this.r=this.g=this.b=r:(this.r=Xn(t=2*r-(r=r<=.5?r*(1+t):r+t-r*t),r,e+1/3),this.g=Xn(t,r,e),this.b=Xn(t,r,e-1/3)),this}setStyle(t){function r(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let e;var n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,r(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,r(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s)){const i=parseFloat(e[1])/360,a=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100;return r(e[4]),this.setHSL(i,a,o)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[1],r=t.length;if(3===r)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===r)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&0<t.length?this.setColorName(t):this}setColorName(e){var t=$n[e.toLowerCase()];return void 0!==t?this.setHex(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}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){t=0<t?1/t:1;return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}copyLinearToSRGB(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){var t=this.r,r=this.g,i=this.b,n=Math.max(t,r,i),s=Math.min(t,r,i);let a,o;var l=(s+n)/2;if(s===n)a=0,o=0;else{const e=n-s;switch(o=l<=.5?e/(n+s):e/(2-n-s),n){case t:a=(r-i)/e+(r<i?6:0);break;case r:a=(i-t)/e+2;break;case i:a=(t-r)/e+4}a/=6}return e.h=a,e.s=o,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,r){return this.getHSL(qn),qn.h+=e,qn.s+=t,qn.l+=r,this.setHSL(qn.h,qn.s,qn.l),this}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,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(qn),e.getHSL(Kn);var e=vi(qn.h,Kn.h,t),r=vi(qn.s,Kn.s,t),t=vi(qn.l,Kn.l,t);return this.setHSL(e,r,t),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),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}g.NAMES=$n,g.prototype.isColor=!0,g.prototype.r=1,g.prototype.g=1,g.prototype.b=1;class Qn extends r{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new g(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.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.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}}Qn.prototype.isMeshBasicMaterial=!0;const i=new Pe,es=new z;class w{constructor(e,t,r){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===r,this.usage=Zr,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(r,i,n){r*=this.itemSize,n*=i.itemSize;for(let e=0,t=this.itemSize;e<t;e++)this.array[r+e]=i.array[n+e];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),e=new g),i[n++]=e.r,i[n++]=e.g,i[n++]=e.b}return this}copyVector2sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),e=new z),i[n++]=e.x,i[n++]=e.y}return this}copyVector3sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),e=new Pe),i[n++]=e.x,i[n++]=e.y,i[n++]=e.z}return this}copyVector4sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),e=new Ie),i[n++]=e.x,i[n++]=e.y,i[n++]=e.z,i[n++]=e.w}return this}applyMatrix3(r){if(2===this.itemSize)for(let e=0,t=this.count;e<t;e++)es.fromBufferAttribute(this,e),es.applyMatrix3(r),this.setXY(e,es.x,es.y);else if(3===this.itemSize)for(let e=0,t=this.count;e<t;e++)i.fromBufferAttribute(this,e),i.applyMatrix3(r),this.setXYZ(e,i.x,i.y,i.z);return this}applyMatrix4(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.applyMatrix4(r),this.setXYZ(e,i.x,i.y,i.z);return this}applyNormalMatrix(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.applyNormalMatrix(r),this.setXYZ(e,i.x,i.y,i.z);return this}transformDirection(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.transformDirection(r),this.setXYZ(e,i.x,i.y,i.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){var e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Zr&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}w.prototype.isBufferAttribute=!0;class ts extends w{constructor(e,t,r){super(new Int8Array(e),t,r)}}class rs extends w{constructor(e,t,r){super(new Uint8Array(e),t,r)}}class is extends w{constructor(e,t,r){super(new Uint8ClampedArray(e),t,r)}}class ns extends w{constructor(e,t,r){super(new Int16Array(e),t,r)}}class ss extends w{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class as extends w{constructor(e,t,r){super(new Int32Array(e),t,r)}}class os extends w{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class ls extends w{constructor(e,t,r){super(new Uint16Array(e),t,r)}}ls.prototype.isFloat16BufferAttribute=!0;class V extends w{constructor(e,t,r){super(new Float32Array(e),t,r)}}class hs extends w{constructor(e,t,r){super(new Float64Array(e),t,r)}}let us=0;const cs=new ke,ds=new c,fs=new Pe,ps=new Ni,ms=new Ni,h=new Pe;class S extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:us++}),this.uuid=pi(),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(65535<Ti(e)?os:ss)(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 void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){const t=(new v).getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return cs.makeRotationFromQuaternion(e),this.applyMatrix4(cs),this}rotateX(e){return cs.makeRotationX(e),this.applyMatrix4(cs),this}rotateY(e){return cs.makeRotationY(e),this.applyMatrix4(cs),this}rotateZ(e){return cs.makeRotationZ(e),this.applyMatrix4(cs),this}translate(e,t,r){return cs.makeTranslation(e,t,r),this.applyMatrix4(cs),this}scale(e,t,r){return cs.makeScale(e,t,r),this.applyMatrix4(cs),this}lookAt(e){return ds.lookAt(e),ds.updateMatrix(),this.applyMatrix4(ds.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fs).negate(),this.translate(fs.x,fs.y,fs.z),this}setFromPoints(r){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e];i.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new V(i,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ni);var e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Pe(-1/0,-1/0,-1/0),new Pe(1/0,1/0,1/0));else{if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),r)for(let e=0,t=r.length;e<t;e++){var i=r[e];ps.setFromBufferAttribute(i),this.morphTargetsRelative?(h.addVectors(this.boundingBox.min,ps.min),this.boundingBox.expandByPoint(h),h.addVectors(this.boundingBox.max,ps.max),this.boundingBox.expandByPoint(h)):(this.boundingBox.expandByPoint(ps.min),this.boundingBox.expandByPoint(ps.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(){null===this.boundingSphere&&(this.boundingSphere=new rn);var i=this.attributes.position,n=this.morphAttributes.position;if(i&&i.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Pe,1/0);else if(i){var s=this.boundingSphere.center;if(ps.setFromBufferAttribute(i),n)for(let e=0,t=n.length;e<t;e++){var a=n[e];ms.setFromBufferAttribute(a),this.morphTargetsRelative?(h.addVectors(ps.min,ms.min),ps.expandByPoint(h),h.addVectors(ps.max,ms.max),ps.expandByPoint(h)):(ps.expandByPoint(ms.min),ps.expandByPoint(ms.max))}ps.getCenter(s);let r=0;for(let e=0,t=i.count;e<t;e++)h.fromBufferAttribute(i,e),r=Math.max(r,s.distanceToSquared(h));if(n)for(let e=0,t=n.length;e<t;e++){var o=n[e],l=this.morphTargetsRelative;for(let e=0,t=o.count;e<t;e++)h.fromBufferAttribute(o,e),l&&(fs.fromBufferAttribute(i,e),h.add(fs)),r=Math.max(r,s.distanceToSquared(h))}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(){const e=this.index,i=this.attributes;if(null===e||void 0===i.position||void 0===i.normal||void 0===i.uv)console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");else{const a=e.array,o=i.position.array,l=i.normal.array,h=i.uv.array,t=o.length/3,u=(void 0===i.tangent&&this.setAttribute("tangent",new w(new Float32Array(4*t),4)),i.tangent.array),c=[],d=[];for(let e=0;e<t;e++)c[e]=new Pe,d[e]=new Pe;const f=new Pe,p=new Pe,m=new Pe,g=new z,v=new z,y=new z,x=new Pe,_=new Pe;let r=this.groups;for(let e=0,t=(r=0===r.length?[{start:0,count:a.length}]:r).length;e<t;++e){const i=r[e],o=i.start;for(let e=o,t=o+i.count;e<t;e+=3)n(a[e+0],a[e+1],a[e+2])}const b=new Pe,T=new Pe,S=new Pe,E=new Pe;for(let e=0,t=r.length;e<t;++e){const i=r[e],o=i.start;for(let e=o,t=o+i.count;e<t;e+=3)s(a[e+0]),s(a[e+1]),s(a[e+2])}function n(e,t,r){f.fromArray(o,3*e),p.fromArray(o,3*t),m.fromArray(o,3*r),g.fromArray(h,2*e),v.fromArray(h,2*t),y.fromArray(h,2*r),p.sub(f),m.sub(f),v.sub(g),y.sub(g);var i=1/(v.x*y.y-y.x*v.y);isFinite(i)&&(x.copy(p).multiplyScalar(y.y).addScaledVector(m,-v.y).multiplyScalar(i),_.copy(m).multiplyScalar(v.x).addScaledVector(p,-y.x).multiplyScalar(i),c[e].add(x),c[t].add(x),c[r].add(x),d[e].add(_),d[t].add(_),d[r].add(_))}function s(e){S.fromArray(l,3*e),E.copy(S);var t=c[e],t=(b.copy(t),b.sub(S.multiplyScalar(S.dot(t))).normalize(),T.crossVectors(E,t),T.dot(d[e])<0?-1:1);u[4*e]=b.x,u[4*e+1]=b.y,u[4*e+2]=b.z,u[4*e+3]=t}}}computeVertexNormals(){var i=this.index,n=this.getAttribute("position");if(void 0!==n){let r=this.getAttribute("normal");if(void 0===r)r=new w(new Float32Array(3*n.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);var s=new Pe,a=new Pe,o=new Pe,l=new Pe,h=new Pe,u=new Pe,c=new Pe,d=new Pe;if(i)for(let e=0,t=i.count;e<t;e+=3){var f=i.getX(e+0),p=i.getX(e+1),m=i.getX(e+2);s.fromBufferAttribute(n,f),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,m),c.subVectors(o,a),d.subVectors(s,a),c.cross(d),l.fromBufferAttribute(r,f),h.fromBufferAttribute(r,p),u.fromBufferAttribute(r,m),l.add(c),h.add(c),u.add(c),r.setXYZ(f,l.x,l.y,l.z),r.setXYZ(p,h.x,h.y,h.z),r.setXYZ(m,u.x,u.y,u.z)}else for(let e=0,t=n.count;e<t;e+=3)s.fromBufferAttribute(n,e+0),a.fromBufferAttribute(n,e+1),o.fromBufferAttribute(n,e+2),c.subVectors(o,a),d.subVectors(s,a),c.cross(d),r.setXYZ(e+0,c.x,c.y,c.z),r.setXYZ(e+1,c.x,c.y,c.z),r.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),r.needsUpdate=!0}}merge(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var r=this.attributes;for(const o in r)if(void 0!==e.attributes[o]){var i=r[o].array,n=e.attributes[o],s=n.array,n=n.itemSize*t,a=Math.min(s.length,i.length-n);for(let e=0,t=n;e<a;e++,t++)i[t]=s[e]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e)}normalizeNormals(){var r=this.attributes.normal;for(let e=0,t=r.count;e<t;e++)h.fromBufferAttribute(r,e),h.normalize(),r.setXYZ(e,h.x,h.y,h.z)}toNonIndexed(){function r(r,i){var n=r.array,s=r.itemSize,e=r.normalized,a=new n.constructor(i.length*s);let o=0,l=0;for(let e=0,t=i.length;e<t;e++){o=r.isInterleavedBufferAttribute?i[e]*r.data.stride+r.offset:i[e]*s;for(let e=0;e<s;e++)a[l++]=n[o++]}return new w(a,s,e)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const i=new S,n=this.index.array,s=this.attributes;for(const e in s){const a=r(s[e],n);i.setAttribute(e,a)}const e=this.morphAttributes;for(const s in e){const a=[],o=e[s];for(let e=0,t=o.length;e<t;e++){const s=r(o[e],n);a.push(s)}i.morphAttributes[s]=a}i.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let e=0,t=a.length;e<t;e++){const n=a[e];i.addGroup(n.start,n.count,n.materialIndex)}return i}toJSON(){var r={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),0<Object.keys(this.userData).length&&(r.userData=this.userData),void 0!==this.parameters){const i=this.parameters;for(const n in i)void 0!==i[n]&&(r[n]=i[n])}else{r.data={attributes:{}};const i=this.index,n=(null!==i&&(r.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)}),this.attributes);for(const i in n){const s=n[i];r.data.attributes[i]=s.toJSON(r.data)}const s={};let e=!1;for(const i in this.morphAttributes){const n=this.morphAttributes[i],a=[];for(let e=0,t=n.length;e<t;e++){const s=n[e];a.push(s.toJSON(r.data))}0<a.length&&(s[i]=a,e=!0)}e&&(r.data.morphAttributes=s,r.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;0<a.length&&(r.data.groups=JSON.parse(JSON.stringify(a)));var t=this.boundingSphere;null!==t&&(r.data.boundingSphere={center:t.center.toArray(),radius:t.radius})}return r}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const r={},i=(this.name=e.name,e.index),n=(null!==i&&this.setIndex(i.clone(r)),e.attributes);for(const e in n){const i=n[e];this.setAttribute(e,i.clone(r))}var t=e.morphAttributes;for(const e in t){const i=[],n=t[e];for(let e=0,t=n.length;e<t;e++)i.push(n[e].clone(r));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;var s=e.groups;for(let e=0,t=s.length;e<t;e++){const r=s[e];this.addGroup(r.start,r.count,r.materialIndex)}var a=e.boundingBox,a=(null!==a&&(this.boundingBox=a.clone()),e.boundingSphere);return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}S.prototype.isBufferGeometry=!0;const gs=new ke,vs=new cn,ys=new rn,xs=new Pe,_s=new Pe,bs=new Pe,Ts=new Pe,Ss=new Pe,Es=new Pe,ws=new Pe,Ms=new Pe,As=new Pe,Ls=new z,Rs=new z,Cs=new z,Ds=new Pe,Is=new Pe;class E extends c{constructor(e=new S,t=new Qn){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(i,n){const e=this.geometry,s=this.material,a=this.matrixWorld;if(void 0!==s&&(null===e.boundingSphere&&e.computeBoundingSphere(),ys.copy(e.boundingSphere),ys.applyMatrix4(a),!1!==i.ray.intersectsSphere(ys))&&(gs.copy(a).invert(),vs.copy(i.ray).applyMatrix4(gs),null===e.boundingBox||!1!==vs.intersectsBox(e.boundingBox))){let r;if(e.isBufferGeometry){const a=e.index,d=e.attributes.position,f=e.morphAttributes.position,p=e.morphTargetsRelative,m=e.attributes.uv,g=e.attributes.uv2,v=e.groups,y=e.drawRange;if(null!==a)if(Array.isArray(s))for(let e=0,t=v.length;e<t;e++){var o=v[e],l=s[o.materialIndex];for(let e=Math.max(o.start,y.start),t=Math.min(a.count,Math.min(o.start+o.count,y.start+y.count));e<t;e+=3){const s=a.getX(e),x=a.getX(e+1),_=a.getX(e+2);(r=Ps(this,l,i,vs,d,f,p,m,g,s,x,_))&&(r.faceIndex=Math.floor(e/3),r.face.materialIndex=o.materialIndex,n.push(r))}}else for(let e=Math.max(0,y.start),t=Math.min(a.count,y.start+y.count);e<t;e+=3){var h=a.getX(e),u=a.getX(e+1),c=a.getX(e+2);(r=Ps(this,s,i,vs,d,f,p,m,g,h,u,c))&&(r.faceIndex=Math.floor(e/3),n.push(r))}else if(void 0!==d)if(Array.isArray(s))for(let e=0,t=v.length;e<t;e++){const a=v[e],b=s[a.materialIndex];for(let e=Math.max(a.start,y.start),t=Math.min(d.count,Math.min(a.start+a.count,y.start+y.count));e<t;e+=3)(r=Ps(this,b,i,vs,d,f,p,m,g,e,e+1,e+2))&&(r.faceIndex=Math.floor(e/3),r.face.materialIndex=a.materialIndex,n.push(r))}else for(let e=Math.max(0,y.start),t=Math.min(d.count,y.start+y.count);e<t;e+=3)(r=Ps(this,s,i,vs,d,f,p,m,g,e,e+1,e+2))&&(r.faceIndex=Math.floor(e/3),n.push(r))}else e.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Ps(e,r,i,t,n,s,a,o,l,h,u,c){xs.fromBufferAttribute(n,h),_s.fromBufferAttribute(n,u),bs.fromBufferAttribute(n,c);var d=e.morphTargetInfluences;if(s&&d){ws.set(0,0,0),Ms.set(0,0,0),As.set(0,0,0);for(let e=0,t=s.length;e<t;e++){const r=d[e],i=s[e];0!==r&&(Ts.fromBufferAttribute(i,h),Ss.fromBufferAttribute(i,u),Es.fromBufferAttribute(i,c),a?(ws.addScaledVector(Ts,r),Ms.addScaledVector(Ss,r),As.addScaledVector(Es,r)):(ws.addScaledVector(Ts.sub(xs),r),Ms.addScaledVector(Ss.sub(_s),r),As.addScaledVector(Es.sub(bs),r)))}xs.add(ws),_s.add(Ms),bs.add(As)}e.isSkinnedMesh&&(e.boneTransform(h,xs),e.boneTransform(u,_s),e.boneTransform(c,bs));n=function(e,t,r,i,n,s,a,o){if(null===(t.side===Ae?i.intersectTriangle(a,s,n,!0,o):i.intersectTriangle(n,s,a,t.side!==Fe,o)))return null;Is.copy(o),Is.applyMatrix4(e.matrixWorld);i=r.ray.origin.distanceTo(Is);return i<r.near||i>r.far?null:{distance:i,point:Is.clone(),object:e}}(e,r,i,t,xs,_s,bs,Ds);if(n){o&&(Ls.fromBufferAttribute(o,h),Rs.fromBufferAttribute(o,u),Cs.fromBufferAttribute(o,c),n.uv=f.getUV(Ds,xs,_s,bs,Ls,Rs,Cs,new z)),l&&(Ls.fromBufferAttribute(l,h),Rs.fromBufferAttribute(l,u),Cs.fromBufferAttribute(l,c),n.uv2=f.getUV(Ds,xs,_s,bs,Ls,Rs,Cs,new z));const e={a:h,b:u,c:c,normal:new Pe,materialIndex:0};f.getNormal(xs,_s,bs,e.normal),n.face=e}return n}E.prototype.isMesh=!0;class ks extends S{constructor(e=1,t=1,r=1,i=1,n=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:s};const b=this,T=(i=Math.floor(i),n=Math.floor(n),s=Math.floor(s),[]),S=[],E=[],w=[];let M=0,A=0;function a(r,i,n,s,a,o,e,l,h,u,t){var c=o/h,d=e/u,f=o/2,p=e/2,m=l/2,g=h+1,v=u+1;let y=0,x=0;var _=new Pe;for(let t=0;t<v;t++){const b=t*d-p;for(let e=0;e<g;e++){const M=e*c-f;_[r]=M*s,_[i]=b*a,_[n]=m,S.push(_.x,_.y,_.z),_[r]=0,_[i]=0,_[n]=0<l?1:-1,E.push(_.x,_.y,_.z),w.push(e/h),w.push(1-t/u),y+=1}}for(let t=0;t<u;t++)for(let e=0;e<h;e++){const n=M+e+g*t,s=M+e+g*(t+1),a=M+(e+1)+g*(t+1),o=M+(e+1)+g*t;T.push(n,s,o),T.push(s,a,o),x+=6}b.addGroup(A,x,t),A+=x,M+=y}a("z","y","x",-1,-1,r,t,e,s,n,0),a("z","y","x",1,-1,r,t,-e,s,n,1),a("x","z","y",1,1,e,r,t,i,s,2),a("x","z","y",1,-1,e,r,-t,i,s,3),a("x","y","z",1,-1,e,t,r,i,n,4),a("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(T),this.setAttribute("position",new V(S,3)),this.setAttribute("normal",new V(E,3)),this.setAttribute("uv",new V(w,2))}static fromJSON(e){return new ks(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Os(e){var t={};for(const i in e){t[i]={};for(const n in e[i]){var r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function Fs(t){var r={};for(let e=0;e<t.length;e++){var i=Os(t[e]);for(const t in i)r[t]=i[t]}return r}const Ns={clone:Os,merge:Fs};class Us extends r{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Os(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){var t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){var r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return 0<Object.keys(i).length&&(t.extensions=i),t}}Us.prototype.isShaderMaterial=!0;class Bs extends c{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}Bs.prototype.isCamera=!0;class N extends Bs{constructor(e=50,t=1,r=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){e=.5*this.getFilmHeight()/e;this.fov=2*di*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){var e=Math.tan(.5*ci*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*di*Math.atan(Math.tan(.5*ci*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,r,i,n,s){this.aspect=e/t,null===this.view&&(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=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*ci*this.fov)/this.zoom,r=2*t,i=this.aspect*r,n=-.5*i;var s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;n+=s.offsetX*i/e,t-=s.offsetY*r/a,i*=s.width/e,r*=s.height/a}const a=this.filmOffset;0!==a&&(n+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,t,t-r,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){e=super.toJSON(e);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}N.prototype.isPerspectiveCamera=!0;class Gs extends c{constructor(e,t,r){super(),this.type="CubeCamera",!0!==r.isWebGLCubeRenderTarget?console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."):(this.renderTarget=r,(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(1,0,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(-1,0,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,0,1),r.lookAt(new Pe(0,1,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,0,-1),r.lookAt(new Pe(0,-1,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(0,0,1)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(0,0,-1)),this.add(r))}update(e,t){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,[i,n,s,a,o,l]=this.children,h=e.xr.enabled,u=e.getRenderTarget(),c=(e.xr.enabled=!1,r.texture.generateMipmaps);r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,i),e.setRenderTarget(r,1),e.render(t,n),e.setRenderTarget(r,2),e.render(t,s),e.setRenderTarget(r,3),e.render(t,a),e.setRenderTarget(r,4),e.render(t,o),r.texture.generateMipmaps=c,e.setRenderTarget(r,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=h}}class Hs extends u{constructor(e,t,r,i,n,s,a,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Ue,r,i,n,s,a,o,l,h),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Hs.prototype.isCubeTexture=!0;class zs extends Di{constructor(e,t,r){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=r),super(e,e,t),t=t||{},this.texture=new Hs(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:U,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=Ce,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",n="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new ks(5,5,5),a=new Us({name:"CubemapFromEquirect",uniforms:Os(r),vertexShader:i,fragmentShader:n,side:Ae,blending:q});a.uniforms.tEquirect.value=t;var o=new E(s,a),l=t.minFilter;return t.minFilter===Ze&&(t.minFilter=U),new Gs(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,r,i,n){var e=t.getRenderTarget();for(let e=0;e<6;e++)t.setRenderTarget(this,e),t.clear(r,i,n);t.setRenderTarget(e)}}zs.prototype.isWebGLCubeRenderTarget=!0;const Vs=new Pe,Ws=new Pe,js=new v;class Ys{constructor(e=new Pe(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){r=Vs.subVectors(r,t).cross(Ws.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){var 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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){var r=e.delta(Vs),i=this.normal.dot(r);return 0===i?0===this.distanceToPoint(e.start)?t.copy(e.start):null:(i=-(e.start.dot(this.normal)+this.constant)/i)<0||1<i?null:t.copy(r).multiplyScalar(i).add(e.start)}intersectsLine(e){var t=this.distanceToPoint(e.start),e=this.distanceToPoint(e.end);return t<0&&0<e||e<0&&0<t}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){t=t||js.getNormalMatrix(e),e=this.coplanarPoint(Vs).applyMatrix4(e),t=this.normal.applyMatrix3(t).normalize();return this.constant=-e.dot(t),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)}}Ys.prototype.isPlane=!0;const $s=new rn,qs=new Pe;class Ks{constructor(e=new Ys,t=new Ys,r=new Ys,i=new Ys,n=new Ys,s=new Ys){this.planes=[e,t,r,i,n,s]}set(e,t,r,i,n,s){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(s),this}copy(t){var r=this.planes;for(let e=0;e<6;e++)r[e].copy(t.planes[e]);return this}setFromProjectionMatrix(e){var t=this.planes,e=e.elements,r=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],e=e[15];return t[0].setComponents(s-r,h-a,f-u,e-p).normalize(),t[1].setComponents(s+r,h+a,f+u,e+p).normalize(),t[2].setComponents(s+i,h+o,f+c,e+m).normalize(),t[3].setComponents(s-i,h-o,f-c,e-m).normalize(),t[4].setComponents(s-n,h-l,f-d,e-g).normalize(),t[5].setComponents(s+n,h+l,f+d,e+g).normalize(),this}intersectsObject(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),$s.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere($s)}intersectsSprite(e){return $s.center.set(0,0,0),$s.radius=.7071067811865476,$s.applyMatrix4(e.matrixWorld),this.intersectsSphere($s)}intersectsSphere(e){var t=this.planes,r=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(r)<i)return!1;return!0}intersectsBox(t){var r=this.planes;for(let e=0;e<6;e++){var i=r[e];if(qs.x=(0<i.normal.x?t.max:t.min).x,qs.y=(0<i.normal.y?t.max:t.min).y,qs.z=(0<i.normal.z?t.max:t.min).z,i.distanceToPoint(qs)<0)return!1}return!0}containsPoint(t){var r=this.planes;for(let e=0;e<6;e++)if(r[e].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Xs(){let r=null,e=!1,i=null,n=null;function s(e,t){i(e,t),n=r.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==i&&(n=r.requestAnimationFrame(s),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(e){i=e},setContext:function(e){r=e}}}function Js(a,e){const o=e.isWebGL2,l=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),l.get(e)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var t=l.get(e);t&&(a.deleteBuffer(t.buffer),l.delete(e))},update:function(e,t){if(e.isGLBufferAttribute){const a=l.get(e);void((!a||a.version<e.version)&&l.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}else{e.isInterleavedBufferAttribute&&(e=e.data);var r,i,n,s=l.get(e);void 0===s?l.set(e,function(e,t){var r=e.array,i=e.usage,n=a.createBuffer();a.bindBuffer(t,n),a.bufferData(t,r,i),e.onUploadCallback();let s=5126;return r instanceof Float32Array?s=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?o?s=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):s=5123:r instanceof Int16Array?s=5122:r instanceof Uint32Array?s=5125:r instanceof Int32Array?s=5124:r instanceof Int8Array?s=5120:(r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&(s=5121),{buffer:n,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,t)):s.version<e.version&&(r=s.buffer,t=t,n=(i=e).array,i=i.updateRange,a.bindBuffer(t,r),-1===i.count?a.bufferSubData(t,0,n):(o?a.bufferSubData(t,i.offset*n.BYTES_PER_ELEMENT,n,i.offset,i.count):a.bufferSubData(t,i.offset*n.BYTES_PER_ELEMENT,n.subarray(i.offset,i.offset+i.count)),i.count=-1),s.version=e.version)}}}}class Zs extends S{constructor(e=1,r=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:r,widthSegments:i,heightSegments:n};const s=e/2,a=r/2,o=Math.floor(i),l=Math.floor(n),h=o+1,u=l+1,c=e/o,d=r/l,f=[],p=[],m=[],g=[];for(let t=0;t<u;t++){const r=t*d-a;for(let e=0;e<h;e++){const n=e*c-s;p.push(n,-r,0),m.push(0,0,1),g.push(e/o),g.push(1-t/l)}}for(let t=0;t<l;t++)for(let e=0;e<o;e++){const i=e+h*t,n=e+h*(t+1),s=e+1+h*(t+1),a=e+1+h*t;f.push(i,n,a),f.push(n,s,a)}this.setIndex(f),this.setAttribute("position",new V(p,3)),this.setAttribute("normal",new V(m,3)),this.setAttribute("uv",new V(g,2))}static fromJSON(e){return new Zs(e.width,e.height,e.widthSegments,e.heightSegments)}}const M={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},A={common:{diffuse:{value:new g(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new v},uv2Transform:{value:new v},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new g(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:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{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 g(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new v}},sprite:{diffuse:{value:new g(16777215)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new v}}},Qs={basic:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.fog]),vertexShader:M.meshbasic_vert,fragmentShader:M.meshbasic_frag},lambert:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.fog,A.lights,{emissive:{value:new g(0)}}]),vertexShader:M.meshlambert_vert,fragmentShader:M.meshlambert_frag},phong:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.fog,A.lights,{emissive:{value:new g(0)},specular:{value:new g(1118481)},shininess:{value:30}}]),vertexShader:M.meshphong_vert,fragmentShader:M.meshphong_frag},standard:{uniforms:Fs([A.common,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.roughnessmap,A.metalnessmap,A.fog,A.lights,{emissive:{value:new g(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag},toon:{uniforms:Fs([A.common,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.gradientmap,A.fog,A.lights,{emissive:{value:new g(0)}}]),vertexShader:M.meshtoon_vert,fragmentShader:M.meshtoon_frag},matcap:{uniforms:Fs([A.common,A.bumpmap,A.normalmap,A.displacementmap,A.fog,{matcap:{value:null}}]),vertexShader:M.meshmatcap_vert,fragmentShader:M.meshmatcap_frag},points:{uniforms:Fs([A.points,A.fog]),vertexShader:M.points_vert,fragmentShader:M.points_frag},dashed:{uniforms:Fs([A.common,A.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:M.linedashed_vert,fragmentShader:M.linedashed_frag},depth:{uniforms:Fs([A.common,A.displacementmap]),vertexShader:M.depth_vert,fragmentShader:M.depth_frag},normal:{uniforms:Fs([A.common,A.bumpmap,A.normalmap,A.displacementmap,{opacity:{value:1}}]),vertexShader:M.meshnormal_vert,fragmentShader:M.meshnormal_frag},sprite:{uniforms:Fs([A.sprite,A.fog]),vertexShader:M.sprite_vert,fragmentShader:M.sprite_frag},background:{uniforms:{uvTransform:{value:new v},t2D:{value:null}},vertexShader:M.background_vert,fragmentShader:M.background_frag},cube:{uniforms:Fs([A.envmap,{opacity:{value:1}}]),vertexShader:M.cube_vert,fragmentShader:M.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:M.equirect_vert,fragmentShader:M.equirect_frag},distanceRGBA:{uniforms:Fs([A.common,A.displacementmap,{referencePosition:{value:new Pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:M.distanceRGBA_vert,fragmentShader:M.distanceRGBA_frag},shadow:{uniforms:Fs([A.lights,A.fog,{color:{value:new g(0)},opacity:{value:1}}]),vertexShader:M.shadow_vert,fragmentShader:M.shadow_frag}};function ea(n,s,r,a,i){const o=new g(0);let l,h,u=0,c=null,d=0,f=null;function p(e,t){r.buffers.color.setClear(e.r,e.g,e.b,t,i)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,p(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,p(o,u)},render:function(e,t){let r=!1,i=!0===t.isScene?t.background:null;i&&i.isTexture&&(i=s.get(i));t=n.xr,t=t.getSession&&t.getSession();null===(i=t&&"additive"===t.environmentBlendMode?null:i)?p(o,u):i&&i.isColor&&(p(i,1),r=!0),(n.autoClear||r)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),i&&(i.isCubeTexture||i.mapping===ze)?(void 0===h&&((h=new E(new ks(1,1,1),new Us({name:"BackgroundCubeMaterial",uniforms:Os(Qs.cube.uniforms),vertexShader:Qs.cube.vertexShader,fragmentShader:Qs.cube.fragmentShader,side:Ae,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(h)),h.material.uniforms.envMap.value=i,h.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c===i&&d===i.version&&f===n.toneMapping||(h.material.needsUpdate=!0,c=i,d=i.version,f=n.toneMapping),e.unshift(h,h.geometry,h.material,0,0,null)):i&&i.isTexture&&(void 0===l&&((l=new E(new Zs(2,2),new Us({name:"BackgroundMaterial",uniforms:Os(Qs.background.uniforms),vertexShader:Qs.background.vertexShader,fragmentShader:Qs.background.fragmentShader,side:Oe,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),!0===(l.material.uniforms.t2D.value=i).matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),c===i&&d===i.version&&f===n.toneMapping||(l.material.needsUpdate=!0,c=i,d=i.version,f=n.toneMapping),e.unshift(l,l.geometry,l.material,0,0,null))}}}function ta(c,d,f,p){const n=c.getParameter(34921),m=p.isWebGL2?null:d.get("OES_vertex_array_object"),g=p.isWebGL2||null!==m,v={},e=_(null);let y=e;function x(e){p.isWebGL2?c.bindVertexArray(e):m.bindVertexArrayOES(e)}function s(e){p.isWebGL2?c.deleteVertexArray(e):m.deleteVertexArrayOES(e)}function _(e){var t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function b(){var r=y.newAttributes;for(let e=0,t=r.length;e<t;e++)r[e]=0}function T(e){S(e,0)}function S(e,t){var r=y.newAttributes,i=y.enabledAttributes,n=y.attributeDivisors;r[e]=1,0===i[e]&&(c.enableVertexAttribArray(e),i[e]=1),n[e]!==t&&((p.isWebGL2?c:d.get("ANGLE_instanced_arrays"))[p.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](e,t),n[e]=t)}function E(){var r=y.newAttributes,i=y.enabledAttributes;for(let e=0,t=i.length;e<t;e++)i[e]!==r[e]&&(c.disableVertexAttribArray(e),i[e]=0)}function w(e,t,r,i,n,s){!0!==p.isWebGL2||5124!==r&&5125!==r?c.vertexAttribPointer(e,t,r,i,n,s):c.vertexAttribIPointer(e,t,r,n,s)}function a(){t(),y!==e&&x((y=e).object)}function t(){e.geometry=null,e.program=null,e.wireframe=!1}return{setup:function(e,a,t,r,i){let n=!1;if(g){const d=function(e,t){var r=!0===a.wireframe;let i=v[e.id],n=(void 0===i&&(i={},v[e.id]=i),i[t.id]),s=(void 0===n&&(n={},i[t.id]=n),n[r]);return void 0===s&&(s=_(p.isWebGL2?c.createVertexArray():m.createVertexArrayOES()),n[r]=s),s}(r,t);if(y!==d&&x((y=d).object),n=function(e,t){var r=y.attributes,i=e.attributes;let n=0;for(const e in i){const t=r[e],s=i[e];if(void 0===t)return!0;if(t.attribute!==s)return!0;if(t.data!==s.data)return!0;n++}return y.attributesNum!==n||y.index!==t}(r,i)){var s=r;var o=i;var l={},h=s.attributes;let e=0;for(const s in h){const o=h[s],u={};(u.attribute=o).data&&(u.data=o.data),l[s]=u,e++}y.attributes=l,y.attributesNum=e,y.index=o}}else{const c=!0===a.wireframe;y.geometry===r.id&&y.program===t.id&&y.wireframe===c||(y.geometry=r.id,y.program=t.id,y.wireframe=c,n=!0)}!0===e.isInstancedMesh&&(n=!0),null!==i&&f.update(i,34963),n&&(function(e,t,r,i){if(!1!==p.isWebGL2||!e.isInstancedMesh&&!i.isInstancedBufferGeometry||null!==d.get("ANGLE_instanced_arrays")){b();const n=i.attributes,s=r.getAttributes(),a=t.defaultAttributeValues;for(const d in s){const p=s[d];if(0<=p.location){let t=n[d];if(void 0!==(t=void 0===t&&("instanceMatrix"===d&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===d)&&e.instanceColor?e.instanceColor:t)){const d=t.normalized,r=t.itemSize,n=f.get(t);if(void 0!==n){const s=n.buffer,a=n.type,o=n.bytesPerElement;if(t.isInterleavedBufferAttribute){const f=t.data,n=f.stride,l=t.offset;if(f&&f.isInstancedInterleavedBuffer){for(let e=0;e<p.locationSize;e++)S(p.location+e,f.meshPerAttribute);!0!==e.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=f.meshPerAttribute*f.count)}else for(let e=0;e<p.locationSize;e++)T(p.location+e);c.bindBuffer(34962,s);for(let e=0;e<p.locationSize;e++)w(p.location+e,r/p.locationSize,a,d,n*o,(l+r/p.locationSize*e)*o)}else{if(t.isInstancedBufferAttribute){for(let e=0;e<p.locationSize;e++)S(p.location+e,t.meshPerAttribute);!0!==e.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<p.locationSize;e++)T(p.location+e);c.bindBuffer(34962,s);for(let e=0;e<p.locationSize;e++)w(p.location+e,r/p.locationSize,a,d,r*o,r/p.locationSize*e*o)}}}else if(void 0!==a){const f=a[d];if(void 0!==f)switch(f.length){case 2:c.vertexAttrib2fv(p.location,f);break;case 3:c.vertexAttrib3fv(p.location,f);break;case 4:c.vertexAttrib4fv(p.location,f);break;default:c.vertexAttrib1fv(p.location,f)}}}}E()}}(e,a,t,r),null!==i)&&c.bindBuffer(34963,f.get(i).buffer)},reset:a,resetDefaultState:t,dispose:function(){a();for(const r in v){var e=v[r];for(const i in e){var t=e[i];for(const n in t)s(t[n].object),delete t[n];delete e[i]}delete v[r]}},releaseStatesOfGeometry:function(e){if(void 0!==v[e.id]){var t=v[e.id];for(const e in t){var r=t[e];for(const e in r)s(r[e].object),delete r[e];delete t[e]}delete v[e.id]}},releaseStatesOfProgram:function(e){for(const i in v){var t=v[i];if(void 0!==t[e.id]){var r=t[e.id];for(const e in r)s(r[e].object),delete r[e];delete t[e.id]}}},initAttributes:b,enableAttribute:T,disableUnusedAttributes:E}}function ra(s,a,o,e){const l=e.isWebGL2;let h;this.setMode=function(e){h=e},this.render=function(e,t){s.drawArrays(h,e,t),o.update(t,h,1)},this.renderInstances=function(r,i,n){if(0!==n){let e,t;if(l)e=s,t="drawArraysInstanced";else if(e=a.get("ANGLE_instanced_arrays"),t="drawArraysInstancedANGLE",null===e)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](h,r,i,n),o.update(i,h,n)}}}function ia(t,r,e){let i;function n(e){if("highp"===e){if(0<t.getShaderPrecisionFormat(35633,36338).precision&&0<t.getShaderPrecisionFormat(35632,36338).precision)return"highp";e="mediump"}return"mediump"===e&&0<t.getShaderPrecisionFormat(35633,36337).precision&&0<t.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let a=void 0!==e.precision?e.precision:"highp";var o=n(a),o=(o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o),s||r.has("WEBGL_draw_buffers")),e=!0===e.logarithmicDepthBuffer,l=t.getParameter(34930),h=t.getParameter(35660),u=t.getParameter(3379),c=t.getParameter(34076),d=t.getParameter(34921),f=t.getParameter(36347),p=t.getParameter(36348),m=t.getParameter(36349),g=0<h,v=s||r.has("OES_texture_float");return{isWebGL2:s,drawBuffers:o,getMaxAnisotropy:function(){var e;return i=void 0===i?!0===r.has("EXT_texture_filter_anisotropic")?(e=r.get("EXT_texture_filter_anisotropic"),t.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT)):0:i},getMaxPrecision:n,precision:a,logarithmicDepthBuffer:e,maxTextures:l,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:c,maxAttributes:d,maxVertexUniforms:f,maxVaryings:p,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v,maxSamples:s?t.getParameter(36183):0}}function na(l){const t=this;let h=null,u=0,c=!1,d=!1;const o=new Ys,f=new v,p={value:null,needsUpdate:!1};function m(){p.value!==h&&(p.value=h,p.needsUpdate=0<u),t.numPlanes=u,t.numIntersection=0}function g(r,e,i,n){var s=null!==r?r.length:0;let a=null;if(0!==s){if(a=p.value,!0!==n||null===a){const t=i+4*s,n=e.matrixWorldInverse;f.getNormalMatrix(n),(null===a||a.length<t)&&(a=new Float32Array(t));for(let e=0,t=i;e!==s;++e,t+=4)o.copy(r[e]).applyMatrix4(n,f),o.normal.toArray(a,t),a[t+3]=o.constant}p.value=a,p.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,a}this.uniform=p,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,r){var i=0!==e.length||t||0!==u||c;return c=t,h=g(e,r,0),u=e.length,i},this.beginShadows=function(){d=!0,g(null)},this.endShadows=function(){d=!1,m()},this.setState=function(t,e,r){var i=t.clippingPlanes,n=t.clipIntersection,s=t.clipShadows,a=l.get(t);if(!c||null===i||0===i.length||d&&!s)d?g(null):m();else{const l=d?0:u,t=4*l;var o=a.clippingState||null;p.value=o,o=g(i,e,t,r);for(let e=0;e!==t;++e)o[e]=h[e];a.clippingState=o,this.numIntersection=n?this.numPlanes:0,this.numPlanes+=l}}}function sa(i){let n=new WeakMap;function s(e,t){return t===Ge?e.mapping=Ue:t===He&&(e.mapping=Be),e}function a(e){var e=e.target,t=(e.removeEventListener("dispose",a),n.get(e));void 0!==t&&(n.delete(e),t.dispose())}return{get:function(e){if(e&&e.isTexture&&!1===e.isRenderTargetTexture){var t,r=e.mapping;if(r===Ge||r===He)return n.has(e)?s(n.get(e).texture,e.mapping):(r=e.image)&&0<r.height?(t=i.getRenderTarget(),(r=new zs(r.height/2)).fromEquirectangularTexture(i,e),n.set(e,r),i.setRenderTarget(t),e.addEventListener("dispose",a),s(r.texture,e.mapping)):null}return e},dispose:function(){n=new WeakMap}}}Qs.physical={uniforms:Fs([Qs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new z(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new g(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new g(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new g(1,1,1)},specularColorMap:{value:null}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag};class aa extends Bs{constructor(e=-1,t=1,r=1,i=-1,n=.1,s=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=n,this.far=s,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,n,s){null===this.view&&(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=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=r-e,s=r+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=e*this.view.offsetX,s=n+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(n,s,a,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){e=super.toJSON(e);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}aa.prototype.isOrthographicCamera=!0;class oa extends Us{constructor(e){super(e),this.type="RawShaderMaterial"}}oa.prototype.isRawShaderMaterial=!0;const la=Math.pow(2,8),ha=[.125,.215,.35,.446,.526,.582],ua=5+ha.length,ca={[De]:0,[wr]:1,[Ar]:2,[Rr]:3,[Cr]:4,[Dr]:5,[Mr]:6},da=new aa,{_lodPlanes:fa,_sizeLods:pa,_sigmas:ma}=function(){const r=[],i=[],n=[];let s=8;for(let t=0;t<ua;t++){var a=Math.pow(2,s);i.push(a);let e=1/a;4<t?e=ha[t-8+4-1]:0==t&&(e=0),n.push(e);var a=1/(a-1),o=-a/2,a=1+a/2,l=[o,o,a,o,a,a,o,o,a,a,o,a],h=new Float32Array(108),u=new Float32Array(72),c=new Float32Array(36);for(let e=0;e<6;e++){const i=e%3*2/3-1,n=2<e?0:-1,s=[i,n,0,i+2/3,n,0,i+2/3,1+n,0,i,n,0,i+2/3,1+n,0,i,1+n,0];h.set(s,18*e),u.set(l,12*e);var d=[e,e,e,e,e,e];c.set(d,6*e)}o=new S;o.setAttribute("position",new w(h,3)),o.setAttribute("uv",new w(u,2)),o.setAttribute("faceIndex",new w(c,1)),r.push(o),4<s&&s--}return{_lodPlanes:r,_sizeLods:i,_sigmas:n}}(),ga=new g;let va=null;const ya=(1+Math.sqrt(5))/2,xa=1/ya,_a=[new Pe(1,1,1),new Pe(-1,1,1),new Pe(1,1,-1),new Pe(-1,1,-1),new Pe(0,ya,xa),new Pe(0,ya,-xa),new Pe(xa,0,ya),new Pe(-xa,0,ya),new Pe(ya,xa,0),new Pe(-ya,xa,0)];class ba{constructor(e){var t;this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=(e=new Float32Array(20),t=new Pe(0,1,0),new oa({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t},inputEncoding:{value:ca[De]},outputEncoding:{value:ca[De]}},vertexShader:Ma(),fragmentShader:`
|
|
1
|
+
(window.webpackJsonpfeffery_utils_components=window.webpackJsonpfeffery_utils_components||[]).push([[0],{553:function(d,e,t){"use strict";t.r(e),t.d(e,"ACESFilmicToneMapping",function(){return Ee}),t.d(e,"AddEquation",function(){return ee}),t.d(e,"AddOperation",function(){return B}),t.d(e,"AdditiveAnimationBlendMode",function(){return br}),t.d(e,"AdditiveBlending",function(){return X}),t.d(e,"AlphaFormat",function(){return dt}),t.d(e,"AlwaysDepth",function(){return ve}),t.d(e,"AlwaysStencilFunc",function(){return Jr}),t.d(e,"AmbientLight",function(){return qc}),t.d(e,"AmbientLightProbe",function(){return cd}),t.d(e,"AnimationClip",function(){return _c}),t.d(e,"AnimationLoader",function(){return Ac}),t.d(e,"AnimationMixer",function(){return Gd}),t.d(e,"AnimationObjectGroup",function(){return Ud}),t.d(e,"AnimationUtils",function(){return p}),t.d(e,"ArcCurve",function(){return Jh}),t.d(e,"ArrayCamera",function(){return El}),t.d(e,"ArrowHelper",function(){return Af}),t.d(e,"Audio",function(){return Td}),t.d(e,"AudioAnalyser",function(){return Ld}),t.d(e,"AudioContext",function(){return ld}),t.d(e,"AudioListener",function(){return bd}),t.d(e,"AudioLoader",function(){return hd}),t.d(e,"AxesHelper",function(){return Lf}),t.d(e,"AxisHelper",function(){return ip}),t.d(e,"BackSide",function(){return Ae}),t.d(e,"BasicDepthPacking",function(){return Ir}),t.d(e,"BasicShadowMap",function(){return R}),t.d(e,"BinaryTextureLoader",function(){return lp}),t.d(e,"Bone",function(){return oh}),t.d(e,"BooleanKeyframeTrack",function(){return fc}),t.d(e,"BoundingBoxHelper",function(){return np}),t.d(e,"Box2",function(){return Xd}),t.d(e,"Box3",function(){return Ni}),t.d(e,"Box3Helper",function(){return Tf}),t.d(e,"BoxBufferGeometry",function(){return ks}),t.d(e,"BoxGeometry",function(){return ks}),t.d(e,"BoxHelper",function(){return bf}),t.d(e,"BufferAttribute",function(){return w}),t.d(e,"BufferGeometry",function(){return S}),t.d(e,"BufferGeometryLoader",function(){return td}),t.d(e,"ByteType",function(){return tt}),t.d(e,"Cache",function(){return bc}),t.d(e,"Camera",function(){return Bs}),t.d(e,"CameraHelper",function(){return xf}),t.d(e,"CanvasRenderer",function(){return up}),t.d(e,"CanvasTexture",function(){return Nh}),t.d(e,"CatmullRomCurve3",function(){return iu}),t.d(e,"CineonToneMapping",function(){return W}),t.d(e,"CircleBufferGeometry",function(){return Bh}),t.d(e,"CircleGeometry",function(){return Bh}),t.d(e,"ClampToEdgeWrapping",function(){return Le}),t.d(e,"Clock",function(){return md}),t.d(e,"Color",function(){return g}),t.d(e,"ColorKeyframeTrack",function(){return pc}),t.d(e,"CompressedTexture",function(){return Fh}),t.d(e,"CompressedTextureLoader",function(){return Lc}),t.d(e,"ConeBufferGeometry",function(){return Hh}),t.d(e,"ConeGeometry",function(){return Hh}),t.d(e,"CubeCamera",function(){return Gs}),t.d(e,"CubeReflectionMapping",function(){return Ue}),t.d(e,"CubeRefractionMapping",function(){return Be}),t.d(e,"CubeTexture",function(){return Hs}),t.d(e,"CubeTextureLoader",function(){return Cc}),t.d(e,"CubeUVReflectionMapping",function(){return ze}),t.d(e,"CubeUVRefractionMapping",function(){return Ve}),t.d(e,"CubicBezierCurve",function(){return ou}),t.d(e,"CubicBezierCurve3",function(){return lu}),t.d(e,"CubicInterpolant",function(){return hc}),t.d(e,"CullFaceBack",function(){return Y}),t.d(e,"CullFaceFront",function(){return $}),t.d(e,"CullFaceFrontBack",function(){return L}),t.d(e,"CullFaceNone",function(){return j}),t.d(e,"Curve",function(){return Kh}),t.d(e,"CurvePath",function(){return mu}),t.d(e,"CustomBlending",function(){return Q}),t.d(e,"CustomToneMapping",function(){return we}),t.d(e,"CylinderBufferGeometry",function(){return Gh}),t.d(e,"CylinderGeometry",function(){return Gh}),t.d(e,"Cylindrical",function(){return qd}),t.d(e,"DataTexture",function(){return lh}),t.d(e,"DataTexture2DArray",function(){return Pa}),t.d(e,"DataTexture3D",function(){return Ba}),t.d(e,"DataTextureLoader",function(){return Dc}),t.d(e,"DataUtils",function(){return If}),t.d(e,"DecrementStencilOp",function(){return Gr}),t.d(e,"DecrementWrapStencilOp",function(){return zr}),t.d(e,"DefaultLoadingManager",function(){return Sc}),t.d(e,"DepthFormat",function(){return vt}),t.d(e,"DepthStencilFormat",function(){return yt}),t.d(e,"DepthTexture",function(){return Uh}),t.d(e,"DirectionalLight",function(){return $c}),t.d(e,"DirectionalLightHelper",function(){return vf}),t.d(e,"DiscreteInterpolant",function(){return cc}),t.d(e,"DodecahedronBufferGeometry",function(){return Vh}),t.d(e,"DodecahedronGeometry",function(){return Vh}),t.d(e,"DoubleSide",function(){return Fe}),t.d(e,"DstAlphaFactor",function(){return ce}),t.d(e,"DstColorFactor",function(){return fe}),t.d(e,"DynamicBufferAttribute",function(){return $f}),t.d(e,"DynamicCopyUsage",function(){return si}),t.d(e,"DynamicDrawUsage",function(){return Qr}),t.d(e,"DynamicReadUsage",function(){return ri}),t.d(e,"EdgesGeometry",function(){return qh}),t.d(e,"EdgesHelper",function(){return sp}),t.d(e,"EllipseCurve",function(){return Xh}),t.d(e,"EqualDepth",function(){return _e}),t.d(e,"EqualStencilFunc",function(){return Yr}),t.d(e,"EquirectangularReflectionMapping",function(){return Ge}),t.d(e,"EquirectangularRefractionMapping",function(){return He}),t.d(e,"Euler",function(){return bn}),t.d(e,"EventDispatcher",function(){return hi}),t.d(e,"ExtrudeBufferGeometry",function(){return Nu}),t.d(e,"ExtrudeGeometry",function(){return Nu}),t.d(e,"FaceColors",function(){return Ff}),t.d(e,"FileLoader",function(){return Mc}),t.d(e,"FlatShading",function(){return P}),t.d(e,"Float16BufferAttribute",function(){return ls}),t.d(e,"Float32Attribute",function(){return tp}),t.d(e,"Float32BufferAttribute",function(){return V}),t.d(e,"Float64Attribute",function(){return rp}),t.d(e,"Float64BufferAttribute",function(){return hs}),t.d(e,"FloatType",function(){return at}),t.d(e,"Fog",function(){return Il}),t.d(e,"FogExp2",function(){return Dl}),t.d(e,"Font",function(){return vp}),t.d(e,"FontLoader",function(){return gp}),t.d(e,"FrontSide",function(){return Oe}),t.d(e,"Frustum",function(){return Ks}),t.d(e,"GLBufferAttribute",function(){return Vd}),t.d(e,"GLSL1",function(){return oi}),t.d(e,"GLSL3",function(){return li}),t.d(e,"GammaEncoding",function(){return Mr}),t.d(e,"GreaterDepth",function(){return Te}),t.d(e,"GreaterEqualDepth",function(){return be}),t.d(e,"GreaterEqualStencilFunc",function(){return Xr}),t.d(e,"GreaterStencilFunc",function(){return qr}),t.d(e,"GridHelper",function(){return df}),t.d(e,"Group",function(){return wl}),t.d(e,"HalfFloatType",function(){return ot}),t.d(e,"HemisphereLight",function(){return kc}),t.d(e,"HemisphereLightHelper",function(){return cf}),t.d(e,"HemisphereLightProbe",function(){return ud}),t.d(e,"IcosahedronBufferGeometry",function(){return Bu}),t.d(e,"IcosahedronGeometry",function(){return Bu}),t.d(e,"ImageBitmapLoader",function(){return ad}),t.d(e,"ImageLoader",function(){return Rc}),t.d(e,"ImageUtils",function(){return Li}),t.d(e,"ImmediateRenderObject",function(){return yp}),t.d(e,"IncrementStencilOp",function(){return Br}),t.d(e,"IncrementWrapStencilOp",function(){return Hr}),t.d(e,"InstancedBufferAttribute",function(){return dh}),t.d(e,"InstancedBufferGeometry",function(){return ed}),t.d(e,"InstancedInterleavedBuffer",function(){return zd}),t.d(e,"InstancedMesh",function(){return vh}),t.d(e,"Int16Attribute",function(){return Jf}),t.d(e,"Int16BufferAttribute",function(){return ns}),t.d(e,"Int32Attribute",function(){return Qf}),t.d(e,"Int32BufferAttribute",function(){return as}),t.d(e,"Int8Attribute",function(){return qf}),t.d(e,"Int8BufferAttribute",function(){return ts}),t.d(e,"IntType",function(){return nt}),t.d(e,"InterleavedBuffer",function(){return kl}),t.d(e,"InterleavedBufferAttribute",function(){return Ol}),t.d(e,"Interpolant",function(){return lc}),t.d(e,"InterpolateDiscrete",function(){return pr}),t.d(e,"InterpolateLinear",function(){return mr}),t.d(e,"InterpolateSmooth",function(){return gr}),t.d(e,"InvertStencilOp",function(){return Vr}),t.d(e,"JSONLoader",function(){return cp}),t.d(e,"KeepStencilOp",function(){return Nr}),t.d(e,"KeyframeTrack",function(){return dc}),t.d(e,"LOD",function(){return eh}),t.d(e,"LatheBufferGeometry",function(){return Gu}),t.d(e,"LatheGeometry",function(){return Gu}),t.d(e,"Layers",function(){return Tn}),t.d(e,"LensFlare",function(){return fp}),t.d(e,"LessDepth",function(){return ye}),t.d(e,"LessEqualDepth",function(){return xe}),t.d(e,"LessEqualStencilFunc",function(){return $r}),t.d(e,"LessStencilFunc",function(){return jr}),t.d(e,"Light",function(){return Pc}),t.d(e,"LightProbe",function(){return Jc}),t.d(e,"Line",function(){return Sh}),t.d(e,"Line3",function(){return Qd}),t.d(e,"LineBasicMaterial",function(){return y}),t.d(e,"LineCurve",function(){return hu}),t.d(e,"LineCurve3",function(){return uu}),t.d(e,"LineDashedMaterial",function(){return ac}),t.d(e,"LineLoop",function(){return Ah}),t.d(e,"LinePieces",function(){return kf}),t.d(e,"LineSegments",function(){return Mh}),t.d(e,"LineStrip",function(){return Pf}),t.d(e,"LinearEncoding",function(){return De}),t.d(e,"LinearFilter",function(){return U}),t.d(e,"LinearInterpolant",function(){return uc}),t.d(e,"LinearMipMapLinearFilter",function(){return Qe}),t.d(e,"LinearMipMapNearestFilter",function(){return Je}),t.d(e,"LinearMipmapLinearFilter",function(){return Ze}),t.d(e,"LinearMipmapNearestFilter",function(){return Xe}),t.d(e,"LinearToneMapping",function(){return G}),t.d(e,"Loader",function(){return Ec}),t.d(e,"LoaderUtils",function(){return Qc}),t.d(e,"LoadingManager",function(){return Tc}),t.d(e,"LogLuvEncoding",function(){return Lr}),t.d(e,"LoopOnce",function(){return cr}),t.d(e,"LoopPingPong",function(){return fr}),t.d(e,"LoopRepeat",function(){return dr}),t.d(e,"LuminanceAlphaFormat",function(){return mt}),t.d(e,"LuminanceFormat",function(){return pt}),t.d(e,"MOUSE",function(){return b}),t.d(e,"Material",function(){return r}),t.d(e,"MaterialLoader",function(){return Zc}),t.d(e,"Math",function(){return bi}),t.d(e,"MathUtils",function(){return bi}),t.d(e,"Matrix3",function(){return v}),t.d(e,"Matrix4",function(){return ke}),t.d(e,"MaxEquation",function(){return ne}),t.d(e,"Mesh",function(){return E}),t.d(e,"MeshBasicMaterial",function(){return Qn}),t.d(e,"MeshDepthMaterial",function(){return yl}),t.d(e,"MeshDistanceMaterial",function(){return xl}),t.d(e,"MeshFaceMaterial",function(){return Uf}),t.d(e,"MeshLambertMaterial",function(){return nc}),t.d(e,"MeshMatcapMaterial",function(){return sc}),t.d(e,"MeshNormalMaterial",function(){return ic}),t.d(e,"MeshPhongMaterial",function(){return tc}),t.d(e,"MeshPhysicalMaterial",function(){return ec}),t.d(e,"MeshStandardMaterial",function(){return Qu}),t.d(e,"MeshToonMaterial",function(){return rc}),t.d(e,"MinEquation",function(){return ie}),t.d(e,"MirroredRepeatWrapping",function(){return je}),t.d(e,"MixOperation",function(){return F}),t.d(e,"MultiMaterial",function(){return Bf}),t.d(e,"MultiplyBlending",function(){return Z}),t.d(e,"MultiplyOperation",function(){return O}),t.d(e,"NearestFilter",function(){return Re}),t.d(e,"NearestMipMapLinearFilter",function(){return Ke}),t.d(e,"NearestMipMapNearestFilter",function(){return $e}),t.d(e,"NearestMipmapLinearFilter",function(){return qe}),t.d(e,"NearestMipmapNearestFilter",function(){return Ye}),t.d(e,"NeverDepth",function(){return ge}),t.d(e,"NeverStencilFunc",function(){return Wr}),t.d(e,"NoBlending",function(){return q}),t.d(e,"NoColors",function(){return Of}),t.d(e,"NoToneMapping",function(){return Ne}),t.d(e,"NormalAnimationBlendMode",function(){return _r}),t.d(e,"NormalBlending",function(){return K}),t.d(e,"NotEqualDepth",function(){return Se}),t.d(e,"NotEqualStencilFunc",function(){return Kr}),t.d(e,"NumberKeyframeTrack",function(){return mc}),t.d(e,"Object3D",function(){return c}),t.d(e,"ObjectLoader",function(){return rd}),t.d(e,"ObjectSpaceNormalMap",function(){return Or}),t.d(e,"OctahedronBufferGeometry",function(){return Hu}),t.d(e,"OctahedronGeometry",function(){return Hu}),t.d(e,"OneFactor",function(){return ae}),t.d(e,"OneMinusDstAlphaFactor",function(){return de}),t.d(e,"OneMinusDstColorFactor",function(){return pe}),t.d(e,"OneMinusSrcAlphaFactor",function(){return ue}),t.d(e,"OneMinusSrcColorFactor",function(){return le}),t.d(e,"OrthographicCamera",function(){return aa}),t.d(e,"PCFShadowMap",function(){return C}),t.d(e,"PCFSoftShadowMap",function(){return D}),t.d(e,"PMREMGenerator",function(){return ba}),t.d(e,"ParametricGeometry",function(){return pp}),t.d(e,"Particle",function(){return Hf}),t.d(e,"ParticleBasicMaterial",function(){return Wf}),t.d(e,"ParticleSystem",function(){return zf}),t.d(e,"ParticleSystemMaterial",function(){return jf}),t.d(e,"Path",function(){return gu}),t.d(e,"PerspectiveCamera",function(){return N}),t.d(e,"Plane",function(){return Ys}),t.d(e,"PlaneBufferGeometry",function(){return Zs}),t.d(e,"PlaneGeometry",function(){return Zs}),t.d(e,"PlaneHelper",function(){return Sf}),t.d(e,"PointCloud",function(){return Gf}),t.d(e,"PointCloudMaterial",function(){return Vf}),t.d(e,"PointLight",function(){return jc}),t.d(e,"PointLightHelper",function(){return of}),t.d(e,"Points",function(){return Ph}),t.d(e,"PointsMaterial",function(){return Lh}),t.d(e,"PolarGridHelper",function(){return ff}),t.d(e,"PolyhedronBufferGeometry",function(){return zh}),t.d(e,"PolyhedronGeometry",function(){return zh}),t.d(e,"PositionalAudio",function(){return Ad}),t.d(e,"PropertyBinding",function(){return x}),t.d(e,"PropertyMixer",function(){return Rd}),t.d(e,"QuadraticBezierCurve",function(){return cu}),t.d(e,"QuadraticBezierCurve3",function(){return du}),t.d(e,"Quaternion",function(){return ki}),t.d(e,"QuaternionKeyframeTrack",function(){return vc}),t.d(e,"QuaternionLinearInterpolant",function(){return gc}),t.d(e,"REVISION",function(){return _}),t.d(e,"RGBADepthPacking",function(){return Pr}),t.d(e,"RGBAFormat",function(){return Ce}),t.d(e,"RGBAIntegerFormat",function(){return Et}),t.d(e,"RGBA_ASTC_10x10_Format",function(){return $t}),t.d(e,"RGBA_ASTC_10x5_Format",function(){return Wt}),t.d(e,"RGBA_ASTC_10x6_Format",function(){return jt}),t.d(e,"RGBA_ASTC_10x8_Format",function(){return Yt}),t.d(e,"RGBA_ASTC_12x10_Format",function(){return qt}),t.d(e,"RGBA_ASTC_12x12_Format",function(){return Kt}),t.d(e,"RGBA_ASTC_4x4_Format",function(){return Ft}),t.d(e,"RGBA_ASTC_5x4_Format",function(){return Nt}),t.d(e,"RGBA_ASTC_5x5_Format",function(){return Ut}),t.d(e,"RGBA_ASTC_6x5_Format",function(){return Bt}),t.d(e,"RGBA_ASTC_6x6_Format",function(){return Gt}),t.d(e,"RGBA_ASTC_8x5_Format",function(){return Ht}),t.d(e,"RGBA_ASTC_8x6_Format",function(){return zt}),t.d(e,"RGBA_ASTC_8x8_Format",function(){return Vt}),t.d(e,"RGBA_BPTC_Format",function(){return Xt}),t.d(e,"RGBA_ETC2_EAC_Format",function(){return Ot}),t.d(e,"RGBA_PVRTC_2BPPV1_Format",function(){return It}),t.d(e,"RGBA_PVRTC_4BPPV1_Format",function(){return Dt}),t.d(e,"RGBA_S3TC_DXT1_Format",function(){return Mt}),t.d(e,"RGBA_S3TC_DXT3_Format",function(){return At}),t.d(e,"RGBA_S3TC_DXT5_Format",function(){return Lt}),t.d(e,"RGBDEncoding",function(){return Dr}),t.d(e,"RGBEEncoding",function(){return Ar}),t.d(e,"RGBEFormat",function(){return gt}),t.d(e,"RGBFormat",function(){return ft}),t.d(e,"RGBIntegerFormat",function(){return St}),t.d(e,"RGBM16Encoding",function(){return Cr}),t.d(e,"RGBM7Encoding",function(){return Rr}),t.d(e,"RGB_ETC1_Format",function(){return Pt}),t.d(e,"RGB_ETC2_Format",function(){return kt}),t.d(e,"RGB_PVRTC_2BPPV1_Format",function(){return Ct}),t.d(e,"RGB_PVRTC_4BPPV1_Format",function(){return Rt}),t.d(e,"RGB_S3TC_DXT1_Format",function(){return wt}),t.d(e,"RGFormat",function(){return bt}),t.d(e,"RGIntegerFormat",function(){return Tt}),t.d(e,"RawShaderMaterial",function(){return oa}),t.d(e,"Ray",function(){return cn}),t.d(e,"Raycaster",function(){return Wd}),t.d(e,"RectAreaLight",function(){return Kc}),t.d(e,"RedFormat",function(){return xt}),t.d(e,"RedIntegerFormat",function(){return _t}),t.d(e,"ReinhardToneMapping",function(){return H}),t.d(e,"RepeatWrapping",function(){return We}),t.d(e,"ReplaceStencilOp",function(){return Ur}),t.d(e,"ReverseSubtractEquation",function(){return re}),t.d(e,"RingBufferGeometry",function(){return zu}),t.d(e,"RingGeometry",function(){return zu}),t.d(e,"SRGB8_ALPHA8_ASTC_10x10_Format",function(){return lr}),t.d(e,"SRGB8_ALPHA8_ASTC_10x5_Format",function(){return sr}),t.d(e,"SRGB8_ALPHA8_ASTC_10x6_Format",function(){return ar}),t.d(e,"SRGB8_ALPHA8_ASTC_10x8_Format",function(){return or}),t.d(e,"SRGB8_ALPHA8_ASTC_12x10_Format",function(){return hr}),t.d(e,"SRGB8_ALPHA8_ASTC_12x12_Format",function(){return ur}),t.d(e,"SRGB8_ALPHA8_ASTC_4x4_Format",function(){return Jt}),t.d(e,"SRGB8_ALPHA8_ASTC_5x4_Format",function(){return Zt}),t.d(e,"SRGB8_ALPHA8_ASTC_5x5_Format",function(){return Qt}),t.d(e,"SRGB8_ALPHA8_ASTC_6x5_Format",function(){return er}),t.d(e,"SRGB8_ALPHA8_ASTC_6x6_Format",function(){return tr}),t.d(e,"SRGB8_ALPHA8_ASTC_8x5_Format",function(){return rr}),t.d(e,"SRGB8_ALPHA8_ASTC_8x6_Format",function(){return ir}),t.d(e,"SRGB8_ALPHA8_ASTC_8x8_Format",function(){return nr}),t.d(e,"Scene",function(){return Pl}),t.d(e,"SceneUtils",function(){return dp}),t.d(e,"ShaderChunk",function(){return M}),t.d(e,"ShaderLib",function(){return Qs}),t.d(e,"ShaderMaterial",function(){return Us}),t.d(e,"ShadowMaterial",function(){return Zu}),t.d(e,"Shape",function(){return vu}),t.d(e,"ShapeBufferGeometry",function(){return Vu}),t.d(e,"ShapeGeometry",function(){return Vu}),t.d(e,"ShapePath",function(){return Rf}),t.d(e,"ShapeUtils",function(){return ku}),t.d(e,"ShortType",function(){return rt}),t.d(e,"Skeleton",function(){return ch}),t.d(e,"SkeletonHelper",function(){return af}),t.d(e,"SkinnedMesh",function(){return ah}),t.d(e,"SmoothShading",function(){return k}),t.d(e,"Sphere",function(){return rn}),t.d(e,"SphereBufferGeometry",function(){return Wu}),t.d(e,"SphereGeometry",function(){return Wu}),t.d(e,"Spherical",function(){return $d}),t.d(e,"SphericalHarmonics3",function(){return Xc}),t.d(e,"SplineCurve",function(){return fu}),t.d(e,"SpotLight",function(){return Gc}),t.d(e,"SpotLightHelper",function(){return tf}),t.d(e,"Sprite",function(){return Xl}),t.d(e,"SpriteMaterial",function(){return Fl}),t.d(e,"SrcAlphaFactor",function(){return he}),t.d(e,"SrcAlphaSaturateFactor",function(){return me}),t.d(e,"SrcColorFactor",function(){return oe}),t.d(e,"StaticCopyUsage",function(){return ni}),t.d(e,"StaticDrawUsage",function(){return Zr}),t.d(e,"StaticReadUsage",function(){return ti}),t.d(e,"StereoCamera",function(){return pd}),t.d(e,"StreamCopyUsage",function(){return ai}),t.d(e,"StreamDrawUsage",function(){return ei}),t.d(e,"StreamReadUsage",function(){return ii}),t.d(e,"StringKeyframeTrack",function(){return yc}),t.d(e,"SubtractEquation",function(){return te}),t.d(e,"SubtractiveBlending",function(){return J}),t.d(e,"TOUCH",function(){return T}),t.d(e,"TangentSpaceNormalMap",function(){return kr}),t.d(e,"TetrahedronBufferGeometry",function(){return ju}),t.d(e,"TetrahedronGeometry",function(){return ju}),t.d(e,"TextGeometry",function(){return mp}),t.d(e,"Texture",function(){return u}),t.d(e,"TextureLoader",function(){return Ic}),t.d(e,"TorusBufferGeometry",function(){return Yu}),t.d(e,"TorusGeometry",function(){return Yu}),t.d(e,"TorusKnotBufferGeometry",function(){return $u}),t.d(e,"TorusKnotGeometry",function(){return $u}),t.d(e,"Triangle",function(){return f}),t.d(e,"TriangleFanDrawMode",function(){return Er}),t.d(e,"TriangleStripDrawMode",function(){return Sr}),t.d(e,"TrianglesDrawMode",function(){return Tr}),t.d(e,"TubeBufferGeometry",function(){return qu}),t.d(e,"TubeGeometry",function(){return qu}),t.d(e,"UVMapping",function(){return Me}),t.d(e,"Uint16Attribute",function(){return Zf}),t.d(e,"Uint16BufferAttribute",function(){return ss}),t.d(e,"Uint32Attribute",function(){return ep}),t.d(e,"Uint32BufferAttribute",function(){return os}),t.d(e,"Uint8Attribute",function(){return Kf}),t.d(e,"Uint8BufferAttribute",function(){return rs}),t.d(e,"Uint8ClampedAttribute",function(){return Xf}),t.d(e,"Uint8ClampedBufferAttribute",function(){return is}),t.d(e,"Uniform",function(){return Hd}),t.d(e,"UniformsLib",function(){return A}),t.d(e,"UniformsUtils",function(){return Ns}),t.d(e,"UnsignedByteType",function(){return et}),t.d(e,"UnsignedInt248Type",function(){return ct}),t.d(e,"UnsignedIntType",function(){return st}),t.d(e,"UnsignedShort4444Type",function(){return lt}),t.d(e,"UnsignedShort5551Type",function(){return ht}),t.d(e,"UnsignedShort565Type",function(){return ut}),t.d(e,"UnsignedShortType",function(){return it}),t.d(e,"VSMShadowMap",function(){return I}),t.d(e,"Vector2",function(){return z}),t.d(e,"Vector3",function(){return Pe}),t.d(e,"Vector4",function(){return Ie}),t.d(e,"VectorKeyframeTrack",function(){return xc}),t.d(e,"Vertex",function(){return Yf}),t.d(e,"VertexColors",function(){return Nf}),t.d(e,"VideoTexture",function(){return Oh}),t.d(e,"WebGL1Renderer",function(){return Cl}),t.d(e,"WebGLCubeRenderTarget",function(){return zs}),t.d(e,"WebGLMultipleRenderTargets",function(){return Ii}),t.d(e,"WebGLMultisampleRenderTarget",function(){return Pi}),t.d(e,"WebGLRenderTarget",function(){return Di}),t.d(e,"WebGLRenderTargetCube",function(){return hp}),t.d(e,"WebGLRenderer",function(){return s}),t.d(e,"WebGLUtils",function(){return Sl}),t.d(e,"WireframeGeometry",function(){return Ku}),t.d(e,"WireframeHelper",function(){return ap}),t.d(e,"WrapAroundEnding",function(){return xr}),t.d(e,"XHRLoader",function(){return op}),t.d(e,"ZeroCurvatureEnding",function(){return vr}),t.d(e,"ZeroFactor",function(){return se}),t.d(e,"ZeroSlopeEnding",function(){return yr}),t.d(e,"ZeroStencilOp",function(){return Fr}),t.d(e,"sRGBEncoding",function(){return wr});const _="134",b={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},T={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},j=0,Y=1,$=2,L=3,R=0,C=1,D=2,I=3,Oe=0,Ae=1,Fe=2,P=1,k=2,q=0,K=1,X=2,J=3,Z=4,Q=5,ee=100,te=101,re=102,ie=103,ne=104,se=200,ae=201,oe=202,le=203,he=204,ue=205,ce=206,de=207,fe=208,pe=209,me=210,ge=0,ve=1,ye=2,xe=3,_e=4,be=5,Te=6,Se=7,O=0,F=1,B=2,Ne=0,G=1,H=2,W=3,Ee=4,we=5,Me=300,Ue=301,Be=302,Ge=303,He=304,ze=306,Ve=307,We=1e3,Le=1001,je=1002,Re=1003,Ye=1004,$e=1004,qe=1005,Ke=1005,U=1006,Xe=1007,Je=1007,Ze=1008,Qe=1008,et=1009,tt=1010,rt=1011,it=1012,nt=1013,st=1014,at=1015,ot=1016,lt=1017,ht=1018,ut=1019,ct=1020,dt=1021,ft=1022,Ce=1023,pt=1024,mt=1025,gt=Ce,vt=1026,yt=1027,xt=1028,_t=1029,bt=1030,Tt=1031,St=1032,Et=1033,wt=33776,Mt=33777,At=33778,Lt=33779,Rt=35840,Ct=35841,Dt=35842,It=35843,Pt=36196,kt=37492,Ot=37496,Ft=37808,Nt=37809,Ut=37810,Bt=37811,Gt=37812,Ht=37813,zt=37814,Vt=37815,Wt=37816,jt=37817,Yt=37818,$t=37819,qt=37820,Kt=37821,Xt=36492,Jt=37840,Zt=37841,Qt=37842,er=37843,tr=37844,rr=37845,ir=37846,nr=37847,sr=37848,ar=37849,or=37850,lr=37851,hr=37852,ur=37853,cr=2200,dr=2201,fr=2202,pr=2300,mr=2301,gr=2302,vr=2400,yr=2401,xr=2402,_r=2500,br=2501,Tr=0,Sr=1,Er=2,De=3e3,wr=3001,Mr=3007,Ar=3002,Lr=3003,Rr=3004,Cr=3005,Dr=3006,Ir=3200,Pr=3201,kr=0,Or=1,Fr=0,Nr=7680,Ur=7681,Br=7682,Gr=7683,Hr=34055,zr=34056,Vr=5386,Wr=512,jr=513,Yr=514,$r=515,qr=516,Kr=517,Xr=518,Jr=519,Zr=35044,Qr=35048,ei=35040,ti=35045,ri=35049,ii=35041,ni=35046,si=35050,ai=35042,oi="100",li="300 es";class hi{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){var r;return void 0!==this._listeners&&void 0!==(r=this._listeners)[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0!==this._listeners){var r=this._listeners[e];if(void 0!==r){const e=r.indexOf(t);-1!==e&&r.splice(e,1)}}}dispatchEvent(r){if(void 0!==this._listeners){var e=this._listeners[r.type];if(void 0!==e){r.target=this;var i=e.slice(0);for(let e=0,t=i.length;e<t;e++)i[e].call(this,r);r.target=null}}}}let ui=1234567;const ci=Math.PI/180,di=180/Math.PI,n=[];for(let e=0;e<256;e++)n[e]=(e<16?"0":"")+e.toString(16);const fi="undefined"!=typeof crypto&&"randomUUID"in crypto;function pi(){var e,t,r,i;return(fi?crypto.randomUUID():(e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n[255&e]+n[e>>8&255]+n[e>>16&255]+n[e>>24&255]+"-"+n[255&t]+n[t>>8&255]+"-"+n[t>>16&15|64]+n[t>>24&255]+"-"+n[63&r|128]+n[r>>8&255]+"-"+n[r>>16&255]+n[r>>24&255]+n[255&i]+n[i>>8&255]+n[i>>16&255]+n[i>>24&255])).toUpperCase()}function mi(e,t,r){return Math.max(t,Math.min(r,e))}function gi(e,t){return(e%t+t)%t}function vi(e,t,r){return(1-r)*e+r*t}function yi(e){return 0==(e&e-1)&&0!==e}function xi(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function _i(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var bi=Object.freeze({__proto__:null,DEG2RAD:ci,RAD2DEG:di,generateUUID:pi,clamp:mi,euclideanModulo:gi,mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},inverseLerp:function(e,t,r){return e!==t?(r-e)/(t-e):0},lerp:vi,damp:function(e,t,r,i){return vi(e,t,1-Math.exp(-r*i))},pingpong:function(e,t=1){return t-Math.abs(gi(e,2*t)-t)},smoothstep:function(e,t,r){return e<=t?0:r<=e?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:r<=e?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return((ui=16807*(ui=void 0!==e?e%2147483647:ui)%2147483647)-1)/2147483646},degToRad:function(e){return e*ci},radToDeg:function(e){return e*di},isPowerOfTwo:yi,ceilPowerOfTwo:xi,floorPowerOfTwo:_i,setQuaternionFromProperEuler:function(e,t,r,i,n){var s=Math.cos,a=Math.sin,o=s(r/2),l=a(r/2),h=s((t+i)/2),u=a((t+i)/2),c=s((t-i)/2),d=a((t-i)/2),f=s((i-t)/2),p=a((i-t)/2);switch(n){case"XYX":e.set(o*u,l*c,l*d,o*h);break;case"YZY":e.set(l*d,o*u,l*c,o*h);break;case"ZXZ":e.set(l*c,l*d,o*u,o*h);break;case"XZX":e.set(o*u,l*p,l*f,o*h);break;case"YXY":e.set(l*f,o*u,l*p,o*h);break;case"ZYZ":e.set(l*p,l*f,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}});class z{constructor(e=0,t=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,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){var t=this.x,r=this.y,e=e.elements;return this.x=e[0]*t+e[3]*r+e[6],this.y=e[1]*t+e[4]*r+e[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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(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}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,e=this.y-e.y;return t*t+e*e}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){var r=Math.cos(t),t=Math.sin(t),i=this.x-e.x,n=this.y-e.y;return this.x=i*r-n*t+e.x,this.y=i*t+n*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}z.prototype.isVector2=!0;class v{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,r,i,n,s,a,o,l){var h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=n,h[5]=o,h[6]=r,h[7]=s,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){e=e.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){var e=e.elements,t=t.elements,r=this.elements,i=e[0],n=e[3],s=e[6],a=e[1],o=e[4],l=e[7],h=e[2],u=e[5],e=e[8],c=t[0],d=t[3],f=t[6],p=t[1],m=t[4],g=t[7],v=t[2],y=t[5],t=t[8];return r[0]=i*c+n*p+s*v,r[3]=i*d+n*m+s*y,r[6]=i*f+n*g+s*t,r[1]=a*c+o*p+l*v,r[4]=a*d+o*m+l*y,r[7]=a*f+o*g+l*t,r[2]=h*c+u*p+e*v,r[5]=h*d+u*m+e*y,r[8]=h*f+u*g+e*t,this}multiplyScalar(e){var 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(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],e=e[8];return t*s*e-t*a*l-r*n*e+r*a*o+i*n*l-i*s*o}invert(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],h=e[8],u=h*s-a*l,c=a*o-h*n,d=l*n-s*o,f=t*u+r*c+i*d;return 0==f?this.set(0,0,0,0,0,0,0,0,0):(e[0]=u*(u=1/f),e[1]=(i*l-h*r)*u,e[2]=(a*r-i*s)*u,e[3]=c*u,e[4]=(h*t-i*o)*u,e[5]=(i*n-a*t)*u,e[6]=d*u,e[7]=(r*o-l*t)*u,e[8]=(s*t-r*n)*u,this)}transpose(){var e=this.elements,t=e[1];return e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){var 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,r,i,n,s,a){var o=Math.cos(n),n=Math.sin(n);return this.set(r*o,r*n,-r*(o*s+n*a)+s+e,-i*n,i*o,-i*(-n*s+o*a)+a+t,0,0,1),this}scale(e,t){var r=this.elements;return r[0]*=e,r[3]*=e,r[6]*=e,r[1]*=t,r[4]*=t,r[7]*=t,this}rotate(e){var t=Math.cos(e),e=Math.sin(e),r=this.elements,i=r[0],n=r[3],s=r[6],a=r[1],o=r[4],l=r[7];return r[0]=t*i+e*a,r[3]=t*n+e*o,r[6]=t*s+e*l,r[1]=-e*i+t*a,r[4]=-e*n+t*o,r[7]=-e*s+t*l,this}translate(e,t){var r=this.elements;return r[0]+=e*r[2],r[3]+=e*r[5],r[6]+=e*r[8],r[1]+=t*r[2],r[4]+=t*r[5],r[7]+=t*r[8],this}equals(e){var t=this.elements,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(t,r=0){for(let e=0;e<9;e++)this.elements[e]=t[e+r];return this}toArray(e=[],t=0){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function Ti(r){if(0===r.length)return-1/0;let i=r[0];for(let e=1,t=r.length;e<t;++e)r[e]>i&&(i=r[e]);return i}v.prototype.isMatrix3=!0;const Si={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Ei(e,t){return new Si[e](t)}function wi(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Mi(r,e=0){let i=3735928559^e,n=1103547991^e;for(let e,t=0;t<r.length;t++)e=r.charCodeAt(t),i=Math.imul(i^e,2654435761),n=Math.imul(n^e,1597334677);return i=Math.imul(i^i>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&(n=Math.imul(n^n>>>16,2246822507)^Math.imul(i^i>>>13,3266489909)))+(i>>>0)}let Ai;class Li{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;var r;return 2048<(t=e instanceof HTMLCanvasElement?e:((Ai=void 0===Ai?wi("canvas"):Ai).width=e.width,Ai.height=e.height,r=Ai.getContext("2d"),e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),Ai)).width||2048<t.height?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}}let Ri=0;class u extends hi{constructor(e=u.DEFAULT_IMAGE,t=u.DEFAULT_MAPPING,r=Le,i=Le,n=U,s=Ze,a=Ce,o=et,l=1,h=De){super(),Object.defineProperty(this,"id",{value:Ri++}),this.uuid=pi(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=r,this.wrapT=i,this.magFilter=n,this.minFilter=s,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=o,this.offset=new z(0,0),this.repeat=new z(1,1),this.center=new z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new v,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}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.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,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.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var r={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,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,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=pi()),!t&&void 0===e.images[i.uuid]){let r;if(Array.isArray(i)){r=[];for(let e=0,t=i.length;e<t;e++)i[e].isDataTexture?r.push(Ci(i[e].image)):r.push(Ci(i[e]))}else r=Ci(i);e.images[i.uuid]={uuid:i.uuid,url:r}}r.image=i.uuid}return"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping===Me){if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case We:e.x=e.x-Math.floor(e.x);break;case Le:e.x=e.x<0?0:1;break;case je:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||1<e.y)switch(this.wrapT){case We:e.y=e.y-Math.floor(e.y);break;case Le:e.y=e.y<0?0:1;break;case je:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}return e}set needsUpdate(e){!0===e&&this.version++}}function Ci(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Li.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}u.DEFAULT_IMAGE=void 0,u.DEFAULT_MAPPING=Me,u.prototype.isTexture=!0;class Ie{constructor(e=0,t=0,r=0,i=1){this.x=e,this.y=t,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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){var t=this.x,r=this.y,i=this.z,n=this.w,e=e.elements;return this.x=e[0]*t+e[4]*r+e[8]*i+e[12]*n,this.y=e[1]*t+e[5]*r+e[9]*i+e[13]*n,this.z=e[2]*t+e[6]*r+e[10]*i+e[14]*n,this.w=e[3]*t+e[7]*r+e[11]*i+e[15]*n,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var 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,r,i,n;const s=e.elements,a=s[0],o=s[4],l=s[8],h=s[1],u=s[5],c=s[9],d=s[2],f=s[6],p=s[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(c-f)<.01)if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(c+f)<.1&&Math.abs(a+u+p-3)<.1)this.set(1,0,0,0);else{t=Math.PI;const e=(a+1)/2,s=(u+1)/2,m=(p+1)/2,g=(o+h)/4,v=(l+d)/4,y=(c+f)/4;e>s&&e>m?n=e<.01?(r=0,i=.707106781):(r=Math.sqrt(e),i=g/r,v/r):s>m?n=s<.01?(r=.707106781,i=0,.707106781):(i=Math.sqrt(s),r=g/i,y/i):m<.01?(r=.707106781,i=.707106781,n=0):(n=Math.sqrt(m),r=v/n,i=y/n),this.set(r,i,n,t)}else{let e=Math.sqrt((f-c)*(f-c)+(l-d)*(l-d)+(h-o)*(h-o));Math.abs(e)<.001&&(e=1),this.x=(f-c)/e,this.y=(l-d)/e,this.z=(h-o)/e,this.w=Math.acos((a+u+p-1)/2)}return 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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,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,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),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}}Ie.prototype.isVector4=!0;class Di extends hi{constructor(e,t,r={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new Ie(0,0,e,t),this.scissorTest=!1,this.viewport=new Ie(0,0,e,t),this.texture=new u(void 0,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=void 0!==r.generateMipmaps&&r.generateMipmaps,this.texture.internalFormat=void 0!==r.internalFormat?r.internalFormat:null,this.texture.minFilter=void 0!==r.minFilter?r.minFilter:U,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0!==r.stencilBuffer&&r.stencilBuffer,this.depthTexture=void 0!==r.depthTexture?r.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,r=1){this.width===e&&this.height===t&&this.depth===r||(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,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){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image={...this.texture.image},this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}Di.prototype.isWebGLRenderTarget=!0;class Ii extends Di{constructor(e,t,r){super(e,t);var i=this.texture;this.texture=[];for(let e=0;e<r;e++)this.texture[e]=i.clone()}setSize(r,i,n=1){if(this.width!==r||this.height!==i||this.depth!==n){this.width=r,this.height=i,this.depth=n;for(let e=0,t=this.texture.length;e<t;e++)this.texture[e].image.width=r,this.texture[e].image.height=i,this.texture[e].image.depth=n;this.dispose()}return this.viewport.set(0,0,r,i),this.scissor.set(0,0,r,i),this}copy(r){this.dispose(),this.width=r.width,this.height=r.height,this.depth=r.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.depthTexture=r.depthTexture;for(let e=this.texture.length=0,t=r.texture.length;e<t;e++)this.texture[e]=r.texture[e].clone();return this}}Ii.prototype.isWebGLMultipleRenderTargets=!0;class Pi extends Di{constructor(e,t,r){super(e,t,r),this.samples=4}copy(e){return super.copy.call(this,e),this.samples=e.samples,this}}Pi.prototype.isWebGLMultisampleRenderTarget=!0;class ki{constructor(e=0,t=0,r=0,i=1){this._x=e,this._y=t,this._z=r,this._w=i}static slerp(e,t,r,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),r.slerpQuaternions(e,t,i)}static slerpFlat(t,r,i,n,s,a,o){let l=i[n+0],h=i[n+1],u=i[n+2],c=i[n+3];var d=s[a+0],f=s[a+1],p=s[a+2],a=s[a+3];if(0===o)t[r+0]=l,t[r+1]=h,t[r+2]=u,t[r+3]=c;else if(1===o)t[r+0]=d,t[r+1]=f,t[r+2]=p,t[r+3]=a;else{if(c!==a||l!==d||h!==f||u!==p){let e=1-o;const r=l*d+h*f+u*p+c*a,i=0<=r?1:-1,n=1-r*r;if(n>Number.EPSILON){const s=Math.sqrt(n),a=Math.atan2(s,r*i);e=Math.sin(e*a)/s,o=Math.sin(o*a)/s}const s=o*i;if(l=l*e+d*s,h=h*e+f*s,u=u*e+p*s,c=c*e+a*s,e===1-o){const t=1/Math.sqrt(l*l+h*h+u*u+c*c);l*=t,h*=t,u*=t,c*=t}}t[r]=l,t[r+1]=h,t[r+2]=u,t[r+3]=c}}static multiplyQuaternionsFlat(e,t,r,i,n,s){var a=r[i],o=r[i+1],l=r[i+2],r=r[i+3],i=n[s],h=n[s+1],u=n[s+2],n=n[s+3];return e[t]=a*n+r*i+o*u-l*h,e[t+1]=o*n+r*h+l*i-a*u,e[t+2]=l*n+r*u+a*h-o*i,e[t+3]=r*n-a*i-o*h-l*u,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,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,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){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var r=e._x,i=e._y,n=e._z,s=e._order,e=Math.cos,a=Math.sin,o=e(r/2),l=e(i/2),h=e(n/2),u=a(r/2),c=a(i/2),d=a(n/2);switch(s){case"XYZ":this._x=u*l*h+o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h-u*c*d;break;case"YXZ":this._x=u*l*h+o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h+u*c*d;break;case"ZXY":this._x=u*l*h-o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h-u*c*d;break;case"ZYX":this._x=u*l*h-o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h+u*c*d;break;case"YZX":this._x=u*l*h+o*c*d,this._y=o*c*h+u*l*d,this._z=o*l*d-u*c*h,this._w=o*l*h-u*c*d;break;case"XZY":this._x=u*l*h-o*c*d,this._y=o*c*h-u*l*d,this._z=o*l*d+u*c*h,this._w=o*l*h+u*c*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){var t=t/2,r=Math.sin(t);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){var e=e.elements,t=e[0],r=e[4],i=e[8],n=e[1],s=e[5],a=e[9],o=e[2],l=e[6],h=e[10],u=t+s+h;if(0<u){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(l-a)*e,this._y=(i-o)*e,this._z=(n-r)*e}else if(s<t&&h<t){const e=2*Math.sqrt(1+t-s-h);this._w=(l-a)/e,this._x=.25*e,this._y=(r+n)/e,this._z=(i+o)/e}else if(h<s){const e=2*Math.sqrt(1+s-t-h);this._w=(i-o)/e,this._x=(r+n)/e,this._y=.25*e,this._z=(a+l)/e}else{const e=2*Math.sqrt(1+h-t-s);this._w=(n-r)/e,this._x=(i+o)/e,this._y=(a+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(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=r,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(mi(this.dot(e),-1,1)))}rotateTowards(e,t){var r=this.angleTo(e);return 0!==r&&(t=Math.min(1,t/r),this.slerp(e,t)),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(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(this._x=this._x*(e=1/e),this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){var r=e._x,i=e._y,n=e._z,e=e._w,s=t._x,a=t._y,o=t._z,t=t._w;return this._x=r*t+e*s+i*o-n*a,this._y=i*t+e*a+n*s-r*o,this._z=n*t+e*o+r*a-i*s,this._w=e*t-r*s-i*a-n*o,this._onChangeCallback(),this}slerp(t,r){if(0!==r){if(1===r)return this.copy(t);var i=this._x,n=this._y,s=this._z,a=this._w;let e=a*t._w+i*t._x+n*t._y+s*t._z;if(e<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,e=-e):this.copy(t),1<=e)this._w=a,this._x=i,this._y=n,this._z=s;else{t=1-e*e;if(t<=Number.EPSILON){const t=1-r;this._w=t*a+r*this._w,this._x=t*i+r*this._x,this._y=t*n+r*this._y,this._z=t*s+r*this._z,this.normalize()}else{var t=Math.sqrt(t),o=Math.atan2(t,e),l=Math.sin((1-r)*o)/t,r=Math.sin(r*o)/t;this._w=a*l+this._w*r,this._x=i*l+this._x*r,this._y=n*l+this._y*r,this._z=s*l+this._z*r}this._onChangeCallback()}}return this}slerpQuaternions(e,t,r){this.copy(e).slerp(t,r)}random(){var e=Math.random(),t=Math.sqrt(1-e),e=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),e*Math.sin(i),e*Math.cos(i),t*Math.sin(r))}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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}ki.prototype.isQuaternion=!0;class Pe{constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,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,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(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,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(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 e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Fi.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Fi.setFromAxisAngle(e,t))}applyMatrix3(e){var t=this.x,r=this.y,i=this.z,e=e.elements;return this.x=e[0]*t+e[3]*r+e[6]*i,this.y=e[1]*t+e[4]*r+e[7]*i,this.z=e[2]*t+e[5]*r+e[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){var t=this.x,r=this.y,i=this.z,e=e.elements,n=1/(e[3]*t+e[7]*r+e[11]*i+e[15]);return this.x=(e[0]*t+e[4]*r+e[8]*i+e[12])*n,this.y=(e[1]*t+e[5]*r+e[9]*i+e[13])*n,this.z=(e[2]*t+e[6]*r+e[10]*i+e[14])*n,this}applyQuaternion(e){var t=this.x,r=this.y,i=this.z,n=e.x,s=e.y,a=e.z,e=e.w,o=e*t+s*i-a*r,l=e*r+a*t-n*i,h=e*i+n*r-s*t,t=-n*t-s*r-a*i;return this.x=o*e+t*-n+l*-a-h*-s,this.y=l*e+t*-s+h*-n-o*-a,this.z=h*e+t*-a+o*-s-l*-n,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){var t=this.x,r=this.y,i=this.z,e=e.elements;return this.x=e[0]*t+e[4]*r+e[8]*i,this.y=e[1]*t+e[5]*r+e[9]*i,this.z=e[2]*t+e[6]*r+e[10]*i,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){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){var r=e.x,i=e.y,e=e.z,n=t.x,s=t.y,t=t.z;return this.x=i*t-e*s,this.y=e*n-r*t,this.z=r*s-i*n,this}projectOnVector(e){var t=e.lengthSq();return 0===t?this.set(0,0,0):(t=e.dot(this)/t,this.copy(e).multiplyScalar(t))}projectOnPlane(e){return Oi.copy(this).projectOnVector(e),this.sub(Oi)}reflect(e){return this.sub(Oi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:(e=this.dot(e)/t,Math.acos(mi(e,-1,1)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,r=this.y-e.y,e=this.z-e.z;return t*t+r*r+e*e}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,r){var i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){e=e.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),e=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=e,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}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,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),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(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Pe.prototype.isVector3=!0;const Oi=new Pe,Fi=new ki;class Ni{constructor(e=new Pe(1/0,1/0,1/0),t=new Pe(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(r){let i=1/0,n=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let e=0,t=r.length;e<t;e+=3){var h=r[e],u=r[e+1],c=r[e+2];h<i&&(i=h),u<n&&(n=u),c<s&&(s=c),h>a&&(a=h),u>o&&(o=u),c>l&&(l=c)}return this.min.set(i,n,s),this.max.set(a,o,l),this}setFromBufferAttribute(r){let i=1/0,n=1/0,s=1/0,a=-1/0,o=-1/0,l=-1/0;for(let e=0,t=r.count;e<t;e++){var h=r.getX(e),u=r.getY(e),c=r.getZ(e);h<i&&(i=h),u<n&&(n=u),c<s&&(s=c),h>a&&(a=h),u>o&&(o=u),c>l&&(l=c)}return this.min.set(i,n,s),this.max.set(a,o,l),this}setFromPoints(r){this.makeEmpty();for(let e=0,t=r.length;e<t;e++)this.expandByPoint(r[e]);return this}setFromCenterAndSize(e,t){t=Bi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),this}setFromObject(e){return this.makeEmpty(),this.expandByObject(e)}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){e.updateWorldMatrix(!1,!1);var t=e.geometry,r=(void 0!==t&&(null===t.boundingBox&&t.computeBoundingBox(),Gi.copy(t.boundingBox),Gi.applyMatrix4(e.matrixWorld),this.union(Gi)),e.children);for(let e=0,t=r.length;e<t;e++)this.expandByObject(r[e]);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,Bi),Bi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return r=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){return!this.isEmpty()&&(this.getCenter($i),qi.subVectors(this.max,$i),Hi.subVectors(e.a,$i),zi.subVectors(e.b,$i),Vi.subVectors(e.c,$i),Wi.subVectors(zi,Hi),ji.subVectors(Vi,zi),Yi.subVectors(Hi,Vi),!!Ji([0,-Wi.z,Wi.y,0,-ji.z,ji.y,0,-Yi.z,Yi.y,Wi.z,0,-Wi.x,ji.z,0,-ji.x,Yi.z,0,-Yi.x,-Wi.y,Wi.x,0,-ji.y,ji.x,0,-Yi.y,Yi.x,0],Hi,zi,Vi,qi))&&!!Ji([1,0,0,0,1,0,0,0,1],Hi,zi,Vi,qi)&&(Ki.crossVectors(Wi,ji),Ji([Ki.x,Ki.y,Ki.z],Hi,zi,Vi,qi))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Bi.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Bi).length(),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()||(Ui[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ui[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ui[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ui[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ui[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ui[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ui[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ui[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ui)),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)}}Ni.prototype.isBox3=!0;const Ui=[new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe,new Pe],Bi=new Pe,Gi=new Ni,Hi=new Pe,zi=new Pe,Vi=new Pe,Wi=new Pe,ji=new Pe,Yi=new Pe,$i=new Pe,qi=new Pe,Ki=new Pe,Xi=new Pe;function Ji(r,i,n,s,a){for(let e=0,t=r.length-3;e<=t;e+=3){Xi.fromArray(r,e);var o=a.x*Math.abs(Xi.x)+a.y*Math.abs(Xi.y)+a.z*Math.abs(Xi.z),l=i.dot(Xi),h=n.dot(Xi),u=s.dot(Xi);if(Math.max(-Math.max(l,h,u),Math.min(l,h,u))>o)return!1}return!0}const Zi=new Ni,Qi=new Pe,en=new Pe,tn=new Pe;class rn{constructor(e=new Pe,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(r,e){var i=this.center;void 0!==e?i.copy(e):Zi.setFromPoints(r).getCenter(i);let n=0;for(let e=0,t=r.length;e<t;e++)n=Math.max(n,i.distanceToSquared(r[e]));return this.radius=Math.sqrt(n),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){var 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){var r=this.center.distanceToSquared(e);return t.copy(e),r>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.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){tn.subVectors(e,this.center);var t=tn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),r=.5*(e-this.radius);this.center.add(tn.multiplyScalar(r/e)),this.radius+=r}return this}union(e){return en.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Qi.copy(e.center).add(en)),this.expandByPoint(Qi.copy(e.center).sub(en)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const nn=new Pe,sn=new Pe,an=new Pe,on=new Pe,ln=new Pe,hn=new Pe,un=new Pe;class cn{constructor(e=new Pe,t=new Pe(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.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,nn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);e=t.dot(this.direction);return e<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(e).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){var t=nn.subVectors(e,this.origin).dot(this.direction);return(t<0?this.origin:(nn.copy(this.direction).multiplyScalar(t).add(this.origin),nn)).distanceToSquared(e)}distanceSqToSegment(e,t,r,i){sn.copy(e).add(t).multiplyScalar(.5),an.copy(t).sub(e).normalize(),on.copy(this.origin).sub(sn);var e=.5*e.distanceTo(t),t=-this.direction.dot(an),n=on.dot(this.direction),s=-on.dot(an),a=on.lengthSq(),o=Math.abs(1-t*t);let l,h,u,c;if(0<o)if(l=t*s-n,h=t*n-s,c=e*o,0<=l)if(h>=-c)if(h<=c){const e=1/o;l*=e,h*=e,u=l*(l+t*h+2*n)+h*(t*l+h+2*s)+a}else h=e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;else h=-e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;else u=h<=-c?(l=Math.max(0,-(-t*e+n)),h=0<l?-e:Math.min(Math.max(-e,-s),e),-l*l+h*(h+2*s)+a):h<=c?(l=0,(h=Math.min(Math.max(-e,-s),e))*(h+2*s)+a):(l=Math.max(0,-(t*e+n)),h=0<l?e:Math.min(Math.max(-e,-s),e),-l*l+h*(h+2*s)+a);else h=0<t?-e:e,l=Math.max(0,-(t*h+n)),u=-l*l+h*(h+2*s)+a;return r&&r.copy(this.direction).multiplyScalar(l).add(this.origin),i&&i.copy(an).multiplyScalar(h).add(sn),u}intersectSphere(e,t){nn.subVectors(e.center,this.origin);var r=nn.dot(this.direction),i=nn.dot(nn)-r*r,e=e.radius*e.radius;return e<i||(i=r+(e=Math.sqrt(e-i)),(r=r-e)<0&&i<0)?null:r<0?this.at(i,t):this.at(r,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){var t=e.normal.dot(this.direction);return 0===t?0===e.distanceToPoint(this.origin)?0:null:0<=(e=-(this.origin.dot(e.normal)+e.constant)/t)?e:null}intersectPlane(e,t){e=this.distanceToPlane(e);return null===e?null:this.at(e,t)}intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,n,s,a,o;var l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,c=this.origin;return i=0<=l?(r=(e.min.x-c.x)*l,(e.max.x-c.x)*l):(r=(e.max.x-c.x)*l,(e.min.x-c.x)*l),s=0<=h?(n=(e.min.y-c.y)*h,(e.max.y-c.y)*h):(n=(e.max.y-c.y)*h,(e.min.y-c.y)*h),r>s||n>i||((n>r||r!=r)&&(r=n),(s<i||i!=i)&&(i=s),o=0<=u?(a=(e.min.z-c.z)*u,(e.max.z-c.z)*u):(a=(e.max.z-c.z)*u,(e.min.z-c.z)*u),r>o)||a>i||((a>r||r!=r)&&(r=a),(i=o<i||i!=i?o:i)<0)?null:this.at(0<=r?r:i,t)}intersectsBox(e){return null!==this.intersectBox(e,nn)}intersectTriangle(e,t,r,i,n){ln.subVectors(t,e),hn.subVectors(r,e),un.crossVectors(ln,hn);let s,a=this.direction.dot(un);if(0<a){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}on.subVectors(this.origin,e);t=s*this.direction.dot(hn.crossVectors(on,hn));return t<0||(r=s*this.direction.dot(ln.cross(on)))<0||t+r>a||(i=-s*on.dot(un))<0?null:this.at(i/a,n)}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)}}class ke{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,r,i,n,s,a,o,l,h,u,c,d,f,p,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=i,g[1]=n,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=h,g[10]=u,g[14]=c,g[3]=d,g[7]=f,g[11]=p,g[15]=m,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 ke).fromArray(this.elements)}copy(e){var t=this.elements,e=e.elements;return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}copyPosition(e){var t=this.elements,e=e.elements;return t[12]=e[12],t[13]=e[13],t[14]=e[14],this}setFromMatrix3(e){e=e.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){var t=this.elements,r=e.elements,i=1/dn.setFromMatrixColumn(e,0).length(),n=1/dn.setFromMatrixColumn(e,1).length(),e=1/dn.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*n,t[5]=r[5]*n,t[6]=r[6]*n,t[7]=0,t[8]=r[8]*e,t[9]=r[9]*e,t[10]=r[10]*e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,r=e.x,i=e.y,n=e.z,s=Math.cos(r),a=Math.sin(r),o=Math.cos(i),l=Math.sin(i),h=Math.cos(n),u=Math.sin(n);if("XYZ"===e.order){const e=s*h,r=s*u,i=a*h,n=a*u;t[0]=o*h,t[4]=-o*u,t[8]=l,t[1]=r+i*l,t[5]=e-n*l,t[9]=-a*o,t[2]=n-e*l,t[6]=i+r*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*h,r=o*u,i=l*h,n=l*u;t[0]=e+n*a,t[4]=i*a-r,t[8]=s*l,t[1]=s*u,t[5]=s*h,t[9]=-a,t[2]=r*a-i,t[6]=n+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*h,r=o*u,i=l*h,n=l*u;t[0]=e-n*a,t[4]=-s*u,t[8]=i+r*a,t[1]=r+i*a,t[5]=s*h,t[9]=n-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*h,r=s*u,i=a*h,n=a*u;t[0]=o*h,t[4]=i*l-r,t[8]=e*l+n,t[1]=o*u,t[5]=n*l+e,t[9]=r*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*h,t[4]=n-e*u,t[8]=i*u+r,t[1]=u,t[5]=s*h,t[9]=-a*h,t[2]=-l*h,t[6]=r*u+i,t[10]=e-n*u}else if("XZY"===e.order){const e=s*o,r=s*l,i=a*o,n=a*l;t[0]=o*h,t[4]=-u,t[8]=l*h,t[1]=e*u+n,t[5]=s*h,t[9]=r*u-i,t[2]=i*u-r,t[6]=a*h,t[10]=n*u+e}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(pn,e,mn)}lookAt(e,t,r){var i=this.elements;return yn.subVectors(e,t),0===yn.lengthSq()&&(yn.z=1),yn.normalize(),gn.crossVectors(r,yn),0===gn.lengthSq()&&(1===Math.abs(r.z)?yn.x+=1e-4:yn.z+=1e-4,yn.normalize(),gn.crossVectors(r,yn)),gn.normalize(),vn.crossVectors(yn,gn),i[0]=gn.x,i[4]=vn.x,i[8]=yn.x,i[1]=gn.y,i[5]=vn.y,i[9]=yn.y,i[2]=gn.z,i[6]=vn.z,i[10]=yn.z,this}multiply(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){var e=e.elements,t=t.elements,r=this.elements,i=e[0],n=e[4],s=e[8],a=e[12],o=e[1],l=e[5],h=e[9],u=e[13],c=e[2],d=e[6],f=e[10],p=e[14],m=e[3],g=e[7],v=e[11],e=e[15],y=t[0],x=t[4],_=t[8],b=t[12],T=t[1],S=t[5],E=t[9],w=t[13],M=t[2],A=t[6],L=t[10],R=t[14],C=t[3],D=t[7],I=t[11],t=t[15];return r[0]=i*y+n*T+s*M+a*C,r[4]=i*x+n*S+s*A+a*D,r[8]=i*_+n*E+s*L+a*I,r[12]=i*b+n*w+s*R+a*t,r[1]=o*y+l*T+h*M+u*C,r[5]=o*x+l*S+h*A+u*D,r[9]=o*_+l*E+h*L+u*I,r[13]=o*b+l*w+h*R+u*t,r[2]=c*y+d*T+f*M+p*C,r[6]=c*x+d*S+f*A+p*D,r[10]=c*_+d*E+f*L+p*I,r[14]=c*b+d*w+f*R+p*t,r[3]=m*y+g*T+v*M+e*C,r[7]=m*x+g*S+v*A+e*D,r[11]=m*_+g*E+v*L+e*I,r[15]=m*b+g*w+v*R+e*t,this}multiplyScalar(e){var 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(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],s=e[1],a=e[5],o=e[9],l=e[13],h=e[2],u=e[6],c=e[10],d=e[14];return e[3]*(+n*o*u-i*l*u-n*a*c+r*l*c+i*a*d-r*o*d)+e[7]*(+t*o*d-t*l*c+n*s*c-i*s*d+i*l*h-n*o*h)+e[11]*(+t*l*u-t*a*d-n*s*u+r*s*d+n*a*h-r*l*h)+e[15]*(-i*a*h-t*o*u+t*a*c+i*s*u-r*s*c+r*o*h)}transpose(){var e=this.elements,t=e[1];return 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,r){var i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],s=e[4],a=e[5],o=e[6],l=e[7],h=e[8],u=e[9],c=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15],v=u*m*l-p*c*l+p*o*d-a*m*d-u*o*g+a*c*g,y=f*c*l-h*m*l-f*o*d+s*m*d+h*o*g-s*c*g,x=h*p*l-f*u*l+f*a*d-s*p*d-h*a*g+s*u*g,_=f*u*o-h*p*o-f*a*c+s*p*c+h*a*m-s*u*m,b=t*v+r*y+i*x+n*_;return 0==b?this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0):(e[0]=v*(v=1/b),e[1]=(p*c*n-u*m*n-p*i*d+r*m*d+u*i*g-r*c*g)*v,e[2]=(a*m*n-p*o*n+p*i*l-r*m*l-a*i*g+r*o*g)*v,e[3]=(u*o*n-a*c*n-u*i*l+r*c*l+a*i*d-r*o*d)*v,e[4]=y*v,e[5]=(h*m*n-f*c*n+f*i*d-t*m*d-h*i*g+t*c*g)*v,e[6]=(f*o*n-s*m*n-f*i*l+t*m*l+s*i*g-t*o*g)*v,e[7]=(s*c*n-h*o*n+h*i*l-t*c*l-s*i*d+t*o*d)*v,e[8]=x*v,e[9]=(f*u*n-h*p*n-f*r*d+t*p*d+h*r*g-t*u*g)*v,e[10]=(s*p*n-f*a*n+f*r*l-t*p*l-s*r*g+t*a*g)*v,e[11]=(h*a*n-s*u*n-h*r*l+t*u*l+s*r*d-t*a*d)*v,e[12]=_*v,e[13]=(h*p*i-f*u*i+f*r*c-t*p*c-h*r*m+t*u*m)*v,e[14]=(f*a*i-s*p*i-f*r*o+t*p*o+s*r*m-t*a*m)*v,e[15]=(s*u*i-h*a*i+h*r*o-t*u*o-s*r*c+t*a*c)*v,this)}scale(e){var t=this.elements,r=e.x,i=e.y,e=e.z;return t[0]*=r,t[4]*=i,t[8]*=e,t[1]*=r,t[5]*=i,t[9]*=e,t[2]*=r,t[6]*=i,t[10]*=e,t[3]*=r,t[7]*=i,t[11]*=e,this}getMaxScaleOnAxis(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,e))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){var t=Math.cos(e),e=Math.sin(e);return this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this}makeRotationY(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this}makeRotationZ(e){var t=Math.cos(e),e=Math.sin(e);return this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){var r=Math.cos(t),t=Math.sin(t),i=1-r,n=e.x,s=e.y,e=e.z,a=i*n,o=i*s;return this.set(a*n+r,a*s-t*e,a*e+t*s,0,a*s+t*e,o*s+r,o*e-t*n,0,a*e-t*s,o*e+t*n,i*e*e+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,n,s){return this.set(1,r,n,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){var i=this.elements,n=t._x,s=t._y,a=t._z,t=t._w,o=n+n,l=s+s,h=a+a,u=n*o,c=n*l,n=n*h,d=s*l,s=s*h,a=a*h,o=t*o,l=t*l,t=t*h,h=r.x,f=r.y,r=r.z;return i[0]=(1-(d+a))*h,i[1]=(c+t)*h,i[2]=(n-l)*h,i[3]=0,i[4]=(c-t)*f,i[5]=(1-(u+a))*f,i[6]=(s+o)*f,i[7]=0,i[8]=(n+l)*r,i[9]=(s-o)*r,i[10]=(1-(u+d))*r,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){var i=this.elements;let n=dn.set(i[0],i[1],i[2]).length();var s=dn.set(i[4],i[5],i[6]).length(),a=dn.set(i[8],i[9],i[10]).length(),e=(this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],fn.copy(this),1/n),i=1/s,o=1/a;return fn.elements[0]*=e,fn.elements[1]*=e,fn.elements[2]*=e,fn.elements[4]*=i,fn.elements[5]*=i,fn.elements[6]*=i,fn.elements[8]*=o,fn.elements[9]*=o,fn.elements[10]*=o,t.setFromRotationMatrix(fn),r.x=n,r.y=s,r.z=a,this}makePerspective(e,t,r,i,n,s){void 0===s&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,o=2*n/(r-i),l=(t+e)/(t-e),r=(r+i)/(r-i),i=-(s+n)/(s-n),s=-2*s*n/(s-n);return a[0]=2*n/(t-e),a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=o,a[9]=r,a[13]=0,a[2]=0,a[6]=0,a[10]=i,a[14]=s,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,r,i,n,s){var a=this.elements,o=1/(t-e),l=1/(r-i),h=1/(s-n),t=(t+e)*o,e=(r+i)*l,r=(s+n)*h;return a[0]=2*o,a[4]=0,a[8]=0,a[12]=-t,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-e,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-r,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){var t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(t,r=0){for(let e=0;e<16;e++)this.elements[e]=t[e+r];return this}toArray(e=[],t=0){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}ke.prototype.isMatrix4=!0;const dn=new Pe,fn=new ke,pn=new Pe(0,0,0),mn=new Pe(1,1,1),gn=new Pe,vn=new Pe,yn=new Pe,xn=new ke,_n=new ki;class bn{constructor(e=0,t=0,r=0,i=bn.DefaultOrder){this._x=e,this._y=t,this._z=r,this._order=i}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,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,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,r=!0){var e=e.elements,i=e[0],n=e[4],s=e[8],a=e[1],o=e[5],l=e[9],h=e[2],u=e[6],c=e[10];switch(t){case"XYZ":this._y=Math.asin(mi(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._z=Math.atan2(-n,i)):(this._x=Math.atan2(u,o),this._z=0);break;case"YXZ":this._x=Math.asin(-mi(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(s,c),this._z=Math.atan2(a,o)):(this._y=Math.atan2(-h,i),this._z=0);break;case"ZXY":this._x=Math.asin(mi(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,c),this._z=Math.atan2(-n,o)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-mi(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,c),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-n,o));break;case"YZX":this._z=Math.asin(mi(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,o),this._y=Math.atan2(-h,i)):(this._x=0,this._y=Math.atan2(s,c));break;case"XZY":this._z=Math.asin(-mi(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,o),this._y=Math.atan2(s,i)):(this._x=Math.atan2(-l,c),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return xn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xn,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _n.setFromEuler(this),this.setFromQuaternion(_n,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],void 0!==e[3]&&(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}toVector3(e){return e?e.set(this._x,this._y,this._z):new Pe(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}bn.prototype.isEuler=!0,bn.DefaultOrder="XYZ",bn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class Tn{constructor(){this.mask=1}set(e){this.mask=1<<e|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 0!=(this.mask&e.mask)}}let Sn=0;const En=new Pe,wn=new ki,Mn=new ke,An=new Pe,Ln=new Pe,Rn=new Pe,Cn=new ki,Dn=new Pe(1,0,0),In=new Pe(0,1,0),Pn=new Pe(0,0,1),kn={type:"added"},On={type:"removed"};class c extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:Sn++}),this.uuid=pi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=c.DefaultUp.clone();const e=new Pe,t=new bn,r=new ki,i=new Pe(1,1,1);t._onChange(function(){r.setFromEuler(t,!1)}),r._onChange(function(){t.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new ke},normalMatrix:{value:new v}}),this.matrix=new ke,this.matrixWorld=new ke,this.matrixAutoUpdate=c.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Tn,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 wn.setFromAxisAngle(e,t),this.quaternion.multiply(wn),this}rotateOnWorldAxis(e,t){return wn.setFromAxisAngle(e,t),this.quaternion.premultiply(wn),this}rotateX(e){return this.rotateOnAxis(Dn,e)}rotateY(e){return this.rotateOnAxis(In,e)}rotateZ(e){return this.rotateOnAxis(Pn,e)}translateOnAxis(e,t){return En.copy(e).applyQuaternion(this.quaternion),this.position.add(En.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Dn,e)}translateY(e){return this.translateOnAxis(In,e)}translateZ(e){return this.translateOnAxis(Pn,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(Mn.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?An.copy(e):An.set(e,t,r);e=this.parent;this.updateWorldMatrix(!0,!1),Ln.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mn.lookAt(Ln,An,this.up):Mn.lookAt(An,Ln,this.up),this.quaternion.setFromRotationMatrix(Mn),e&&(Mn.extractRotation(e.matrixWorld),wn.setFromRotationMatrix(Mn),this.quaternion.premultiply(wn.invert()))}add(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.add(arguments[e]);else e===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),(e.parent=this).children.push(e),e.dispatchEvent(kn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);else{var t=this.children.indexOf(e);-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(On))}return this}removeFromParent(){var e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){var t=this.children[e];t.parent=null,t.dispatchEvent(On)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Mn.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Mn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Mn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(r,i){if(this[r]===i)return this;for(let e=0,t=this.children.length;e<t;e++){var n=this.children[e].getObjectByProperty(r,i);if(void 0!==n)return n}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ln,e,Rn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ln,Cn,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(r){r(this);var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].traverse(r)}traverseVisible(r){if(!1!==this.visible){r(this);var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].traverseVisible(r)}}traverseAncestors(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),r=!(this.matrixWorldNeedsUpdate=!1));var i=this.children;for(let e=0,t=i.length;e<t;e++)i[e].updateMatrixWorld(r)}updateWorldMatrix(r,e){var t=this.parent;if(!0===r&&null!==t&&t.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===e){const r=this.children;for(let e=0,t=r.length;e<t;e++)r[e].updateWorldMatrix(!1,!0)}}toJSON(r){const i=void 0===r||"string"==typeof r,n={},s=(i&&(r={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"}),{});function a(e,t){return void 0===e[t.uuid]&&(e[t.uuid]=t.toJSON(r)),t.uuid}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),!0===this.castShadow&&(s.castShadow=!0),!0===this.receiveShadow&&(s.receiveShadow=!0),!1===this.visible&&(s.visible=!1),!1===this.frustumCulled&&(s.frustumCulled=!1),0!==this.renderOrder&&(s.renderOrder=this.renderOrder),"{}"!==JSON.stringify(this.userData)&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor)&&(s.instanceColor=this.instanceColor.toJSON()),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(r).uuid)),this.environment&&this.environment.isTexture&&(s.environment=this.environment.toJSON(r).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=a(r.geometries,this.geometry);const i=this.geometry.parameters;if(void 0!==i&&void 0!==i.shapes){const n=i.shapes;if(Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const s=n[e];a(r.shapes,s)}else a(r.shapes,n)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton)&&(a(r.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid),void 0!==this.material)if(Array.isArray(this.material)){const i=[];for(let e=0,t=this.material.length;e<t;e++)i.push(a(r.materials,this.material[e]));s.material=i}else s.material=a(r.materials,this.material);if(0<this.children.length){s.children=[];for(let e=0;e<this.children.length;e++)s.children.push(this.children[e].toJSON(r).object)}if(0<this.animations.length){s.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];s.animations.push(a(r.animations,n))}}if(i){const i=e(r.geometries),s=e(r.materials),a=e(r.textures),t=e(r.images),o=e(r.shapes),l=e(r.skeletons),h=e(r.animations);0<i.length&&(n.geometries=i),0<s.length&&(n.materials=s),0<a.length&&(n.textures=a),0<t.length&&(n.images=t),0<o.length&&(n.shapes=o),0<l.length&&(n.skeletons=l),0<h.length&&(n.animations=h)}return n.object=s,n;function e(e){var t=[];for(const i in e){var r=e[i];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){var r=t.children[e];this.add(r.clone())}return this}}c.DefaultUp=new Pe(0,1,0),c.DefaultMatrixAutoUpdate=!0,c.prototype.isObject3D=!0;const Fn=new Pe,Nn=new Pe,Un=new Pe,Bn=new Pe,Gn=new Pe,Hn=new Pe,zn=new Pe,Vn=new Pe,Wn=new Pe,jn=new Pe;class f{constructor(e=new Pe,t=new Pe,r=new Pe){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),Fn.subVectors(e,t),i.cross(Fn);r=i.lengthSq();return 0<r?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,r,i,n){Fn.subVectors(i,t),Nn.subVectors(r,t),Un.subVectors(e,t);var i=Fn.dot(Fn),r=Fn.dot(Nn),e=Fn.dot(Un),t=Nn.dot(Nn),s=Nn.dot(Un),a=i*t-r*r;return 0==a?n.set(-2,-1,-1):n.set(1-(t=(t*e-r*s)*(n=1/a))-(a=(i*s-r*e)*n),a,t)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,Bn),0<=Bn.x&&0<=Bn.y&&Bn.x+Bn.y<=1}static getUV(e,t,r,i,n,s,a,o){return this.getBarycoord(e,t,r,i,Bn),o.set(0,0),o.addScaledVector(n,Bn.x),o.addScaledVector(s,Bn.y),o.addScaledVector(a,Bn.z),o}static isFrontFacing(e,t,r,i){return Fn.subVectors(r,t),Nn.subVectors(e,t),Fn.cross(Nn).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 Fn.subVectors(this.c,this.b),Nn.subVectors(this.a,this.b),.5*Fn.cross(Nn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return f.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return f.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,i,n){return f.getUV(e,this.a,this.b,this.c,t,r,i,n)}containsPoint(e){return f.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return f.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){var r=this.a,i=this.b,n=this.c;let s,a;Gn.subVectors(i,r),Hn.subVectors(n,r),Vn.subVectors(e,r);var o=Gn.dot(Vn),l=Hn.dot(Vn);if(o<=0&&l<=0)return t.copy(r);Wn.subVectors(e,i);var h=Gn.dot(Wn),u=Hn.dot(Wn);if(0<=h&&u<=h)return t.copy(i);var c=o*u-h*l;if(c<=0&&0<=o&&h<=0)return s=o/(o-h),t.copy(r).addScaledVector(Gn,s);jn.subVectors(e,n);var e=Gn.dot(jn),d=Hn.dot(jn);return 0<=d&&e<=d?t.copy(n):(o=e*l-o*d)<=0&&0<=l&&d<=0?(a=l/(l-d),t.copy(r).addScaledVector(Hn,a)):(l=h*d-e*u)<=0&&0<=u-h&&0<=e-d?(zn.subVectors(n,i),a=(u-h)/(u-h+(e-d)),t.copy(i).addScaledVector(zn,a)):(n=1/(l+o+c),s=o*n,a=c*n,t.copy(r).addScaledVector(Gn,s).addScaledVector(Hn,a))}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Yn=0;class r extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:Yn++}),this.uuid=pi(),this.name="",this.type="Material",this.fog=!0,this.blending=K,this.side=Oe,this.vertexColors=!1,this.opacity=1,this.format=Ce,this.transparent=!1,this.blendSrc=he,this.blendDst=ue,this.blendEquation=ee,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=xe,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Jr,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Nr,this.stencilZFail=Nr,this.stencilZPass=Nr,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.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){0<this._alphaTest!=0<e&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const i in e){var t,r=e[i];void 0===r?console.warn("THREE.Material: '"+i+"' parameter is undefined."):"shading"===i?(console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=r===P):void 0!==(t=this[i])?t&&t.isColor?t.set(r):t&&t.isVector3&&r&&r.isVector3?t.copy(r):this[i]=r:console.warn("THREE."+this.type+": '"+i+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){var t=[];for(const i in e){var r=e[i];delete r.metadata,t.push(r)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine)&&(r.combine=this.combine),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==K&&(r.blending=this.blending),this.side!==Oe&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.format!==Ce&&(r.format=this.format),!0===this.transparent&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),0<this.alphaTest&&(r.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(r.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(r.wireframe=this.wireframe),1<this.wireframeLinewidth&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=this.flatShading),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),t){const t=i(e.textures),n=i(e.images);0<t.length&&(r.textures=t),0<n.length&&(r.images=n)}return r}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.format=t.format,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var r=t.clippingPlanes;let i=null;if(null!==r){const t=r.length;i=new Array(t);for(let e=0;e!==t;++e)i[e]=r[e].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}r.prototype.isMaterial=!0;const $n={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},qn={h:0,s:0,l:0},Kn={h:0,s:0,l:0};function Xn(e,t,r){return r<0&&(r+=1),1<r&&--r,r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}function Jn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Zn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class g{constructor(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,r){return this.r=e,this.g=t,this.b=r,this}setHSL(e,t,r){return e=gi(e,1),t=mi(t,0,1),r=mi(r,0,1),0===t?this.r=this.g=this.b=r:(this.r=Xn(t=2*r-(r=r<=.5?r*(1+t):r+t-r*t),r,e+1/3),this.g=Xn(t,r,e),this.b=Xn(t,r,e-1/3)),this}setStyle(t){function r(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let e;var n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,r(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,r(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s)){const i=parseFloat(e[1])/360,a=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100;return r(e[4]),this.setHSL(i,a,o)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[1],r=t.length;if(3===r)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===r)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return t&&0<t.length?this.setColorName(t):this}setColorName(e){var t=$n[e.toLowerCase()];return void 0!==t?this.setHex(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}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){t=0<t?1/t:1;return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}copyLinearToSRGB(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){var t=this.r,r=this.g,i=this.b,n=Math.max(t,r,i),s=Math.min(t,r,i);let a,o;var l=(s+n)/2;if(s===n)a=0,o=0;else{const e=n-s;switch(o=l<=.5?e/(n+s):e/(2-n-s),n){case t:a=(r-i)/e+(r<i?6:0);break;case r:a=(i-t)/e+2;break;case i:a=(t-r)/e+4}a/=6}return e.h=a,e.s=o,e.l=l,e}getStyle(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"}offsetHSL(e,t,r){return this.getHSL(qn),qn.h+=e,qn.s+=t,qn.l+=r,this.setHSL(qn.h,qn.s,qn.l),this}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,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(qn),e.getHSL(Kn);var e=vi(qn.h,Kn.h,t),r=vi(qn.s,Kn.s,t),t=vi(qn.l,Kn.l,t);return this.setHSL(e,r,t),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),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}g.NAMES=$n,g.prototype.isColor=!0,g.prototype.r=1,g.prototype.g=1,g.prototype.b=1;class Qn extends r{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new g(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.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.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}}Qn.prototype.isMeshBasicMaterial=!0;const i=new Pe,es=new z;class w{constructor(e,t,r){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===r,this.usage=Zr,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(r,i,n){r*=this.itemSize,n*=i.itemSize;for(let e=0,t=this.itemSize;e<t;e++)this.array[r+e]=i.array[n+e];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",t),e=new g),i[n++]=e.r,i[n++]=e.g,i[n++]=e.b}return this}copyVector2sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",t),e=new z),i[n++]=e.x,i[n++]=e.y}return this}copyVector3sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",t),e=new Pe),i[n++]=e.x,i[n++]=e.y,i[n++]=e.z}return this}copyVector4sArray(r){var i=this.array;let n=0;for(let t=0,e=r.length;t<e;t++){let e=r[t];void 0===e&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",t),e=new Ie),i[n++]=e.x,i[n++]=e.y,i[n++]=e.z,i[n++]=e.w}return this}applyMatrix3(r){if(2===this.itemSize)for(let e=0,t=this.count;e<t;e++)es.fromBufferAttribute(this,e),es.applyMatrix3(r),this.setXY(e,es.x,es.y);else if(3===this.itemSize)for(let e=0,t=this.count;e<t;e++)i.fromBufferAttribute(this,e),i.applyMatrix3(r),this.setXYZ(e,i.x,i.y,i.z);return this}applyMatrix4(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.applyMatrix4(r),this.setXYZ(e,i.x,i.y,i.z);return this}applyNormalMatrix(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.applyNormalMatrix(r),this.setXYZ(e,i.x,i.y,i.z);return this}transformDirection(r){for(let e=0,t=this.count;e<t;e++)i.x=this.getX(e),i.y=this.getY(e),i.z=this.getZ(e),i.transformDirection(r),this.setXYZ(e,i.x,i.y,i.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){var e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Zr&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}w.prototype.isBufferAttribute=!0;class ts extends w{constructor(e,t,r){super(new Int8Array(e),t,r)}}class rs extends w{constructor(e,t,r){super(new Uint8Array(e),t,r)}}class is extends w{constructor(e,t,r){super(new Uint8ClampedArray(e),t,r)}}class ns extends w{constructor(e,t,r){super(new Int16Array(e),t,r)}}class ss extends w{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class as extends w{constructor(e,t,r){super(new Int32Array(e),t,r)}}class os extends w{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class ls extends w{constructor(e,t,r){super(new Uint16Array(e),t,r)}}ls.prototype.isFloat16BufferAttribute=!0;class V extends w{constructor(e,t,r){super(new Float32Array(e),t,r)}}class hs extends w{constructor(e,t,r){super(new Float64Array(e),t,r)}}let us=0;const cs=new ke,ds=new c,fs=new Pe,ps=new Ni,ms=new Ni,h=new Pe;class S extends hi{constructor(){super(),Object.defineProperty(this,"id",{value:us++}),this.uuid=pi(),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(65535<Ti(e)?os:ss)(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 void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var r=this.attributes.normal;if(void 0!==r){const t=(new v).getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return cs.makeRotationFromQuaternion(e),this.applyMatrix4(cs),this}rotateX(e){return cs.makeRotationX(e),this.applyMatrix4(cs),this}rotateY(e){return cs.makeRotationY(e),this.applyMatrix4(cs),this}rotateZ(e){return cs.makeRotationZ(e),this.applyMatrix4(cs),this}translate(e,t,r){return cs.makeTranslation(e,t,r),this.applyMatrix4(cs),this}scale(e,t,r){return cs.makeScale(e,t,r),this.applyMatrix4(cs),this}lookAt(e){return ds.lookAt(e),ds.updateMatrix(),this.applyMatrix4(ds.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(fs).negate(),this.translate(fs.x,fs.y,fs.z),this}setFromPoints(r){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e];i.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new V(i,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Ni);var e=this.attributes.position,r=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Pe(-1/0,-1/0,-1/0),new Pe(1/0,1/0,1/0));else{if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),r)for(let e=0,t=r.length;e<t;e++){var i=r[e];ps.setFromBufferAttribute(i),this.morphTargetsRelative?(h.addVectors(this.boundingBox.min,ps.min),this.boundingBox.expandByPoint(h),h.addVectors(this.boundingBox.max,ps.max),this.boundingBox.expandByPoint(h)):(this.boundingBox.expandByPoint(ps.min),this.boundingBox.expandByPoint(ps.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(){null===this.boundingSphere&&(this.boundingSphere=new rn);var i=this.attributes.position,n=this.morphAttributes.position;if(i&&i.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Pe,1/0);else if(i){var s=this.boundingSphere.center;if(ps.setFromBufferAttribute(i),n)for(let e=0,t=n.length;e<t;e++){var a=n[e];ms.setFromBufferAttribute(a),this.morphTargetsRelative?(h.addVectors(ps.min,ms.min),ps.expandByPoint(h),h.addVectors(ps.max,ms.max),ps.expandByPoint(h)):(ps.expandByPoint(ms.min),ps.expandByPoint(ms.max))}ps.getCenter(s);let r=0;for(let e=0,t=i.count;e<t;e++)h.fromBufferAttribute(i,e),r=Math.max(r,s.distanceToSquared(h));if(n)for(let e=0,t=n.length;e<t;e++){var o=n[e],l=this.morphTargetsRelative;for(let e=0,t=o.count;e<t;e++)h.fromBufferAttribute(o,e),l&&(fs.fromBufferAttribute(i,e),h.add(fs)),r=Math.max(r,s.distanceToSquared(h))}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(){const e=this.index,i=this.attributes;if(null===e||void 0===i.position||void 0===i.normal||void 0===i.uv)console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");else{const a=e.array,o=i.position.array,l=i.normal.array,h=i.uv.array,t=o.length/3,u=(void 0===i.tangent&&this.setAttribute("tangent",new w(new Float32Array(4*t),4)),i.tangent.array),c=[],d=[];for(let e=0;e<t;e++)c[e]=new Pe,d[e]=new Pe;const f=new Pe,p=new Pe,m=new Pe,g=new z,v=new z,y=new z,x=new Pe,_=new Pe;let r=this.groups;for(let e=0,t=(r=0===r.length?[{start:0,count:a.length}]:r).length;e<t;++e){const i=r[e],o=i.start;for(let e=o,t=o+i.count;e<t;e+=3)n(a[e+0],a[e+1],a[e+2])}const b=new Pe,T=new Pe,S=new Pe,E=new Pe;for(let e=0,t=r.length;e<t;++e){const i=r[e],o=i.start;for(let e=o,t=o+i.count;e<t;e+=3)s(a[e+0]),s(a[e+1]),s(a[e+2])}function n(e,t,r){f.fromArray(o,3*e),p.fromArray(o,3*t),m.fromArray(o,3*r),g.fromArray(h,2*e),v.fromArray(h,2*t),y.fromArray(h,2*r),p.sub(f),m.sub(f),v.sub(g),y.sub(g);var i=1/(v.x*y.y-y.x*v.y);isFinite(i)&&(x.copy(p).multiplyScalar(y.y).addScaledVector(m,-v.y).multiplyScalar(i),_.copy(m).multiplyScalar(v.x).addScaledVector(p,-y.x).multiplyScalar(i),c[e].add(x),c[t].add(x),c[r].add(x),d[e].add(_),d[t].add(_),d[r].add(_))}function s(e){S.fromArray(l,3*e),E.copy(S);var t=c[e],t=(b.copy(t),b.sub(S.multiplyScalar(S.dot(t))).normalize(),T.crossVectors(E,t),T.dot(d[e])<0?-1:1);u[4*e]=b.x,u[4*e+1]=b.y,u[4*e+2]=b.z,u[4*e+3]=t}}}computeVertexNormals(){var i=this.index,n=this.getAttribute("position");if(void 0!==n){let r=this.getAttribute("normal");if(void 0===r)r=new w(new Float32Array(3*n.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);var s=new Pe,a=new Pe,o=new Pe,l=new Pe,h=new Pe,u=new Pe,c=new Pe,d=new Pe;if(i)for(let e=0,t=i.count;e<t;e+=3){var f=i.getX(e+0),p=i.getX(e+1),m=i.getX(e+2);s.fromBufferAttribute(n,f),a.fromBufferAttribute(n,p),o.fromBufferAttribute(n,m),c.subVectors(o,a),d.subVectors(s,a),c.cross(d),l.fromBufferAttribute(r,f),h.fromBufferAttribute(r,p),u.fromBufferAttribute(r,m),l.add(c),h.add(c),u.add(c),r.setXYZ(f,l.x,l.y,l.z),r.setXYZ(p,h.x,h.y,h.z),r.setXYZ(m,u.x,u.y,u.z)}else for(let e=0,t=n.count;e<t;e+=3)s.fromBufferAttribute(n,e+0),a.fromBufferAttribute(n,e+1),o.fromBufferAttribute(n,e+2),c.subVectors(o,a),d.subVectors(s,a),c.cross(d),r.setXYZ(e+0,c.x,c.y,c.z),r.setXYZ(e+1,c.x,c.y,c.z),r.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),r.needsUpdate=!0}}merge(e,t){if(e&&e.isBufferGeometry){void 0===t&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));var r=this.attributes;for(const o in r)if(void 0!==e.attributes[o]){var i=r[o].array,n=e.attributes[o],s=n.array,n=n.itemSize*t,a=Math.min(s.length,i.length-n);for(let e=0,t=n;e<a;e++,t++)i[t]=s[e]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e)}normalizeNormals(){var r=this.attributes.normal;for(let e=0,t=r.count;e<t;e++)h.fromBufferAttribute(r,e),h.normalize(),r.setXYZ(e,h.x,h.y,h.z)}toNonIndexed(){function r(r,i){var n=r.array,s=r.itemSize,e=r.normalized,a=new n.constructor(i.length*s);let o=0,l=0;for(let e=0,t=i.length;e<t;e++){o=r.isInterleavedBufferAttribute?i[e]*r.data.stride+r.offset:i[e]*s;for(let e=0;e<s;e++)a[l++]=n[o++]}return new w(a,s,e)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const i=new S,n=this.index.array,s=this.attributes;for(const e in s){const a=r(s[e],n);i.setAttribute(e,a)}const e=this.morphAttributes;for(const s in e){const a=[],o=e[s];for(let e=0,t=o.length;e<t;e++){const s=r(o[e],n);a.push(s)}i.morphAttributes[s]=a}i.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let e=0,t=a.length;e<t;e++){const n=a[e];i.addGroup(n.start,n.count,n.materialIndex)}return i}toJSON(){var r={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),0<Object.keys(this.userData).length&&(r.userData=this.userData),void 0!==this.parameters){const i=this.parameters;for(const n in i)void 0!==i[n]&&(r[n]=i[n])}else{r.data={attributes:{}};const i=this.index,n=(null!==i&&(r.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)}),this.attributes);for(const i in n){const s=n[i];r.data.attributes[i]=s.toJSON(r.data)}const s={};let e=!1;for(const i in this.morphAttributes){const n=this.morphAttributes[i],a=[];for(let e=0,t=n.length;e<t;e++){const s=n[e];a.push(s.toJSON(r.data))}0<a.length&&(s[i]=a,e=!0)}e&&(r.data.morphAttributes=s,r.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;0<a.length&&(r.data.groups=JSON.parse(JSON.stringify(a)));var t=this.boundingSphere;null!==t&&(r.data.boundingSphere={center:t.center.toArray(),radius:t.radius})}return r}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const r={},i=(this.name=e.name,e.index),n=(null!==i&&this.setIndex(i.clone(r)),e.attributes);for(const e in n){const i=n[e];this.setAttribute(e,i.clone(r))}var t=e.morphAttributes;for(const e in t){const i=[],n=t[e];for(let e=0,t=n.length;e<t;e++)i.push(n[e].clone(r));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;var s=e.groups;for(let e=0,t=s.length;e<t;e++){const r=s[e];this.addGroup(r.start,r.count,r.materialIndex)}var a=e.boundingBox,a=(null!==a&&(this.boundingBox=a.clone()),e.boundingSphere);return null!==a&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}S.prototype.isBufferGeometry=!0;const gs=new ke,vs=new cn,ys=new rn,xs=new Pe,_s=new Pe,bs=new Pe,Ts=new Pe,Ss=new Pe,Es=new Pe,ws=new Pe,Ms=new Pe,As=new Pe,Ls=new z,Rs=new z,Cs=new z,Ds=new Pe,Is=new Pe;class E extends c{constructor(e=new S,t=new Qn){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(i,n){const e=this.geometry,s=this.material,a=this.matrixWorld;if(void 0!==s&&(null===e.boundingSphere&&e.computeBoundingSphere(),ys.copy(e.boundingSphere),ys.applyMatrix4(a),!1!==i.ray.intersectsSphere(ys))&&(gs.copy(a).invert(),vs.copy(i.ray).applyMatrix4(gs),null===e.boundingBox||!1!==vs.intersectsBox(e.boundingBox))){let r;if(e.isBufferGeometry){const a=e.index,d=e.attributes.position,f=e.morphAttributes.position,p=e.morphTargetsRelative,m=e.attributes.uv,g=e.attributes.uv2,v=e.groups,y=e.drawRange;if(null!==a)if(Array.isArray(s))for(let e=0,t=v.length;e<t;e++){var o=v[e],l=s[o.materialIndex];for(let e=Math.max(o.start,y.start),t=Math.min(a.count,Math.min(o.start+o.count,y.start+y.count));e<t;e+=3){const s=a.getX(e),x=a.getX(e+1),_=a.getX(e+2);(r=Ps(this,l,i,vs,d,f,p,m,g,s,x,_))&&(r.faceIndex=Math.floor(e/3),r.face.materialIndex=o.materialIndex,n.push(r))}}else for(let e=Math.max(0,y.start),t=Math.min(a.count,y.start+y.count);e<t;e+=3){var h=a.getX(e),u=a.getX(e+1),c=a.getX(e+2);(r=Ps(this,s,i,vs,d,f,p,m,g,h,u,c))&&(r.faceIndex=Math.floor(e/3),n.push(r))}else if(void 0!==d)if(Array.isArray(s))for(let e=0,t=v.length;e<t;e++){const a=v[e],b=s[a.materialIndex];for(let e=Math.max(a.start,y.start),t=Math.min(d.count,Math.min(a.start+a.count,y.start+y.count));e<t;e+=3)(r=Ps(this,b,i,vs,d,f,p,m,g,e,e+1,e+2))&&(r.faceIndex=Math.floor(e/3),r.face.materialIndex=a.materialIndex,n.push(r))}else for(let e=Math.max(0,y.start),t=Math.min(d.count,y.start+y.count);e<t;e+=3)(r=Ps(this,s,i,vs,d,f,p,m,g,e,e+1,e+2))&&(r.faceIndex=Math.floor(e/3),n.push(r))}else e.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Ps(e,r,i,t,n,s,a,o,l,h,u,c){xs.fromBufferAttribute(n,h),_s.fromBufferAttribute(n,u),bs.fromBufferAttribute(n,c);var d=e.morphTargetInfluences;if(s&&d){ws.set(0,0,0),Ms.set(0,0,0),As.set(0,0,0);for(let e=0,t=s.length;e<t;e++){const r=d[e],i=s[e];0!==r&&(Ts.fromBufferAttribute(i,h),Ss.fromBufferAttribute(i,u),Es.fromBufferAttribute(i,c),a?(ws.addScaledVector(Ts,r),Ms.addScaledVector(Ss,r),As.addScaledVector(Es,r)):(ws.addScaledVector(Ts.sub(xs),r),Ms.addScaledVector(Ss.sub(_s),r),As.addScaledVector(Es.sub(bs),r)))}xs.add(ws),_s.add(Ms),bs.add(As)}e.isSkinnedMesh&&(e.boneTransform(h,xs),e.boneTransform(u,_s),e.boneTransform(c,bs));n=function(e,t,r,i,n,s,a,o){if(null===(t.side===Ae?i.intersectTriangle(a,s,n,!0,o):i.intersectTriangle(n,s,a,t.side!==Fe,o)))return null;Is.copy(o),Is.applyMatrix4(e.matrixWorld);i=r.ray.origin.distanceTo(Is);return i<r.near||i>r.far?null:{distance:i,point:Is.clone(),object:e}}(e,r,i,t,xs,_s,bs,Ds);if(n){o&&(Ls.fromBufferAttribute(o,h),Rs.fromBufferAttribute(o,u),Cs.fromBufferAttribute(o,c),n.uv=f.getUV(Ds,xs,_s,bs,Ls,Rs,Cs,new z)),l&&(Ls.fromBufferAttribute(l,h),Rs.fromBufferAttribute(l,u),Cs.fromBufferAttribute(l,c),n.uv2=f.getUV(Ds,xs,_s,bs,Ls,Rs,Cs,new z));const e={a:h,b:u,c:c,normal:new Pe,materialIndex:0};f.getNormal(xs,_s,bs,e.normal),n.face=e}return n}E.prototype.isMesh=!0;class ks extends S{constructor(e=1,t=1,r=1,i=1,n=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:s};const b=this,T=(i=Math.floor(i),n=Math.floor(n),s=Math.floor(s),[]),S=[],E=[],w=[];let M=0,A=0;function a(r,i,n,s,a,o,e,l,h,u,t){var c=o/h,d=e/u,f=o/2,p=e/2,m=l/2,g=h+1,v=u+1;let y=0,x=0;var _=new Pe;for(let t=0;t<v;t++){const b=t*d-p;for(let e=0;e<g;e++){const M=e*c-f;_[r]=M*s,_[i]=b*a,_[n]=m,S.push(_.x,_.y,_.z),_[r]=0,_[i]=0,_[n]=0<l?1:-1,E.push(_.x,_.y,_.z),w.push(e/h),w.push(1-t/u),y+=1}}for(let t=0;t<u;t++)for(let e=0;e<h;e++){const n=M+e+g*t,s=M+e+g*(t+1),a=M+(e+1)+g*(t+1),o=M+(e+1)+g*t;T.push(n,s,o),T.push(s,a,o),x+=6}b.addGroup(A,x,t),A+=x,M+=y}a("z","y","x",-1,-1,r,t,e,s,n,0),a("z","y","x",1,-1,r,t,-e,s,n,1),a("x","z","y",1,1,e,r,t,i,s,2),a("x","z","y",1,-1,e,r,-t,i,s,3),a("x","y","z",1,-1,e,t,r,i,n,4),a("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(T),this.setAttribute("position",new V(S,3)),this.setAttribute("normal",new V(E,3)),this.setAttribute("uv",new V(w,2))}static fromJSON(e){return new ks(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Os(e){var t={};for(const i in e){t[i]={};for(const n in e[i]){var r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function Fs(t){var r={};for(let e=0;e<t.length;e++){var i=Os(t[e]);for(const t in i)r[t]=i[t]}return r}const Ns={clone:Os,merge:Fs};class Us extends r{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&(void 0!==e.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Os(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){var t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){var r=this.uniforms[i].value;r&&r.isTexture?t.uniforms[i]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[i]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[i]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[i]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[i]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[i]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[i]={type:"m4",value:r.toArray()}:t.uniforms[i]={value:r}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return 0<Object.keys(i).length&&(t.extensions=i),t}}Us.prototype.isShaderMaterial=!0;class Bs extends c{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ke,this.projectionMatrix=new ke,this.projectionMatrixInverse=new ke}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}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)}}Bs.prototype.isCamera=!0;class N extends Bs{constructor(e=50,t=1,r=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){e=.5*this.getFilmHeight()/e;this.fov=2*di*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){var e=Math.tan(.5*ci*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*di*Math.atan(Math.tan(.5*ci*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,r,i,n,s){this.aspect=e/t,null===this.view&&(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=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*ci*this.fov)/this.zoom,r=2*t,i=this.aspect*r,n=-.5*i;var s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;n+=s.offsetX*i/e,t-=s.offsetY*r/a,i*=s.width/e,r*=s.height/a}const a=this.filmOffset;0!==a&&(n+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+i,t,t-r,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){e=super.toJSON(e);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}N.prototype.isPerspectiveCamera=!0;class Gs extends c{constructor(e,t,r){super(),this.type="CubeCamera",!0!==r.isWebGLCubeRenderTarget?console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."):(this.renderTarget=r,(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(1,0,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(-1,0,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,0,1),r.lookAt(new Pe(0,1,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,0,-1),r.lookAt(new Pe(0,-1,0)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(0,0,1)),this.add(r),(r=new N(90,1,e,t)).layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Pe(0,0,-1)),this.add(r))}update(e,t){null===this.parent&&this.updateMatrixWorld();var r=this.renderTarget,[i,n,s,a,o,l]=this.children,h=e.xr.enabled,u=e.getRenderTarget(),c=(e.xr.enabled=!1,r.texture.generateMipmaps);r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,i),e.setRenderTarget(r,1),e.render(t,n),e.setRenderTarget(r,2),e.render(t,s),e.setRenderTarget(r,3),e.render(t,a),e.setRenderTarget(r,4),e.render(t,o),r.texture.generateMipmaps=c,e.setRenderTarget(r,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=h}}class Hs extends u{constructor(e,t,r,i,n,s,a,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Ue,r,i,n,s,a,o,l,h),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Hs.prototype.isCubeTexture=!0;class zs extends Di{constructor(e,t,r){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=r),super(e,e,t),t=t||{},this.texture=new Hs(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:U,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=Ce,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",n="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",s=new ks(5,5,5),a=new Us({name:"CubemapFromEquirect",uniforms:Os(r),vertexShader:i,fragmentShader:n,side:Ae,blending:q});a.uniforms.tEquirect.value=t;var o=new E(s,a),l=t.minFilter;return t.minFilter===Ze&&(t.minFilter=U),new Gs(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(t,r,i,n){var e=t.getRenderTarget();for(let e=0;e<6;e++)t.setRenderTarget(this,e),t.clear(r,i,n);t.setRenderTarget(e)}}zs.prototype.isWebGLCubeRenderTarget=!0;const Vs=new Pe,Ws=new Pe,js=new v;class Ys{constructor(e=new Pe(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){r=Vs.subVectors(r,t).cross(Ws.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){var 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(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){var r=e.delta(Vs),i=this.normal.dot(r);return 0===i?0===this.distanceToPoint(e.start)?t.copy(e.start):null:(i=-(e.start.dot(this.normal)+this.constant)/i)<0||1<i?null:t.copy(r).multiplyScalar(i).add(e.start)}intersectsLine(e){var t=this.distanceToPoint(e.start),e=this.distanceToPoint(e.end);return t<0&&0<e||e<0&&0<t}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){t=t||js.getNormalMatrix(e),e=this.coplanarPoint(Vs).applyMatrix4(e),t=this.normal.applyMatrix3(t).normalize();return this.constant=-e.dot(t),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)}}Ys.prototype.isPlane=!0;const $s=new rn,qs=new Pe;class Ks{constructor(e=new Ys,t=new Ys,r=new Ys,i=new Ys,n=new Ys,s=new Ys){this.planes=[e,t,r,i,n,s]}set(e,t,r,i,n,s){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(s),this}copy(t){var r=this.planes;for(let e=0;e<6;e++)r[e].copy(t.planes[e]);return this}setFromProjectionMatrix(e){var t=this.planes,e=e.elements,r=e[0],i=e[1],n=e[2],s=e[3],a=e[4],o=e[5],l=e[6],h=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],e=e[15];return t[0].setComponents(s-r,h-a,f-u,e-p).normalize(),t[1].setComponents(s+r,h+a,f+u,e+p).normalize(),t[2].setComponents(s+i,h+o,f+c,e+m).normalize(),t[3].setComponents(s-i,h-o,f-c,e-m).normalize(),t[4].setComponents(s-n,h-l,f-d,e-g).normalize(),t[5].setComponents(s+n,h+l,f+d,e+g).normalize(),this}intersectsObject(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),$s.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere($s)}intersectsSprite(e){return $s.center.set(0,0,0),$s.radius=.7071067811865476,$s.applyMatrix4(e.matrixWorld),this.intersectsSphere($s)}intersectsSphere(e){var t=this.planes,r=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(r)<i)return!1;return!0}intersectsBox(t){var r=this.planes;for(let e=0;e<6;e++){var i=r[e];if(qs.x=(0<i.normal.x?t.max:t.min).x,qs.y=(0<i.normal.y?t.max:t.min).y,qs.z=(0<i.normal.z?t.max:t.min).z,i.distanceToPoint(qs)<0)return!1}return!0}containsPoint(t){var r=this.planes;for(let e=0;e<6;e++)if(r[e].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Xs(){let r=null,e=!1,i=null,n=null;function s(e,t){i(e,t),n=r.requestAnimationFrame(s)}return{start:function(){!0!==e&&null!==i&&(n=r.requestAnimationFrame(s),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(e){i=e},setContext:function(e){r=e}}}function Js(a,e){const o=e.isWebGL2,l=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),l.get(e)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);var t=l.get(e);t&&(a.deleteBuffer(t.buffer),l.delete(e))},update:function(e,t){if(e.isGLBufferAttribute){const a=l.get(e);void((!a||a.version<e.version)&&l.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}else{e.isInterleavedBufferAttribute&&(e=e.data);var r,i,n,s=l.get(e);void 0===s?l.set(e,function(e,t){var r=e.array,i=e.usage,n=a.createBuffer();a.bindBuffer(t,n),a.bufferData(t,r,i),e.onUploadCallback();let s=5126;return r instanceof Float32Array?s=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?e.isFloat16BufferAttribute?o?s=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):s=5123:r instanceof Int16Array?s=5122:r instanceof Uint32Array?s=5125:r instanceof Int32Array?s=5124:r instanceof Int8Array?s=5120:(r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&(s=5121),{buffer:n,type:s,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(e,t)):s.version<e.version&&(r=s.buffer,t=t,n=(i=e).array,i=i.updateRange,a.bindBuffer(t,r),-1===i.count?a.bufferSubData(t,0,n):(o?a.bufferSubData(t,i.offset*n.BYTES_PER_ELEMENT,n,i.offset,i.count):a.bufferSubData(t,i.offset*n.BYTES_PER_ELEMENT,n.subarray(i.offset,i.offset+i.count)),i.count=-1),s.version=e.version)}}}}class Zs extends S{constructor(e=1,r=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:r,widthSegments:i,heightSegments:n};const s=e/2,a=r/2,o=Math.floor(i),l=Math.floor(n),h=o+1,u=l+1,c=e/o,d=r/l,f=[],p=[],m=[],g=[];for(let t=0;t<u;t++){const r=t*d-a;for(let e=0;e<h;e++){const n=e*c-s;p.push(n,-r,0),m.push(0,0,1),g.push(e/o),g.push(1-t/l)}}for(let t=0;t<l;t++)for(let e=0;e<o;e++){const i=e+h*t,n=e+h*(t+1),s=e+1+h*(t+1),a=e+1+h*t;f.push(i,n,a),f.push(n,s,a)}this.setIndex(f),this.setAttribute("position",new V(p,3)),this.setAttribute("normal",new V(m,3)),this.setAttribute("uv",new V(g,2))}static fromJSON(e){return new Zs(e.width,e.height,e.widthSegments,e.heightSegments)}}const M={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include <envmap_common_pars_fragment>\nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - clearcoat * Fcc ) + clearcoatSpecular * clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},A={common:{diffuse:{value:new g(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new v},uv2Transform:{value:new v},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new g(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:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{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 g(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new v}},sprite:{diffuse:{value:new g(16777215)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new v}}},Qs={basic:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.fog]),vertexShader:M.meshbasic_vert,fragmentShader:M.meshbasic_frag},lambert:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.fog,A.lights,{emissive:{value:new g(0)}}]),vertexShader:M.meshlambert_vert,fragmentShader:M.meshlambert_frag},phong:{uniforms:Fs([A.common,A.specularmap,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.fog,A.lights,{emissive:{value:new g(0)},specular:{value:new g(1118481)},shininess:{value:30}}]),vertexShader:M.meshphong_vert,fragmentShader:M.meshphong_frag},standard:{uniforms:Fs([A.common,A.envmap,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.roughnessmap,A.metalnessmap,A.fog,A.lights,{emissive:{value:new g(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag},toon:{uniforms:Fs([A.common,A.aomap,A.lightmap,A.emissivemap,A.bumpmap,A.normalmap,A.displacementmap,A.gradientmap,A.fog,A.lights,{emissive:{value:new g(0)}}]),vertexShader:M.meshtoon_vert,fragmentShader:M.meshtoon_frag},matcap:{uniforms:Fs([A.common,A.bumpmap,A.normalmap,A.displacementmap,A.fog,{matcap:{value:null}}]),vertexShader:M.meshmatcap_vert,fragmentShader:M.meshmatcap_frag},points:{uniforms:Fs([A.points,A.fog]),vertexShader:M.points_vert,fragmentShader:M.points_frag},dashed:{uniforms:Fs([A.common,A.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:M.linedashed_vert,fragmentShader:M.linedashed_frag},depth:{uniforms:Fs([A.common,A.displacementmap]),vertexShader:M.depth_vert,fragmentShader:M.depth_frag},normal:{uniforms:Fs([A.common,A.bumpmap,A.normalmap,A.displacementmap,{opacity:{value:1}}]),vertexShader:M.meshnormal_vert,fragmentShader:M.meshnormal_frag},sprite:{uniforms:Fs([A.sprite,A.fog]),vertexShader:M.sprite_vert,fragmentShader:M.sprite_frag},background:{uniforms:{uvTransform:{value:new v},t2D:{value:null}},vertexShader:M.background_vert,fragmentShader:M.background_frag},cube:{uniforms:Fs([A.envmap,{opacity:{value:1}}]),vertexShader:M.cube_vert,fragmentShader:M.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:M.equirect_vert,fragmentShader:M.equirect_frag},distanceRGBA:{uniforms:Fs([A.common,A.displacementmap,{referencePosition:{value:new Pe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:M.distanceRGBA_vert,fragmentShader:M.distanceRGBA_frag},shadow:{uniforms:Fs([A.lights,A.fog,{color:{value:new g(0)},opacity:{value:1}}]),vertexShader:M.shadow_vert,fragmentShader:M.shadow_frag}};function ea(n,s,r,a,i){const o=new g(0);let l,h,u=0,c=null,d=0,f=null;function p(e,t){r.buffers.color.setClear(e.r,e.g,e.b,t,i)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),u=t,p(o,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,p(o,u)},render:function(e,t){let r=!1,i=!0===t.isScene?t.background:null;i&&i.isTexture&&(i=s.get(i));t=n.xr,t=t.getSession&&t.getSession();null===(i=t&&"additive"===t.environmentBlendMode?null:i)?p(o,u):i&&i.isColor&&(p(i,1),r=!0),(n.autoClear||r)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),i&&(i.isCubeTexture||i.mapping===ze)?(void 0===h&&((h=new E(new ks(1,1,1),new Us({name:"BackgroundCubeMaterial",uniforms:Os(Qs.cube.uniforms),vertexShader:Qs.cube.vertexShader,fragmentShader:Qs.cube.fragmentShader,side:Ae,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(h)),h.material.uniforms.envMap.value=i,h.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c===i&&d===i.version&&f===n.toneMapping||(h.material.needsUpdate=!0,c=i,d=i.version,f=n.toneMapping),e.unshift(h,h.geometry,h.material,0,0,null)):i&&i.isTexture&&(void 0===l&&((l=new E(new Zs(2,2),new Us({name:"BackgroundMaterial",uniforms:Os(Qs.background.uniforms),vertexShader:Qs.background.vertexShader,fragmentShader:Qs.background.fragmentShader,side:Oe,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),!0===(l.material.uniforms.t2D.value=i).matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),c===i&&d===i.version&&f===n.toneMapping||(l.material.needsUpdate=!0,c=i,d=i.version,f=n.toneMapping),e.unshift(l,l.geometry,l.material,0,0,null))}}}function ta(c,d,f,p){const n=c.getParameter(34921),m=p.isWebGL2?null:d.get("OES_vertex_array_object"),g=p.isWebGL2||null!==m,v={},e=_(null);let y=e;function x(e){p.isWebGL2?c.bindVertexArray(e):m.bindVertexArrayOES(e)}function s(e){p.isWebGL2?c.deleteVertexArray(e):m.deleteVertexArrayOES(e)}function _(e){var t=[],r=[],i=[];for(let e=0;e<n;e++)t[e]=0,r[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:r,attributeDivisors:i,object:e,attributes:{},index:null}}function b(){var r=y.newAttributes;for(let e=0,t=r.length;e<t;e++)r[e]=0}function T(e){S(e,0)}function S(e,t){var r=y.newAttributes,i=y.enabledAttributes,n=y.attributeDivisors;r[e]=1,0===i[e]&&(c.enableVertexAttribArray(e),i[e]=1),n[e]!==t&&((p.isWebGL2?c:d.get("ANGLE_instanced_arrays"))[p.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](e,t),n[e]=t)}function E(){var r=y.newAttributes,i=y.enabledAttributes;for(let e=0,t=i.length;e<t;e++)i[e]!==r[e]&&(c.disableVertexAttribArray(e),i[e]=0)}function w(e,t,r,i,n,s){!0!==p.isWebGL2||5124!==r&&5125!==r?c.vertexAttribPointer(e,t,r,i,n,s):c.vertexAttribIPointer(e,t,r,n,s)}function a(){t(),y!==e&&x((y=e).object)}function t(){e.geometry=null,e.program=null,e.wireframe=!1}return{setup:function(e,a,t,r,i){let n=!1;if(g){const d=function(e,t){var r=!0===a.wireframe;let i=v[e.id],n=(void 0===i&&(i={},v[e.id]=i),i[t.id]),s=(void 0===n&&(n={},i[t.id]=n),n[r]);return void 0===s&&(s=_(p.isWebGL2?c.createVertexArray():m.createVertexArrayOES()),n[r]=s),s}(r,t);if(y!==d&&x((y=d).object),n=function(e,t){var r=y.attributes,i=e.attributes;let n=0;for(const e in i){const t=r[e],s=i[e];if(void 0===t)return!0;if(t.attribute!==s)return!0;if(t.data!==s.data)return!0;n++}return y.attributesNum!==n||y.index!==t}(r,i)){var s=r;var o=i;var l={},h=s.attributes;let e=0;for(const s in h){const o=h[s],u={};(u.attribute=o).data&&(u.data=o.data),l[s]=u,e++}y.attributes=l,y.attributesNum=e,y.index=o}}else{const c=!0===a.wireframe;y.geometry===r.id&&y.program===t.id&&y.wireframe===c||(y.geometry=r.id,y.program=t.id,y.wireframe=c,n=!0)}!0===e.isInstancedMesh&&(n=!0),null!==i&&f.update(i,34963),n&&(function(e,t,r,i){if(!1!==p.isWebGL2||!e.isInstancedMesh&&!i.isInstancedBufferGeometry||null!==d.get("ANGLE_instanced_arrays")){b();const n=i.attributes,s=r.getAttributes(),a=t.defaultAttributeValues;for(const d in s){const p=s[d];if(0<=p.location){let t=n[d];if(void 0!==(t=void 0===t&&("instanceMatrix"===d&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===d)&&e.instanceColor?e.instanceColor:t)){const d=t.normalized,r=t.itemSize,n=f.get(t);if(void 0!==n){const s=n.buffer,a=n.type,o=n.bytesPerElement;if(t.isInterleavedBufferAttribute){const f=t.data,n=f.stride,l=t.offset;if(f&&f.isInstancedInterleavedBuffer){for(let e=0;e<p.locationSize;e++)S(p.location+e,f.meshPerAttribute);!0!==e.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=f.meshPerAttribute*f.count)}else for(let e=0;e<p.locationSize;e++)T(p.location+e);c.bindBuffer(34962,s);for(let e=0;e<p.locationSize;e++)w(p.location+e,r/p.locationSize,a,d,n*o,(l+r/p.locationSize*e)*o)}else{if(t.isInstancedBufferAttribute){for(let e=0;e<p.locationSize;e++)S(p.location+e,t.meshPerAttribute);!0!==e.isInstancedMesh&&void 0===i._maxInstanceCount&&(i._maxInstanceCount=t.meshPerAttribute*t.count)}else for(let e=0;e<p.locationSize;e++)T(p.location+e);c.bindBuffer(34962,s);for(let e=0;e<p.locationSize;e++)w(p.location+e,r/p.locationSize,a,d,r*o,r/p.locationSize*e*o)}}}else if(void 0!==a){const f=a[d];if(void 0!==f)switch(f.length){case 2:c.vertexAttrib2fv(p.location,f);break;case 3:c.vertexAttrib3fv(p.location,f);break;case 4:c.vertexAttrib4fv(p.location,f);break;default:c.vertexAttrib1fv(p.location,f)}}}}E()}}(e,a,t,r),null!==i)&&c.bindBuffer(34963,f.get(i).buffer)},reset:a,resetDefaultState:t,dispose:function(){a();for(const r in v){var e=v[r];for(const i in e){var t=e[i];for(const n in t)s(t[n].object),delete t[n];delete e[i]}delete v[r]}},releaseStatesOfGeometry:function(e){if(void 0!==v[e.id]){var t=v[e.id];for(const e in t){var r=t[e];for(const e in r)s(r[e].object),delete r[e];delete t[e]}delete v[e.id]}},releaseStatesOfProgram:function(e){for(const i in v){var t=v[i];if(void 0!==t[e.id]){var r=t[e.id];for(const e in r)s(r[e].object),delete r[e];delete t[e.id]}}},initAttributes:b,enableAttribute:T,disableUnusedAttributes:E}}function ra(s,a,o,e){const l=e.isWebGL2;let h;this.setMode=function(e){h=e},this.render=function(e,t){s.drawArrays(h,e,t),o.update(t,h,1)},this.renderInstances=function(r,i,n){if(0!==n){let e,t;if(l)e=s,t="drawArraysInstanced";else if(e=a.get("ANGLE_instanced_arrays"),t="drawArraysInstancedANGLE",null===e)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](h,r,i,n),o.update(i,h,n)}}}function ia(t,r,e){let i;function n(e){if("highp"===e){if(0<t.getShaderPrecisionFormat(35633,36338).precision&&0<t.getShaderPrecisionFormat(35632,36338).precision)return"highp";e="mediump"}return"mediump"===e&&0<t.getShaderPrecisionFormat(35633,36337).precision&&0<t.getShaderPrecisionFormat(35632,36337).precision?"mediump":"lowp"}var s="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let a=void 0!==e.precision?e.precision:"highp";var o=n(a),o=(o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o),s||r.has("WEBGL_draw_buffers")),e=!0===e.logarithmicDepthBuffer,l=t.getParameter(34930),h=t.getParameter(35660),u=t.getParameter(3379),c=t.getParameter(34076),d=t.getParameter(34921),f=t.getParameter(36347),p=t.getParameter(36348),m=t.getParameter(36349),g=0<h,v=s||r.has("OES_texture_float");return{isWebGL2:s,drawBuffers:o,getMaxAnisotropy:function(){var e;return i=void 0===i?!0===r.has("EXT_texture_filter_anisotropic")?(e=r.get("EXT_texture_filter_anisotropic"),t.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT)):0:i},getMaxPrecision:n,precision:a,logarithmicDepthBuffer:e,maxTextures:l,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:c,maxAttributes:d,maxVertexUniforms:f,maxVaryings:p,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v,maxSamples:s?t.getParameter(36183):0}}function na(l){const t=this;let h=null,u=0,c=!1,d=!1;const o=new Ys,f=new v,p={value:null,needsUpdate:!1};function m(){p.value!==h&&(p.value=h,p.needsUpdate=0<u),t.numPlanes=u,t.numIntersection=0}function g(r,e,i,n){var s=null!==r?r.length:0;let a=null;if(0!==s){if(a=p.value,!0!==n||null===a){const t=i+4*s,n=e.matrixWorldInverse;f.getNormalMatrix(n),(null===a||a.length<t)&&(a=new Float32Array(t));for(let e=0,t=i;e!==s;++e,t+=4)o.copy(r[e]).applyMatrix4(n,f),o.normal.toArray(a,t),a[t+3]=o.constant}p.value=a,p.needsUpdate=!0}return t.numPlanes=s,t.numIntersection=0,a}this.uniform=p,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,r){var i=0!==e.length||t||0!==u||c;return c=t,h=g(e,r,0),u=e.length,i},this.beginShadows=function(){d=!0,g(null)},this.endShadows=function(){d=!1,m()},this.setState=function(t,e,r){var i=t.clippingPlanes,n=t.clipIntersection,s=t.clipShadows,a=l.get(t);if(!c||null===i||0===i.length||d&&!s)d?g(null):m();else{const l=d?0:u,t=4*l;var o=a.clippingState||null;p.value=o,o=g(i,e,t,r);for(let e=0;e!==t;++e)o[e]=h[e];a.clippingState=o,this.numIntersection=n?this.numPlanes:0,this.numPlanes+=l}}}function sa(i){let n=new WeakMap;function s(e,t){return t===Ge?e.mapping=Ue:t===He&&(e.mapping=Be),e}function a(e){var e=e.target,t=(e.removeEventListener("dispose",a),n.get(e));void 0!==t&&(n.delete(e),t.dispose())}return{get:function(e){if(e&&e.isTexture&&!1===e.isRenderTargetTexture){var t,r=e.mapping;if(r===Ge||r===He)return n.has(e)?s(n.get(e).texture,e.mapping):(r=e.image)&&0<r.height?(t=i.getRenderTarget(),(r=new zs(r.height/2)).fromEquirectangularTexture(i,e),n.set(e,r),i.setRenderTarget(t),e.addEventListener("dispose",a),s(r.texture,e.mapping)):null}return e},dispose:function(){n=new WeakMap}}}Qs.physical={uniforms:Fs([Qs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new z(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new g(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new g(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new g(1,1,1)},specularColorMap:{value:null}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag};class aa extends Bs{constructor(e=-1,t=1,r=1,i=-1,n=.1,s=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=n,this.far=s,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=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,n,s){null===this.view&&(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=r,this.view.offsetY=i,this.view.width=n,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let n=r-e,s=r+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;n+=e*this.view.offsetX,s=n+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(n,s,a,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){e=super.toJSON(e);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}aa.prototype.isOrthographicCamera=!0;class oa extends Us{constructor(e){super(e),this.type="RawShaderMaterial"}}oa.prototype.isRawShaderMaterial=!0;const la=Math.pow(2,8),ha=[.125,.215,.35,.446,.526,.582],ua=5+ha.length,ca={[De]:0,[wr]:1,[Ar]:2,[Rr]:3,[Cr]:4,[Dr]:5,[Mr]:6},da=new aa,{_lodPlanes:fa,_sizeLods:pa,_sigmas:ma}=function(){const r=[],i=[],n=[];let s=8;for(let t=0;t<ua;t++){var a=Math.pow(2,s);i.push(a);let e=1/a;4<t?e=ha[t-8+4-1]:0==t&&(e=0),n.push(e);var a=1/(a-1),o=-a/2,a=1+a/2,l=[o,o,a,o,a,a,o,o,a,a,o,a],h=new Float32Array(108),u=new Float32Array(72),c=new Float32Array(36);for(let e=0;e<6;e++){const i=e%3*2/3-1,n=2<e?0:-1,s=[i,n,0,i+2/3,n,0,i+2/3,1+n,0,i,n,0,i+2/3,1+n,0,i,1+n,0];h.set(s,18*e),u.set(l,12*e);var d=[e,e,e,e,e,e];c.set(d,6*e)}o=new S;o.setAttribute("position",new w(h,3)),o.setAttribute("uv",new w(u,2)),o.setAttribute("faceIndex",new w(c,1)),r.push(o),4<s&&s--}return{_lodPlanes:r,_sizeLods:i,_sigmas:n}}(),ga=new g;let va=null;const ya=(1+Math.sqrt(5))/2,xa=1/ya,_a=[new Pe(1,1,1),new Pe(-1,1,1),new Pe(1,1,-1),new Pe(-1,1,-1),new Pe(0,ya,xa),new Pe(0,ya,-xa),new Pe(xa,0,ya),new Pe(-xa,0,ya),new Pe(ya,xa,0),new Pe(-ya,xa,0)];class ba{constructor(e){var t;this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=(e=new Float32Array(20),t=new Pe(0,1,0),new oa({name:"SphericalGaussianBlur",defines:{n:20},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t},inputEncoding:{value:ca[De]},outputEncoding:{value:ca[De]}},vertexShader:Ma(),fragmentShader:`
|
|
2
2
|
|
|
3
3
|
precision mediump float;
|
|
4
4
|
precision mediump int;
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
gl_FragColor = linearToOutputTexel( gl_FragColor );
|
|
119
119
|
|
|
120
120
|
}
|
|
121
|
-
`,blending:q,depthTest:!1,depthWrite:!1})}function Ma(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Aa(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function La(n){let s=new WeakMap,a=null;function o(e){var e=e.target,t=(e.removeEventListener("dispose",o),s.get(e));void 0!==t&&(s.delete(e),t.dispose())}return{get:function(e){if(e&&e.isTexture&&!1===e.isRenderTargetTexture){var t,r=e.mapping,i=r===Ge||r===He,r=r===Ue||r===Be;if(i||r)return s.has(e)?s.get(e).texture:(t=e.image,i&&t&&0<t.height||r&&t&&function(t){let r=0;for(let e=0;e<6;e++)void 0!==t[e]&&r++;return 6===r}(t)?(r=n.getRenderTarget(),null===a&&(a=new ba(n)),t=i?a.fromEquirectangular(e):a.fromCubemap(e),s.set(e,t),n.setRenderTarget(r),e.addEventListener("dispose",o),t.texture):null)}return e},dispose:function(){s=new WeakMap,null!==a&&(a.dispose(),a=null)}}}function Ra(r){const i={};function n(e){if(void 0!==i[e])return i[e];let t;switch(e){case"WEBGL_depth_texture":t=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":t=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":t=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":t=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:t=r.getExtension(e)}return i[e]=t}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(e){var t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ca(e,o,r,i){const n={},l=new WeakMap;function s(e){var t=e.target;null!==t.index&&o.remove(t.index);for(const e in t.attributes)o.remove(t.attributes[e]);t.removeEventListener("dispose",s),delete n[t.id];e=l.get(t);e&&(o.remove(e),l.delete(t)),i.releaseStatesOfGeometry(t),!0===t.isInstancedBufferGeometry&&delete t._maxInstanceCount,r.memory.geometries--}function a(r){const i=[],n=r.index,s=r.attributes.position;let e=0;if(null!==n){const r=n.array;e=n.version;for(let e=0,t=r.length;e<t;e+=3){const n=r[e+0],s=r[e+1],l=r[e+2];i.push(n,s,s,l,l,n)}}else{const r=s.array;e=s.version;for(let e=0,t=r.length/3-1;e<t;e+=3){const r=e+0,n=e+1,s=e+2;i.push(r,n,n,s,s,r)}}var t=new(65535<Ti(i)?os:ss)(i,1),a=(t.version=e,l.get(r));a&&o.remove(a),l.set(r,t)}return{get:function(e,t){return!0!==n[t.id]&&(t.addEventListener("dispose",s),n[t.id]=!0,r.memory.geometries++),t},update:function(e){const r=e.attributes;for(const e in r)o.update(r[e],34962);var t=e.morphAttributes;for(const e in t){const r=t[e];for(let e=0,t=r.length;e<t;e++)o.update(r[e],34962)}},getWireframeAttribute:function(e){var t,r=l.get(e);return(!r||null!==(t=e.index)&&r.version<t.version)&&a(e),l.get(e)}}}function Da(s,a,o,e){const l=e.isWebGL2;let h,u,c;this.setMode=function(e){h=e},this.setIndex=function(e){u=e.type,c=e.bytesPerElement},this.render=function(e,t){s.drawElements(h,t,u,e*c),o.update(t,h,1)},this.renderInstances=function(r,i,n){if(0!==n){let e,t;if(l)e=s,t="drawElementsInstanced";else if(e=a.get("ANGLE_instanced_arrays"),t="drawElementsInstancedANGLE",null===e)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](h,i,u,r*c,n),o.update(i,h,n)}}}function Ia(e){const i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:i,programs:null,autoReset:!0,reset:function(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0},update:function(e,t,r){switch(i.calls++,t){case 4:i.triangles+=r*(e/3);break;case 1:i.lines+=r*(e/2);break;case 3:i.lines+=r*(e-1);break;case 2:i.lines+=r*e;break;case 0:i.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",t)}}}}class Pa extends u{constructor(e=null,t=1,r=1,i=1){super(null),this.image={data:e,width:t,height:r,depth:i},this.magFilter=Re,this.minFilter=Re,this.wrapR=Le,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}function ka(e,t){return e[0]-t[0]}function Oa(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Fa(e,t){let r=1;t=(t.isInterleavedBufferAttribute?t.data:t).array;t instanceof Int8Array?r=127:t instanceof Int16Array?r=32767:t instanceof Int32Array?r=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",t),e.divideScalar(r)}function Na(h,u,c){const d={},f=new Float32Array(8),p=new WeakMap,m=new Pe,g=[];for(let e=0;e<8;e++)g[e]=[e,0];return{update:function(i,n,e,s){const a=i.morphTargetInfluences;if(!0===u.isWebGL2){const d=n.morphAttributes.position.length;let e=p.get(n);if(void 0===e||e.count!==d){void 0!==e&&e.texture.dispose();const h=void 0!==n.morphAttributes.normal,c=n.morphAttributes.position,g=n.morphAttributes.normal||[],i=!0==h?2:1;let t=n.attributes.position.count*i,r=1;t>u.maxTextureSize&&(r=Math.ceil(t/u.maxTextureSize),t=u.maxTextureSize);const a=new Float32Array(t*r*4*d),l=new Pa(a,t,r,d);l.format=Ce,l.type=at;var o=4*i;for(let e=0;e<d;e++){const d=c[e],f=g[e],p=t*r*4*e;for(let e=0;e<d.count;e++){m.fromBufferAttribute(d,e),!0===d.normalized&&Fa(m,d);const c=e*o;a[p+c]=m.x,a[p+c+1]=m.y,a[p+c+2]=m.z,!(a[p+c+3]=0)==h&&(m.fromBufferAttribute(f,e),!0===f.normalized&&Fa(m,f),a[p+c+4]=m.x,a[p+c+5]=m.y,a[p+c+6]=m.z,a[p+c+7]=0)}}e={count:d,texture:l,size:new z(t,r)},p.set(n,e)}let t=0;for(let e=0;e<a.length;e++)t+=a[e];const i=n.morphTargetsRelative?1:1-t;s.getUniforms().setValue(h,"morphTargetBaseInfluence",i),s.getUniforms().setValue(h,"morphTargetInfluences",a),s.getUniforms().setValue(h,"morphTargetsTexture",e.texture,c),s.getUniforms().setValue(h,"morphTargetsTextureSize",e.size)}else{const u=void 0===a?0:a.length;let t=d[n.id];if(void 0===t||t.length!==u){t=[];for(let e=0;e<u;e++)t[e]=[e,0];d[n.id]=t}for(let e=0;e<u;e++){const u=t[e];u[0]=e,u[1]=a[e]}t.sort(Oa);for(let e=0;e<8;e++)e<u&&t[e][1]?(g[e][0]=t[e][0],g[e][1]=t[e][1]):(g[e][0]=Number.MAX_SAFE_INTEGER,g[e][1]=0);g.sort(ka);const p=n.morphAttributes.position,m=n.morphAttributes.normal;let r=0;for(let e=0;e<8;e++){const u=g[e],c=u[0],d=u[1];c!==Number.MAX_SAFE_INTEGER&&d?(p&&n.getAttribute("morphTarget"+e)!==p[c]&&n.setAttribute("morphTarget"+e,p[c]),m&&n.getAttribute("morphNormal"+e)!==m[c]&&n.setAttribute("morphNormal"+e,m[c]),f[e]=d,r+=d):(p&&!0===n.hasAttribute("morphTarget"+e)&&n.deleteAttribute("morphTarget"+e),m&&!0===n.hasAttribute("morphNormal"+e)&&n.deleteAttribute("morphNormal"+e),f[e]=0)}const e=n.morphTargetsRelative?1:1-r;s.getUniforms().setValue(h,"morphTargetBaseInfluence",e),s.getUniforms().setValue(h,"morphTargetInfluences",f)}}}}function Ua(e,i,n,s){let a=new WeakMap;function o(e){e=e.target;e.removeEventListener("dispose",o),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(e){var t=s.render.frame,r=e.geometry,r=i.get(e,r);return a.get(r)!==t&&(i.update(r),a.set(r,t)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor)&&n.update(e.instanceColor,34962),r},dispose:function(){a=new WeakMap}}}Pa.prototype.isDataTexture2DArray=!0;class Ba extends u{constructor(e=null,t=1,r=1,i=1){super(null),this.image={data:e,width:t,height:r,depth:i},this.magFilter=Re,this.minFilter=Re,this.wrapR=Le,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Ba.prototype.isDataTexture3D=!0;const Ga=new u,Ha=new Pa,za=new Ba,Va=new Hs,Wa=[],ja=[],Ya=new Float32Array(16),$a=new Float32Array(9),qa=new Float32Array(4);function Ka(r,i,n){var e=r[0];if(e<=0||0<e)return r;var t=i*n;let s=Wa[t];if(void 0===s&&(s=new Float32Array(t),Wa[t]=s),0!==i){e.toArray(s,0);for(let e=1,t=0;e!==i;++e)t+=n,r[e].toArray(s,t)}return s}function Xa(r,i){if(r.length===i.length){for(let e=0,t=r.length;e<t;e++)if(r[e]!==i[e])return;return 1}}function Ja(r,i){for(let e=0,t=i.length;e<t;e++)r[e]=i[e]}function Za(t,r){let i=ja[r];void 0===i&&(i=new Int32Array(r),ja[r]=i);for(let e=0;e!==r;++e)i[e]=t.allocateTextureUnit();return i}function Qa(e,t){var r=this.cache;r[0]!==t&&(e.uniform1f(this.addr,t),r[0]=t)}function eo(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y):Xa(r,t)||(e.uniform2fv(this.addr,t),Ja(r,t))}function to(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z):void 0!==t.r?r[0]===t.r&&r[1]===t.g&&r[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),r[0]=t.r,r[1]=t.g,r[2]=t.b):Xa(r,t)||(e.uniform3fv(this.addr,t),Ja(r,t))}function ro(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w):Xa(r,t)||(e.uniform4fv(this.addr,t),Ja(r,t))}function io(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix2fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||(qa.set(i),e.uniformMatrix2fv(this.addr,!1,qa),Ja(r,i))}function no(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix3fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||($a.set(i),e.uniformMatrix3fv(this.addr,!1,$a),Ja(r,i))}function so(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix4fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||(Ya.set(i),e.uniformMatrix4fv(this.addr,!1,Ya),Ja(r,i))}function ao(e,t){var r=this.cache;r[0]!==t&&(e.uniform1i(this.addr,t),r[0]=t)}function oo(e,t){var r=this.cache;Xa(r,t)||(e.uniform2iv(this.addr,t),Ja(r,t))}function lo(e,t){var r=this.cache;Xa(r,t)||(e.uniform3iv(this.addr,t),Ja(r,t))}function ho(e,t){var r=this.cache;Xa(r,t)||(e.uniform4iv(this.addr,t),Ja(r,t))}function uo(e,t){var r=this.cache;r[0]!==t&&(e.uniform1ui(this.addr,t),r[0]=t)}function co(e,t){var r=this.cache;Xa(r,t)||(e.uniform2uiv(this.addr,t),Ja(r,t))}function fo(e,t){var r=this.cache;Xa(r,t)||(e.uniform3uiv(this.addr,t),Ja(r,t))}function po(e,t){var r=this.cache;Xa(r,t)||(e.uniform4uiv(this.addr,t),Ja(r,t))}function mo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.safeSetTexture2D(t||Ga,n)}function go(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTexture3D(t||za,n)}function vo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.safeSetTextureCube(t||Va,n)}function yo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTexture2DArray(t||Ha,n)}function xo(e,t){e.uniform1fv(this.addr,t)}function _o(e,t){t=Ka(t,this.size,2);e.uniform2fv(this.addr,t)}function bo(e,t){t=Ka(t,this.size,3);e.uniform3fv(this.addr,t)}function To(e,t){t=Ka(t,this.size,4);e.uniform4fv(this.addr,t)}function So(e,t){t=Ka(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,t)}function Eo(e,t){t=Ka(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,t)}function wo(e,t){t=Ka(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,t)}function Mo(e,t){e.uniform1iv(this.addr,t)}function Ao(e,t){e.uniform2iv(this.addr,t)}function Lo(e,t){e.uniform3iv(this.addr,t)}function Ro(e,t){e.uniform4iv(this.addr,t)}function Co(e,t){e.uniform1uiv(this.addr,t)}function Do(e,t){e.uniform2uiv(this.addr,t)}function Io(e,t){e.uniform3uiv(this.addr,t)}function Po(e,t){e.uniform4uiv(this.addr,t)}function ko(e,t,r){var i=t.length,n=Za(r,i);e.uniform1iv(this.addr,n);for(let e=0;e!==i;++e)r.safeSetTexture2D(t[e]||Ga,n[e])}function Oo(e,t,r){var i=t.length,n=Za(r,i);e.uniform1iv(this.addr,n);for(let e=0;e!==i;++e)r.safeSetTextureCube(t[e]||Va,n[e])}function Fo(e,t,r){this.id=e,this.addr=r,this.cache=[],this.setValue=function(){switch(t.type){case 5126:return Qa;case 35664:return eo;case 35665:return to;case 35666:return ro;case 35674:return io;case 35675:return no;case 35676:return so;case 5124:case 35670:return ao;case 35667:case 35671:return oo;case 35668:case 35672:return lo;case 35669:case 35673:return ho;case 5125:return uo;case 36294:return co;case 36295:return fo;case 36296:return po;case 35678:case 36198:case 36298:case 36306:case 35682:return mo;case 35679:case 36299:case 36307:return go;case 35680:case 36300:case 36308:case 36293:return vo;case 36289:case 36303:case 36311:case 36292:return yo}}()}function No(e,t,r){this.id=e,this.addr=r,this.cache=[],this.size=t.size,this.setValue=function(){switch(t.type){case 5126:return xo;case 35664:return _o;case 35665:return bo;case 35666:return To;case 35674:return So;case 35675:return Eo;case 35676:return wo;case 5124:case 35670:return Mo;case 35667:case 35671:return Ao;case 35668:case 35672:return Lo;case 35669:case 35673:return Ro;case 5125:return Co;case 36294:return Do;case 36295:return Io;case 36296:return Po;case 35678:case 36198:case 36298:case 36306:case 35682:return ko;case 35680:case 36300:case 36308:case 36293:return Oo}}()}function Uo(e){this.id=e,this.seq=[],this.map={}}No.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Ja(t,e)},Uo.prototype.setValue=function(r,i,n){var s=this.seq;for(let e=0,t=s.length;e!==t;++e){var a=s[e];a.setValue(r,i[a.id],n)}};const Bo=/(\w+)(\])?(\[|\.)?/g;function Go(e,t){e.seq.push(t),e.map[t.id]=t}function Ho(t,r){this.seq=[],this.map={};const i=t.getProgramParameter(r,35718);for(let e=0;e<i;++e){const i=t.getActiveUniform(r,e);c=u=h=l=o=a=s=n=void 0;var n=i,s=t.getUniformLocation(r,i.name),a=this,o=n.name,l=o.length;for(Bo.lastIndex=0;;){var h=Bo.exec(o),u=Bo.lastIndex;let t=h[1];var c="]"===h[2],h=h[3];if(c&&(t|=0),void 0===h||"["===h&&u+2===l){Go(a,new(void 0===h?Fo:No)(t,n,s));break}{let e=a.map[t];void 0===e&&Go(a,e=new Uo(t)),a=e}}}}function zo(e,t,r){t=e.createShader(t);return e.shaderSource(t,r),e.compileShader(t),t}Ho.prototype.setValue=function(e,t,r,i){t=this.map[t];void 0!==t&&t.setValue(e,r,i)},Ho.prototype.setOptional=function(e,t,r){t=t[r];void 0!==t&&this.setValue(e,r,t)},Ho.upload=function(r,i,n,s){for(let e=0,t=i.length;e!==t;++e){var a=i[e],o=n[a.id];!1!==o.needsUpdate&&a.setValue(r,o.value,s)}},Ho.seqWithValue=function(r,i){var n=[];for(let e=0,t=r.length;e!==t;++e){var s=r[e];s.id in i&&n.push(s)}return n};let Vo=0;function Wo(e){switch(e){case De:return["Linear","( value )"];case wr:return["sRGB","( value )"];case Ar:return["RGBE","( value )"];case Rr:return["RGBM","( value, 7.0 )"];case Cr:return["RGBM","( value, 16.0 )"];case Dr:return["RGBD","( value, 256.0 )"];case Mr:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case Lr:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function jo(e,r,t){var i=e.getShaderParameter(r,35713),n=e.getShaderInfoLog(r).trim();return i&&""===n?"":t.toUpperCase()+"\n\n"+n+"\n\n"+function(){var t=e.getShaderSource(r).split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}()}function Yo(e,t){t=Wo(t);return"vec4 "+e+"( vec4 value ) { return "+t[0]+"ToLinear"+t[1]+"; }"}function $o(e){return""!==e}function qo(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ko(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Xo=/^[ \t]*#include +<([\w\d./]+)>/gm;function Jo(e){return e.replace(Xo,Zo)}function Zo(e,t){var r=M[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");return Jo(r)}const Qo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,el=/#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;function tl(e){return e.replace(el,il).replace(Qo,rl)}function rl(e,t,r,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),il(0,t,r,i)}function il(e,t,r,i){let n="";for(let e=parseInt(t);e<parseInt(r);e++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return n}function nl(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function sl(r,i,n,e){const s=r.getContext(),t=n.defines;var a=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===C?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===D?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===I&&(t="SHADOWMAP_TYPE_VSM"),t}(n),h=function(){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Ue:case Be:e="ENVMAP_TYPE_CUBE";break;case ze:case Ve:e="ENVMAP_TYPE_CUBE_UV"}return e}(),u=function(){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Be:case Ve:e="ENVMAP_MODE_REFRACTION"}return e}(),c=function(){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case O:e="ENVMAP_BLENDING_MULTIPLY";break;case F:e="ENVMAP_BLENDING_MIX";break;case B:e="ENVMAP_BLENDING_ADD"}return e}(),d=0<r.gammaFactor?r.gammaFactor:1,f=n.isWebGL2?"":[n.extensionDerivatives||n.envMapCubeUV||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||"physical"===n.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter($o).join("\n"),p=function(e){var t=[];for(const i in e){var r=e[i];!1!==r&&t.push("#define "+i+" "+r)}return t.join("\n")}(t),m=s.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(0<(g=[p].filter($o).join("\n")).length&&(g+="\n"),0<(v=[f,p].filter($o).join("\n")).length&&(v+="\n")):(g=[nl(n),"#define SHADER_NAME "+n.shaderName,p,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter($o).join("\n"),v=[f,nl(n),"#define SHADER_NAME "+n.shaderName,p,"#define GAMMA_FACTOR "+d,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ne?"#define TONE_MAPPING":"",n.toneMapping!==Ne?M.tonemapping_pars_fragment:"",n.toneMapping!==Ne?function(e,t){let r;switch(t){case G:r="Linear";break;case H:r="Reinhard";break;case W:r="OptimizedCineon";break;case Ee:r="ACESFilmic";break;case we:r="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),r="Linear"}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===ft?"#define OPAQUE":"",M.encodings_pars_fragment,n.map?Yo("mapTexelToLinear",n.mapEncoding):"",n.matcap?Yo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Yo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Yo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularColorMap?Yo("specularColorMapTexelToLinear",n.specularColorMapEncoding):"",n.sheenColorMap?Yo("sheenColorMapTexelToLinear",n.sheenColorMapEncoding):"",n.lightMap?Yo("lightMapTexelToLinear",n.lightMapEncoding):"",(x="linearToOutputTexel",_=Wo(_=n.outputEncoding),"vec4 "+x+"( vec4 value ) { return LinearTo"+_[0]+_[1]+"; }"),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter($o).join("\n")),a=Ko(qo(Jo(a),n),n),o=Ko(qo(Jo(o),n),n),a=tl(a),o=tl(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===li?"":"out highp vec4 pc_fragColor;",n.glslVersion===li?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);var x=y+v+o,_=zo(s,35633,y+g+a),o=zo(s,35632,x);if(s.attachShader(m,_),s.attachShader(m,o),void 0!==n.index0AttributeName?s.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(m,0,"position"),s.linkProgram(m),r.debug.checkShaderErrors){const r=s.getProgramInfoLog(m).trim(),i=s.getShaderInfoLog(_).trim(),n=s.getShaderInfoLog(o).trim();let e=!0,t=!0;if(!1===s.getProgramParameter(m,35714)){e=!1;const i=jo(s,_,"vertex"),n=jo(s,o,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(m,35715)+"\n\nProgram Info Log: "+r+"\n"+i+"\n"+n)}else""!==r?console.warn("THREE.WebGLProgram: Program Info Log:",r):""!==i&&""!==n||(t=!1);t&&(this.diagnostics={runnable:e,programLog:r,vertexShader:{log:i,prefix:g},fragmentShader:{log:n,prefix:v}})}let b,T;return s.deleteShader(_),s.deleteShader(o),this.getUniforms=function(){return b=void 0===b?new Ho(s,m):b},this.getAttributes=function(){return T=void 0===T?function(r,i){const n={},s=r.getProgramParameter(i,35721);for(let t=0;t<s;t++){const s=r.getActiveAttrib(i,t),a=s.name;let e=1;35674===s.type&&(e=2),35675===s.type&&(e=3),35676===s.type&&(e=4),n[a]={type:s.type,location:r.getAttribLocation(i,a),locationSize:e}}return n}(s,m):T},this.destroy=function(){e.releaseStatesOfProgram(this),s.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=Vo++,this.cacheKey=i,this.usedTimes=1,this.program=m,this.vertexShader=_,this.fragmentShader=o,this}function al(f,p,m,g,v,e,y){const s=[],x=v.isWebGL2,_=v.logarithmicDepthBuffer,b=v.floatVertexTextures,T=v.maxVertexUniforms,S=v.vertexTextures;let E=v.precision;const w={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"},i=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap",,"roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","morphTargetsCount","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","specularIntensityMap","specularColorMap","specularColorMapEncoding","transmission","transmissionMap","thicknessMap","sheen","sheenColorMap","sheenColorMapEncoding","sheenRoughnessMap"];function M(e){let t;return t=e&&e.isTexture?e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e.texture.encoding):De,t=x&&e&&e.isTexture&&e.format===Ce&&e.type===et&&e.encoding===wr?De:t}return{getParameters:function(e,t,r,i,n){var s=i.fog,i=e.isMeshStandardMaterial?i.environment:null,i=(e.isMeshStandardMaterial?m:p).get(e.envMap||i),a=w[e.type],o=n.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(b)return 1024;{const e=T,r=Math.floor((e-20)/4),i=Math.min(r,t.length);return i<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+i+"."),0):i}}(n):0;let l,h;if(null!==e.precision&&(E=v.getMaxPrecision(e.precision))!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",E,"instead."),a){const f=Qs[a];l=f.vertexShader,h=f.fragmentShader}else l=e.vertexShader,h=e.fragmentShader;var u=f.getRenderTarget(),c=0<e.alphaTest,d=0<e.clearcoat;return{isWebGL2:x,shaderID:a,shaderName:e.type,vertexShader:l,fragmentShader:h,defines:e.defines,isRawShaderMaterial:!0===e.isRawShaderMaterial,glslVersion:e.glslVersion,precision:E,instancing:!0===n.isInstancedMesh,instancingColor:!0===n.isInstancedMesh&&null!==n.instanceColor,supportsVertexTextures:S,outputEncoding:null!==u?M(u.texture):f.outputEncoding,map:!!e.map,mapEncoding:M(e.map),matcap:!!e.matcap,matcapEncoding:M(e.matcap),envMap:!!i,envMapMode:i&&i.mapping,envMapEncoding:M(i),envMapCubeUV:!!i&&(i.mapping===ze||i.mapping===Ve),lightMap:!!e.lightMap,lightMapEncoding:M(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:M(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:e.normalMapType===Or,tangentSpaceNormalMap:e.normalMapType===kr,clearcoat:d,clearcoatMap:d&&!!e.clearcoatMap,clearcoatRoughnessMap:d&&!!e.clearcoatRoughnessMap,clearcoatNormalMap:d&&!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,specularIntensityMap:!!e.specularIntensityMap,specularColorMap:!!e.specularColorMap,specularColorMapEncoding:M(e.specularColorMap),alphaMap:!!e.alphaMap,alphaTest:c,gradientMap:!!e.gradientMap,sheen:0<e.sheen,sheenColorMap:!!e.sheenColorMap,sheenColorMapEncoding:M(e.sheenColorMap),sheenRoughnessMap:!!e.sheenRoughnessMap,transmission:0<e.transmission,transmissionMap:!!e.transmissionMap,thicknessMap:!!e.thicknessMap,combine:e.combine,vertexTangents:!!e.normalMap&&!!n.geometry&&!!n.geometry.attributes.tangent,vertexColors:e.vertexColors,vertexAlphas:!0===e.vertexColors&&!!n.geometry&&!!n.geometry.attributes.color&&4===n.geometry.attributes.color.itemSize,vertexUvs:!!e.map||!!e.bumpMap||!!e.normalMap||!!e.specularMap||!!e.alphaMap||!!e.emissiveMap||!!e.roughnessMap||!!e.metalnessMap||!!e.clearcoatMap||!!e.clearcoatRoughnessMap||!!e.clearcoatNormalMap||!!e.displacementMap||!!e.transmissionMap||!!e.thicknessMap||!!e.specularIntensityMap||!!e.specularColorMap||!!e.sheenColorMap||e.sheenRoughnessMap,uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||0<e.transmission||e.transmissionMap||e.thicknessMap||e.specularIntensityMap||e.specularColorMap||0<!!e.sheen||e.sheenColorMap||e.sheenRoughnessMap||!e.displacementMap),fog:!!s,useFog:e.fog,fogExp2:s&&s.isFogExp2,flatShading:!!e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:_,skinning:!0===n.isSkinnedMesh&&0<o,maxBones:o,useVertexTexture:b,morphTargets:!!n.geometry&&!!n.geometry.morphAttributes.position,morphNormals:!!n.geometry&&!!n.geometry.morphAttributes.normal,morphTargetsCount:n.geometry&&n.geometry.morphAttributes.position?n.geometry.morphAttributes.position.length:0,numDirLights:t.directional.length,numPointLights:t.point.length,numSpotLights:t.spot.length,numRectAreaLights:t.rectArea.length,numHemiLights:t.hemi.length,numDirLightShadows:t.directionalShadowMap.length,numPointLightShadows:t.pointShadowMap.length,numSpotLightShadows:t.spotShadowMap.length,numClippingPlanes:y.numPlanes,numClipIntersection:y.numIntersection,format:e.format,dithering:e.dithering,shadowMapEnabled:f.shadowMap.enabled&&0<r.length,shadowMapType:f.shadowMap.type,toneMapping:e.toneMapped?f.toneMapping:Ne,physicallyCorrectLights:f.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,doubleSided:e.side===Fe,flipSided:e.side===Ae,depthPacking:void 0!==e.depthPacking&&e.depthPacking,index0AttributeName:e.index0AttributeName,extensionDerivatives:e.extensions&&e.extensions.derivatives,extensionFragDepth:e.extensions&&e.extensions.fragDepth,extensionDrawBuffers:e.extensions&&e.extensions.drawBuffers,extensionShaderTextureLOD:e.extensions&&e.extensions.shaderTextureLOD,rendererExtensionFragDepth:x||g.has("EXT_frag_depth"),rendererExtensionDrawBuffers:x||g.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:x||g.has("EXT_shader_texture_lod"),customProgramCacheKey:e.customProgramCacheKey()}},getProgramCacheKey:function(t){var r=[];if(t.shaderID?r.push(t.shaderID):(r.push(Mi(t.fragmentShader)),r.push(Mi(t.vertexShader))),void 0!==t.defines)for(const f in t.defines)r.push(f),r.push(t.defines[f]);if(!1===t.isRawShaderMaterial){for(let e=0;e<i.length;e++)r.push(t[i[e]]);r.push(f.outputEncoding),r.push(f.gammaFactor)}return r.push(t.customProgramCacheKey),r.join()},getUniforms:function(e){var t=w[e.type];let r;if(t){const e=Qs[t];r=Ns.clone(e.uniforms)}else r=e.uniforms;return r},acquireProgram:function(r,i){let n;for(let e=0,t=s.length;e<t;e++){const r=s[e];if(r.cacheKey===i){++(n=r).usedTimes;break}}return void 0===n&&(n=new sl(f,i,r,e),s.push(n)),n},releaseProgram:function(e){var t;0==--e.usedTimes&&(t=s.indexOf(e),s[t]=s[s.length-1],s.pop(),e.destroy())},programs:s}}function ol(){let i=new WeakMap;return{get:function(e){let t=i.get(e);return void 0===t&&(t={},i.set(e,t)),t},remove:function(e){i.delete(e)},update:function(e,t,r){i.get(e)[t]=r},dispose:function(){i=new WeakMap}}}function ll(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function hl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function ul(l){const h=[];let u=0;const a=[],o=[],c=[],d={id:-1};function f(e,t,r,i,n,s){let a=h[u];var o=l.get(r);return void 0===a?(a={id:e.id,object:e,geometry:t,material:r,program:o.program||d,groupOrder:i,renderOrder:e.renderOrder,z:n,group:s},h[u]=a):(a.id=e.id,a.object=e,a.geometry=t,a.material=r,a.program=o.program||d,a.groupOrder=i,a.renderOrder=e.renderOrder,a.z=n,a.group=s),u++,a}return{opaque:a,transmissive:o,transparent:c,init:function(){u=0,a.length=0,o.length=0,c.length=0},push:function(e,t,r,i,n,s){e=f(e,t,r,i,n,s);(0<r.transmission?o:!0===r.transparent?c:a).push(e)},unshift:function(e,t,r,i,n,s){e=f(e,t,r,i,n,s);(0<r.transmission?o:!0===r.transparent?c:a).unshift(e)},finish:function(){for(let e=u,t=h.length;e<t;e++){const u=h[e];if(null===u.id)break;u.id=null,u.object=null,u.geometry=null,u.material=null,u.program=null,u.group=null}},sort:function(e,t){1<a.length&&a.sort(e||ll),1<o.length&&o.sort(t||hl),1<c.length&&c.sort(t||hl)}}}function cl(i){let n=new WeakMap;return{get:function(e,t){let r;return!1===n.has(e)?(r=new ul(i),n.set(e,[r])):t>=n.get(e).length?(r=new ul(i),n.get(e).push(r)):r=n.get(e)[t],r},dispose:function(){n=new WeakMap}}}function dl(){const r={};return{get:function(e){if(void 0!==r[e.id])return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Pe,color:new g};break;case"SpotLight":t={position:new Pe,direction:new Pe,color:new g,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Pe,color:new g,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Pe,skyColor:new g,groundColor:new g};break;case"RectAreaLight":t={color:new g,position:new Pe,halfWidth:new Pe,halfHeight:new Pe}}return r[e.id]=t}}}let fl=0;function pl(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function ml(x,_){const b=new dl,T=function(){const r={};return{get:function(e){if(void 0!==r[e.id])return r[e.id];let t;switch(e.type){case"DirectionalLight":case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z,shadowCameraNear:1,shadowCameraFar:1e3}}return r[e.id]=t}}}(),S={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)S.probe.push(new Pe);const u=new Pe,c=new ke,d=new ke;return{setup:function(r,i){let n=0,s=0,a=0;for(let e=0;e<9;e++)S.probe[e].set(0,0,0);let o=0,l=0,h=0,u=0,c=0,d=0,f=0,p=0;r.sort(pl);var m=!0!==i?Math.PI:1;for(let e=0,t=r.length;e<t;e++){const _=r[e],i=_.color,g=_.intensity,v=_.distance,y=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)n+=i.r*g*m,s+=i.g*g*m,a+=i.b*g*m;else if(_.isLightProbe)for(let e=0;e<9;e++)S.probe[e].addScaledVector(_.sh.coefficients[e],g);else if(_.isDirectionalLight){const x=b.get(_);if(x.color.copy(_.color).multiplyScalar(_.intensity*m),_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,S.directionalShadow[o]=b,S.directionalShadowMap[o]=y,S.directionalShadowMatrix[o]=_.shadow.matrix,d++}S.directional[o]=x,o++}else if(_.isSpotLight){const x=b.get(_);if(x.position.setFromMatrixPosition(_.matrixWorld),x.color.copy(i).multiplyScalar(g*m),x.distance=v,x.coneCos=Math.cos(_.angle),x.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),x.decay=_.decay,_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,S.spotShadow[h]=b,S.spotShadowMap[h]=y,S.spotShadowMatrix[h]=_.shadow.matrix,p++}S.spot[h]=x,h++}else if(_.isRectAreaLight){const x=b.get(_);x.color.copy(i).multiplyScalar(g),x.halfWidth.set(.5*_.width,0,0),x.halfHeight.set(0,.5*_.height,0),S.rectArea[u]=x,u++}else if(_.isPointLight){const x=b.get(_);if(x.color.copy(_.color).multiplyScalar(_.intensity*m),x.distance=_.distance,x.decay=_.decay,_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,b.shadowCameraNear=x.camera.near,b.shadowCameraFar=x.camera.far,S.pointShadow[l]=b,S.pointShadowMap[l]=y,S.pointShadowMatrix[l]=_.shadow.matrix,f++}S.point[l]=x,l++}else if(_.isHemisphereLight){const x=b.get(_);x.skyColor.copy(_.color).multiplyScalar(g*m),x.groundColor.copy(_.groundColor).multiplyScalar(g*m),S.hemi[c]=x,c++}}0<u&&(_.isWebGL2||!0===x.has("OES_texture_float_linear")?(S.rectAreaLTC1=A.LTC_FLOAT_1,S.rectAreaLTC2=A.LTC_FLOAT_2):!0===x.has("OES_texture_half_float_linear")?(S.rectAreaLTC1=A.LTC_HALF_1,S.rectAreaLTC2=A.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),S.ambient[0]=n,S.ambient[1]=s,S.ambient[2]=a;const g=S.hash;g.directionalLength===o&&g.pointLength===l&&g.spotLength===h&&g.rectAreaLength===u&&g.hemiLength===c&&g.numDirectionalShadows===d&&g.numPointShadows===f&&g.numSpotShadows===p||(S.directional.length=o,S.spot.length=h,S.rectArea.length=u,S.point.length=l,S.hemi.length=c,S.directionalShadow.length=d,S.directionalShadowMap.length=d,S.pointShadow.length=f,S.pointShadowMap.length=f,S.spotShadow.length=p,S.spotShadowMap.length=p,S.directionalShadowMatrix.length=d,S.pointShadowMatrix.length=f,S.spotShadowMatrix.length=p,g.directionalLength=o,g.pointLength=l,g.spotLength=h,g.rectAreaLength=u,g.hemiLength=c,g.numDirectionalShadows=d,g.numPointShadows=f,g.numSpotShadows=p,S.version=fl++)},setupView:function(r,e){let i=0,n=0,s=0,a=0,o=0;var l=e.matrixWorldInverse;for(let e=0,t=r.length;e<t;e++){var h=r[e];if(h.isDirectionalLight){const r=S.directional[i];r.direction.setFromMatrixPosition(h.matrixWorld),u.setFromMatrixPosition(h.target.matrixWorld),r.direction.sub(u),r.direction.transformDirection(l),i++}else if(h.isSpotLight){const r=S.spot[s];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),r.direction.setFromMatrixPosition(h.matrixWorld),u.setFromMatrixPosition(h.target.matrixWorld),r.direction.sub(u),r.direction.transformDirection(l),s++}else if(h.isRectAreaLight){const r=S.rectArea[a];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),d.identity(),c.copy(h.matrixWorld),c.premultiply(l),d.extractRotation(c),r.halfWidth.set(.5*h.width,0,0),r.halfHeight.set(0,.5*h.height,0),r.halfWidth.applyMatrix4(d),r.halfHeight.applyMatrix4(d),a++}else if(h.isPointLight){const r=S.point[n];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),n++}else if(h.isHemisphereLight){const r=S.hemi[o];r.direction.setFromMatrixPosition(h.matrixWorld),r.direction.transformDirection(l),r.direction.normalize(),o++}}},state:S}}function gl(e,t){const r=new ml(e,t),i=[],n=[];return{init:function(){i.length=0,n.length=0},state:{lightsArray:i,shadowsArray:n,lights:r},setupLights:function(e){r.setup(i,e)},setupLightsView:function(e){r.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){n.push(e)}}}function vl(i,n){let s=new WeakMap;return{get:function(e,t=0){let r;return!1===s.has(e)?(r=new gl(i,n),s.set(e,[r])):t>=s.get(e).length?(r=new gl(i,n),s.get(e).push(r)):r=s.get(e)[t],r},dispose:function(){s=new WeakMap}}}class yl extends r{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=Ir,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}yl.prototype.isMeshDepthMaterial=!0;class xl extends r{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Pe,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function _l(d,f,e){let p=new Ks;const m=new z,g=new z,v=new Ie,l=new yl({depthPacking:Pr}),h=new xl,u={},y=e.maxTextureSize,c={0:Ae,1:Oe,2:Fe},x=new Us({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new z},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),_=x.clone();_.defines.HORIZONTAL_PASS=1;e=new S;e.setAttribute("position",new w(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new E(e,x),t=this;function T(r,e,i,t,n,s,a){let o=null;r=!0===t.isPointLight?r.customDistanceMaterial:r.customDepthMaterial;if(o=void 0!==r?r:!0===t.isPointLight?h:l,d.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&0<i.alphaTest){const d=o.uuid,r=i.uuid;let e=u[d],t=(void 0===e&&(e={},u[d]=e),e[r]);void 0===t&&(t=o.clone(),e[r]=t),o=t}return o.visible=i.visible,o.wireframe=i.wireframe,o.side=a===I?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:c[i.side],o.alphaMap=i.alphaMap,o.alphaTest=i.alphaTest,o.clipShadows=i.clipShadows,o.clippingPlanes=i.clippingPlanes,o.clipIntersection=i.clipIntersection,o.displacementMap=i.displacementMap,o.displacementScale=i.displacementScale,o.displacementBias=i.displacementBias,o.wireframeLinewidth=i.wireframeLinewidth,o.linewidth=i.linewidth,!0===t.isPointLight&&!0===o.isMeshDistanceMaterial&&(o.referencePosition.setFromMatrixPosition(t.matrixWorld),o.nearDistance=n,o.farDistance=s),o}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=C,this.render=function(r,i,n){if(!1!==t.enabled&&(!1!==t.autoUpdate||!1!==t.needsUpdate)&&0!==r.length){const e=d.getRenderTarget(),h=d.getActiveCubeFace(),u=d.getActiveMipmapLevel(),c=d.state;c.setBlending(q),c.buffers.color.setClear(1,1,1,1),c.buffers.depth.setTest(!0),c.setScissorTest(!1);for(let e=0,t=r.length;e<t;e++){const h=r[e],u=h.shadow;if(void 0===u)console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");else if(!1!==u.autoUpdate||!1!==u.needsUpdate){m.copy(u.mapSize);var s=u.getFrameExtents();if(m.multiply(s),g.copy(u.mapSize),(m.x>y||m.y>y)&&(m.x>y&&(g.x=Math.floor(y/s.x),m.x=g.x*s.x,u.mapSize.x=g.x),m.y>y)&&(g.y=Math.floor(y/s.y),m.y=g.y*s.y,u.mapSize.y=g.y),null===u.map&&!u.isPointLightShadow&&this.type===I){const d={minFilter:U,magFilter:U,format:Ce};u.map=new Di(m.x,m.y,d),u.map.texture.name=h.name+".shadowMap",u.mapPass=new Di(m.x,m.y,d),u.camera.updateProjectionMatrix()}if(null===u.map){const d={minFilter:Re,magFilter:Re,format:Ce};u.map=new Di(m.x,m.y,d),u.map.texture.name=h.name+".shadowMap",u.camera.updateProjectionMatrix()}d.setRenderTarget(u.map),d.clear();var a=u.getViewportCount();for(let e=0;e<a;e++){const r=u.getViewport(e);v.set(g.x*r.x,g.y*r.y,g.x*r.z,g.y*r.w),c.viewport(v),u.updateMatrices(h,e),p=u.getFrustum(),function r(i,n,s,a,o){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&o===I)&&(!i.frustumCulled||p.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const p=f.update(i),n=i.material;if(Array.isArray(n)){const f=p.groups;for(let e=0,t=f.length;e<t;e++){var l=f[e],h=n[l.materialIndex];if(h&&h.visible){const f=T(i,0,h,a,s.near,s.far,o);d.renderBufferDirect(s,null,p,f,i,l)}}}else if(n.visible){const f=T(i,0,n,a,s.near,s.far,o);d.renderBufferDirect(s,null,p,f,i,null)}}var u=i.children;for(let e=0,t=u.length;e<t;e++)r(u[e],n,s,a,o)}}(i,n,u.camera,h,this.type)}u.isPointLightShadow||this.type!==I||(s=u,o=n,l=void 0,l=f.update(b),x.defines.VSM_SAMPLES!==s.blurSamples&&(x.defines.VSM_SAMPLES=s.blurSamples,_.defines.VSM_SAMPLES=s.blurSamples,x.needsUpdate=!0,_.needsUpdate=!0),x.uniforms.shadow_pass.value=s.map.texture,x.uniforms.resolution.value=s.mapSize,x.uniforms.radius.value=s.radius,d.setRenderTarget(s.mapPass),d.clear(),d.renderBufferDirect(o,null,l,x,b,null),_.uniforms.shadow_pass.value=s.mapPass.texture,_.uniforms.resolution.value=s.mapSize,_.uniforms.radius.value=s.radius,d.setRenderTarget(s.map),d.clear(),d.renderBufferDirect(o,null,l,_,b,null)),u.needsUpdate=!1}}var o,l;t.needsUpdate=!1,d.setRenderTarget(e,h,u)}}}function bl(u,F,e){const r=e.isWebGL2,i=new function(){let t=!1;const s=new Ie;let r=null;const a=new Ie(0,0,0,0);return{setMask:function(e){r===e||t||(u.colorMask(e,e,e,e),r=e)},setLocked:function(e){t=e},setClear:function(e,t,r,i,n){!0===n&&(e*=i,t*=i,r*=i),s.set(e,t,r,i),!1===a.equals(s)&&(u.clearColor(e,t,r,i),a.copy(s))},reset:function(){t=!1,r=null,a.set(-1,0,0,0)}}},n=new function(){let t=!1,r=null,i=null,n=null;return{setTest:function(e){(e?D:I)(2929)},setMask:function(e){r===e||t||(u.depthMask(e),r=e)},setFunc:function(e){if(i!==e){if(e)switch(e){case ge:u.depthFunc(512);break;case ve:u.depthFunc(519);break;case ye:u.depthFunc(513);break;case xe:u.depthFunc(515);break;case _e:u.depthFunc(514);break;case be:u.depthFunc(518);break;case Te:u.depthFunc(516);break;case Se:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);i=e}},setLocked:function(e){t=e},setClear:function(e){n!==e&&(u.clearDepth(e),n=e)},reset:function(){t=!1,r=null,i=null,n=null}}},s=new function(){let t=!1,r=null,i=null,n=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(e){t||(e?D:I)(2960)},setMask:function(e){r===e||t||(u.stencilMask(e),r=e)},setFunc:function(e,t,r){i===e&&n===t&&s===r||(u.stencilFunc(e,t,r),i=e,n=t,s=r)},setOp:function(e,t,r){a===e&&o===t&&l===r||(u.stencilOp(e,t,r),a=e,o=t,l=r)},setLocked:function(e){t=e},setClear:function(e){h!==e&&(u.clearStencil(e),h=e)},reset:function(){t=!1,r=null,i=null,n=null,s=null,a=null,o=null,l=null,h=null}}};let t={},a=null,o={},l=null,h=!1,c=null,d=null,f=null,p=null,m=null,g=null,v=null,y=!1,x=null,_=null,b=null,T=null,S=null;const N=u.getParameter(35661);let E=!1,w=0;e=u.getParameter(7938);-1!==e.indexOf("WebGL")?(w=parseFloat(/^WebGL (\d)/.exec(e)[1]),E=1<=w):-1!==e.indexOf("OpenGL ES")&&(w=parseFloat(/^OpenGL ES (\d)/.exec(e)[1]),E=2<=w);let M=null,A={};const U=u.getParameter(3088),B=u.getParameter(2978),L=(new Ie).fromArray(U),R=(new Ie).fromArray(B);function G(e,t,r){var i=new Uint8Array(4),n=u.createTexture();u.bindTexture(e,n),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(let e=0;e<r;e++)u.texImage2D(t+e,0,6408,1,1,0,6408,5121,i);return n}const C={};function D(e){!0!==t[e]&&(u.enable(e),t[e]=!0)}function I(e){!1!==t[e]&&(u.disable(e),t[e]=!1)}C[3553]=G(3553,3553,1),C[34067]=G(34067,34069,6),i.setClear(0,0,0,1),n.setClear(1),s.setClear(0),D(2929),n.setFunc(xe),H(!1),z(Y),D(2884),O(q);const P={[ee]:32774,[te]:32778,[re]:32779};if(r)P[ie]=32775,P[ne]=32776;else{const u=F.get("EXT_blend_minmax");null!==u&&(P[ie]=u.MIN_EXT,P[ne]=u.MAX_EXT)}const k={[se]:0,[ae]:1,[oe]:768,[he]:770,[me]:776,[fe]:774,[ce]:772,[le]:769,[ue]:771,[pe]:775,[de]:773};function O(e,t,r,i,n,s,a,o){if(e!==q){if(!1===h&&(D(3042),h=!0),e===Q)n=n||t,s=s||r,a=a||i,t===d&&n===m||(u.blendEquationSeparate(P[t],P[n]),d=t,m=n),r===f&&i===p&&s===g&&a===v||(u.blendFuncSeparate(k[r],k[i],k[s],k[a]),f=r,p=i,g=s,v=a),c=e,y=null;else if(e!==c||o!==y){if(d===ee&&m===ee||(u.blendEquation(32774),d=ee,m=ee),o)switch(e){case K:u.blendFuncSeparate(1,771,1,771);break;case X:u.blendFunc(1,1);break;case J:u.blendFuncSeparate(0,0,769,771);break;case Z:u.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case K:u.blendFuncSeparate(770,771,1,771);break;case X:u.blendFunc(770,1);break;case J:u.blendFunc(0,769);break;case Z:u.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,p=null,g=null,v=null,c=e,y=o}}else!0===h&&(I(3042),h=!1)}function H(e){x!==e&&(e?u.frontFace(2304):u.frontFace(2305),x=e)}function z(e){e!==j?(D(2884),e!==_&&(e===Y?u.cullFace(1029):e===$?u.cullFace(1028):u.cullFace(1032))):I(2884),_=e}function V(e,t,r){e?(D(32823),T===t&&S===r||(u.polygonOffset(t,r),T=t,S=r)):I(32823)}function W(e){void 0===e&&(e=33984+N-1),M!==e&&(u.activeTexture(e),M=e)}return{buffers:{color:i,depth:n,stencil:s},enable:D,disable:I,bindFramebuffer:function(e,t){return null===t&&null!==a&&(t=a),o[e]!==t&&(u.bindFramebuffer(e,t),o[e]=t,r&&(36009===e&&(o[36160]=t),36160===e)&&(o[36009]=t),!0)},bindXRFramebuffer:function(e){e!==a&&(u.bindFramebuffer(36160,e),a=e)},useProgram:function(e){return l!==e&&(u.useProgram(e),l=e,!0)},setBlending:O,setMaterial:function(e,t){(e.side===Fe?I:D)(2884);let r=e.side===Ae;H(r=t?!r:r),e.blending===K&&!1===e.transparent?O(q):O(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);t=e.stencilWrite;s.setTest(t),t&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),V(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),(!0===e.alphaToCoverage?D:I)(32926)},setFlipSided:H,setCullFace:z,setLineWidth:function(e){e!==b&&(E&&u.lineWidth(e),b=e)},setPolygonOffset:V,setScissorTest:function(e){(e?D:I)(3089)},activeTexture:W,bindTexture:function(e,t){null===M&&W();let r=A[M];void 0===r&&(r={type:void 0,texture:void 0},A[M]=r),r.type===e&&r.texture===t||(u.bindTexture(e,t||C[e]),r.type=e,r.texture=t)},unbindTexture:function(){var e=A[M];void 0!==e&&void 0!==e.type&&(u.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{u.compressedTexImage2D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{u.texImage2D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{u.texImage3D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(e){!1===L.equals(e)&&(u.scissor(e.x,e.y,e.z,e.w),L.copy(e))},viewport:function(e){!1===R.equals(e)&&(u.viewport(e.x,e.y,e.z,e.w),R.copy(e))},reset:function(){u.disable(3042),u.disable(2884),u.disable(2929),u.disable(32823),u.disable(3089),u.disable(2960),u.disable(32926),u.blendEquation(32774),u.blendFunc(1,0),u.blendFuncSeparate(1,0,1,0),u.colorMask(!0,!0,!0,!0),u.clearColor(0,0,0,0),u.depthMask(!0),u.depthFunc(513),u.clearDepth(1),u.stencilMask(4294967295),u.stencilFunc(519,0,4294967295),u.stencilOp(7680,7680,7680),u.clearStencil(0),u.cullFace(1029),u.frontFace(2305),u.polygonOffset(0,0),u.activeTexture(33984),u.bindFramebuffer(36160,null),!0===r&&(u.bindFramebuffer(36009,null),u.bindFramebuffer(36008,null)),u.useProgram(null),u.lineWidth(1),u.scissor(0,0,u.canvas.width,u.canvas.height),u.viewport(0,0,u.canvas.width,u.canvas.height),t={},M=null,A={},a=null,o={},l=null,h=!1,c=null,d=null,f=null,p=null,m=null,g=null,v=null,y=!1,x=null,_=null,b=null,T=null,S=null,L.set(0,0,u.canvas.width,u.canvas.height),R.set(0,0,u.canvas.width,u.canvas.height),i.reset(),n.reset(),s.reset()}}}function Tl(d,s,f,p,c,m,g){const v=c.isWebGL2,t=c.maxTextures,y=c.maxCubemapSize,u=c.maxTextureSize,N=c.maxSamples,a=new WeakMap;let o,r=!1;try{r="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(d){}function l(e,t){return r?new OffscreenCanvas(e,t):wi("canvas")}function x(e,t,r,i){let n=1;if((n=e.width>i||e.height>i?i/Math.max(e.width,e.height):n)<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?_i:Math.floor,s=i(n*e.width),a=i(n*e.height);void 0===o&&(o=l(s,a));t=r?l(s,a):o;return t.width=s,t.height=a,t.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),t}"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+").")}return e}function _(e){return yi(e.width)&&yi(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==Re&&e.minFilter!==U}function T(e,t,r,i,n=1){d.generateMipmap(e),p.get(t).__maxMipLevel=Math.log2(Math.max(r,i,n))}function S(e,t,r,i){if(!1===v)return t;if(null!==e){if(void 0!==d[e])return d[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let n=t;return 6403===t&&(5126===r&&(n=33326),5131===r&&(n=33325),5121===r)&&(n=33321),6407===t&&(5126===r&&(n=34837),5131===r&&(n=34843),5121===r)&&(n=32849),33325!==(n=6408===t&&(5126===r&&(n=34836),5131===r&&(n=34842),5121===r)?i===wr?35907:32856:n)&&33326!==n&&34842!==n&&34836!==n||s.get("EXT_color_buffer_float"),n}function i(e){return e===Re||e===Ye||e===qe?9728:9729}function n(e){var t,r,e=e.target;e.removeEventListener("dispose",n),t=e,void 0!==(r=p.get(t)).__webglInit&&(d.deleteTexture(r.__webglTexture),p.remove(t)),e.isVideoTexture&&a.delete(e),g.memory.textures--}function E(e){e=e.target;e.removeEventListener("dispose",E);{const r=e.texture,i=p.get(e),t=p.get(r);if(e){if(void 0!==t.__webglTexture&&(d.deleteTexture(t.__webglTexture),g.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)d.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&d.deleteRenderbuffer(i.__webglDepthbuffer[e]);else d.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&d.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&d.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&d.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&d.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,t=r.length;e<t;e++){const i=p.get(r[e]);i.__webglTexture&&(d.deleteTexture(i.__webglTexture),g.memory.textures--),p.remove(r[e])}p.remove(r),p.remove(e)}}}let h=0;function w(e,t){var r,i,n=p.get(e);if(e.isVideoTexture&&(r=e,i=g.render.frame,a.get(r)!==i&&(a.set(r,i),r.update())),0<e.version&&n.__version!==e.version){const f=e.image;if(void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==f.complete)return void D(n,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}f.activeTexture(33984+t),f.bindTexture(3553,n.__webglTexture)}function M(e,t){var r=p.get(e);if(0<e.version&&r.__version!==e.version){var i=r,n=e,s=t;if(6===n.image.length){C(i,n),f.activeTexture(33984+s),f.bindTexture(34067,i.__webglTexture),d.pixelStorei(37440,n.flipY),d.pixelStorei(37441,n.premultiplyAlpha),d.pixelStorei(3317,n.unpackAlignment),d.pixelStorei(37443,0);var a=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),o=n.image[0]&&n.image[0].isDataTexture,l=[];for(let e=0;e<6;e++)l[e]=a||o?o?n.image[e].image:n.image[e]:x(n.image[e],!1,!0,y);var s=l[0],e=_(s)||v,h=m.convert(n.format),u=m.convert(n.type),c=S(n.internalFormat,h,u,n.encoding);let r;if(R(34067,n,e),a){for(let t=0;t<6;t++){r=l[t].mipmaps;for(let e=0;e<r.length;e++){const s=r[e];n.format!==Ce&&n.format!==ft?null!==h?f.compressedTexImage2D(34069+t,e,c,s.width,s.height,0,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):f.texImage2D(34069+t,e,c,s.width,s.height,0,h,u,s.data)}}i.__maxMipLevel=r.length-1}else{r=n.mipmaps;for(let t=0;t<6;t++)if(o){f.texImage2D(34069+t,0,c,l[t].width,l[t].height,0,h,u,l[t].data);for(let e=0;e<r.length;e++){const n=r[e].image[t].image;f.texImage2D(34069+t,e+1,c,n.width,n.height,0,h,u,n.data)}}else{f.texImage2D(34069+t,0,c,h,u,l[t]);for(let e=0;e<r.length;e++){const n=r[e];f.texImage2D(34069+t,e+1,c,h,u,n.image[t])}}i.__maxMipLevel=r.length}b(n,e)&&T(34067,n,s.width,s.height),i.__version=n.version,n.onUpdate&&n.onUpdate(n)}}else f.activeTexture(33984+t),f.bindTexture(34067,r.__webglTexture)}const A={[We]:10497,[Le]:33071,[je]:33648},L={[Re]:9728,[Ye]:9984,[qe]:9986,[U]:9729,[Xe]:9985,[Ze]:9987};function R(e,t,r){if(r?(d.texParameteri(e,10242,A[t.wrapS]),d.texParameteri(e,10243,A[t.wrapT]),32879!==e&&35866!==e||d.texParameteri(e,32882,A[t.wrapR]),d.texParameteri(e,10240,L[t.magFilter]),d.texParameteri(e,10241,L[t.minFilter])):(d.texParameteri(e,10242,33071),d.texParameteri(e,10243,33071),32879!==e&&35866!==e||d.texParameteri(e,32882,33071),t.wrapS===Le&&t.wrapT===Le||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),d.texParameteri(e,10240,i(t.magFilter)),d.texParameteri(e,10241,i(t.minFilter)),t.minFilter!==Re&&t.minFilter!==U&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===s.has("EXT_texture_filter_anisotropic")){const r=s.get("EXT_texture_filter_anisotropic");t.type===at&&!1===s.has("OES_texture_float_linear")||!1===v&&t.type===ot&&!1===s.has("OES_texture_half_float_linear")||(1<t.anisotropy||p.get(t).__currentAnisotropy)&&(d.texParameterf(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,c.getMaxAnisotropy())),p.get(t).__currentAnisotropy=t.anisotropy)}}function C(e,t){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",n),e.__webglTexture=d.createTexture(),g.memory.textures++)}function D(e,r,t){let i=3553;r.isDataTexture2DArray&&(i=35866),r.isDataTexture3D&&(i=32879),C(e,r),f.activeTexture(33984+t),f.bindTexture(i,e.__webglTexture),d.pixelStorei(37440,r.flipY),d.pixelStorei(37441,r.premultiplyAlpha),d.pixelStorei(3317,r.unpackAlignment),d.pixelStorei(37443,0);t=r;var t=!v&&(t.wrapS!==Le||t.wrapT!==Le||t.minFilter!==Re&&t.minFilter!==U)&&!1===_(r.image),t=x(r.image,t,!1,u),n=_(t)||v,s=m.convert(r.format);let a,o=m.convert(r.type),l=S(r.internalFormat,s,o,r.encoding);R(i,r,n);var h=r.mipmaps;if(r.isDepthTexture)l=6402,v?l=r.type===at?36012:r.type===st?33190:r.type===ct?35056:33189:r.type===at&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===vt&&6402===l&&r.type!==it&&r.type!==st&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=it,o=m.convert(r.type)),r.format===yt&&6402===l&&(l=34041,r.type!==ct)&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ct,o=m.convert(r.type)),f.texImage2D(3553,0,l,t.width,t.height,0,s,o,null);else if(r.isDataTexture)if(0<h.length&&n){for(let e=0,t=h.length;e<t;e++)a=h[e],f.texImage2D(3553,e,l,a.width,a.height,0,s,o,a.data);r.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else f.texImage2D(3553,0,l,t.width,t.height,0,s,o,t.data),e.__maxMipLevel=0;else if(r.isCompressedTexture){for(let e=0,t=h.length;e<t;e++)a=h[e],r.format!==Ce&&r.format!==ft?null!==s?f.compressedTexImage2D(3553,e,l,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):f.texImage2D(3553,e,l,a.width,a.height,0,s,o,a.data);e.__maxMipLevel=h.length-1}else if(r.isDataTexture2DArray)f.texImage3D(35866,0,l,t.width,t.height,t.depth,0,s,o,t.data),e.__maxMipLevel=0;else if(r.isDataTexture3D)f.texImage3D(32879,0,l,t.width,t.height,t.depth,0,s,o,t.data),e.__maxMipLevel=0;else if(0<h.length&&n){for(let e=0,t=h.length;e<t;e++)a=h[e],f.texImage2D(3553,e,l,s,o,a);r.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else f.texImage2D(3553,0,l,s,o,t),e.__maxMipLevel=0;b(r,n)&&T(i,r,t.width,t.height),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}function I(e,t,r,i,n){var s=m.convert(r.format),a=m.convert(r.type),o=S(r.internalFormat,s,a,r.encoding);32879===n||35866===n?f.texImage3D(n,0,o,t.width,t.height,t.depth,0,s,a,null):f.texImage2D(n,0,o,t.width,t.height,0,s,a,null),f.bindFramebuffer(36160,e),d.framebufferTexture2D(36160,i,n,p.get(r).__webglTexture,0),f.bindFramebuffer(36160,null)}function P(t,r,i){if(d.bindRenderbuffer(36161,t),r.depthBuffer&&!r.stencilBuffer){let e=33189;if(i){const t=r.depthTexture,i=(t&&t.isDepthTexture&&(t.type===at?e=36012:t.type===st&&(e=33190)),k(r));d.renderbufferStorageMultisample(36161,i,e,r.width,r.height)}else d.renderbufferStorage(36161,e,r.width,r.height);d.framebufferRenderbuffer(36160,36096,36161,t)}else if(r.depthBuffer&&r.stencilBuffer){if(i){const t=k(r);d.renderbufferStorageMultisample(36161,t,35056,r.width,r.height)}else d.renderbufferStorage(36161,34041,r.width,r.height);d.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===r.isWebGLMultipleRenderTargets?r.texture[0]:r.texture,e=m.convert(t.format),n=m.convert(t.type),s=S(t.internalFormat,e,n,t.encoding);if(i){const t=k(r);d.renderbufferStorageMultisample(36161,t,s,r.width,r.height)}else d.renderbufferStorage(36161,s,r.width,r.height)}d.bindRenderbuffer(36161,null)}function k(e){return v&&e.isWebGLMultisampleRenderTarget?Math.min(N,e.samples):0}let O=!1,F=!1;this.allocateTextureUnit=function(){var e=h;return e>=t&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+t),h+=1,e},this.resetTextureUnits=function(){h=0},this.setTexture2D=w,this.setTexture2DArray=function(e,t){var r=p.get(e);0<e.version&&r.__version!==e.version?D(r,e,t):(f.activeTexture(33984+t),f.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){var r=p.get(e);0<e.version&&r.__version!==e.version?D(r,e,t):(f.activeTexture(33984+t),f.bindTexture(32879,r.__webglTexture))},this.setTextureCube=M,this.setupRenderTarget=function(r){var t=r.texture,i=p.get(r),n=p.get(t),e=(r.addEventListener("dispose",E),!0!==r.isWebGLMultipleRenderTargets&&(n.__webglTexture=d.createTexture(),n.__version=t.version,g.memory.textures++),!0===r.isWebGLCubeRenderTarget),s=!0===r.isWebGLMultipleRenderTargets,a=!0===r.isWebGLMultisampleRenderTarget,o=t.isDataTexture3D||t.isDataTexture2DArray,l=_(r)||v;if(!v||t.format!==ft||t.type!==at&&t.type!==ot||(t.format=Ce,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),e){i.__webglFramebuffer=[];for(let e=0;e<6;e++)i.__webglFramebuffer[e]=d.createFramebuffer()}else if(i.__webglFramebuffer=d.createFramebuffer(),s)if(c.drawBuffers){const f=r.texture;for(let e=0,t=f.length;e<t;e++){const c=p.get(f[e]);void 0===c.__webglTexture&&(c.__webglTexture=d.createTexture(),g.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(a)if(v){i.__webglMultisampledFramebuffer=d.createFramebuffer(),i.__webglColorRenderbuffer=d.createRenderbuffer(),d.bindRenderbuffer(36161,i.__webglColorRenderbuffer);const p=m.convert(t.format),c=m.convert(t.type),g=S(t.internalFormat,p,c,t.encoding),v=k(r);d.renderbufferStorageMultisample(36161,v,g,r.width,r.height),f.bindFramebuffer(36160,i.__webglMultisampledFramebuffer),d.framebufferRenderbuffer(36160,36064,36161,i.__webglColorRenderbuffer),d.bindRenderbuffer(36161,null),r.depthBuffer&&(i.__webglDepthRenderbuffer=d.createRenderbuffer(),P(i.__webglDepthRenderbuffer,r,!0)),f.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(e){f.bindTexture(34067,n.__webglTexture),R(34067,t,l);for(let e=0;e<6;e++)I(i.__webglFramebuffer[e],r,t,36064,34069+e);b(t,l)&&T(34067,t,r.width,r.height)}else if(s){const d=r.texture;for(let e=0,t=d.length;e<t;e++){const m=d[e],g=p.get(m);f.bindTexture(3553,g.__webglTexture),R(3553,m,l),I(i.__webglFramebuffer,r,m,36064+e,3553),b(m,l)&&T(3553,m,r.width,r.height)}}else{let e=3553;o&&(v?e=t.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),f.bindTexture(e,n.__webglTexture),R(e,t,l),I(i.__webglFramebuffer,r,t,36064,e),b(t,l)&&T(e,t,r.width,r.height,r.depth)}if(f.unbindTexture(),r.depthBuffer){var h=r,u=p.get(h),a=!0===h.isWebGLCubeRenderTarget;if(h.depthTexture){if(a)throw new Error("target.depthTexture not supported in Cube render targets");e=u.__webglFramebuffer,s=h;if(s&&s.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(f.bindFramebuffer(36160,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");if(p.get(s.depthTexture).__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),w(s.depthTexture,0),e=p.get(s.depthTexture).__webglTexture,s.depthTexture.format===vt)d.framebufferTexture2D(36160,36096,3553,e,0);else{if(s.depthTexture.format!==yt)throw new Error("Unknown depthTexture format");d.framebufferTexture2D(36160,33306,3553,e,0)}}else if(a){u.__webglDepthbuffer=[];for(let e=0;e<6;e++)f.bindFramebuffer(36160,u.__webglFramebuffer[e]),u.__webglDepthbuffer[e]=d.createRenderbuffer(),P(u.__webglDepthbuffer[e],h,!1)}else f.bindFramebuffer(36160,u.__webglFramebuffer),u.__webglDepthbuffer=d.createRenderbuffer(),P(u.__webglDepthbuffer,h,!1);f.bindFramebuffer(36160,null)}},this.updateRenderTargetMipmap=function(r){const i=_(r)||v,n=!0===r.isWebGLMultipleRenderTargets?r.texture:[r.texture];for(let e=0,t=n.length;e<t;e++){var s=n[e];if(b(s,i)){const i=r.isWebGLCubeRenderTarget?34067:3553,n=p.get(s).__webglTexture;f.bindTexture(i,n),T(i,s,r.width,r.height),f.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(v){var r=t.width,i=t.height;let e=16384;t.depthBuffer&&(e|=256),t.stencilBuffer&&(e|=1024);const v=p.get(t);f.bindFramebuffer(36008,v.__webglMultisampledFramebuffer),f.bindFramebuffer(36009,v.__webglFramebuffer),d.blitFramebuffer(0,0,r,i,0,0,r,i,e,9728),f.bindFramebuffer(36008,null),f.bindFramebuffer(36009,v.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),w(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===F&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),e=e.texture),M(e,t)}}function Sl(e,r,t){const i=t.isWebGL2;return{convert:function(e){let t;if(e===et)return 5121;if(e===lt)return 32819;if(e===ht)return 32820;if(e===ut)return 33635;if(e===tt)return 5120;if(e===rt)return 5122;if(e===it)return 5123;if(e===nt)return 5124;if(e===st)return 5125;if(e===at)return 5126;if(e===ot)return i?5131:null!==(t=r.get("OES_texture_half_float"))?t.HALF_FLOAT_OES:null;if(e===dt)return 6406;if(e===ft)return 6407;if(e===Ce)return 6408;if(e===pt)return 6409;if(e===mt)return 6410;if(e===vt)return 6402;if(e===yt)return 34041;if(e===xt)return 6403;if(e===_t)return 36244;if(e===bt)return 33319;if(e===Tt)return 33320;if(e===St)return 36248;if(e===Et)return 36249;if(e===wt||e===Mt||e===At||e===Lt){if(null===(t=r.get("WEBGL_compressed_texture_s3tc")))return null;if(e===wt)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Mt)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===At)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Lt)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===Rt||e===Ct||e===Dt||e===It){if(null===(t=r.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===Rt)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Ct)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Dt)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===It)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===Pt)return null!==(t=r.get("WEBGL_compressed_texture_etc1"))?t.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===kt||e===Ot)&&null!==(t=r.get("WEBGL_compressed_texture_etc"))){if(e===kt)return t.COMPRESSED_RGB8_ETC2;if(e===Ot)return t.COMPRESSED_RGBA8_ETC2_EAC}return e===Ft||e===Nt||e===Ut||e===Bt||e===Gt||e===Ht||e===zt||e===Vt||e===Wt||e===jt||e===Yt||e===$t||e===qt||e===Kt||e===Jt||e===Zt||e===Qt||e===er||e===tr||e===rr||e===ir||e===nr||e===sr||e===ar||e===or||e===lr||e===hr||e===ur?null!==(t=r.get("WEBGL_compressed_texture_astc"))?e:null:e===Xt?null!==(t=r.get("EXT_texture_compression_bptc"))?e:null:e===ct?i?34042:null!==(t=r.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}xl.prototype.isMeshDistanceMaterial=!0;class El extends N{constructor(e=[]){super(),this.cameras=e}}El.prototype.isArrayCamera=!0;class wl extends c{constructor(){super(),this.type="Group"}}wl.prototype.isGroup=!0;const Ml={type:"move"};class Al{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new wl,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new wl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Pe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Pe),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new wl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Pe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Pe),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let i=null,n=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==a&&null!==(i=t.getPose(e.targetRaySpace,r))&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Ml)),l&&e.hand){s=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,r);if(void 0===l.joints[i.jointName]){const e=new wl;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[i.jointName]=e,l.add(e)}const n=l.joints[i.jointName];null!==e&&(n.matrix.fromArray(e.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.jointRadius=e.radius),n.visible=null!==e}const i=l.joints["index-finger-tip"],n=l.joints["thumb-tip"],a=i.position.distanceTo(n.position),o=.02;l.inputState.pinching&&.025<a?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(n=t.getPose(e.gripSpace,r))&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1);return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==n),null!==l&&(l.visible=null!==s),this}}class Ll extends hi{constructor(e,a){super();const r=this,o=e.state;let p=null,i=1,l=null,n="local-floor",h,u=null,c=null,d=null,f=null,m=!1,g=null,s=null,v=null,y=null,x=null,_=null;const b=[],T=new Map,S=new N,E=(S.layers.enable(1),S.viewport=new Ie,new N),w=(E.layers.enable(2),E.viewport=new Ie,[S,E]),M=new El;M.layers.enable(1),M.layers.enable(2);let A=null,L=null;function R(e){var t=T.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function C(){T.forEach(function(e,t){e.disconnect(t)}),T.clear(),A=null,L=null,o.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),c&&a.deleteFramebuffer(c),g&&a.deleteFramebuffer(g),s&&a.deleteRenderbuffer(s),v&&a.deleteRenderbuffer(v),c=null,g=null,s=null,v=null,f=null,d=null,u=null,p=null,F.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}function D(t){var r=p.inputSources;for(let e=0;e<b.length;e++)T.set(r[e],b[e]);for(let e=0;e<t.removed.length;e++){var i=t.removed[e],n=T.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),T.delete(i))}for(let e=0;e<t.added.length;e++){var s=t.added[e],a=T.get(s);a&&a.dispatchEvent({type:"connected",data:s})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){n=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l},this.getBaseLayer=function(){return null!==d?d:f},this.getBinding=function(){return u},this.getFrame=function(){return y},this.getSession=function(){return p},this.setSession=async function(t){if(null!==(p=t)){p.addEventListener("select",R),p.addEventListener("selectstart",R),p.addEventListener("selectend",R),p.addEventListener("squeeze",R),p.addEventListener("squeezestart",R),p.addEventListener("squeezeend",R),p.addEventListener("end",C),p.addEventListener("inputsourceschange",D);const t=a.getContextAttributes();if(!0!==t.xrCompatible&&await a.makeXRCompatible(),void 0===p.renderState.layers){const r={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(p,a,r),p.updateRenderState({baseLayer:f})}else if(a instanceof WebGLRenderingContext){const r={antialias:!0,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(p,a,r),p.updateRenderState({layers:[f]})}else{m=t.antialias;let e=null;t.depth&&(_=256,t.stencil&&(_|=1024),x=t.stencil?33306:36096,e=t.stencil?35056:33190);const l={colorFormat:t.alpha?32856:32849,depthFormat:e,scaleFactor:i};u=new XRWebGLBinding(p,a),d=u.createProjectionLayer(l),c=a.createFramebuffer(),p.updateRenderState({layers:[d]}),m&&(g=a.createFramebuffer(),s=a.createRenderbuffer(),a.bindRenderbuffer(36161,s),a.renderbufferStorageMultisample(36161,4,32856,d.textureWidth,d.textureHeight),o.bindFramebuffer(36160,g),a.framebufferRenderbuffer(36160,36064,36161,s),a.bindRenderbuffer(36161,null),null!==e&&(v=a.createRenderbuffer(),a.bindRenderbuffer(36161,v),a.renderbufferStorageMultisample(36161,4,e,d.textureWidth,d.textureHeight),a.framebufferRenderbuffer(36160,x,36161,v),a.bindRenderbuffer(36161,null)),o.bindFramebuffer(36160,null))}l=await p.requestReferenceSpace(n),F.setContext(p),F.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};const I=new Pe,P=new Pe;function k(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null!==p){M.near=E.near=S.near=e.near,M.far=E.far=S.far=e.far,A===M.near&&L===M.far||(p.updateRenderState({depthNear:M.near,depthFar:M.far}),A=M.near,L=M.far);var t=e.parent,r=M.cameras;k(M,t);for(let e=0;e<r.length;e++)k(r[e],t);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),e.position.copy(M.position),e.quaternion.copy(M.quaternion),e.scale.copy(M.scale),e.matrix.copy(M.matrix),e.matrixWorld.copy(M.matrixWorld);var i,n,s,a,o,l,h,u,c,d,f=e.children;for(let e=0,t=f.length;e<t;e++)f[e].updateMatrixWorld(!0);2===r.length?(e=M,i=S,n=E,I.setFromMatrixPosition(i.matrixWorld),P.setFromMatrixPosition(n.matrixWorld),s=I.distanceTo(P),a=i.projectionMatrix.elements,n=n.projectionMatrix.elements,o=a[14]/(a[10]-1),l=a[14]/(a[10]+1),h=(a[9]+1)/a[5],u=(a[9]-1)/a[5],a=(a[8]-1)/a[0],n=(n[8]+1)/n[0],c=o*a,d=o*n,a=(n=s/(n-a))*-a,i.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(a),e.translateZ(n),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i=o+n,o=l+n,e.projectionMatrix.makePerspective(c-a,s-a+d,h*l/o*i,u*l/o*i,i,o)):M.projectionMatrix.copy(S.projectionMatrix)}},this.getCamera=function(){return M},this.getFoveation=function(){return null!==d?d.fixedFoveation:null!==f?f.fixedFoveation:void 0},this.setFoveation=function(e){null!==d&&(d.fixedFoveation=e),null!==f&&void 0!==f.fixedFoveation&&(f.fixedFoveation=e)};let O=null;const F=new Xs;F.setAnimationLoop(function(i,t){if(h=t.getViewerPose(l),y=t,null!==h){const i=h.views;null!==f&&o.bindXRFramebuffer(f.framebuffer);let r=!1;i.length!==M.cameras.length&&(M.cameras.length=0,r=!0);for(let t=0;t<i.length;t++){const s=i[t];let e=null;if(null!==f)e=f.getViewport(s);else{const i=u.getViewSubImage(d,s);o.bindXRFramebuffer(c),void 0!==i.depthStencilTexture&&a.framebufferTexture2D(36160,x,3553,i.depthStencilTexture,0),a.framebufferTexture2D(36160,36064,3553,i.colorTexture,0),e=i.viewport}var n=w[t];n.matrix.fromArray(s.transform.matrix),n.projectionMatrix.fromArray(s.projectionMatrix),n.viewport.set(e.x,e.y,e.width,e.height),0===t&&M.matrix.copy(n.matrix),!0===r&&M.cameras.push(n)}m&&(o.bindXRFramebuffer(g),null!==_)&&a.clear(_)}const s=p.inputSources;for(let e=0;e<b.length;e++){const a=b[e],o=s[e];a.update(o,t,l)}if(O&&O(i,t),m){const i=d.textureWidth,t=d.textureHeight;o.bindFramebuffer(36008,g),o.bindFramebuffer(36009,c),a.invalidateFramebuffer(36008,[x]),a.invalidateFramebuffer(36009,[x]),a.blitFramebuffer(0,0,i,t,0,0,i,t,16384,9728),a.invalidateFramebuffer(36008,[36064]),o.bindFramebuffer(36008,null),o.bindFramebuffer(36009,null),o.bindFramebuffer(36160,g)}y=null}),this.setAnimationLoop=function(e){O=e},this.dispose=function(){}}}function Rl(s){function d(e,t){e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),0<t.alphaTest&&(e.alphaTest.value=t.alphaTest);var r=s.get(t).envMap;if(r){e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=t.reflectivity,e.ior.value=t.ior,e.refractionRatio.value=t.refractionRatio;const i=s.get(r).__maxMipLevel;void 0!==i&&(e.maxMipLevel.value=i)}let i,n;t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap?i=t.emissiveMap:t.clearcoatMap?i=t.clearcoatMap:t.clearcoatNormalMap?i=t.clearcoatNormalMap:t.clearcoatRoughnessMap?i=t.clearcoatRoughnessMap:t.specularIntensityMap?i=t.specularIntensityMap:t.specularColorMap?i=t.specularColorMap:t.transmissionMap?i=t.transmissionMap:t.thicknessMap?i=t.thicknessMap:t.sheenColorMap?i=t.sheenColorMap:t.sheenRoughnessMap&&(i=t.sheenRoughnessMap),void 0!==i&&(!0===(i=i.isWebGLRenderTarget?i.texture:i).matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),t.aoMap?n=t.aoMap:t.lightMap&&(n=t.lightMap),void 0!==n&&(!0===(n=n.isWebGLRenderTarget?n.texture:n).matrixAutoUpdate&&n.updateMatrix(),e.uv2Transform.value.copy(n.matrix))}function f(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Ae)&&(e.bumpScale.value*=-1),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Ae)&&e.normalScale.value.negate(),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),s.get(t).envMap&&(e.envMapIntensity.value=t.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(t,r,i,n,s){if(r.isMeshBasicMaterial)d(t,r);else if(r.isMeshLambertMaterial)d(t,r),c=t,r.emissiveMap&&(c.emissiveMap.value=r.emissiveMap);else if(r.isMeshToonMaterial)d(t,r),c=t,(u=r).gradientMap&&(c.gradientMap.value=u.gradientMap),u.emissiveMap&&(c.emissiveMap.value=u.emissiveMap),u.bumpMap&&(c.bumpMap.value=u.bumpMap,c.bumpScale.value=u.bumpScale,u.side===Ae)&&(c.bumpScale.value*=-1),u.normalMap&&(c.normalMap.value=u.normalMap,c.normalScale.value.copy(u.normalScale),u.side===Ae)&&c.normalScale.value.negate(),u.displacementMap&&(c.displacementMap.value=u.displacementMap,c.displacementScale.value=u.displacementScale,c.displacementBias.value=u.displacementBias);else if(r.isMeshPhongMaterial)d(t,r),u=r,(h=t).specular.value.copy(u.specular),h.shininess.value=Math.max(u.shininess,1e-4),u.emissiveMap&&(h.emissiveMap.value=u.emissiveMap),u.bumpMap&&(h.bumpMap.value=u.bumpMap,h.bumpScale.value=u.bumpScale,u.side===Ae)&&(h.bumpScale.value*=-1),u.normalMap&&(h.normalMap.value=u.normalMap,h.normalScale.value.copy(u.normalScale),u.side===Ae)&&h.normalScale.value.negate(),u.displacementMap&&(h.displacementMap.value=u.displacementMap,h.displacementScale.value=u.displacementScale,h.displacementBias.value=u.displacementBias);else if(r.isMeshStandardMaterial)d(t,r),r.isMeshPhysicalMaterial?(h=s,f(s=t,l=r),s.ior.value=l.ior,0<l.sheen&&(s.sheenColor.value.copy(l.sheenColor).multiplyScalar(l.sheen),s.sheenRoughness.value=l.sheenRoughness,l.sheenColorMap&&(s.sheenColorMap.value=l.sheenColorMap),l.sheenRoughnessMap)&&(s.sheenRoughnessMap.value=l.sheenRoughnessMap),0<l.clearcoat&&(s.clearcoat.value=l.clearcoat,s.clearcoatRoughness.value=l.clearcoatRoughness,l.clearcoatMap&&(s.clearcoatMap.value=l.clearcoatMap),l.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap.value=l.clearcoatRoughnessMap),l.clearcoatNormalMap)&&(s.clearcoatNormalScale.value.copy(l.clearcoatNormalScale),s.clearcoatNormalMap.value=l.clearcoatNormalMap,l.side===Ae)&&s.clearcoatNormalScale.value.negate(),0<l.transmission&&(s.transmission.value=l.transmission,s.transmissionSamplerMap.value=h.texture,s.transmissionSamplerSize.value.set(h.width,h.height),l.transmissionMap&&(s.transmissionMap.value=l.transmissionMap),s.thickness.value=l.thickness,l.thicknessMap&&(s.thicknessMap.value=l.thicknessMap),s.attenuationDistance.value=l.attenuationDistance,s.attenuationColor.value.copy(l.attenuationColor)),s.specularIntensity.value=l.specularIntensity,s.specularColor.value.copy(l.specularColor),l.specularIntensityMap&&(s.specularIntensityMap.value=l.specularIntensityMap),l.specularColorMap&&(s.specularColorMap.value=l.specularColorMap)):f(t,r);else if(r.isMeshMatcapMaterial)d(t,r),s=t,(l=r).matcap&&(s.matcap.value=l.matcap),l.bumpMap&&(s.bumpMap.value=l.bumpMap,s.bumpScale.value=l.bumpScale,l.side===Ae)&&(s.bumpScale.value*=-1),l.normalMap&&(s.normalMap.value=l.normalMap,s.normalScale.value.copy(l.normalScale),l.side===Ae)&&s.normalScale.value.negate(),l.displacementMap&&(s.displacementMap.value=l.displacementMap,s.displacementScale.value=l.displacementScale,s.displacementBias.value=l.displacementBias);else if(r.isMeshDepthMaterial)d(t,r),s=t,(o=r).displacementMap&&(s.displacementMap.value=o.displacementMap,s.displacementScale.value=o.displacementScale,s.displacementBias.value=o.displacementBias);else if(r.isMeshDistanceMaterial)d(t,r),s=t,(o=r).displacementMap&&(s.displacementMap.value=o.displacementMap,s.displacementScale.value=o.displacementScale,s.displacementBias.value=o.displacementBias),s.referencePosition.value.copy(o.referencePosition),s.nearDistance.value=o.nearDistance,s.farDistance.value=o.farDistance;else if(r.isMeshNormalMaterial)d(t,r),s=t,(e=r).bumpMap&&(s.bumpMap.value=e.bumpMap,s.bumpScale.value=e.bumpScale,e.side===Ae)&&(s.bumpScale.value*=-1),e.normalMap&&(s.normalMap.value=e.normalMap,s.normalScale.value.copy(e.normalScale),e.side===Ae)&&s.normalScale.value.negate(),e.displacementMap&&(s.displacementMap.value=e.displacementMap,s.displacementScale.value=e.displacementScale,s.displacementBias.value=e.displacementBias);else if(r.isLineBasicMaterial)s=r,(e=t).diffuse.value.copy(s.color),e.opacity.value=s.opacity,r.isLineDashedMaterial&&(s=r,(a=t).dashSize.value=s.dashSize,a.totalSize.value=s.dashSize+s.gapSize,a.scale.value=s.scale);else if(r.isPointsMaterial){s=r,(a=t).diffuse.value.copy(s.color),a.opacity.value=s.opacity,a.size.value=s.size*i,a.scale.value=.5*n,s.map&&(a.map.value=s.map),s.alphaMap&&(a.alphaMap.value=s.alphaMap),0<s.alphaTest&&(a.alphaTest.value=s.alphaTest);let e;s.map?e=s.map:s.alphaMap&&(e=s.alphaMap),void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),a.uvTransform.value.copy(e.matrix))}else if(r.isSpriteMaterial){n=r,(i=t).diffuse.value.copy(n.color),i.opacity.value=n.opacity,i.rotation.value=n.rotation,n.map&&(i.map.value=n.map),n.alphaMap&&(i.alphaMap.value=n.alphaMap),0<n.alphaTest&&(i.alphaTest.value=n.alphaTest);let e;n.map?e=n.map:n.alphaMap&&(e=n.alphaMap),void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),i.uvTransform.value.copy(e.matrix))}else r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1);var a,e,o,l,h,u,c}}}function s(e={}){const n=void 0!==e.canvas?e.canvas:((j=wi("canvas")).style.display="block",j),F=void 0!==e.context?e.context:null,N=void 0!==e.alpha&&e.alpha,U=void 0===e.depth||e.depth,B=void 0===e.stencil||e.stencil,G=void 0!==e.antialias&&e.antialias,H=void 0===e.premultipliedAlpha||e.premultipliedAlpha,z=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,V=void 0!==e.powerPreference?e.powerPreference:"default",W=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;var j;let u=null,_=null;const t=[],s=[],b=(this.domElement=n,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=De,this.physicallyCorrectLights=!1,this.toneMapping=Ne,this.toneMappingExposure=1,this);let Y=!1,$=0,q=0,T=null,S=-1,E=null;const c=new Ie,K=new Ie;let X=null,i=n.width,w=n.height,M=1,J=null,Z=null;const o=new Ie(0,0,i,w),l=new Ie(0,0,i,w);let Q=!1;const h=[],ee=new Ks;let te=!1,re=!1,A=null;const ie=new ke,L=new Pe,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function se(){return null===T?M:1}let d,R,C,f,D,I,P,ae,oe,le,p,m,he,ue,ce,k,a,g,de,fe,pe,v,y,O=F;function me(t,r){for(let e=0;e<t.length;e++){var i=t[e],i=n.getContext(i,r);if(null!==i)return i}return null}try{const e={alpha:N,depth:U,stencil:B,antialias:G,premultipliedAlpha:H,preserveDrawingBuffer:z,powerPreference:V,failIfMajorPerformanceCaveat:W};if(n.addEventListener("webglcontextlost",ve,!1),n.addEventListener("webglcontextrestored",ye,!1),null===O){const n=["webgl2","webgl","experimental-webgl"];if(!0===b.isWebGL1Renderer&&n.shift(),null===(O=me(n,e)))throw me(n)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===O.getShaderPrecisionFormat&&(O.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function ge(){d=new Ra(O),R=new ia(O,d,e),d.init(R),v=new Sl(O,d,R),C=new bl(O,d,R),h[0]=1029,f=new Ia(O),D=new ol,I=new Tl(O,d,C,D,R,v,f),P=new sa(b),ae=new La(b),oe=new Js(O,R),y=new ta(O,d,oe,R),le=new Ca(O,oe,f,y),p=new Ua(O,le,oe,f),de=new Na(O,R,I),k=new na(D),m=new al(b,P,ae,d,R,y,k),he=new Rl(D),ue=new cl(D),ce=new vl(d,R),g=new ea(b,P,C,p,H),a=new _l(b,p,R),fe=new ra(O,d,f,R),pe=new Da(O,d,f,R),f.programs=m.programs,b.capabilities=R,b.extensions=d,b.properties=D,b.renderLists=ue,b.shadowMap=a,b.state=C,b.info=f}ge();const x=new Ll(b,O);function ve(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),Y=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),Y=!1;var e=f.autoReset,t=a.enabled,r=a.autoUpdate,i=a.needsUpdate,n=a.type;ge(),f.autoReset=e,a.enabled=t,a.autoUpdate=r,a.needsUpdate=i,a.type=n}function xe(e){var t,e=e.target;e.removeEventListener("dispose",xe),t=e=e,void 0!==(t=D.get(t).programs)&&t.forEach(function(e){m.releaseProgram(e)}),D.remove(e)}this.xr=x,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){var e=d.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=d.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return M},this.setPixelRatio=function(e){void 0!==e&&(M=e,this.setSize(i,w,!1))},this.getSize=function(e){return e.set(i,w)},this.setSize=function(e,t,r){x.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(i=e,w=t,n.width=Math.floor(e*M),n.height=Math.floor(t*M),!1!==r&&(n.style.width=e+"px",n.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(i*M,w*M).floor()},this.setDrawingBufferSize=function(e,t,r){i=e,w=t,M=r,n.width=Math.floor(e*r),n.height=Math.floor(t*r),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(c)},this.getViewport=function(e){return e.copy(o)},this.setViewport=function(e,t,r,i){e.isVector4?o.set(e.x,e.y,e.z,e.w):o.set(e,t,r,i),C.viewport(c.copy(o).multiplyScalar(M).floor())},this.getScissor=function(e){return e.copy(l)},this.setScissor=function(e,t,r,i){e.isVector4?l.set(e.x,e.y,e.z,e.w):l.set(e,t,r,i),C.scissor(K.copy(l).multiplyScalar(M).floor())},this.getScissorTest=function(){return Q},this.setScissorTest=function(e){C.setScissorTest(Q=e)},this.setOpaqueSort=function(e){J=e},this.setTransparentSort=function(e){Z=e},this.getClearColor=function(e){return e.copy(g.getClearColor())},this.setClearColor=function(){g.setClearColor.apply(g,arguments)},this.getClearAlpha=function(){return g.getClearAlpha()},this.setClearAlpha=function(){g.setClearAlpha.apply(g,arguments)},this.clear=function(e,t,r){let i=0;void 0!==e&&!e||(i|=16384),void 0!==t&&!t||(i|=256),void 0!==r&&!r||(i|=1024),O.clear(i)},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(){n.removeEventListener("webglcontextlost",ve,!1),n.removeEventListener("webglcontextrestored",ye,!1),ue.dispose(),ce.dispose(),D.dispose(),P.dispose(),ae.dispose(),p.dispose(),y.dispose(),x.dispose(),x.removeEventListener("sessionstart",be),x.removeEventListener("sessionend",Te),A&&(A.dispose(),A=null),r.stop()},this.renderBufferDirect=function(e,t,r,i,n,s){null===t&&(t=ne);var a=n.isMesh&&n.matrixWorld.determinant()<0,e=function(e,t,r,i,n){!0!==t.isScene&&(t=ne),I.resetTextureUnits();var s=t.fog,a=i.isMeshStandardMaterial?t.environment:null,o=null===T?b.outputEncoding:T.texture.encoding,a=(i.isMeshStandardMaterial?ae:P).get(i.envMap||a),l=!0===i.vertexColors&&!!r.attributes.color&&4===r.attributes.color.itemSize,h=!!i.normalMap&&!!r.attributes.tangent,u=!!r.morphAttributes.position,c=!!r.morphAttributes.normal,d=r.morphAttributes.position?r.morphAttributes.position.length:0,f=D.get(i),p=_.state.lights;if(!0===te&&(!0===re||e!==E)){const t=e===E&&i.id===S;k.setState(i,e,t)}let m=!1,g=(i.version===f.__version?(f.needsLights&&f.lightsStateVersion!==p.state.version||f.outputEncoding!==o||n.isInstancedMesh&&!1===f.instancing||!n.isInstancedMesh&&!0===f.instancing||n.isSkinnedMesh&&!1===f.skinning||!n.isSkinnedMesh&&!0===f.skinning||f.envMap!==a||i.fog&&f.fog!==s||void 0!==f.numClippingPlanes&&(f.numClippingPlanes!==k.numPlanes||f.numIntersection!==k.numIntersection)||f.vertexAlphas!==l||f.vertexTangents!==h||f.morphTargets!==u||f.morphNormals!==c||!0===R.isWebGL2&&f.morphTargetsCount!==d)&&(m=!0):(m=!0,f.__version=i.version),f.currentProgram),v=!1,y=!1,x=!1;p=(g=!0===m?we(i,t,n):g).getUniforms(),o=f.uniforms;if(C.useProgram(g.program)&&(v=!0,y=!0,x=!0),i.id!==S&&(S=i.id,y=!0),v||E!==e){if(p.setValue(O,"projectionMatrix",e.projectionMatrix),R.logarithmicDepthBuffer&&p.setValue(O,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),E!==e&&(E=e,y=!0,x=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=p.map.cameraPosition;void 0!==t&&t.setValue(O,L.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&p.setValue(O,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||n.isSkinnedMesh)&&p.setValue(O,"viewMatrix",e.matrixWorldInverse)}if(n.isSkinnedMesh){p.setOptional(O,n,"bindMatrix"),p.setOptional(O,n,"bindMatrixInverse");const e=n.skeleton;e&&(R.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),p.setValue(O,"boneTexture",e.boneTexture,I),p.setValue(O,"boneTextureSize",e.boneTextureSize)):p.setOptional(O,e,"boneMatrices"))}return!r||void 0===r.morphAttributes.position&&void 0===r.morphAttributes.normal||de.update(n,r,i,g),!y&&f.receiveShadow===n.receiveShadow||(f.receiveShadow=n.receiveShadow,p.setValue(O,"receiveShadow",n.receiveShadow)),y&&(p.setValue(O,"toneMappingExposure",b.toneMappingExposure),f.needsLights&&(a=x,(l=o).ambientLightColor.needsUpdate=a,l.lightProbe.needsUpdate=a,l.directionalLights.needsUpdate=a,l.directionalLightShadows.needsUpdate=a,l.pointLights.needsUpdate=a,l.pointLightShadows.needsUpdate=a,l.spotLights.needsUpdate=a,l.spotLightShadows.needsUpdate=a,l.rectAreaLights.needsUpdate=a,l.hemisphereLights.needsUpdate=a),s&&i.fog&&he.refreshFogUniforms(o,s),he.refreshMaterialUniforms(o,i,M,w,A),Ho.upload(O,f.uniformsList,o,I)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Ho.upload(O,f.uniformsList,o,I),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&p.setValue(O,"center",n.center),p.setValue(O,"modelViewMatrix",n.modelViewMatrix),p.setValue(O,"normalMatrix",n.normalMatrix),p.setValue(O,"modelMatrix",n.matrixWorld),g}(e,t,r,i,n);C.setMaterial(i,a);let o=r.index;t=r.attributes.position;if(null===o){if(void 0===t||0===t.count)return}else if(0===o.count)return;let l,h=1,u=(!0===i.wireframe&&(o=le.getWireframeAttribute(r),h=2),y.setup(n,i,e,r,o),fe);null!==o&&(l=oe.get(o),(u=pe).setIndex(l));var a=(null!==o?o:t).count,e=r.drawRange.start*h,t=r.drawRange.count*h,c=null!==s?s.start*h:0,s=null!==s?s.count*h:1/0,d=Math.max(e,c),a=Math.min(a,e+t,c+s)-1,t=Math.max(0,a-d+1);if(0!==t){if(n.isMesh)!0===i.wireframe?(C.setLineWidth(i.wireframeLinewidth*se()),u.setMode(1)):u.setMode(4);else if(n.isLine){let e=i.linewidth;void 0===e&&(e=1),C.setLineWidth(e*se()),n.isLineSegments?u.setMode(1):n.isLineLoop?u.setMode(2):u.setMode(3)}else n.isPoints?u.setMode(0):n.isSprite&&u.setMode(4);if(n.isInstancedMesh)u.renderInstances(d,t,n.count);else if(r.isInstancedBufferGeometry){const e=Math.min(r.instanceCount,r._maxInstanceCount);u.renderInstances(d,t,e)}else u.render(d,t)}},this.compile=function(i,t){(_=ce.get(i)).init(),s.push(_),i.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow)&&_.pushShadow(e)}),_.setupLights(b.physicallyCorrectLights),i.traverse(function(t){var r=t.material;if(r)if(Array.isArray(r))for(let e=0;e<r.length;e++)we(r[e],i,t);else we(r,i,t)}),s.pop(),_=null};let _e=null;function be(){r.stop()}function Te(){r.start()}const r=new Xs;function Se(e,t,r,i){var n=e.opaque,s=e.transmissive,e=e.transparent;if(_.setupLightsView(r),0<s.length){var a=n,o=t,l=r;if(null===A){const a=!0===G&&!0===R.isWebGL2;A=new(a?Pi:Di)(1024,1024,{generateMipmaps:!0,type:null!==v.convert(ot)?ot:et,minFilter:Ze,magFilter:Re,wrapS:Le,wrapT:Le})}var h=b.getRenderTarget(),u=(b.setRenderTarget(A),b.clear(),b.toneMapping);b.toneMapping=Ne,Ee(a,o,l),b.toneMapping=u,I.updateMultisampleRenderTarget(A),I.updateRenderTargetMipmap(A),b.setRenderTarget(h)}i&&C.viewport(c.copy(i)),0<n.length&&Ee(n,t,r),0<s.length&&Ee(s,t,r),0<e.length&&Ee(e,t,r)}function Ee(r,i,n){var s,a,o=!0===i.isScene?i.overrideMaterial:null;for(let e=0,t=r.length;e<t;e++){var l=r[e],h=l.object,u=l.geometry,c=null===o?l.material:o,l=l.group;h.layers.test(n.layers)&&(s=i,a=n,u=u,c=c,l=l,(h=h).onBeforeRender(b,s,a,u,c,l),h.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,h.matrixWorld),h.normalMatrix.getNormalMatrix(h.modelViewMatrix),c.onBeforeRender(b,s,a,u,h,l),!0===c.transparent&&c.side===Fe?(c.side=Ae,c.needsUpdate=!0,b.renderBufferDirect(a,s,u,c,h,l),c.side=Oe,c.needsUpdate=!0,b.renderBufferDirect(a,s,u,c,h,l),c.side=Fe):b.renderBufferDirect(a,s,u,c,h,l),h.onAfterRender(b,s,a,u,c,l))}}function we(e,t,r){!0!==t.isScene&&(t=ne);var i=D.get(e),n=_.state.lights,s=_.state.shadowsArray,a=n.state.version,s=m.getParameters(e,n.state,s,t,r),o=m.getProgramCacheKey(s);let l=i.programs,h=(i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?ae:P).get(e.envMap||i.environment),void 0===l&&(e.addEventListener("dispose",xe),l=new Map,i.programs=l),l.get(o));if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return Me(e,s),h}else s.uniforms=m.getUniforms(e),e.onBuild(r,s,b),e.onBeforeCompile(s,b),h=m.acquireProgram(s,o),l.set(o,h),i.uniforms=s.uniforms;t=i.uniforms,(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(t.clippingPlanes=k.uniform),Me(e,s),i.needsLights=e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights,i.lightsStateVersion=a,i.needsLights&&(t.ambientLightColor.value=n.state.ambient,t.lightProbe.value=n.state.probe,t.directionalLights.value=n.state.directional,t.directionalLightShadows.value=n.state.directionalShadow,t.spotLights.value=n.state.spot,t.spotLightShadows.value=n.state.spotShadow,t.rectAreaLights.value=n.state.rectArea,t.ltc_1.value=n.state.rectAreaLTC1,t.ltc_2.value=n.state.rectAreaLTC2,t.pointLights.value=n.state.point,t.pointLightShadows.value=n.state.pointShadow,t.hemisphereLights.value=n.state.hemi,t.directionalShadowMap.value=n.state.directionalShadowMap,t.directionalShadowMatrix.value=n.state.directionalShadowMatrix,t.spotShadowMap.value=n.state.spotShadowMap,t.spotShadowMatrix.value=n.state.spotShadowMatrix,t.pointShadowMap.value=n.state.pointShadowMap,t.pointShadowMatrix.value=n.state.pointShadowMatrix),r=h.getUniforms(),o=Ho.seqWithValue(r.seq,t);return i.currentProgram=h,i.uniformsList=o,h}function Me(e,t){e=D.get(e);e.outputEncoding=t.outputEncoding,e.instancing=t.instancing,e.skinning=t.skinning,e.morphTargets=t.morphTargets,e.morphNormals=t.morphNormals,e.morphTargetsCount=t.morphTargetsCount,e.numClippingPlanes=t.numClippingPlanes,e.numIntersection=t.numClipIntersection,e.vertexAlphas=t.vertexAlphas,e.vertexTangents=t.vertexTangents}r.setAnimationLoop(function(e){_e&&_e(e)}),"undefined"!=typeof window&&r.setContext(window),this.setAnimationLoop=function(e){_e=e,x.setAnimationLoop(e),null===e?r.stop():r.start()},x.addEventListener("sessionstart",be),x.addEventListener("sessionend",Te),this.render=function(r,e){if(void 0!==e&&!0!==e.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else if(!0!==Y){!0===r.autoUpdate&&r.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===x.enabled&&!0===x.isPresenting&&(!0===x.cameraAutoUpdate&&x.updateCamera(e),e=x.getCamera()),!0===r.isScene&&r.onBeforeRender(b,r,e,T),(_=ce.get(r,s.length)).init(),s.push(_),ie.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),ee.setFromProjectionMatrix(ie),re=this.localClippingEnabled,te=k.init(this.clippingPlanes,re,e),(u=ue.get(r,t.length)).init(),t.push(u),function r(i,n,s,a){if(!1!==i.visible){if(i.layers.test(n.layers))if(i.isGroup)s=i.renderOrder;else if(i.isLOD)!0===i.autoUpdate&&i.update(n);else if(i.isLight)_.pushLight(i),i.castShadow&&_.pushShadow(i);else if(i.isSprite){if(!i.frustumCulled||ee.intersectsSprite(i)){a&&L.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ie);const r=p.update(i),n=i.material;n.visible&&u.push(i,r,n,s,L.z,null)}}else if((i.isMesh||i.isLine||i.isPoints)&&(i.isSkinnedMesh&&i.skeleton.frame!==f.render.frame&&(i.skeleton.update(),i.skeleton.frame=f.render.frame),!i.frustumCulled||ee.intersectsObject(i))){a&&L.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ie);const r=p.update(i),n=i.material;if(Array.isArray(n)){const a=r.groups;for(let e=0,t=a.length;e<t;e++){var o=a[e],l=n[o.materialIndex];l&&l.visible&&u.push(i,r,l,s,L.z,o)}}else n.visible&&u.push(i,r,n,s,L.z,null)}var h=i.children;for(let e=0,t=h.length;e<t;e++)r(h[e],n,s,a)}}(r,e,0,b.sortObjects),u.finish(),!0===b.sortObjects&&u.sort(J,Z),!0===te&&k.beginShadows();const n=_.state.shadowsArray;if(a.render(n,r,e),!0===te&&k.endShadows(),!0===this.info.autoReset&&this.info.reset(),g.render(u,r),_.setupLights(b.physicallyCorrectLights),e.isArrayCamera){const n=e.cameras;for(let e=0,t=n.length;e<t;e++){var i=n[e];Se(u,r,i,i.viewport)}}else Se(u,r,e);null!==T&&(I.updateMultisampleRenderTarget(T),I.updateRenderTargetMipmap(T)),!0===r.isScene&&r.onAfterRender(b,r,e),C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1),y.resetDefaultState(),S=-1,E=null,s.pop(),_=0<s.length?s[s.length-1]:null,t.pop(),u=0<t.length?t[t.length-1]:null}},this.getActiveCubeFace=function(){return $},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return T},this.setRenderTarget=function(t,e=0,r=0){T=t,$=e,q=r,t&&void 0===D.get(t).__webglFramebuffer&&I.setupRenderTarget(t);let i=null,n=!1,s=!1;if(t){const r=t.texture;(r.isDataTexture3D||r.isDataTexture2DArray)&&(s=!0);var a=D.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=a[e],n=!0):i=t.isWebGLMultisampleRenderTarget?D.get(t).__webglMultisampledFramebuffer:a,c.copy(t.viewport),K.copy(t.scissor),X=t.scissorTest}else c.copy(o).multiplyScalar(M).floor(),K.copy(l).multiplyScalar(M).floor(),X=Q;if(C.bindFramebuffer(36160,i)&&R.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const r=t.texture;if(h.length!==r.length||36064!==h[0]){for(let e=0,t=r.length;e<t;e++)h[e]=36064+e;h.length=r.length,e=!0}}else 1===h.length&&36064===h[0]||(h[0]=36064,h.length=1,e=!0);else 1===h.length&&1029===h[0]||(h[0]=1029,h.length=1,e=!0);e&&(R.isWebGL2?O.drawBuffers(h):d.get("WEBGL_draw_buffers").drawBuffersWEBGL(h))}if(C.viewport(c),C.scissor(K),C.setScissorTest(X),n){const i=D.get(t.texture);O.framebufferTexture2D(36160,36064,34069+e,i.__webglTexture,r)}else if(s){const i=D.get(t.texture),n=e||0;O.framebufferTextureLayer(36160,36064,i.__webglTexture,r||0,n)}S=-1},this.readRenderTargetPixels=function(t,r,i,n,s,a,o){if(t&&t.isWebGLRenderTarget){let e=D.get(t).__webglFramebuffer;if(e=t.isWebGLCubeRenderTarget&&void 0!==o?e[o]:e){C.bindFramebuffer(36160,e);try{const o=t.texture,e=o.format,h=o.type;var l;e!==Ce&&v.convert(e)!==O.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):(l=h===ot&&(d.has("EXT_color_buffer_half_float")||R.isWebGL2&&d.has("EXT_color_buffer_float")),h===et||v.convert(h)===O.getParameter(35738)||h===at&&(R.isWebGL2||d.has("OES_texture_float")||d.has("WEBGL_color_buffer_float"))||l?36053===O.checkFramebufferStatus(36160)?0<=r&&r<=t.width-n&&0<=i&&i<=t.height-s&&O.readPixels(r,i,n,s,v.convert(e),v.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."))}finally{const t=null!==T?D.get(T).__webglFramebuffer:null;C.bindFramebuffer(36160,t)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,r=0){var i=Math.pow(2,-r),n=Math.floor(t.image.width*i),i=Math.floor(t.image.height*i);let s=v.convert(t.format);R.isWebGL2&&6408===(s=6407===s?32849:s)&&(s=32856),I.setTexture2D(t,0),O.copyTexImage2D(3553,r,s,e.x,e.y,n,i,0),C.unbindTexture()},this.copyTextureToTexture=function(e,t,r,i=0){var n=t.image.width,s=t.image.height,a=v.convert(r.format),o=v.convert(r.type);I.setTexture2D(r,0),O.pixelStorei(37440,r.flipY),O.pixelStorei(37441,r.premultiplyAlpha),O.pixelStorei(3317,r.unpackAlignment),t.isDataTexture?O.texSubImage2D(3553,i,e.x,e.y,n,s,a,o,t.image.data):t.isCompressedTexture?O.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):O.texSubImage2D(3553,i,e.x,e.y,a,o,t.image),0===i&&r.generateMipmaps&&O.generateMipmap(3553),C.unbindTexture()},this.copyTextureToTexture3D=function(t,r,i,n,s=0){if(b.isWebGL1Renderer)console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var a=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,l=t.max.z-t.min.z+1,h=v.convert(n.format),u=v.convert(n.type);let e;if(n.isDataTexture3D)I.setTexture3D(n,0),e=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");I.setTexture2DArray(n,0),e=35866}O.pixelStorei(37440,n.flipY),O.pixelStorei(37441,n.premultiplyAlpha),O.pixelStorei(3317,n.unpackAlignment);var c=O.getParameter(3314),d=O.getParameter(32878),f=O.getParameter(3316),p=O.getParameter(3315),m=O.getParameter(32877),g=i.isCompressedTexture?i.mipmaps[0]:i.image;O.pixelStorei(3314,g.width),O.pixelStorei(32878,g.height),O.pixelStorei(3316,t.min.x),O.pixelStorei(3315,t.min.y),O.pixelStorei(32877,t.min.z),i.isDataTexture||i.isDataTexture3D?O.texSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,u,g.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),O.compressedTexSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,g.data)):O.texSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,u,g),O.pixelStorei(3314,c),O.pixelStorei(32878,d),O.pixelStorei(3316,f),O.pixelStorei(3315,p),O.pixelStorei(32877,m),0===s&&n.generateMipmaps&&O.generateMipmap(e),C.unbindTexture()}},this.initTexture=function(e){I.setTexture2D(e,0),C.unbindTexture()},this.resetState=function(){$=0,q=0,T=null,C.reset(),y.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}s.prototype.isWebGLRenderer=!0;class Cl extends s{}Cl.prototype.isWebGL1Renderer=!0;class Dl{constructor(e,t=25e-5){this.name="",this.color=new g(e),this.density=t}clone(){return new Dl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Dl.prototype.isFogExp2=!0;class Il{constructor(e,t=1,r=1e3){this.name="",this.color=new g(e),this.near=t,this.far=r}clone(){return new Il(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Il.prototype.isFog=!0;class Pl extends c{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){e=super.toJSON(e);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Pl.prototype.isScene=!0;class kl{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Zr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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(r,i,n){r*=this.stride,n*=i.stride;for(let e=0,t=this.stride;e<t;e++)this.array[r+e]=i.array[n+e];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);e=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),e=new this.constructor(e,this.stride);return e.setUsage(this.usage),e}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}kl.prototype.isInterleavedBuffer=!0;const a=new Pe;class Ol{constructor(e,t,r,i=!1){this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=!0===i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(r){for(let e=0,t=this.data.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.applyMatrix4(r),this.setXYZ(e,a.x,a.y,a.z);return this}applyNormalMatrix(r){for(let e=0,t=this.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.applyNormalMatrix(r),this.setXYZ(e,a.x,a.y,a.z);return this}transformDirection(r){for(let e=0,t=this.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.transformDirection(r),this.setXYZ(e,a.x,a.y,a.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=n,this}clone(t){if(void 0!==t)return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ol(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);{console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){var r=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[r+e])}return new w(new this.array.constructor(t),this.itemSize,this.normalized)}}toJSON(t){if(void 0!==t)return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized};{console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){var r=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[r+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}}}Ol.prototype.isInterleavedBufferAttribute=!0;class Fl extends r{constructor(e){super(),this.type="SpriteMaterial",this.color=new g(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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}}let Nl;Fl.prototype.isSpriteMaterial=!0;const Ul=new Pe,Bl=new Pe,Gl=new Pe,Hl=new z,zl=new z,Vl=new ke,Wl=new Pe,jl=new Pe,Yl=new Pe,$l=new z,ql=new z,Kl=new z;class Xl extends c{constructor(e){if(super(),this.type="Sprite",void 0===Nl){Nl=new S;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new kl(e,5);Nl.setIndex([0,1,2,0,2,3]),Nl.setAttribute("position",new Ol(t,3,0,!1)),Nl.setAttribute("uv",new Ol(t,2,3,!1))}this.geometry=Nl,this.material=void 0!==e?e:new Fl,this.center=new z(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Bl.setFromMatrixScale(this.matrixWorld),Vl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Gl.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Bl.multiplyScalar(-Gl.z);var r=this.material.rotation;let i,n;0!==r&&(n=Math.cos(r),i=Math.sin(r));var r=this.center,s=(Jl(Wl.set(-.5,-.5,0),Gl,r,Bl,i,n),Jl(jl.set(.5,-.5,0),Gl,r,Bl,i,n),Jl(Yl.set(.5,.5,0),Gl,r,Bl,i,n),$l.set(0,0),ql.set(1,0),Kl.set(1,1),e.ray.intersectTriangle(Wl,jl,Yl,!1,Ul));null===s&&(Jl(jl.set(-.5,.5,0),Gl,r,Bl,i,n),ql.set(0,1),null===(s=e.ray.intersectTriangle(Wl,Yl,jl,!1,Ul)))||(r=e.ray.origin.distanceTo(Ul))<e.near||r>e.far||t.push({distance:r,point:Ul.clone(),uv:f.getUV(Ul,Wl,jl,Yl,$l,ql,Kl,new z),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Jl(e,t,r,i,n,s){Hl.subVectors(e,r).addScalar(.5).multiply(i),void 0!==n?(zl.x=s*Hl.x-n*Hl.y,zl.y=n*Hl.x+s*Hl.y):zl.copy(Hl),e.copy(t),e.x+=zl.x,e.y+=zl.y,e.applyMatrix4(Vl)}Xl.prototype.isSprite=!0;const Zl=new Pe,Ql=new Pe;class eh extends c{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);var r=e.levels;for(let e=0,t=r.length;e<t;e++){var i=r[e];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);var r=this.levels;let i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(r){var i=this.levels;if(0<i.length){let e,t;for(e=1,t=i.length;e<t&&!(r<i[e].distance);e++);return i[e-1].object}return null}raycast(e,t){var r;0<this.levels.length&&(Zl.setFromMatrixPosition(this.matrixWorld),r=e.ray.origin.distanceTo(Zl),this.getObjectForDistance(r).raycast(e,t))}update(r){var i=this.levels;if(1<i.length){Zl.setFromMatrixPosition(r.matrixWorld),Ql.setFromMatrixPosition(this.matrixWorld);var n=Zl.distanceTo(Ql)/r.zoom;let e,t;for(i[0].object.visible=!0,e=1,t=i.length;e<t&&n>=i[e].distance;e++)i[e-1].object.visible=!1,i[e].object.visible=!0;for(this._currentLevel=e-1;e<t;e++)i[e].object.visible=!1}}toJSON(e){var r=super.toJSON(e),i=(!1===this.autoUpdate&&(r.object.autoUpdate=!1),r.object.levels=[],this.levels);for(let e=0,t=i.length;e<t;e++){var n=i[e];r.object.levels.push({object:n.object.uuid,distance:n.distance})}return r}}const th=new Pe,rh=new Ie,ih=new Ie,nh=new Pe,sh=new ke;class ah extends E{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ke,this.bindMatrixInverse=new ke}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){var r=new Ie,i=this.geometry.attributes.skinWeight;for(let e=0,t=i.count;e<t;e++){r.x=i.getX(e),r.y=i.getY(e),r.z=i.getZ(e),r.w=i.getW(e);var n=1/r.manhattanLength();n!=1/0?r.multiplyScalar(n):r.set(1,0,0,0),i.setXYZW(e,r.x,r.y,r.z,r.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const r=this.skeleton,i=this.geometry;rh.fromBufferAttribute(i.attributes.skinIndex,e),ih.fromBufferAttribute(i.attributes.skinWeight,e),th.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=ih.getComponent(e);var n;0!==i&&(n=rh.getComponent(e),sh.multiplyMatrices(r.bones[n].matrixWorld,r.boneInverses[n]),t.addScaledVector(nh.copy(th).applyMatrix4(sh),i))}return t.applyMatrix4(this.bindMatrixInverse)}}ah.prototype.isSkinnedMesh=!0;class oh extends c{constructor(){super(),this.type="Bone"}}oh.prototype.isBone=!0;class lh extends u{constructor(e=null,t=1,r=1,i,n,s,a,o,l=Re,h=Re,u,c){super(null,s,a,o,l,h,i,n,u,c),this.image={data:e,width:t,height:r},this.magFilter=l,this.minFilter=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}lh.prototype.isDataTexture=!0;const hh=new ke,uh=new ke;class ch{constructor(e=[],t=[]){this.uuid=pi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){var e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)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 e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new ke)}}calculateInverses(){for(let e=this.boneInverses.length=0,t=this.bones.length;e<t;e++){var r=new ke;this.bones[e]&&r.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){var r=this.bones[e];r&&r.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){var 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(){var r=this.bones,i=this.boneInverses,n=this.boneMatrices,e=this.boneTexture;for(let e=0,t=r.length;e<t;e++){var s=r[e]?r[e].matrixWorld:uh;hh.multiplyMatrices(s,i[e]),hh.toArray(n,16*e)}null!==e&&(e.needsUpdate=!0)}clone(){return new ch(this.bones,this.boneInverses)}computeBoneTexture(){var e=xi(Math.sqrt(4*this.bones.length)),t=(e=Math.max(e,4),new Float32Array(e*e*4)),r=(t.set(this.boneMatrices),new lh(t,e,e,Ce,at));return this.boneMatrices=t,this.boneTexture=r,this.boneTextureSize=e,this}getBoneByName(r){for(let e=0,t=this.bones.length;e<t;e++){var i=this.bones[e];if(i.name===r)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(r,i){this.uuid=r.uuid;for(let t=0,e=r.bones.length;t<e;t++){var n=r.bones[t];let e=i[n];void 0===e&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),e=new oh),this.bones.push(e),this.boneInverses.push((new ke).fromArray(r.boneInverses[t]))}return this.init(),this}toJSON(){var r={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]},i=(r.uuid=this.uuid,this.bones),n=this.boneInverses;for(let e=0,t=i.length;e<t;e++){var s=i[e],s=(r.bones.push(s.uuid),n[e]);r.boneInverses.push(s.toArray())}return r}}class dh extends w{constructor(e,t,r,i=1){"number"==typeof r&&(i=r,r=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,r),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){var e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}dh.prototype.isInstancedBufferAttribute=!0;const fh=new ke,ph=new ke,mh=[],gh=new E;class vh extends E{constructor(e,t,r){super(e,t),this.instanceMatrix=new dh(new Float32Array(16*r),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,i){const n=this.matrixWorld,t=this.count;if(gh.geometry=this.geometry,gh.material=this.material,void 0!==gh.material)for(let r=0;r<t;r++){this.getMatrixAt(r,fh),ph.multiplyMatrices(n,fh),gh.matrixWorld=ph,gh.raycast(e,mh);for(let e=0,t=mh.length;e<t;e++){const n=mh[e];n.instanceId=r,n.object=this,i.push(n)}mh.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new dh(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}vh.prototype.isInstancedMesh=!0;class y extends r{constructor(e){super(),this.type="LineBasicMaterial",this.color=new g(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}y.prototype.isLineBasicMaterial=!0;const yh=new Pe,xh=new Pe,_h=new ke,bh=new cn,Th=new rn;class Sh extends c{constructor(e=new S,t=new y){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var r=e.attributes.position,i=[0];for(let e=1,t=r.count;e<t;e++)yh.fromBufferAttribute(r,e-1),xh.fromBufferAttribute(r,e),i[e]=i[e-1],i[e]+=yh.distanceTo(xh);e.setAttribute("lineDistance",new V(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(r,i){const e=this.geometry,n=this.matrixWorld,s=r.params.Line.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),Th.copy(e.boundingSphere),Th.applyMatrix4(n),Th.radius+=s,!1!==r.ray.intersectsSphere(Th)){_h.copy(n).invert(),bh.copy(r.ray).applyMatrix4(_h);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=new Pe,u=new Pe,c=new Pe,d=new Pe,f=this.isLineSegments?2:1;if(e.isBufferGeometry){const n=e.index,s=e.attributes.position;if(null!==n)for(let e=Math.max(0,a.start),t=Math.min(n.count,a.start+a.count)-1;e<t;e+=f){const a=n.getX(e),o=n.getX(e+1);if(h.fromBufferAttribute(s,a),u.fromBufferAttribute(s,o),!(bh.distanceSqToSegment(h,u,d,c)>l)){d.applyMatrix4(this.matrixWorld);const f=r.ray.origin.distanceTo(d);f<r.near||f>r.far||i.push({distance:f,point:c.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this})}}else for(let e=Math.max(0,a.start),t=Math.min(s.count,a.start+a.count)-1;e<t;e+=f)if(h.fromBufferAttribute(s,e),u.fromBufferAttribute(s,e+1),!(bh.distanceSqToSegment(h,u,d,c)>l)){d.applyMatrix4(this.matrixWorld);const n=r.ray.origin.distanceTo(d);n<r.near||n>r.far||i.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this})}}else e.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Sh.prototype.isLine=!0;const Eh=new Pe,wh=new Pe;class Mh extends Sh{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var r=e.attributes.position,i=[];for(let e=0,t=r.count;e<t;e+=2)Eh.fromBufferAttribute(r,e),wh.fromBufferAttribute(r,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Eh.distanceTo(wh);e.setAttribute("lineDistance",new V(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}Mh.prototype.isLineSegments=!0;class Ah extends Sh{constructor(e,t){super(e,t),this.type="LineLoop"}}Ah.prototype.isLineLoop=!0;class Lh extends r{constructor(e){super(),this.type="PointsMaterial",this.color=new g(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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}}Lh.prototype.isPointsMaterial=!0;const Rh=new ke,Ch=new cn,Dh=new rn,Ih=new Pe;class Ph extends c{constructor(e=new S,t=new Lh){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(r,i){const e=this.geometry,n=this.matrixWorld,s=r.params.Points.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),Dh.copy(e.boundingSphere),Dh.applyMatrix4(n),Dh.radius+=s,!1!==r.ray.intersectsSphere(Dh)){Rh.copy(n).invert(),Ch.copy(r.ray).applyMatrix4(Rh);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o;if(e.isBufferGeometry){const s=e.index,o=e.attributes.position;if(null!==s)for(let e=Math.max(0,a.start),t=Math.min(s.count,a.start+a.count);e<t;e++){const a=s.getX(e);Ih.fromBufferAttribute(o,a),kh(Ih,a,l,n,r,i,this)}else for(let e=Math.max(0,a.start),t=Math.min(o.count,a.start+a.count);e<t;e++)Ih.fromBufferAttribute(o,e),kh(Ih,e,l,n,r,i,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function kh(e,t,r,i,n,s,a){var o=Ch.distanceSqToPoint(e);if(o<r){const r=new Pe;Ch.closestPointToPoint(e,r),r.applyMatrix4(i);e=n.ray.origin.distanceTo(r);e<n.near||e>n.far||s.push({distance:e,distanceToRay:Math.sqrt(o),point:r,index:t,face:null,object:a})}}Ph.prototype.isPoints=!0;class Oh extends u{constructor(t,e,r,i,n,s,a,o,l){super(t,e,r,i,n,s,a,o,l),this.format=void 0!==a?a:ft,this.minFilter=void 0!==s?s:U,this.magFilter=void 0!==n?n:U,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){var e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Oh.prototype.isVideoTexture=!0;class Fh extends u{constructor(e,t,r,i,n,s,a,o,l,h,u,c){super(null,s,a,o,l,h,i,n,u,c),this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Fh.prototype.isCompressedTexture=!0;class Nh extends u{constructor(e,t,r,i,n,s,a,o,l){super(e,t,r,i,n,s,a,o,l),this.needsUpdate=!0}}Nh.prototype.isCanvasTexture=!0;class Uh extends u{constructor(e,t,r,i,n,s,a,o,l,h){if((h=void 0!==h?h:vt)!==vt&&h!==yt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,i,n,s,a,o,h,r=void 0===(r=void 0===r&&h===vt?it:r)&&h===yt?ct:r,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:Re,this.minFilter=void 0!==o?o:Re,this.flipY=!1,this.generateMipmaps=!1}}Uh.prototype.isDepthTexture=!0;class Bh extends S{constructor(r=1,i=8,n=0,s=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:r,segments:i,thetaStart:n,thetaLength:s},i=Math.max(3,i);var t=[],a=[],o=[],l=[],h=new Pe,u=new z;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let e=0,t=3;e<=i;e++,t+=3){var c=n+e/i*s;h.x=r*Math.cos(c),h.y=r*Math.sin(c),a.push(h.x,h.y,h.z),o.push(0,0,1),u.x=(a[t]/r+1)/2,u.y=(a[t+1]/r+1)/2,l.push(u.x,u.y)}for(let e=1;e<=i;e++)t.push(e,e+1,0);this.setIndex(t),this.setAttribute("position",new V(a,3)),this.setAttribute("normal",new V(o,3)),this.setAttribute("uv",new V(l,2))}static fromJSON(e){return new Bh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Gh extends S{constructor(h=1,u=1,i=1,c=8,n=1,e=!1,d=0,f=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:h,radiusBottom:u,height:i,radialSegments:c,heightSegments:n,openEnded:e,thetaStart:d,thetaLength:f};const p=this,m=(c=Math.floor(c),n=Math.floor(n),[]),g=[],v=[],y=[];let x=0;const s=[],_=i/2;let b=0;function t(t){const r=x,i=new z,n=new Pe;let s=0;var a=!0===t?h:u,o=!0===t?1:-1;for(let e=1;e<=c;e++)g.push(0,_*o,0),v.push(0,o,0),y.push(.5,.5),x++;var l=x;for(let e=0;e<=c;e++){const u=e/c*f+d,t=Math.cos(u),r=Math.sin(u);n.x=a*r,n.y=_*o,n.z=a*t,g.push(n.x,n.y,n.z),v.push(0,o,0),i.x=.5*t+.5,i.y=.5*r*o+.5,y.push(i.x,i.y),x++}for(let e=0;e<c;e++){const u=r+e,c=l+e;!0===t?m.push(c,c+1,u):m.push(c+1,c,u),s+=3}p.addGroup(b,s,!0===t?1:2),b+=s}{const o=new Pe,l=new Pe;let r=0;var a=(u-h)/i;for(let e=0;e<=n;e++){const m=[],b=e/n,t=b*(u-h)+h;for(let e=0;e<=c;e++){const u=e/c,n=u*f+d,p=Math.sin(n),s=Math.cos(n);l.x=t*p,l.y=-b*i+_,l.z=t*s,g.push(l.x,l.y,l.z),o.set(p,a,s).normalize(),v.push(o.x,o.y,o.z),y.push(u,1-b),m.push(x++)}s.push(m)}for(let t=0;t<c;t++)for(let e=0;e<n;e++){const i=s[e][t],c=s[e+1][t],n=s[e+1][t+1],o=s[e][t+1];m.push(i,c,o),m.push(c,n,o),r+=6}p.addGroup(b,r,0),b+=r}!1===e&&(0<h&&t(!0),0<u)&&t(!1),this.setIndex(m),this.setAttribute("position",new V(g,3)),this.setAttribute("normal",new V(v,3)),this.setAttribute("uv",new V(y,2))}static fromJSON(e){return new Gh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Hh extends Gh{constructor(e=1,t=1,r=8,i=1,n=!1,s=0,a=2*Math.PI){super(0,e,t,r,i,n,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Hh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class zh extends S{constructor(r=[],t=[],e=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:r,indices:t,radius:e,detail:i};const n=[],s=[];function a(e){n.push(e.x,e.y,e.z)}function o(e,t){e*=3;t.x=r[0+e],t.y=r[1+e],t.z=r[2+e]}function l(e,t,r,i){i<0&&1===e.x&&(s[t]=e.x-1),0===r.x&&0===r.z&&(s[t]=i/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}var u=i,c=new Pe,d=new Pe,f=new Pe;for(let e=0;e<t.length;e+=3){o(t[e+0],c),o(t[e+1],d),o(t[e+2],f);{p=void 0;m=void 0;g=void 0;v=void 0;y=void 0;x=void 0;var p=c;var m=d;var g=f;var v=u;var y=v+1,x=[];for(let t=0;t<=y;t++){x[t]=[];const k=p.clone().lerp(g,t/y),a=m.clone().lerp(g,t/y),O=y-t;for(let e=0;e<=O;e++)x[t][e]=0===e&&t===y?k:k.clone().lerp(a,e/O)}for(let t=0;t<y;t++)for(let e=0;e<2*(y-t)-1;e++){const g=Math.floor(e/2);e%2==0?(a(x[t][g+1]),a(x[t+1][g]),a(x[t][g])):(a(x[t][g+1]),a(x[t+1][g+1]),a(x[t+1][g]))}}}var _=e,b=new Pe;for(let e=0;e<n.length;e+=3)b.x=n[e+0],b.y=n[e+1],b.z=n[e+2],b.normalize().multiplyScalar(_),n[e+0]=b.x,n[e+1]=b.y,n[e+2]=b.z;var T=new Pe;for(let e=0;e<n.length;e+=3){T.x=n[e+0],T.y=n[e+1],T.z=n[e+2];var F=h(T)/2/Math.PI+.5,N=Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))/Math.PI+.5;s.push(F,1-N)}var S=new Pe,E=new Pe,w=new Pe,M=new Pe,A=new z,L=new z,R=new z;for(let e=0,t=0;e<n.length;e+=9,t+=6){S.set(n[e+0],n[e+1],n[e+2]),E.set(n[e+3],n[e+4],n[e+5]),w.set(n[e+6],n[e+7],n[e+8]),A.set(s[t+0],s[t+1]),L.set(s[t+2],s[t+3]),R.set(s[t+4],s[t+5]),M.copy(S).add(E).add(w).divideScalar(3);var C=h(M);l(A,t+0,S,C),l(L,t+2,E,C),l(R,t+4,w,C)}for(let e=0;e<s.length;e+=6){var D=s[e+0],I=s[e+2],P=s[e+4],U=Math.max(D,I,P),B=Math.min(D,I,P);.9<U&&B<.1&&(D<.2&&(s[e+0]+=1),I<.2&&(s[e+2]+=1),P<.2)&&(s[e+4]+=1)}this.setAttribute("position",new V(n,3)),this.setAttribute("normal",new V(n.slice(),3)),this.setAttribute("uv",new V(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new zh(e.vertices,e.indices,e.radius,e.details)}}class Vh extends zh{constructor(e=1,t=0){var r=(1+Math.sqrt(5))/2,i=1/r;super([-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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],[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],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Vh(e.radius,e.detail)}}const Wh=new Pe,jh=new Pe,Yh=new Pe,$h=new f;class qh extends S{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){var r=Math.pow(10,4),i=Math.cos(ci*t),n=e.getIndex(),s=e.getAttribute("position"),a=(n||s).count,o=[0,0,0],l=["a","b","c"],h=new Array(3),u={},c=[];for(let e=0;e<a;e+=3){n?(o[0]=n.getX(e),o[1]=n.getX(e+1),o[2]=n.getX(e+2)):(o[0]=e,o[1]=e+1,o[2]=e+2);const{a:t,b:d,c:f}=$h;if(t.fromBufferAttribute(s,o[0]),d.fromBufferAttribute(s,o[1]),f.fromBufferAttribute(s,o[2]),$h.getNormal(Yh),h[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},`+Math.round(t.z*r),h[1]=`${Math.round(d.x*r)},${Math.round(d.y*r)},`+Math.round(d.z*r),h[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},`+Math.round(f.z*r),h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let e=0;e<3;e++){const t=(e+1)%3,p=h[e],m=h[t],g=$h[l[e]],v=$h[l[t]],y=p+"_"+m,x=m+"_"+p;x in u&&u[x]?(Yh.dot(u[x].normal)<=i&&(c.push(g.x,g.y,g.z),c.push(v.x,v.y,v.z)),u[x]=null):y in u||(u[y]={index0:o[e],index1:o[t],normal:Yh.clone()})}}for(const e in u)if(u[e]){const{index0:t,index1:_}=u[e];Wh.fromBufferAttribute(s,t),jh.fromBufferAttribute(s,_),c.push(Wh.x,Wh.y,Wh.z),c.push(jh.x,jh.y,jh.z)}this.setAttribute("position",new V(c,3))}}}class Kh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){e=this.getUtoTmapping(e);return this.getPoint(e,t)}getPoints(t=5){var r=[];for(let e=0;e<=t;e++)r.push(this.getPoint(e/t));return r}getSpacedPoints(t=5){var r=[];for(let e=0;e<=t;e++)r.push(this.getPointAt(e/t));return r}getLength(){var e=this.getLengths();return e[e.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var r=[];let i,n=this.getPoint(0),s=0;r.push(0);for(let e=1;e<=t;e++)i=this.getPoint(e/t),s+=i.distanceTo(n),r.push(s),n=i;return this.cacheArcLengths=r}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){var r=this.getLengths();let i=0;var n=r.length,s=t||e*r[n-1];let a,o=0,l=n-1;for(;o<=l;)if((a=r[i=Math.floor(o+(l-o)/2)]-s)<0)o=i+1;else{if(!(0<a)){l=i;break}l=i-1}return r[i=l]===s?i/(n-1):(t=r[i],(i+(s-t)/(r[i+1]-t))/(n-1))}getTangent(e,t){let r=e-1e-4,i=e+1e-4;r<0&&(r=0),1<i&&(i=1);var e=this.getPoint(r),n=this.getPoint(i),t=t||new(e.isVector2?z:Pe);return t.copy(n).sub(e).normalize(),t}getTangentAt(e,t){e=this.getUtoTmapping(e);return this.getTangent(e,t)}computeFrenetFrames(r,e){const t=new Pe,i=[],n=[],s=[],a=new Pe,o=new ke;for(let e=0;e<=r;e++){const t=e/r;i[e]=this.getTangentAt(t,new Pe)}n[0]=new Pe,s[0]=new Pe;let l=Number.MAX_VALUE;var h=Math.abs(i[0].x),u=Math.abs(i[0].y),c=Math.abs(i[0].z);h<=l&&(l=h,t.set(1,0,0)),u<=l&&(l=u,t.set(0,1,0)),c<=l&&t.set(0,0,1),a.crossVectors(i[0],t).normalize(),n[0].crossVectors(i[0],a),s[0].crossVectors(i[0],n[0]);for(let e=1;e<=r;e++){if(n[e]=n[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const r=Math.acos(mi(i[e-1].dot(i[e]),-1,1));n[e].applyMatrix4(o.makeRotationAxis(a,r))}s[e].crossVectors(i[e],n[e])}if(!0===e){let t=Math.acos(mi(n[0].dot(n[r]),-1,1));t/=r,0<i[0].dot(a.crossVectors(n[0],n[r]))&&(t=-t);for(let e=1;e<=r;e++)n[e].applyMatrix4(o.makeRotationAxis(i[e],t*e)),s[e].crossVectors(i[e],n[e])}return{tangents:i,normals:n,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xh extends Kh{constructor(e=0,t=0,r=1,i=1,n=0,s=2*Math.PI,a=!1,o=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const r=t||new z,i=2*Math.PI;let n=this.aEndAngle-this.aStartAngle;for(t=Math.abs(n)<Number.EPSILON;n<0;)n+=i;for(;n>i;)n-=i;n<Number.EPSILON&&(n=t?0:i),!0!==this.aClockwise||t||(n===i?n=-i:n-=i);t=this.aStartAngle+e*n;let s=this.aX+this.xRadius*Math.cos(t),a=this.aY+this.yRadius*Math.sin(t);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),r=s-this.aX,i=a-this.aY;s=r*e-i*t+this.aX,a=r*t+i*e+this.aY}return r.set(s,a)}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(){var 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}}Xh.prototype.isEllipseCurve=!0;class Jh extends Xh{constructor(e,t,r,i,n,s){super(e,t,r,r,i,n,s),this.type="ArcCurve"}}function Zh(){let n=0,s=0,a=0,o=0;function l(e,t,r,i){n=e,s=r,a=-3*e+3*t-2*r-i,o=2*e-2*t+r+i}return{initCatmullRom:function(e,t,r,i,n){l(t,r,n*(r-e),n*(i-t))},initNonuniformCatmullRom:function(e,t,r,i,n,s,a){e=(t-e)/n-(r-e)/(n+s)+(r-t)/s,n=(r-t)/s-(i-t)/(s+a)+(i-r)/a;l(t,r,e*=s,n*=s)},calc:function(e){var t=e*e;return n+s*e+a*t+o*(t*e)}}}Jh.prototype.isArcCurve=!0;const Qh=new Pe,eu=new Zh,tu=new Zh,ru=new Zh;class iu extends Kh{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(i,e=new Pe){var t=this.points,r=t.length,i=(r-(this.closed?0:1))*i;let n,s,a=Math.floor(i),o=i-a;this.closed?a+=0<a?0:(Math.floor(Math.abs(a)/r)+1)*r:0===o&&a===r-1&&(a=r-2,o=1),n=this.closed||0<a?t[(a-1)%r]:(Qh.subVectors(t[0],t[1]).add(t[0]),Qh);var l=t[a%r],h=t[(a+1)%r];if(s=this.closed||a+2<r?t[(a+2)%r]:(Qh.subVectors(t[r-1],t[r-2]).add(t[r-1]),Qh),"centripetal"===this.curveType||"chordal"===this.curveType){const i="chordal"===this.curveType?.5:.25;let e=Math.pow(n.distanceToSquared(l),i),t=Math.pow(l.distanceToSquared(h),i),r=Math.pow(h.distanceToSquared(s),i);t<1e-4&&(t=1),e<1e-4&&(e=t),r<1e-4&&(r=t),eu.initNonuniformCatmullRom(n.x,l.x,h.x,s.x,e,t,r),tu.initNonuniformCatmullRom(n.y,l.y,h.y,s.y,e,t,r),ru.initNonuniformCatmullRom(n.z,l.z,h.z,s.z,e,t,r)}else"catmullrom"===this.curveType&&(eu.initCatmullRom(n.x,l.x,h.x,s.x,this.tension),tu.initCatmullRom(n.y,l.y,h.y,s.y,this.tension),ru.initCatmullRom(n.z,l.z,h.z,s.z,this.tension));return e.set(eu.calc(o),tu.calc(o),ru.calc(o)),e}copy(r){super.copy(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push(i.clone())}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}toJSON(){var r=super.toJSON();r.points=[];for(let e=0,t=this.points.length;e<t;e++){var i=this.points[e];r.points.push(i.toArray())}return r.closed=this.closed,r.curveType=this.curveType,r.tension=this.tension,r}fromJSON(r){super.fromJSON(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push((new Pe).fromArray(i))}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}}function nu(e,t,r,i,n){var t=.5*(i-t),n=.5*(n-r),s=e*e;return e*s*(2*r-2*i+t+n)+(-3*r+3*i-2*t-n)*s+t*e+r}function su(e,t,r,i){return(n=1-e)*n*t+2*(1-e)*e*r+e*e*i;var n}function au(e,t,r,i,n){return(s=1-e)*s*s*t+3*(s=1-e)*s*e*r+3*(1-e)*e*e*i+e*e*e*n;var s}iu.prototype.isCatmullRomCurve3=!0;class ou extends Kh{constructor(e=new z,t=new z,r=new z,i=new z){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new z){var r=this.v0,i=this.v1,n=this.v2,s=this.v3;return t.set(au(e,r.x,i.x,n.x,s.x),au(e,r.y,i.y,n.y,s.y)),t}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(){var 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}}ou.prototype.isCubicBezierCurve=!0;class lu extends Kh{constructor(e=new Pe,t=new Pe,r=new Pe,i=new Pe){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new Pe){var r=this.v0,i=this.v1,n=this.v2,s=this.v3;return t.set(au(e,r.x,i.x,n.x,s.x),au(e,r.y,i.y,n.y,s.y),au(e,r.z,i.z,n.z,s.z)),t}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(){var 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}}lu.prototype.isCubicBezierCurve3=!0;class hu extends Kh{constructor(e=new z,t=new z){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new z){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){t=t||new z;return t.copy(this.v2).sub(this.v1).normalize(),t}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}hu.prototype.isLineCurve=!0;class uu extends Kh{constructor(e=new Pe,t=new Pe){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Pe){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}class cu extends Kh{constructor(e=new z,t=new z,r=new z){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new z){var r=this.v0,i=this.v1,n=this.v2;return t.set(su(e,r.x,i.x,n.x),su(e,r.y,i.y,n.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}cu.prototype.isQuadraticBezierCurve=!0;class du extends Kh{constructor(e=new Pe,t=new Pe,r=new Pe){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new Pe){var r=this.v0,i=this.v1,n=this.v2;return t.set(su(e,r.x,i.x,n.x),su(e,r.y,i.y,n.y),su(e,r.z,i.z,n.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}du.prototype.isQuadraticBezierCurve3=!0;class fu extends Kh{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new z){var r=this.points,e=(r.length-1)*e,i=Math.floor(e),e=e-i,n=r[0===i?i:i-1],s=r[i],a=r[i>r.length-2?r.length-1:i+1],r=r[i>r.length-3?r.length-1:i+2];return t.set(nu(e,n.x,s.x,a.x,r.x),nu(e,n.y,s.y,a.y,r.y)),t}copy(r){super.copy(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push(i.clone())}return this}toJSON(){var r=super.toJSON();r.points=[];for(let e=0,t=this.points.length;e<t;e++){var i=this.points[e];r.points.push(i.toArray())}return r}fromJSON(r){super.fromJSON(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push((new z).fromArray(i))}return this}}fu.prototype.isSplineCurve=!0;var pu=Object.freeze({__proto__:null,ArcCurve:Jh,CatmullRomCurve3:iu,CubicBezierCurve:ou,CubicBezierCurve3:lu,EllipseCurve:Xh,LineCurve:hu,LineCurve3:uu,QuadraticBezierCurve:cu,QuadraticBezierCurve3:du,SplineCurve:fu});class mu extends Kh{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new hu(t,e))}getPoint(e,t){var r=e*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=r){const e=i[n]-r,s=this.curves[n],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}n++}return null}getLength(){var 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;var r=[];let i=0;for(let e=0,t=this.curves.length;e<t;e++)i+=this.curves[e].getLength(),r.push(i);return this.cacheLengths=r}getSpacedPoints(t=40){var r=[];for(let e=0;e<=t;e++)r.push(this.getPoint(e/t));return this.autoClose&&r.push(r[0]),r}getPoints(r=12){var i=[];let n;for(let e=0,t=this.curves;e<t.length;e++){var s=t[e],a=s&&s.isEllipseCurve?2*r:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?r*s.points.length:r,o=s.getPoints(a);for(let e=0;e<o.length;e++){var l=o[e];n&&n.equals(l)||(i.push(l),n=l)}}return this.autoClose&&1<i.length&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(r){super.copy(r),this.curves=[];for(let e=0,t=r.curves.length;e<t;e++){var i=r.curves[e];this.curves.push(i.clone())}return this.autoClose=r.autoClose,this}toJSON(){var r=super.toJSON();r.autoClose=this.autoClose,r.curves=[];for(let e=0,t=this.curves.length;e<t;e++){var i=this.curves[e];r.curves.push(i.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.autoClose=r.autoClose,this.curves=[];for(let e=0,t=r.curves.length;e<t;e++){var i=r.curves[e];this.curves.push((new pu[i.type]).fromJSON(i))}return this}}class gu extends mu{constructor(e){super(),this.type="Path",this.currentPoint=new z,e&&this.setFromPoints(e)}setFromPoints(r){this.moveTo(r[0].x,r[0].y);for(let e=1,t=r.length;e<t;e++)this.lineTo(r[e].x,r[e].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){var r=new hu(this.currentPoint.clone(),new z(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){e=new cu(this.currentPoint.clone(),new z(e,t),new z(r,i));return this.curves.push(e),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,n,s){e=new ou(this.currentPoint.clone(),new z(e,t),new z(r,i),new z(n,s));return this.curves.push(e),this.currentPoint.set(n,s),this}splineThru(e){var t=[this.currentPoint.clone()].concat(e),t=new fu(t);return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,n,s){var a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,r,i,n,s),this}absarc(e,t,r,i,n,s){return this.absellipse(e,t,r,r,i,n,s),this}ellipse(e,t,r,i,n,s,a,o){var l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,r,i,n,s,a,o),this}absellipse(e,t,r,i,n,s,a,o){t=new Xh(e,t,r,i,n,s,a,o);if(0<this.curves.length){const e=t.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(t);e=t.getPoint(1);return this.currentPoint.copy(e),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){var e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class vu extends gu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(r){var i=[];for(let e=0,t=this.holes.length;e<t;e++)i[e]=this.holes[e].getPoints(r);return i}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(r){super.copy(r),this.holes=[];for(let e=0,t=r.holes.length;e<t;e++){var i=r.holes[e];this.holes.push(i.clone())}return this}toJSON(){var r=super.toJSON();r.uuid=this.uuid,r.holes=[];for(let e=0,t=this.holes.length;e<t;e++){var i=this.holes[e];r.holes.push(i.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.uuid=r.uuid,this.holes=[];for(let e=0,t=r.holes.length;e<t;e++){var i=r.holes[e];this.holes.push((new gu).fromJSON(i))}return this}}function yu(o,l,h=2){var u=l&&l.length,c=u?l[0]*h:o.length;let d=xu(o,0,c,h,!0);var f=[];if(d&&d.next!==d.prev){let t,r,i,n,s,a,e;if(u&&(d=function(e,t,r,i){var n,s,a=[];let o,l,h,u,c;for(o=0,l=t.length;o<l;o++)h=t[o]*i,u=o<l-1?t[o+1]*i:e.length,(c=xu(e,h,u,i,!1))===c.next&&(c.steiner=!0),a.push(function(e){let t=e,r=e;for(;(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next,t!==e;);return r}(c));for(a.sort(Tu),o=0;o<a.length;o++)n=a[o],(s=function(r,e){let i=e;var n=r.x,s=r.y;let a,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const r=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(r<=n&&r>o){if((o=r)===n){if(s===i.y)return i;if(s===i.next.y)return i.next}a=i.x<i.next.x?i:i.next}}}while((i=i.next)!==e);if(!a)return null;if(n!==o){var l,h,u=a,c=a.x,d=a.y;let e,t=1/0;for(i=a;n>=i.x&&i.x>=c&&n!==i.x&&Eu(s<d?n:o,s,c,d,s<d?o:n,s,i.x,i.y)&&(e=Math.abs(s-i.y)/(n-i.x),Ru(i,r))&&(e<t||e===t&&(i.x>a.x||i.x===a.x&&(l=a,h=i,m(l.prev,l,h.prev)<0)&&m(h.next,l,l.next)<0))&&(a=i,t=e),(i=i.next)!==u;);}return a}(n,s=r))&&(n=Cu(s,n),_u(s,s.next),_u(n,n.next)),r=_u(r,r.next);return r}(o,l,d,h)),o.length>80*h){t=i=o[0],r=n=o[1];for(let e=h;e<c;e+=h)s=o[e],a=o[e+1],s<t&&(t=s),a<r&&(r=a),s>i&&(i=s),a>n&&(n=a);e=0!==(e=Math.max(i-t,n-r))?1/e:0}bu(d,f,h,t,r,e)}return f}function xu(e,a,t,r,i){let n,s;if(i===0<function(r,i,n){let s=0;for(let e=a,t=i-n;e<i;e+=n)s+=(r[t]-r[e])*(r[e+1]+r[t+1]),t=e;return s}(e,t,r))for(n=a;n<t;n+=r)s=Du(n,e[n],e[n+1],s);else for(n=t-r;n>=a;n-=r)s=Du(n,e[n],e[n+1],s);return s&&wu(s,s.next)&&(Iu(s),s=s.next),s}function _u(e,t){if(!e)return e;t=t||e;let r,i=e;do{if(r=!1,i.steiner||!wu(i,i.next)&&0!==m(i.prev,i,i.next))i=i.next;else{if(Iu(i),(i=t=i.prev)===i.next)break;r=!0}}while(r||i!==t);return t}function bu(i,n,s,a,o,l,h){if(i){if(!h&&l){var u=i;var c=a;var d=o;var f=l;let h=u;for(;null===h.z&&(h.z=Su(h.x,h.y,c,d,f)),h.prevZ=h.prev,h.nextZ=h.next,(h=h.next)!==u;);h.prevZ.nextZ=null,h.prevZ=null;{var p=h;let e,t,r,i,n,s,a,o,l=1;do{for(t=p,p=null,n=null,s=0;t;){for(s++,r=t,a=0,e=0;e<l&&(a++,r=r.nextZ);e++);for(o=l;0<a||0<o&&r;)0!==a&&(0===o||!r||t.z<=r.z)?(t=(i=t).nextZ,a--):(r=(i=r).nextZ,o--),n?n.nextZ=i:p=i,i.prevZ=n,n=i;t=r}}while(n.nextZ=null,l*=2,1<s)}}let e,t,r=i;for(;i.prev!==i.next;)if(e=i.prev,t=i.next,l?function(e,t,r,i){var n=e.prev,s=e,a=e.next;if(0<=m(n,s,a))return;var o=(n.x<s.x?n.x<a.x?n:a:s.x<a.x?s:a).x,l=(n.y<s.y?n.y<a.y?n:a:s.y<a.y?s:a).y,h=(n.x>s.x?n.x>a.x?n:a:s.x>a.x?s:a).x,u=(n.y>s.y?n.y>a.y?n:a:s.y>a.y?s:a).y,c=Su(o,l,t,r,i),d=Su(h,u,t,r,i);let f=e.prevZ,p=e.nextZ;for(;f&&f.z>=c&&p&&p.z<=d;){if(f!==e.prev&&f!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&0<=m(f.prev,f,f.next))return;if(f=f.prevZ,p!==e.prev&&p!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&0<=m(p.prev,p,p.next))return;p=p.nextZ}for(;f&&f.z>=c;){if(f!==e.prev&&f!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&0<=m(f.prev,f,f.next))return;f=f.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&0<=m(p.prev,p,p.next))return;p=p.nextZ}return 1}(i,a,o,l):function(e){var t=e.prev,r=e,i=e.next;if(0<=m(t,r,i))return;let n=e.next.next;for(;n!==e.prev;){if(Eu(t.x,t.y,r.x,r.y,i.x,i.y,n.x,n.y)&&0<=m(n.prev,n,n.next))return;n=n.next}return 1}(i))n.push(e.i/s),n.push(i.i/s),n.push(t.i/s),Iu(i),i=t.next,r=t.next;else if((i=t)===r){h?1===h?bu(i=function(e,t,r){let i=e;do{var n=i.prev,s=i.next.next;!wu(n,s)&&Mu(n,i,i.next,s)&&Ru(n,s)&&Ru(s,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(s.i/r),Iu(i),Iu(i.next),i=e=s),i=i.next}while(i!==e);return _u(i)}(_u(i),n,s),n,s,a,o,l,2):2===h&&function(e,t,r,i,n,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){var o;if(a.i!==e.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Mu(r,r.next,e,t))return 1}while((r=r.next)!==e)}(e,t)&&(Ru(e,t)&&Ru(t,e)&&function(e,t){let r=e,i=!1;for(var n=(e.x+t.x)/2,s=(e.y+t.y)/2;r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),(r=r.next)!==e;);return i}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||wu(e,t)&&0<m(e.prev,e,e.next)&&0<m(t.prev,t,t.next))}(a,e))return o=Cu(a,e),a=_u(a,a.next),o=_u(o,o.next),bu(a,t,r,i,n,s),bu(o,t,r,i,n,s);e=e.next}}while(a=a.next,a!==e)}(i,n,s,a,o,l):bu(_u(i),n,s,a,o,l,1);break}}}function Tu(e,t){return e.x-t.x}function Su(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Eu(e,t,r,i,n,s,a,o){return 0<=(n-a)*(t-o)-(e-a)*(s-o)&&0<=(e-a)*(i-o)-(r-a)*(t-o)&&0<=(r-a)*(s-o)-(n-a)*(i-o)}function m(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function wu(e,t){return e.x===t.x&&e.y===t.y}function Mu(e,t,r,i){var n=Lu(m(e,t,r)),s=Lu(m(e,t,i)),a=Lu(m(r,i,e)),o=Lu(m(r,i,t));return n!==s&&a!==o||0===n&&Au(e,r,t)||0===s&&Au(e,i,t)||0===a&&Au(r,e,i)||0===o&&Au(r,t,i)}function Au(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Lu(e){return 0<e?1:e<0?-1:0}function Ru(e,t){return m(e.prev,e,e.next)<0?0<=m(e,t,e.next)&&0<=m(e,e.prev,t):m(e,t,e.prev)<0||m(e,e.next,t)<0}function Cu(e,t){var r=new Pu(e.i,e.x,e.y),i=new Pu(t.i,t.x,t.y),n=e.next,s=t.prev;return(e.next=t).prev=e,(r.next=n).prev=r,(i.next=r).prev=i,(s.next=i).prev=s,i}function Du(e,t,r,i){e=new Pu(e,t,r);return i?(e.next=i.next,(e.prev=i).next.prev=e,i.next=e):(e.prev=e).next=e,e}function Iu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Pu(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ku{static area(r){var i=r.length;let n=0;for(let e=i-1,t=0;t<i;e=t++)n+=r[e].x*r[t].y-r[t].x*r[e].y;return.5*n}static isClockWise(e){return ku.area(e)<0}static triangulateShape(e,t){var r=[],i=[],n=[];Ou(e),Fu(r,e);let s=e.length;t.forEach(Ou);for(let e=0;e<t.length;e++)i.push(s),s+=t[e].length,Fu(r,t[e]);var a=yu(r,i);for(let e=0;e<a.length;e+=3)n.push(a.slice(e,e+3));return n}}function Ou(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function Fu(t,r){for(let e=0;e<r.length;e++)t.push(r[e].x),t.push(r[e].y)}class Nu extends S{constructor(r=new vu([new z(.5,.5),new z(-.5,.5),new z(-.5,-.5),new z(.5,-.5)]),U={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:r,options:U},r=Array.isArray(r)?r:[r];const B=this,G=[],H=[];for(let e=0,t=r.length;e<t;e++)!function(e){const i=[],F=void 0!==U.curveSegments?U.curveSegments:12,c=void 0!==U.steps?U.steps:1;let r=void 0!==U.depth?U.depth:1,n=void 0===U.bevelEnabled||U.bevelEnabled,t=void 0!==U.bevelThickness?U.bevelThickness:.2,s=void 0!==U.bevelSize?U.bevelSize:t-.1,a=void 0!==U.bevelOffset?U.bevelOffset:0,d=void 0!==U.bevelSegments?U.bevelSegments:3;const o=U.extrudePath,f=void 0!==U.UVGenerator?U.UVGenerator:Uu;void 0!==U.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),r=U.amount);let l,h,u,p,m,g=!1;o&&(l=o.getSpacedPoints(c),g=!0,n=!1,h=o.computeFrenetFrames(c,!1),u=new Pe,p=new Pe,m=new Pe),n||(d=0,t=0,s=0,a=0);e=e.extractPoints(F);let v=e.shape;const y=e.holes;if(!ku.isClockWise(v)){v=v.reverse();for(let e=0,t=y.length;e<t;e++){const U=y[e];ku.isClockWise(U)&&(y[e]=U.reverse())}}const x=ku.triangulateShape(v,y),_=v;for(let e=0,t=y.length;e<t;e++){const U=y[e];v=v.concat(U)}function b(e,t,r){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(r).add(e)}const T=v.length,S=x.length;function E(e,t,r){let i,n,s;const a=e.x-t.x,o=e.y-t.y,l=r.x-e.x,h=r.y-e.y,u=a*a+o*o,c=a*h-o*l;if(Math.abs(c)>Number.EPSILON){const c=Math.sqrt(u),d=Math.sqrt(l*l+h*h),f=t.x-o/c,p=t.y+a/c,m=((r.x-h/d-f)*h-(r.y+l/d-p)*l)/(a*h-o*l);i=f+a*m-e.x,n=p+o*m-e.y;t=i*i+n*n;if(t<=2)return new z(i,n);s=Math.sqrt(t/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),s=e?(i=-o,n=a,Math.sqrt(u)):(i=a,n=o,Math.sqrt(u/2))}return new z(i/s,n/s)}var w=[];for(let e=0,t=_.length,r=t-1,i=e+1;e<t;e++,r++,i++)r===t&&(r=0),i===t&&(i=0),w[e]=E(_[e],_[r],_[i]);var M=[];let A,L=w.concat();for(let e=0,t=y.length;e<t;e++){const U=y[e];A=[];for(let e=0,t=U.length,r=t-1,i=e+1;e<t;e++,r++,i++)r===t&&(r=0),i===t&&(i=0),A[e]=E(U[e],U[r],U[i]);M.push(A),L=L.concat(A)}for(let e=0;e<d;e++){const U=e/d,B=t*Math.cos(U*Math.PI/2),G=s*Math.sin(U*Math.PI/2)+a;for(let e=0,t=_.length;e<t;e++){const U=b(_[e],w[e],G);C(U.x,U.y,-B)}for(let e=0,t=y.length;e<t;e++){const U=y[e];A=M[e];for(let e=0,t=U.length;e<t;e++){const H=b(U[e],A[e],G);C(H.x,H.y,-B)}}}var R=s+a;for(let e=0;e<T;e++){const U=n?b(v[e],L[e],R):v[e];g?(p.copy(h.normals[0]).multiplyScalar(U.x),u.copy(h.binormals[0]).multiplyScalar(U.y),m.copy(l[0]).add(p).add(u),C(m.x,m.y,m.z)):C(U.x,U.y,0)}for(let t=1;t<=c;t++)for(let e=0;e<T;e++){const B=n?b(v[e],L[e],R):v[e];g?(p.copy(h.normals[t]).multiplyScalar(B.x),u.copy(h.binormals[t]).multiplyScalar(B.y),m.copy(l[t]).add(p).add(u),C(m.x,m.y,m.z)):C(B.x,B.y,r/c*t)}for(let e=d-1;0<=e;e--){const U=e/d,B=t*Math.cos(U*Math.PI/2),G=s*Math.sin(U*Math.PI/2)+a;for(let e=0,t=_.length;e<t;e++){const U=b(_[e],w[e],G);C(U.x,U.y,r+B)}for(let e=0,t=y.length;e<t;e++){const U=y[e];A=M[e];for(let e=0,t=U.length;e<t;e++){const H=b(U[e],A[e],G);g?C(H.x,H.y+l[c-1].y,l[c-1].x+B):C(H.x,H.y,r+B)}}}function N(e,i){let n=e.length;for(;0<=--n;){var s=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,t=c+2*d;e<t;e++){const n=T*e,u=T*(e+1);h=l=o=a=void 0;var a=i+s+n,o=i+r+n,l=i+r+u,h=i+s+u;I(a),I(o),I(h),I(o),I(l),I(h),a=G.length/3,P((o=f.generateSideWallUV(B,G,a-6,a-3,a-2,a-1))[0]),P(o[1]),P(o[3]),P(o[1]),P(o[2]),P(o[3])}}}function C(e,t,r){i.push(e),i.push(t),i.push(r)}function D(e,t,r){I(e),I(t),I(r);e=G.length/3,t=f.generateTopUV(B,G,e-3,e-2,e-1);P(t[0]),P(t[1]),P(t[2])}function I(e){G.push(i[3*e+0]),G.push(i[3*e+1]),G.push(i[3*e+2])}function P(e){H.push(e.x),H.push(e.y)}{e=G.length/3;if(n){let e=0,t=0*T;for(let e=0;e<S;e++){const B=x[e];D(B[2]+t,B[1]+t,B[0]+t)}e=c+2*d,t=T*e;for(let e=0;e<S;e++){const B=x[e];D(B[0]+t,B[1]+t,B[2]+t)}}else{for(let e=0;e<S;e++){var k=x[e];D(k[2],k[1],k[0])}for(let e=0;e<S;e++){var O=x[e];D(O[0]+T*c,O[1]+T*c,O[2]+T*c)}}B.addGroup(e,G.length/3-e,0)}{e=G.length/3;let r=0;N(_,r),r+=_.length;for(let e=0,t=y.length;e<t;e++){const B=y[e];N(B,r),r+=B.length}B.addGroup(e,G.length/3-e,1)}}(r[e]);this.setAttribute("position",new V(G,3)),this.setAttribute("uv",new V(H,2)),this.computeVertexNormals()}toJSON(){var e=super.toJSON(),r=this.parameters.shapes,t=this.parameters.options,i=e;if(i.shapes=[],Array.isArray(r))for(let e=0,t=r.length;e<t;e++){var n=r[e];i.shapes.push(n.uuid)}else i.shapes.push(r.uuid);return void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}static fromJSON(r,i){var n=[];for(let e=0,t=r.shapes.length;e<t;e++){var s=i[r.shapes[e]];n.push(s)}var e=r.options.extrudePath;return void 0!==e&&(r.options.extrudePath=(new pu[e.type]).fromJSON(e)),new Nu(n,r.options)}}const Uu={generateTopUV:function(e,t,r,i,n){var s=t[3*r],r=t[3*r+1],a=t[3*i],i=t[3*i+1],o=t[3*n],t=t[3*n+1];return[new z(s,r),new z(a,i),new z(o,t)]},generateSideWallUV:function(e,t,r,i,n,s){var a=t[3*r],o=t[3*r+1],r=t[3*r+2],l=t[3*i],h=t[3*i+1],i=t[3*i+2],u=t[3*n],c=t[3*n+1],n=t[3*n+2],d=t[3*s],f=t[3*s+1],t=t[3*s+2];return Math.abs(o-h)<Math.abs(a-l)?[new z(a,1-r),new z(l,1-i),new z(u,1-n),new z(d,1-t)]:[new z(o,1-r),new z(h,1-i),new z(c,1-n),new z(f,1-t)]}};class Bu extends zh{constructor(e=1,t=0){var r=(1+Math.sqrt(5))/2;super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[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],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Bu(e.radius,e.detail)}}class Gu extends S{constructor(r=[new z(0,.5),new z(.5,0),new z(0,-.5)],i=12,n=0,s=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:r,segments:i,phiStart:n,phiLength:s},i=Math.floor(i),s=mi(s,0,2*Math.PI);const a=[],o=[],l=[],h=1/i,u=new Pe,c=new z;for(let t=0;t<=i;t++){var e=n+t*h*s,d=Math.sin(e),f=Math.cos(e);for(let e=0;e<=r.length-1;e++)u.x=r[e].x*d,u.y=r[e].y,u.z=r[e].x*f,o.push(u.x,u.y,u.z),c.x=t/i,c.y=e/(r.length-1),l.push(c.x,c.y)}for(let t=0;t<i;t++)for(let e=0;e<r.length-1;e++){const s=e+t*r.length,o=s,l=s+r.length,h=s+r.length+1,u=s+1;a.push(o,l,u),a.push(l,h,u)}if(this.setIndex(a),this.setAttribute("position",new V(o,3)),this.setAttribute("uv",new V(l,2)),this.computeVertexNormals(),s===2*Math.PI){const n=this.attributes.normal.array,s=new Pe,a=new Pe,o=new Pe,l=i*r.length*3;for(let e=0,t=0;e<r.length;e++,t+=3)s.x=n[t+0],s.y=n[t+1],s.z=n[t+2],a.x=n[l+t+0],a.y=n[l+t+1],a.z=n[l+t+2],o.addVectors(s,a).normalize(),n[t+0]=n[l+t+0]=o.x,n[t+1]=n[l+t+1]=o.y,n[t+2]=n[l+t+2]=o.z}}static fromJSON(e){return new Gu(e.points,e.segments,e.phiStart,e.phiLength)}}class Hu extends zh{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Hu(e.radius,e.detail)}}class zu extends S{constructor(e=.5,t=1,r=8,i=1,n=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:i,thetaStart:n,thetaLength:s},r=Math.max(3,r);const a=[],o=[],l=[],h=[];let u=e;var c=(t-e)/(i=Math.max(1,i)),d=new Pe,f=new z;for(let e=0;e<=i;e++){for(let e=0;e<=r;e++){const i=n+e/r*s;d.x=u*Math.cos(i),d.y=u*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),f.x=(d.x/t+1)/2,f.y=(d.y/t+1)/2,h.push(f.x,f.y)}u+=c}for(let e=0;e<i;e++){const t=e*(r+1);for(let e=0;e<r;e++){const i=e+t,n=i,s=i+r+1,o=i+r+2,l=i+1;a.push(n,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new V(o,3)),this.setAttribute("normal",new V(l,3)),this.setAttribute("uv",new V(h,2))}static fromJSON(e){return new zu(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Vu extends S{constructor(t=new vu([new z(0,.5),new z(-.5,-.5),new z(.5,-.5)]),a=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:a};const o=[],l=[],h=[],u=[];let r=0,c=0;if(!1===Array.isArray(t))i(t);else for(let e=0;e<t.length;e++)i(t[e]),this.addGroup(r,c,e),r+=c,c=0;function i(e){var r=l.length/3,e=e.extractPoints(a);let i=e.shape;var n=e.holes;!1===ku.isClockWise(i)&&(i=i.reverse());for(let e=0,t=n.length;e<t;e++){const a=n[e];!0===ku.isClockWise(a)&&(n[e]=a.reverse())}var s=ku.triangulateShape(i,n);for(let e=0,t=n.length;e<t;e++){const a=n[e];i=i.concat(a)}for(let e=0,t=i.length;e<t;e++){const a=i[e];l.push(a.x,a.y,0),h.push(0,0,1),u.push(a.x,a.y)}for(let e=0,t=s.length;e<t;e++){const a=s[e],l=a[0]+r,h=a[1]+r,u=a[2]+r;o.push(l,h,u),c+=3}}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}toJSON(){var e=super.toJSON(),r=this.parameters.shapes,i=e;if(i.shapes=[],Array.isArray(r))for(let e=0,t=r.length;e<t;e++){var n=r[e];i.shapes.push(n.uuid)}else i.shapes.push(r.uuid);return i}static fromJSON(r,i){var n=[];for(let e=0,t=r.shapes.length;e<t;e++){var s=i[r.shapes[e]];n.push(s)}return new Vu(n,r.curveSegments)}}class Wu extends S{constructor(r=1,i=32,n=16,s=0,a=2*Math.PI,o=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:r,widthSegments:i,heightSegments:n,phiStart:s,phiLength:a,thetaStart:o,thetaLength:l},i=Math.max(3,Math.floor(i)),n=Math.max(2,Math.floor(n));const h=Math.min(o+l,Math.PI);let u=0;var c=[],d=new Pe,f=new Pe,p=[],m=[],g=[],v=[];for(let e=0;e<=n;e++){var y=[],x=e/n;let t=0;0==e&&0==o?t=.5/i:e==n&&h==Math.PI&&(t=-.5/i);for(let e=0;e<=i;e++){const h=e/i;d.x=-r*Math.cos(s+h*a)*Math.sin(o+x*l),d.y=r*Math.cos(o+x*l),d.z=r*Math.sin(s+h*a)*Math.sin(o+x*l),m.push(d.x,d.y,d.z),f.copy(d).normalize(),g.push(f.x,f.y,f.z),v.push(h+t,1-x),y.push(u++)}c.push(y)}for(let t=0;t<n;t++)for(let e=0;e<i;e++){const i=c[t][e+1],a=c[t][e],l=c[t+1][e],u=c[t+1][e+1];(0!==t||0<o)&&p.push(i,a,u),(t!==n-1||h<Math.PI)&&p.push(a,l,u)}this.setIndex(p),this.setAttribute("position",new V(m,3)),this.setAttribute("normal",new V(g,3)),this.setAttribute("uv",new V(v,2))}static fromJSON(e){return new Wu(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ju extends zh{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ju(e.radius,e.detail)}}class Yu extends S{constructor(r=1,i=.4,n=8,s=6,a=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:r,tube:i,radialSegments:n,tubularSegments:s,arc:a},n=Math.floor(n),s=Math.floor(s);const o=[],l=[],h=[],u=[],c=new Pe,d=new Pe,f=new Pe;for(let t=0;t<=n;t++)for(let e=0;e<=s;e++){var p=e/s*a,m=t/n*Math.PI*2;d.x=(r+i*Math.cos(m))*Math.cos(p),d.y=(r+i*Math.cos(m))*Math.sin(p),d.z=i*Math.sin(m),l.push(d.x,d.y,d.z),c.x=r*Math.cos(p),c.y=r*Math.sin(p),f.subVectors(d,c).normalize(),h.push(f.x,f.y,f.z),u.push(e/s),u.push(t/n)}for(let t=1;t<=n;t++)for(let e=1;e<=s;e++){const n=(s+1)*t+e-1,a=(s+1)*(t-1)+e-1,l=(s+1)*(t-1)+e,h=(s+1)*t+e;o.push(n,a,h),o.push(a,l,h)}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}static fromJSON(e){return new Yu(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class $u extends S{constructor(e=1,r=.4,i=64,n=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:r,tubularSegments:i,radialSegments:n,p:s,q:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],h=[],u=[],c=new Pe,d=new Pe,f=new Pe,p=new Pe,m=new Pe,g=new Pe,v=new Pe;for(let t=0;t<=i;++t){var y=t/i*s*Math.PI*2;x(y,s,a,e,f),x(.01+y,s,a,e,p),g.subVectors(p,f),v.addVectors(p,f),m.crossVectors(g,v),v.crossVectors(m,g),m.normalize(),v.normalize();for(let e=0;e<=n;++e){const s=e/n*Math.PI*2,a=-r*Math.cos(s),p=r*Math.sin(s);c.x=f.x+(a*v.x+p*m.x),c.y=f.y+(a*v.y+p*m.y),c.z=f.z+(a*v.z+p*m.z),l.push(c.x,c.y,c.z),d.subVectors(c,f).normalize(),h.push(d.x,d.y,d.z),u.push(t/i),u.push(e/n)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),s=(n+1)*t+(e-1),a=(n+1)*t+e,l=(n+1)*(t-1)+e;o.push(i,s,l),o.push(s,a,l)}function x(e,t,r,i,n){var s=Math.cos(e),a=Math.sin(e),r=r/t*e,t=Math.cos(r);n.x=i*(2+t)*.5*s,n.y=i*(2+t)*a*.5,n.z=i*Math.sin(r)*.5}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}static fromJSON(e){return new $u(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class qu extends S{constructor(e=new du(new Pe(-1,-1,0),new Pe(-1,1,0),new Pe(1,1,0)),n=64,s=1,a=8,t=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:n,radius:s,radialSegments:a,closed:t};const o=e.computeFrenetFrames(n,t),l=(this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,new Pe),h=new Pe,r=new z;let u=new Pe;const c=[],d=[],i=[],f=[];function p(t){u=e.getPointAt(t/n,u);var r=o.normals[t],i=o.binormals[t];for(let e=0;e<=a;e++){const n=e/a*Math.PI*2,t=Math.sin(n),o=-Math.cos(n);h.x=o*r.x+t*i.x,h.y=o*r.y+t*i.y,h.z=o*r.z+t*i.z,h.normalize(),d.push(h.x,h.y,h.z),l.x=u.x+s*h.x,l.y=u.y+s*h.y,l.z=u.z+s*h.z,c.push(l.x,l.y,l.z)}}for(let e=0;e<n;e++)p(e);p(!1===t?n:0);for(let t=0;t<=n;t++)for(let e=0;e<=a;e++)r.x=t/n,r.y=e/a,i.push(r.x,r.y);for(let t=1;t<=n;t++)for(let e=1;e<=a;e++){var m=(a+1)*(t-1)+(e-1),g=(a+1)*t+(e-1),v=(a+1)*t+e,y=(a+1)*(t-1)+e;f.push(m,g,y),f.push(g,v,y)}this.setIndex(f),this.setAttribute("position",new V(c,3)),this.setAttribute("normal",new V(d,3)),this.setAttribute("uv",new V(i,2))}toJSON(){var e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new qu((new pu[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Ku extends S{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){var i=[],n=new Set,s=new Pe,a=new Pe;if(null!==e.index){var o=e.attributes.position,l=e.index;let r=e.groups;for(let e=0,t=(r=0===r.length?[{start:0,count:l.count,materialIndex:0}]:r).length;e<t;++e){var h=r[e],u=h.start;for(let t=u,e=u+h.count;t<e;t+=3)for(let e=0;e<3;e++){var c=l.getX(t+e),d=l.getX(t+(e+1)%3);s.fromBufferAttribute(o,c),a.fromBufferAttribute(o,d),!0===Xu(s,a,n)&&(i.push(s.x,s.y,s.z),i.push(a.x,a.y,a.z))}}}else{var r=e.attributes.position;for(let t=0,e=r.count/3;t<e;t++)for(let e=0;e<3;e++){var f=3*t+e,p=3*t+(e+1)%3;s.fromBufferAttribute(r,f),a.fromBufferAttribute(r,p),!0===Xu(s,a,n)&&(i.push(s.x,s.y,s.z),i.push(a.x,a.y,a.z))}}this.setAttribute("position",new V(i,3))}}}function Xu(e,t,r){var i=`${e.x},${e.y},${e.z}-${t.x},${t.y},`+t.z,t=`${t.x},${t.y},${t.z}-${e.x},${e.y},`+e.z;return!0!==r.has(i)&&!0!==r.has(t)&&(r.add(i,t),!0)}var Ju=Object.freeze({__proto__:null,BoxGeometry:ks,BoxBufferGeometry:ks,CircleGeometry:Bh,CircleBufferGeometry:Bh,ConeGeometry:Hh,ConeBufferGeometry:Hh,CylinderGeometry:Gh,CylinderBufferGeometry:Gh,DodecahedronGeometry:Vh,DodecahedronBufferGeometry:Vh,EdgesGeometry:qh,ExtrudeGeometry:Nu,ExtrudeBufferGeometry:Nu,IcosahedronGeometry:Bu,IcosahedronBufferGeometry:Bu,LatheGeometry:Gu,LatheBufferGeometry:Gu,OctahedronGeometry:Hu,OctahedronBufferGeometry:Hu,PlaneGeometry:Zs,PlaneBufferGeometry:Zs,PolyhedronGeometry:zh,PolyhedronBufferGeometry:zh,RingGeometry:zu,RingBufferGeometry:zu,ShapeGeometry:Vu,ShapeBufferGeometry:Vu,SphereGeometry:Wu,SphereBufferGeometry:Wu,TetrahedronGeometry:ju,TetrahedronBufferGeometry:ju,TorusGeometry:Yu,TorusBufferGeometry:Yu,TorusKnotGeometry:$u,TorusKnotBufferGeometry:$u,TubeGeometry:qu,TubeBufferGeometry:qu,WireframeGeometry:Ku});class Zu extends r{constructor(e){super(),this.type="ShadowMaterial",this.color=new g(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}Zu.prototype.isShadowMaterial=!0;class Qu extends r{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new g(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 g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.envMapIntensity=e.envMapIntensity,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}}Qu.prototype.isMeshStandardMaterial=!0;class ec extends Qu{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new z(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return mi(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenColor=new g(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new g(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new g(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){0<this._sheen!=0<e&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){0<this._clearcoat!=0<e&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){0<this._transmission!=0<e&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},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.ior=e.ior,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}}ec.prototype.isMeshPhysicalMaterial=!0;class tc extends r{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new g(16777215),this.specular=new g(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.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}}tc.prototype.isMeshPhongMaterial=!0;class rc extends r{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new g(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(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.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}}rc.prototype.isMeshToonMaterial=!0;class ic extends r{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}ic.prototype.isMeshNormalMaterial=!0;class nc extends r{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new g(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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}}nc.prototype.isMeshLambertMaterial=!0;class sc extends r{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new g(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,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}}sc.prototype.isMeshMatcapMaterial=!0;class ac extends y{constructor(e){super(),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}}ac.prototype.isLineDashedMaterial=!0;var oc=Object.freeze({__proto__:null,ShadowMaterial:Zu,SpriteMaterial:Fl,RawShaderMaterial:oa,ShaderMaterial:Us,PointsMaterial:Lh,MeshPhysicalMaterial:ec,MeshStandardMaterial:Qu,MeshPhongMaterial:tc,MeshToonMaterial:rc,MeshNormalMaterial:ic,MeshLambertMaterial:nc,MeshDepthMaterial:yl,MeshDistanceMaterial:xl,MeshBasicMaterial:Qn,MeshMatcapMaterial:sc,LineDashedMaterial:ac,LineBasicMaterial:y,Material:r});const p={arraySlice:function(e,t,r){return p.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==r?r:e.length)):e.slice(t,r)},convertArray:function(e,t,r){return!e||!r&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(r){var t=r.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort(function(e,t){return r[e]-r[t]}),i},sortedArray:function(r,i,n){const s=r.length,a=new r.constructor(s);for(let e=0,t=0;t!==s;++e){const s=n[e]*i;for(let e=0;e!==i;++e)a[t++]=r[s+e]}return a},flattenJSON:function(t,r,i,n){let s=1,a=t[0];for(;void 0!==a&&void 0===a[n];)a=t[s++];if(void 0!==a){let e=a[n];if(void 0!==e)if(Array.isArray(e))for(;void 0!==(e=a[n])&&(r.push(a.time),i.push.apply(i,e)),void 0!==(a=t[s++]););else if(void 0!==e.toArray)for(;void 0!==(e=a[n])&&(r.push(a.time),e.toArray(i,i.length)),void 0!==(a=t[s++]););else for(;void 0!==(e=a[n])&&(r.push(a.time),i.push(e)),void 0!==(a=t[s++]););}},subclip:function(e,r,i,n,s=30){const a=e.clone();a.name=r;var t=[];for(let e=0;e<a.tracks.length;++e){const r=a.tracks[e],o=r.getValueSize(),l=[],h=[];for(let t=0;t<r.times.length;++t){const a=r.times[t]*s;if(!(a<i||a>=n)){l.push(r.times[t]);for(let e=0;e<o;++e)h.push(r.values[t*o+e])}}0!==l.length&&(r.times=p.convertArray(l,r.times.constructor),r.values=p.convertArray(h,r.values.constructor),t.push(r))}a.tracks=t;let o=1/0;for(let e=0;e<a.tracks.length;++e)o>a.tracks[e].times[0]&&(o=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*o);return a.resetDuration(),a},makeClipAdditive:function(i,n=0,s=i,a=30){const o=s.tracks.length,l=n/(a=a<=0?30:a);for(let e=0;e<o;++e){const a=s.tracks[e],o=a.ValueTypeName;if("bool"!==o&&"string"!==o){var h=i.tracks.find(function(e){return e.name===a.name&&e.ValueTypeName===o});if(void 0!==h){let e=0;var u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(e=u/3);let t=0;var c=h.getValueSize(),d=(h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(t=c/3),a.times.length-1);let r;if(l<=a.times[0]){const i=e,n=u-e;r=p.arraySlice(a.values,i,n)}else if(l>=a.times[d]){const i=d*u+e,n=i+u-e;r=p.arraySlice(a.values,i,n)}else{const i=a.createInterpolant(),n=e,s=u-e;i.evaluate(l),r=p.arraySlice(i.resultBuffer,n,s)}"quaternion"===o&&(new ki).fromArray(r).normalize().conjugate().toArray(r);var f=h.times.length;for(let e=0;e<f;++e){const n=e*c+t;if("quaternion"===o)ki.multiplyQuaternionsFlat(h.values,n,r,0,h.values,n);else{const i=c-2*t;for(let e=0;e<i;++e)h.values[n+e]-=r[e]}}}}}return i.blendMode=br,i}};class lc{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){var r=this.parameterPositions;let i=this._cachedIndex,n=r[i],s=r[i-1];e:{t:{let e;r:{i:if(!(t<n)){for(var a=i+2;;){if(void 0===n){if(t<s)break i;return i=r.length,this._cachedIndex=i,this.afterEnd_(i-1,t,s)}if(i===a)break;if(s=n,t<(n=r[++i]))break t}e=r.length;break r}if(t>=s)break e;var o=r[1];t<o&&(i=2,s=o);for(var l=i-2;;){if(void 0===s)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===l)break;if(n=s,t>=(s=r[--i-1]))break t}e=i,i=0}for(;i<e;){const n=i+e>>>1;t<r[n]?e=n:i=1+n}if(n=r[i],void 0===(s=r[i-1]))return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=r.length,this._cachedIndex=i,this.afterEnd_(i-1,s,t)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){var t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i;for(let e=0;e!==i;++e)t[e]=r[n+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}lc.prototype.beforeStart_=lc.prototype.copySampleValue_,lc.prototype.afterEnd_=lc.prototype.copySampleValue_;class hc extends lc{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vr,endingEnd:vr}}intervalChanged_(e,t,r){var i=this.parameterPositions;let n=e-2,s=e+1,a=i[n],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case yr:n=e,a=2*t-r;break;case xr:n=i.length-2,a=t+i[n]-i[n+1];break;default:n=e,a=r}if(void 0===o)switch(this.getSettings_().endingEnd){case yr:s=e,o=2*r-t;break;case xr:s=1,o=r+i[1]-i[0];break;default:s=e-1,o=t}var l=.5*(r-t),h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-r),this._offsetPrev=n*h,this._offsetNext=s*h}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,e=this._weightPrev,c=this._weightNext,r=(r-t)/(i-t),i=r*r,t=i*r,d=-e*t+2*e*i-e*r,f=(1+e)*t+(-1.5-2*e)*i+(-.5+e)*r+1,p=(-1-c)*t+(1.5+c)*i+.5*r,m=c*t-c*i;for(let e=0;e!==a;++e)n[e]=d*s[h+e]+f*s[l+e]+p*s[o+e]+m*s[u+e];return n}}class uc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(r-t)/(i-t),u=1-h;for(let e=0;e!==a;++e)n[e]=s[l+e]*u+s[o+e]*h;return n}}class cc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class dc{constructor(e,t,r,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=p.convertArray(t,this.TimeBufferType),this.values=p.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:p.convertArray(e.times,Array),values:p.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(r.interpolation=t)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new cc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hc(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case pr:t=this.InterpolantFactoryMethodDiscrete;break;case mr:t=this.InterpolantFactoryMethodLinear;break;case gr:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrack:",t)}else this.createInterpolant=t;return this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pr;case this.InterpolantFactoryMethodLinear:return mr;case this.InterpolantFactoryMethodSmooth:return gr}}getValueSize(){return this.values.length/this.times.length}shift(r){if(0!==r){var i=this.times;for(let e=0,t=i.length;e!==t;++e)i[e]+=r}return this}scale(r){if(1!==r){var i=this.times;for(let e=0,t=i.length;e!==t;++e)i[e]*=r}return this}trim(e,t){var r=this.times,i=r.length;let n=0,s=i-1;for(;n!==i&&r[n]<e;)++n;for(;-1!==s&&r[s]>t;)--s;if(++s,0!==n||s!==i){n>=s&&(s=Math.max(s,1),n=s-1);const e=this.getValueSize();this.times=p.arraySlice(r,n,s),this.values=p.arraySlice(this.values,n*e,s*e)}return this}validate(){let r=!0;var e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),r=!1);const i=this.times,n=this.values,t=i.length;0===t&&(console.error("THREE.KeyframeTrack: Track is empty.",this),r=!1);let s=null;for(let e=0;e!==t;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),r=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,s),r=!1;break}s=n}if(void 0!==n&&p.isTypedArray(n))for(let e=0,t=n.length;e!==t;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),r=!1;break}}return r}optimize(){const r=p.arraySlice(this.times),i=p.arraySlice(this.values),n=this.getValueSize(),s=this.getInterpolation()===gr,a=r.length-1;let o=1;for(let e=1;e<a;++e){let t=!1;var l=r[e];if(l!==r[e+1]&&(1!==e||l!==r[0]))if(s)t=!0;else{const r=e*n,s=r-n,o=r+n;for(let e=0;e!==n;++e){const n=i[r+e];if(n!==i[s+e]||n!==i[o+e]){t=!0;break}}}if(t){if(e!==o){r[o]=r[e];const s=e*n,a=o*n;for(let e=0;e!==n;++e)i[a+e]=i[s+e]}++o}}if(0<a){r[o]=r[a];for(let e=a*n,t=o*n,r=0;r!==n;++r)i[t+r]=i[e+r];++o}return o!==r.length?(this.times=p.arraySlice(r,0,o),this.values=p.arraySlice(i,0,o*n)):(this.times=r,this.values=i),this}clone(){var e=p.arraySlice(this.times,0),t=p.arraySlice(this.values,0),e=new this.constructor(this.name,e,t);return e.createInterpolant=this.createInterpolant,e}}dc.prototype.TimeBufferType=Float32Array,dc.prototype.ValueBufferType=Float32Array,dc.prototype.DefaultInterpolation=mr;class fc extends dc{}fc.prototype.ValueTypeName="bool",fc.prototype.ValueBufferType=Array,fc.prototype.DefaultInterpolation=pr,fc.prototype.InterpolantFactoryMethodLinear=void 0,fc.prototype.InterpolantFactoryMethodSmooth=void 0;class pc extends dc{}pc.prototype.ValueTypeName="color";class mc extends dc{}mc.prototype.ValueTypeName="number";class gc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(r-t)/(i-t);let l=e*a;for(var h=l+a;l!==h;l+=4)ki.slerpFlat(n,0,s,l-a,s,l,o);return n}}class vc extends dc{InterpolantFactoryMethodLinear(e){return new gc(this.times,this.values,this.getValueSize(),e)}}vc.prototype.ValueTypeName="quaternion",vc.prototype.DefaultInterpolation=mr,vc.prototype.InterpolantFactoryMethodSmooth=void 0;class yc extends dc{}yc.prototype.ValueTypeName="string",yc.prototype.ValueBufferType=Array,yc.prototype.DefaultInterpolation=pr,yc.prototype.InterpolantFactoryMethodLinear=void 0,yc.prototype.InterpolantFactoryMethodSmooth=void 0;class xc extends dc{}class _c{constructor(e,t=-1,r,i=_r){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=pi(),this.duration<0&&this.resetDuration()}static parse(e){var r=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,t=i.length;e!==t;++e)r.push(function(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return mc;case"vector":case"vector2":case"vector3":case"vector4":return xc;case"color":return pc;case"quaternion":return vc;case"bool":case"boolean":return fc;case"string":return yc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],r=[];p.flattenJSON(e.keys,t,r,"value"),e.times=t,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}(i[e]).scale(n));var t=new this(e.name,e.duration,r,e.blendMode);return t.uuid=e.uuid,t}static toJSON(e){var r=[],i=e.tracks,e={name:e.name,duration:e.duration,tracks:r,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,t=i.length;e!==t;++e)r.push(dc.toJSON(i[e]));return e}static CreateFromMorphTargetSequence(e,i,n,s){var a=i.length,o=[];for(let r=0;r<a;r++){let e=[],t=[];e.push((r+a-1)%a,r,(r+1)%a),t.push(0,1,0);var l=p.getKeyframeOrder(e);e=p.sortedArray(e,1,l),t=p.sortedArray(t,1,l),s||0!==e[0]||(e.push(a),t.push(t[0])),o.push(new mc(".morphTargetInfluences["+i[r].name+"]",e,t).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const t=e;r=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<r.length;e++)if(r[e].name===t)return r[e];return null}static CreateClipsFromMorphTargetSequences(r,e,i){var n={},s=/^([\w-]*?)([\d]+)$/;for(let e=0,t=r.length;e<t;e++){const i=r[e],a=i.name.match(s);if(a&&1<a.length){const r=a[1];let e=n[r];e||(n[r]=e=[]),e.push(i)}}const a=[];for(const r in n)a.push(this.CreateFromMorphTargetSequence(r,n[r],e,i));return a}static parseAnimation(r,t){if(!r)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,r,i,n){var s,a;0!==r.length&&(s=[],a=[],p.flattenJSON(r,s,a,i),0!==s.length)&&n.push(new e(t,s,a))},n=[],s=r.name||"default",a=r.fps||30,e=r.blendMode;let o=r.length||-1;var l=r.hierarchy||[];for(let e=0;e<l.length;e++){const s=l[e].keys;if(s&&0!==s.length)if(s[0].morphTargets){const r={};let t;for(t=0;t<s.length;t++)if(s[t].morphTargets)for(let e=0;e<s[t].morphTargets.length;e++)r[s[t].morphTargets[e]]=-1;for(const i in r){const r=[],a=[];for(let e=0;e!==s[t].morphTargets.length;++e){const n=s[t];r.push(n.time),a.push(n.morphTarget===i?1:0)}n.push(new mc(".morphTargetInfluence["+i+"]",r,a))}o=r.length*(a||1)}else{const a=".bones["+t[e].name+"]";i(xc,a+".position",s,"pos",n),i(vc,a+".quaternion",s,"rot",n),i(xc,a+".scale",s,"scl",n)}}return 0===n.length?null:new this(s,o,n,e)}resetDuration(){let r=0;for(let e=0,t=this.tracks.length;e!==t;++e){var i=this.tracks[e];r=Math.max(r,i.times[i.times.length-1])}return this.duration=r,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){var t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}const bc={enabled:!(xc.prototype.ValueTypeName="vector"),files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class Tc{constructor(e,t,r){const i=this;let n=!1,s=0,a=0,o=void 0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){a++,!1===n&&void 0!==i.onStart&&i.onStart(e,s,a),n=!0},this.itemEnd=function(e){s++,void 0!==i.onProgress&&i.onProgress(e,s,a),s===a&&(n=!1,void 0!==i.onLoad)&&i.onLoad()},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){e=l.indexOf(e);return-1!==e&&l.splice(e,2),this},this.getHandler=function(r){for(let e=0,t=l.length;e<t;e+=2){var i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(r))return n}return null}}}const Sc=new Tc;class Ec{constructor(e){this.manager=void 0!==e?e:Sc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(r,i){const n=this;return new Promise(function(e,t){n.load(r,e,i,t)})}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}}const wc={};class Mc extends Ec{constructor(e){super(e)}load(l,e,t,r){void 0===l&&(l=""),void 0!==this.path&&(l=this.path+l),l=this.manager.resolveURL(l);const i=bc.get(l);if(void 0!==i)return this.manager.itemStart(l),setTimeout(()=>{e&&e(i),this.manager.itemEnd(l)},0),i;void 0!==wc[l]?wc[l].push({onLoad:e,onProgress:t,onError:r}):(wc[l]=[],wc[l].push({onLoad:e,onProgress:t,onError:r}),t=new Request(l,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),fetch(t).then(e=>{if(200!==e.status&&0!==e.status)throw Error(`fetch for "${e.url}" responded with ${e.status}: `+e.statusText);{0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const s=wc[l],r=e.body.getReader(),t=e.headers.get("Content-Length"),a=t?parseInt(t):0,o=0!==a;let n=0;return new ReadableStream({start(t){!function i(){r.read().then(({done:r,value:e})=>{if(r)t.close();else{n+=e.byteLength;const r=new ProgressEvent("progress",{lengthComputable:o,loaded:n,total:a});for(let e=0,t=s.length;e<t;e++){const i=s[e];i.onProgress&&i.onProgress(r)}t.enqueue(e),i()}})}()}})}}).then(e=>{var t=new Response(e);switch(this.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(e=>(new DOMParser).parseFromString(e,this.mimeType));case"json":return t.json();default:return t.text()}}).then(r=>{bc.add(l,r);var i=wc[l];delete wc[l];for(let e=0,t=i.length;e<t;e++){var n=i[e];n.onLoad&&n.onLoad(r)}this.manager.itemEnd(l)}).catch(r=>{var i=wc[l];delete wc[l];for(let e=0,t=i.length;e<t;e++){var n=i[e];n.onError&&n.onError(r)}this.manager.itemError(l),this.manager.itemEnd(l)}),this.manager.itemStart(l))}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ac extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(t){var r=[];for(let e=0;e<t.length;e++){var i=_c.parse(t[e]);r.push(i)}return r}}class Lc extends Ec{constructor(e){super(e)}load(r,i,n,s){const a=this,o=[],l=new Fh,h=new Mc(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setWithCredentials(a.withCredentials);let u=0;if(Array.isArray(r))for(let e=0,t=r.length;e<t;++e)!function(t){h.load(r[t],function(e){e=a.parse(e,!0);o[t]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(u+=1)&&(1===e.mipmapCount&&(l.minFilter=U),l.image=o,l.format=e.format,l.needsUpdate=!0,i)&&i(l)},n,s)}(e);else h.load(r,function(e){var r=a.parse(e,!0);if(r.isCubemap){const e=r.mipmaps.length/r.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<r.mipmapCount;e++)o[t].mipmaps.push(r.mipmaps[t*r.mipmapCount+e]),o[t].format=r.format,o[t].width=r.width,o[t].height=r.height}l.image=o}else l.image.width=r.width,l.image.height=r.height,l.mipmaps=r.mipmaps;1===r.mipmapCount&&(l.minFilter=U),l.format=r.format,l.needsUpdate=!0,i&&i(l)},n,s);return l}}class Rc extends Ec{constructor(e){super(e)}load(t,e,r,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,s=bc.get(t);if(void 0!==s)return n.manager.itemStart(t),setTimeout(function(){e&&e(s),n.manager.itemEnd(t)},0),s;const a=wi("img");function o(){h(),bc.add(t,this),e&&e(this),n.manager.itemEnd(t)}function l(e){h(),i&&i(e),n.manager.itemError(t),n.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(t),a.src=t,a}}class Cc extends Ec{constructor(e){super(e)}load(r,i,e,n){const s=new Hs,a=new Rc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;for(let e=0;e<r.length;++e)!function(t){a.load(r[t],function(e){s.images[t]=e,6===++o&&(s.needsUpdate=!0,i)&&i(s)},void 0,n)}(e);return s}}class Dc extends Ec{constructor(e){super(e)}load(e,t,r,i){const n=this,s=new lh,a=new Mc(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(n.withCredentials),a.load(e,function(e){e=n.parse(e);e&&(void 0!==e.image?s.image=e.image:void 0!==e.data&&(s.image.width=e.width,s.image.height=e.height,s.image.data=e.data),s.wrapS=void 0!==e.wrapS?e.wrapS:Le,s.wrapT=void 0!==e.wrapT?e.wrapT:Le,s.magFilter=void 0!==e.magFilter?e.magFilter:U,s.minFilter=void 0!==e.minFilter?e.minFilter:U,s.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.encoding&&(s.encoding=e.encoding),void 0!==e.flipY&&(s.flipY=e.flipY),void 0!==e.format&&(s.format=e.format),void 0!==e.type&&(s.type=e.type),void 0!==e.mipmaps&&(s.mipmaps=e.mipmaps,s.minFilter=Ze),1===e.mipmapCount&&(s.minFilter=U),void 0!==e.generateMipmaps&&(s.generateMipmaps=e.generateMipmaps),s.needsUpdate=!0,t)&&t(s,e)},r,i),s}}class Ic extends Ec{constructor(e){super(e)}load(e,t,r,i){const n=new u,s=new Rc(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){n.image=e,n.needsUpdate=!0,void 0!==t&&t(n)},r,i),n}}class Pc extends c{constructor(e,t=1){super(),this.type="Light",this.color=new g(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){e=super.toJSON(e);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}Pc.prototype.isLight=!0;class kc extends Pc{constructor(e,t,r){super(e,r),this.type="HemisphereLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.groundColor=new g(t)}copy(e){return Pc.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}kc.prototype.isHemisphereLight=!0;const Oc=new ke,Fc=new Pe,Nc=new Pe;class Uc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new z(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ks,this._frameExtents=new z(1,1),this._viewportCount=1,this._viewports=[new Ie(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){var t=this.camera,r=this.matrix;Fc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Fc),Nc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Nc),t.updateMatrixWorld(),Oc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Oc),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(t.projectionMatrix),r.multiply(t.matrixWorldInverse)}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(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Bc extends Uc{constructor(){super(new N(50,1,.5,500)),this.focus=1}updateMatrices(e){var t=this.camera,r=2*di*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Bc.prototype.isSpotLightShadow=!0;class Gc extends Pc{constructor(e,t,r=0,i=Math.PI/3,n=0,s=1){super(e,t),this.type="SpotLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,this.distance=r,this.angle=i,this.penumbra=n,this.decay=s,this.shadow=new Bc}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),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}}Gc.prototype.isSpotLight=!0;const Hc=new ke,zc=new Pe,Vc=new Pe;class Wc extends Uc{constructor(){super(new N(90,1,.5,500)),this._frameExtents=new z(4,2),this._viewportCount=6,this._viewports=[new Ie(2,1,1,1),new Ie(0,1,1,1),new Ie(3,1,1,1),new Ie(1,1,1,1),new Ie(3,0,1,1),new Ie(1,0,1,1)],this._cubeDirections=[new Pe(1,0,0),new Pe(-1,0,0),new Pe(0,0,1),new Pe(0,0,-1),new Pe(0,1,0),new Pe(0,-1,0)],this._cubeUps=[new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,0,1),new Pe(0,0,-1)]}updateMatrices(e,t=0){var r=this.camera,i=this.matrix,n=e.distance||r.far;n!==r.far&&(r.far=n,r.updateProjectionMatrix()),zc.setFromMatrixPosition(e.matrixWorld),r.position.copy(zc),Vc.copy(r.position),Vc.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Vc),r.updateMatrixWorld(),i.makeTranslation(-zc.x,-zc.y,-zc.z),Hc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hc)}}Wc.prototype.isPointLightShadow=!0;class jc extends Pc{constructor(e,t,r=0,i=1){super(e,t),this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Wc}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}jc.prototype.isPointLight=!0;class Yc extends Uc{constructor(){super(new aa(-5,5,5,-5,.5,500))}}Yc.prototype.isDirectionalLightShadow=!0;class $c extends Pc{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,this.shadow=new Yc}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}$c.prototype.isDirectionalLight=!0;class qc extends Pc{constructor(e,t){super(e,t),this.type="AmbientLight"}}qc.prototype.isAmbientLight=!0;class Kc extends Pc{constructor(e,t,r=10,i=10){super(e,t),this.type="RectAreaLight",this.width=r,this.height=i}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){e=super.toJSON(e);return e.object.width=this.width,e.object.height=this.height,e}}Kc.prototype.isRectAreaLight=!0;class Xc{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Pe)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){var r=e.x,i=e.y,e=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.282095),t.addScaledVector(n[1],.488603*i),t.addScaledVector(n[2],.488603*e),t.addScaledVector(n[3],.488603*r),t.addScaledVector(n[4],r*i*1.092548),t.addScaledVector(n[5],i*e*1.092548),t.addScaledVector(n[6],.315392*(3*e*e-1)),t.addScaledVector(n[7],r*e*1.092548),t.addScaledVector(n[8],.546274*(r*r-i*i)),t}getIrradianceAt(e,t){var r=e.x,i=e.y,e=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.886227),t.addScaledVector(n[1],1.023328*i),t.addScaledVector(n[2],1.023328*e),t.addScaledVector(n[3],1.023328*r),t.addScaledVector(n[4],.858086*r*i),t.addScaledVector(n[5],.858086*i*e),t.addScaledVector(n[6],.743125*e*e-.247708),t.addScaledVector(n[7],.858086*r*e),t.addScaledVector(n[8],.429043*(r*r-i*i)),t}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,r){for(let e=0;e<9;e++)this.coefficients[e].addScaledVector(t.coefficients[e],r);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,r){for(let e=0;e<9;e++)this.coefficients[e].lerp(t.coefficients[e],r);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,r=0){var i=this.coefficients;for(let e=0;e<9;e++)i[e].fromArray(t,r+3*e);return this}toArray(t=[],r=0){var i=this.coefficients;for(let e=0;e<9;e++)i[e].toArray(t,r+3*e);return t}static getBasisAt(e,t){var r=e.x,i=e.y,e=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*e,t[3]=.488603*r,t[4]=1.092548*r*i,t[5]=1.092548*i*e,t[6]=.315392*(3*e*e-1),t[7]=1.092548*r*e,t[8]=.546274*(r*r-i*i)}}Xc.prototype.isSphericalHarmonics3=!0;class Jc extends Pc{constructor(e=new Xc,t=1){super(void 0,t),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){e=super.toJSON(e);return e.object.sh=this.sh.toArray(),e}}Jc.prototype.isLightProbe=!0;class Zc extends Ec{constructor(e){super(e),this.textures={}}load(t,r,e,i){const n=this,s=new Mc(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(t){const r=this.textures;function e(e){return void 0===r[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),r[e]}var i=new oc[t.type];if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new g).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.format&&(i.format=t.format),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),1!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=0<t.vertexColors:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const r in t.uniforms){var n=t.uniforms[r];switch(i.uniforms[r]={},n.type){case"t":i.uniforms[r].value=e(n.value);break;case"c":i.uniforms[r].value=(new g).setHex(n.value);break;case"v2":i.uniforms[r].value=(new z).fromArray(n.value);break;case"v3":i.uniforms[r].value=(new Pe).fromArray(n.value);break;case"v4":i.uniforms[r].value=(new Ie).fromArray(n.value);break;case"m3":i.uniforms[r].value=(new v).fromArray(n.value);break;case"m4":i.uniforms[r].value=(new ke).fromArray(n.value);break;default:i.uniforms[r].value=n.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const r in t.extensions)i.extensions[r]=t.extensions[r];if(void 0!==t.shading&&(i.flatShading=1===t.shading),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=e(t.map)),void 0!==t.matcap&&(i.matcap=e(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=e(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=e(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new z).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=e(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=e(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=e(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=e(t.envMap)),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=e(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=e(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=e(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=e(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new z).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(i.transmissionMap=e(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=e(t.thicknessMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=e(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=e(t.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}}class Qc{static decodeText(r){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);let i="";for(let e=0,t=r.length;e<t;e++)i+=String.fromCharCode(r[e]);try{return decodeURIComponent(escape(i))}catch(r){return i}}static extractUrlBase(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===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)}}class ed extends S{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){var e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}ed.prototype.isInstancedBufferGeometry=!0;class td extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(r){const n={},s={};function i(e,t){var r,i;return void 0!==n[t]?n[t]:(r=e.interleavedBuffers[t],e=e,i=r.buffer,i=void 0!==s[i]?s[i]:(e=e.arrayBuffers[i],e=new Uint32Array(e).buffer,s[i]=e),e=Ei(r.type,i),(i=new kl(e,r.stride)).uuid=r.uuid,n[t]=i)}const a=new(r.isInstancedBufferGeometry?ed:S),o=r.data.index;if(void 0!==o){const r=Ei(o.type,o.array);a.setIndex(new w(r,1))}var t=r.data.attributes;for(const n in t){const s=t[n];let e;if(s.isInterleavedBufferAttribute){const n=i(r.data,s.data);e=new Ol(n,s.itemSize,s.offset,s.normalized)}else{const r=Ei(s.type,s.array);e=new(s.isInstancedBufferAttribute?dh:w)(r,s.itemSize,s.normalized)}void 0!==s.name&&(e.name=s.name),void 0!==s.usage&&e.setUsage(s.usage),void 0!==s.updateRange&&(e.updateRange.offset=s.updateRange.offset,e.updateRange.count=s.updateRange.count),a.setAttribute(n,e)}var e=r.data.morphAttributes;if(e)for(const n in e){const s=e[n],o=[];for(let t=0,e=s.length;t<e;t++){const a=s[t];let e;if(a.isInterleavedBufferAttribute){const n=i(r.data,a.data);e=new Ol(n,a.itemSize,a.offset,a.normalized)}else{const r=Ei(a.type,a.array);e=new w(r,a.itemSize,a.normalized)}void 0!==a.name&&(e.name=a.name),o.push(e)}a.morphAttributes[n]=o}r.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);var l=r.data.groups||r.data.drawcalls||r.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const n=l[e];a.addGroup(n.start,n.count,n.materialIndex)}var h=r.data.boundingSphere;if(void 0!==h){const r=new Pe;void 0!==h.center&&r.fromArray(h.center),a.boundingSphere=new rn(r,h.radius)}return r.name&&(a.name=r.name),r.userData&&(a.userData=r.userData),a}}class rd extends Ec{constructor(e){super(e)}load(r,i,e,n){const s=this,t=""===this.path?Qc.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||t;var a=new Mc(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(r,function(e){let t=null;try{t=JSON.parse(e)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+r+".",e.message)}e=t.metadata;void 0!==e&&void 0!==e.type&&"geometry"!==e.type.toLowerCase()?s.parse(t,i):console.error("THREE.ObjectLoader: Can't load "+r)},e,n)}async loadAsync(e,t){var r=""===this.path?Qc.extractUrlBase(e):this.path,r=(this.resourcePath=this.resourcePath||r,new Mc(this.manager)),r=(r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),await r.loadAsync(e,t)),t=JSON.parse(r),r=t.metadata;if(void 0===r||void 0===r.type||"geometry"===r.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return this.parseAsync(t)}parse(e,t){const r=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),s=this.parseImages(e.images,function(){void 0!==t&&t(l)}),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,n,o,a,r),h=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,h),void 0!==t){let e=!1;for(const t in s)if(s[t]instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){var t=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,r),i=await this.parseImagesAsync(e.images),i=this.parseTextures(e.textures,i),n=this.parseMaterials(e.materials,i),r=this.parseObject(e.object,r,n,i,t),n=this.parseSkeletons(e.skeletons,r);return this.bindSkeletons(r,n),r}parseShapes(r){var i={};if(void 0!==r)for(let e=0,t=r.length;e<t;e++){var n=(new vu).fromJSON(r[e]);i[n.uuid]=n}return i}parseSkeletons(r,e){const i={},n={};if(e.traverse(function(e){e.isBone&&(n[e.uuid]=e)}),void 0!==r)for(let e=0,t=r.length;e<t;e++){var s=(new ch).fromJSON(r[e],n);i[s.uuid]=s}return i}parseGeometries(r,i){var n={};if(void 0!==r){var s=new td;for(let t=0,e=r.length;t<e;t++){let e;var a=r[t];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":e=s.parse(a);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:a.type in Ju?e=Ju[a.type].fromJSON(a,i):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}e.uuid=a.uuid,void 0!==a.name&&(e.name=a.name),!0===e.isBufferGeometry&&void 0!==a.userData&&(e.userData=a.userData),n[a.uuid]=e}}return n}parseMaterials(r,e){const i={},n={};if(void 0!==r){var s=new Zc;s.setTextures(e);for(let e=0,t=r.length;e<t;e++){var a=r[e];if("MultiMaterial"===a.type){const r=[];for(let e=0;e<a.materials.length;e++){const n=a.materials[e];void 0===i[n.uuid]&&(i[n.uuid]=s.parse(n)),r.push(i[n.uuid])}n[a.uuid]=r}else void 0===i[a.uuid]&&(i[a.uuid]=s.parse(a)),n[a.uuid]=i[a.uuid]}}return n}parseAnimations(t){var r={};if(void 0!==t)for(let e=0;e<t.length;e++){var i=t[e],i=_c.parse(i);r[i.uuid]=i}return r}parseImages(r,i){const n=this,s={};let a;function o(e){var t,r;return"string"==typeof e?(r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:n.resourcePath+t,n.manager.itemStart(r),a.load(r,function(){n.manager.itemEnd(r)},void 0,function(){n.manager.itemError(r),n.manager.itemEnd(r)})):e.data?{data:Ei(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==r&&0<r.length){const n=new Tc(i);(a=new Rc(n)).setCrossOrigin(this.crossOrigin);for(let e=0,t=r.length;e<t;e++){const n=r[e],a=n.url;if(Array.isArray(a)){s[n.uuid]=[];for(let e=0,t=a.length;e<t;e++){const i=o(a[e]);null!==i&&(i instanceof HTMLImageElement?s[n.uuid].push(i):s[n.uuid].push(new lh(i.data,i.width,i.height)))}}else{const r=o(n.url);null!==r&&(s[n.uuid]=r)}}}return s}async parseImagesAsync(r){const i=this,n={};let s;async function a(e){var t;return"string"==typeof e?(t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:i.resourcePath+t,s.loadAsync(t)):e.data?{data:Ei(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==r&&0<r.length){(s=new Rc(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,t=r.length;e<t;e++){const s=r[e],o=s.url;if(Array.isArray(o)){n[s.uuid]=[];for(let e=0,t=o.length;e<t;e++){const i=o[e],l=await a(i);null!==l&&(l instanceof HTMLImageElement?n[s.uuid].push(l):n[s.uuid].push(new lh(l.data,l.width,l.height)))}}else{const r=await a(s.url);null!==r&&(n[s.uuid]=r)}}}return n}parseTextures(r,i){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var s={};if(void 0!==r)for(let t=0,e=r.length;t<e;t++){var a=r[t];let e;void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===i[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);var o=i[a.image];Array.isArray(o)?(e=new Hs(o),6===o.length&&(e.needsUpdate=!0)):(e=o&&o.data?new lh(o.data,o.width,o.height):new u(o),o&&(e.needsUpdate=!0)),e.uuid=a.uuid,void 0!==a.name&&(e.name=a.name),void 0!==a.mapping&&(e.mapping=n(a.mapping,id)),void 0!==a.offset&&e.offset.fromArray(a.offset),void 0!==a.repeat&&e.repeat.fromArray(a.repeat),void 0!==a.center&&e.center.fromArray(a.center),void 0!==a.rotation&&(e.rotation=a.rotation),void 0!==a.wrap&&(e.wrapS=n(a.wrap[0],nd),e.wrapT=n(a.wrap[1],nd)),void 0!==a.format&&(e.format=a.format),void 0!==a.type&&(e.type=a.type),void 0!==a.encoding&&(e.encoding=a.encoding),void 0!==a.minFilter&&(e.minFilter=n(a.minFilter,sd)),void 0!==a.magFilter&&(e.magFilter=n(a.magFilter,sd)),void 0!==a.anisotropy&&(e.anisotropy=a.anisotropy),void 0!==a.flipY&&(e.flipY=a.flipY),void 0!==a.premultiplyAlpha&&(e.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(e.unpackAlignment=a.unpackAlignment),void 0!==a.userData&&(e.userData=a.userData),s[a.uuid]=e}return s}parseObject(e,t,s,r,i){let n,a,o;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function h(r){if(void 0!==r){if(Array.isArray(r)){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e];void 0===s[n]&&console.warn("THREE.ObjectLoader: Undefined material",n),i.push(s[n])}return i}return void 0===s[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),s[r]}}function u(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":n=new Pl,void 0!==e.background&&(Number.isInteger(e.background)?n.background=new g(e.background):n.background=u(e.background)),void 0!==e.environment&&(n.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?n.fog=new Il(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(n.fog=new Dl(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":n=new N(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(n.focus=e.focus),void 0!==e.zoom&&(n.zoom=e.zoom),void 0!==e.filmGauge&&(n.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(n.filmOffset=e.filmOffset),void 0!==e.view&&(n.view=Object.assign({},e.view));break;case"OrthographicCamera":n=new aa(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(n.zoom=e.zoom),void 0!==e.view&&(n.view=Object.assign({},e.view));break;case"AmbientLight":n=new qc(e.color,e.intensity);break;case"DirectionalLight":n=new $c(e.color,e.intensity);break;case"PointLight":n=new jc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":n=new Kc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":n=new Gc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":n=new kc(e.color,e.groundColor,e.intensity);break;case"LightProbe":n=(new Jc).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),o=h(e.material),n=new ah(a,o),void 0!==e.bindMode&&(n.bindMode=e.bindMode),void 0!==e.bindMatrix&&n.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(n.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),o=h(e.material),n=new E(a,o);break;case"InstancedMesh":a=l(e.geometry),o=h(e.material);const t=e.count,s=e.instanceMatrix,r=e.instanceColor;(n=new vh(a,o,t)).instanceMatrix=new dh(new Float32Array(s.array),16),void 0!==r&&(n.instanceColor=new dh(new Float32Array(r.array),r.itemSize));break;case"LOD":n=new eh;break;case"Line":n=new Sh(l(e.geometry),h(e.material));break;case"LineLoop":n=new Ah(l(e.geometry),h(e.material));break;case"LineSegments":n=new Mh(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":n=new Ph(l(e.geometry),h(e.material));break;case"Sprite":n=new Xl(h(e.material));break;case"Group":n=new wl;break;case"Bone":n=new oh;break;default:n=new c}if(n.uuid=e.uuid,void 0!==e.name&&(n.name=e.name),void 0!==e.matrix?(n.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==e.position&&n.position.fromArray(e.position),void 0!==e.rotation&&n.rotation.fromArray(e.rotation),void 0!==e.quaternion&&n.quaternion.fromArray(e.quaternion),void 0!==e.scale&&n.scale.fromArray(e.scale)),void 0!==e.castShadow&&(n.castShadow=e.castShadow),void 0!==e.receiveShadow&&(n.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(n.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(n.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(n.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&n.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera)&&(n.shadow.camera=this.parseObject(e.shadow.camera)),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.frustumCulled&&(n.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(n.renderOrder=e.renderOrder),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.layers&&(n.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)n.add(this.parseObject(a[e],t,s,r,i))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const s=t[e];n.animations.push(i[s])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(n.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const s=t[e],r=n.getObjectByProperty("uuid",s.object);void 0!==r&&n.addLevel(r,s.distance)}}return n}bindSkeletons(e,r){0!==Object.keys(r).length&&e.traverse(function(e){var t;!0===e.isSkinnedMesh&&void 0!==e.skeleton&&(void 0===(t=r[e.skeleton])?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(t,e.bindMatrix))})}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}const id={UVMapping:Me,CubeReflectionMapping:Ue,CubeRefractionMapping:Be,EquirectangularReflectionMapping:Ge,EquirectangularRefractionMapping:He,CubeUVReflectionMapping:ze,CubeUVRefractionMapping:Ve},nd={RepeatWrapping:We,ClampToEdgeWrapping:Le,MirroredRepeatWrapping:je},sd={NearestFilter:Re,NearestMipmapNearestFilter:Ye,NearestMipmapLinearFilter:qe,LinearFilter:U,LinearMipmapNearestFilter:Xe,LinearMipmapLinearFilter:Ze};class ad extends Ec{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(t,r,e,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,s=bc.get(t);if(void 0!==s)return n.manager.itemStart(t),setTimeout(function(){r&&r(s),n.manager.itemEnd(t)},0),s;var a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(t,a).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(e){bc.add(t,e),r&&r(e),n.manager.itemEnd(t)}).catch(function(e){i&&i(e),n.manager.itemError(t),n.manager.itemEnd(t)}),n.manager.itemStart(t)}}let od;ad.prototype.isImageBitmapLoader=!0;const ld={getContext:function(){return od=void 0===od?new(window.AudioContext||window.webkitAudioContext):od},setContext:function(e){od=e}};class hd extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{const t=e.slice(0);ld.getContext().decodeAudioData(t,function(e){r(e)})}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}}class ud extends Jc{constructor(e,t,r=1){super(void 0,r);var r=(new g).set(e),e=(new g).set(t),t=new Pe(r.r,r.g,r.b),r=new Pe(e.r,e.g,e.b),e=Math.sqrt(Math.PI),i=e*Math.sqrt(.75);this.sh.coefficients[0].copy(t).add(r).multiplyScalar(e),this.sh.coefficients[1].copy(t).sub(r).multiplyScalar(i)}}ud.prototype.isHemisphereLightProbe=!0;class cd extends Jc{constructor(e,t=1){super(void 0,t);t=(new g).set(e);this.sh.coefficients[0].set(t.r,t.g,t.b).multiplyScalar(2*Math.sqrt(Math.PI))}}cd.prototype.isAmbientLightProbe=!0;const dd=new ke,fd=new ke;class pd{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new N,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new N,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){var t,r,i,n,s,a=this._cache;a.focus===e.focus&&a.fov===e.fov&&a.aspect===e.aspect*this.aspect&&a.near===e.near&&a.far===e.far&&a.zoom===e.zoom&&a.eyeSep===this.eyeSep||(a.focus=e.focus,a.fov=e.fov,a.aspect=e.aspect*this.aspect,a.near=e.near,a.far=e.far,a.zoom=e.zoom,a.eyeSep=this.eyeSep,t=e.projectionMatrix.clone(),r=(n=a.eyeSep/2)*a.near/a.focus,i=a.near*Math.tan(ci*a.fov*.5)/a.zoom,fd.elements[12]=-n,dd.elements[12]=n,n=-i*a.aspect+r,s=i*a.aspect+r,t.elements[0]=2*a.near/(s-n),t.elements[8]=(s+n)/(s-n),this.cameraL.projectionMatrix.copy(t),n=-i*a.aspect-r,s=i*a.aspect-r,t.elements[0]=2*a.near/(s-n),t.elements[8]=(s+n)/(s-n),this.cameraR.projectionMatrix.copy(t)),this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fd),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(dd)}}class md{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gd(),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;var t;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(t=gd(),e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e),e)}}function gd(){return("undefined"==typeof performance?Date:performance).now()}const vd=new Pe,yd=new ki,xd=new Pe,_d=new Pe;class bd extends c{constructor(){super(),this.type="AudioListener",this.context=ld.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new md}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(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(null!==this.filter?(this.gain.disconnect(this.filter),this.filter):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);var t=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(vd,yd,xd),_d.set(0,0,-1).applyQuaternion(yd),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(vd.x,e),t.positionY.linearRampToValueAtTime(vd.y,e),t.positionZ.linearRampToValueAtTime(vd.z,e),t.forwardX.linearRampToValueAtTime(_d.x,e),t.forwardY.linearRampToValueAtTime(_d.y,e),t.forwardZ.linearRampToValueAtTime(_d.z,e),t.upX.linearRampToValueAtTime(r.x,e),t.upY.linearRampToValueAtTime(r.y,e),t.upZ.linearRampToValueAtTime(r.z,e)}else t.setPosition(vd.x,vd.y,vd.z),t.setOrientation(_d.x,_d.y,_d.z,r.x,r.y,r.z)}}class Td extends c{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(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else{if(!1!==this.hasPlaybackControl)return this._startedAt=this.context.currentTime+e,(e=this.context.createBufferSource()).buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect();console.warn("THREE.Audio: this Audio has no playback control.")}}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(0<this.filters.length){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(0<this.filters.length){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||[],!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&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(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}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}}const Sd=new Pe,Ed=new ki,wd=new Pe,Md=new Pe;class Ad extends Td{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(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,r){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=r,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(Sd,Ed,wd),Md.set(0,0,1).applyQuaternion(Ed);var t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Sd.x,e),t.positionY.linearRampToValueAtTime(Sd.y,e),t.positionZ.linearRampToValueAtTime(Sd.z,e),t.orientationX.linearRampToValueAtTime(Md.x,e),t.orientationY.linearRampToValueAtTime(Md.y,e),t.orientationZ.linearRampToValueAtTime(Md.z,e)}else t.setPosition(Sd.x,Sd.y,Sd.z),t.setOrientation(Md.x,Md.y,Md.z)}}}class Ld{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 t=0;var r=this.getFrequencyData();for(let e=0;e<r.length;e++)t+=r[e];return t/r.length}}class Rd{constructor(e,t,r){let i,n,s;switch(this.binding=e,this.valueSize=r,t){case"quaternion":i=this._slerp,n=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*r),this._workIndex=5;break;case"string":case"bool":i=this._select,n=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*r);break;default:i=this._lerp,n=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*r)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=n,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){var r=this.buffer,i=this.valueSize,n=e*i+i;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==i;++e)r[n+e]=r[e];s=t}else{const e=t/(s+=t);this._mixBufferRegion(r,n,0,e,i)}this.cumulativeWeight=s}accumulateAdditive(e){var t=this.buffer,r=this.valueSize,i=r*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){var r=this.valueSize,i=this.buffer,n=e*r+r,t=this.cumulativeWeight,e=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,t<1){const e=r*this._origIndex;this._mixBufferRegion(i,n,e,1-t,r)}0<e&&this._mixBufferRegionAdditive(i,n,this._addIndex*r,1,r);for(let e=r,t=r+r;e!==t;++e)if(i[e]!==i[e+r]){s.setValue(i,n);break}}saveOriginalState(){var e=this.binding,r=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(r,n);for(let e=i,t=n;e!==t;++e)r[e]=r[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){var t=this._addIndex*this.valueSize,r=t+this.valueSize;for(let e=t;e<r;e++)this.buffer[e]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){var t=this._origIndex*this.valueSize,r=this._addIndex*this.valueSize;for(let e=0;e<this.valueSize;e++)this.buffer[r+e]=this.buffer[t+e]}_select(t,r,i,e,n){if(.5<=e)for(let e=0;e!==n;++e)t[r+e]=t[i+e]}_slerp(e,t,r,i){ki.slerpFlat(e,t,e,t,e,r,i)}_slerpAdditive(e,t,r,i,n){n=this._workIndex*n;ki.multiplyQuaternionsFlat(e,n,e,t,e,r),ki.slerpFlat(e,t,e,t,e,n,i)}_lerp(t,r,i,n,s){var a=1-n;for(let e=0;e!==s;++e){const s=r+e;t[s]=t[s]*a+t[i+e]*n}}_lerpAdditive(t,r,i,n,s){for(let e=0;e!==s;++e){const s=r+e;t[s]=t[s]+t[i+e]*n}}}const Cd=new RegExp("[\\[\\]\\.:\\/]","g"),Dd="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Id=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Pd=/(WCOD+)?/.source.replace("WCOD",Dd),kd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Od=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Fd=new RegExp("^"+Id+Pd+kd+Od+"$"),Nd=["material","materials","bones"];class x{constructor(e,t,r){this.path=t,this.parsedPath=r||x.parseTrackName(t),this.node=x.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return new(e&&e.isAnimationObjectGroup?x.Composite:x)(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Cd,"")}static parseTrackName(e){var t=Fd.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var t={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=t.nodeName&&t.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=t.nodeName.substring(r+1);-1!==Nd.indexOf(e)&&(t.nodeName=t.nodeName.substring(0,r),t.objectName=e)}if(null===t.propertyName||0===t.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}static findNode(e,i){if(!i||""===i||"."===i||-1===i||i===e.name||i===e.uuid)return e;if(e.skeleton){var t=e.skeleton.getBoneByName(i);if(void 0!==t)return t}if(e.children){const n=function(t){for(let e=0;e<t.length;e++){var r=t[e];if(r.name===i||r.uuid===i)return r;r=n(r.children);if(r)return r}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)r[i++]=n[e]}_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(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++]}_setValue_array_setNeedsUpdate(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++];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 r=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(r||(r=x.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=r),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,r){if(i){let t=e.objectIndex;switch(i){case"materials":if(!r.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!r.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);r=r.material.materials;break;case"bones":if(!r.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);r=r.skeleton.bones;for(let e=0;e<r.length;e++)if(r[e].name===t){t=e;break}break;default:if(void 0===r[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);r=r[i]}if(void 0!==t){if(void 0===r[t])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,r);r=r[t]}}var a=r[n];if(void 0===a){const i=e.nodeName;void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",r)}else{let e=this.Versioning.None,t=(void 0!==(this.targetObject=r).needsUpdate?e=this.Versioning.NeedsUpdate:void 0!==r.matrixWorldNeedsUpdate&&(e=this.Versioning.MatrixWorldNeedsUpdate),this.BindingType.Direct);if(void 0!==s){if("morphTargetInfluences"===n){if(!r.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!r.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!r.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==r.morphTargetDictionary[s]&&(s=r.morphTargetDictionary[s])}t=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else void 0!==a.fromArray&&void 0!==a.toArray?(t=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(t=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[t],this.setValue=this.SetterByBindingTypeAndVersioning[t][e]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}x.Composite=class{constructor(e,t,r){r=r||x.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();var r=this._targetGroup.nCachedObjects_,r=this._bindings[r];void 0!==r&&r.getValue(e,t)}setValue(r,i){var n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].setValue(r,i)}bind(){var r=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=r.length;e!==t;++e)r[e].bind()}unbind(){var r=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=r.length;e!==t;++e)r[e].unbind()}},x.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},x.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},x.prototype.GetterByBindingType=[x.prototype._getValue_direct,x.prototype._getValue_array,x.prototype._getValue_arrayElement,x.prototype._getValue_toArray],x.prototype.SetterByBindingTypeAndVersioning=[[x.prototype._setValue_direct,x.prototype._setValue_direct_setNeedsUpdate,x.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[x.prototype._setValue_array,x.prototype._setValue_array_setNeedsUpdate,x.prototype._setValue_array_setMatrixWorldNeedsUpdate],[x.prototype._setValue_arrayElement,x.prototype._setValue_arrayElement_setNeedsUpdate,x.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[x.prototype._setValue_fromArray,x.prototype._setValue_fromArray_setNeedsUpdate,x.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ud{constructor(){this.uuid=pi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var r={};this._indicesByUUID=r;for(let e=0,t=arguments.length;e!==t;++e)r[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const i=this._objects,n=this._indicesByUUID,s=this._paths,a=this._parsedPaths,o=this._bindings,l=o.length;let h=void 0,u=i.length,c=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var d=arguments[e],f=d.uuid;let r=n[f];if(void 0===r){r=u++,n[f]=r,i.push(d);for(let e=0,t=l;e!==t;++e)o[e].push(new x(d,s[e],a[e]))}else if(r<c){h=i[r];const u=--c,p=i[u];n[p.uuid]=r,i[r]=p,n[f]=u,i[u]=d;for(let t=0,e=l;t!==e;++t){const n=o[t],l=n[u];let e=n[r];n[r]=l,void 0===e&&(e=new x(d,s[t],a[t])),n[u]=e}}else i[r]!==h&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const r=this._objects,i=this._indicesByUUID,n=this._bindings,s=n.length;let a=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var o=arguments[e],l=o.uuid,h=i[l];if(void 0!==h&&h>=a){var u=a++,c=r[u];i[c.uuid]=h,r[h]=c,i[l]=u,r[u]=o;for(let e=0,t=s;e!==t;++e){const i=n[e],s=i[u],a=i[h];i[h]=s,i[u]=a}}}this.nCachedObjects_=a}uncache(){const r=this._objects,i=this._indicesByUUID,n=this._bindings,s=n.length;let a=this.nCachedObjects_,o=r.length;for(let e=0,t=arguments.length;e!==t;++e){var l=arguments[e].uuid,h=i[l];if(void 0!==h)if(delete i[l],h<a){var u=--a,l=r[u],c=--o,d=r[c];i[l.uuid]=h,r[h]=l,i[d.uuid]=u,r[u]=d,r.pop();for(let e=0,t=s;e!==t;++e){const i=n[e],s=i[u],a=i[c];i[h]=s,i[u]=a,i.pop()}}else{const a=--o,f=r[a];0<a&&(i[f.uuid]=h),r[h]=f,r.pop();for(let e=0,t=s;e!==t;++e){const i=n[e];i[h]=i[a],i.pop()}}}this.nCachedObjects_=a}subscribe_(r,i){var e=this._bindingsIndicesByPath;let n=e[r];var t=this._bindings;if(void 0!==n)return t[n];var s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,u=new Array(l);n=t.length,e[r]=n,s.push(r),a.push(i),t.push(u);for(let e=h,t=o.length;e!==t;++e){const n=o[e];u[e]=new x(n,r,i)}return u}unsubscribe_(e){var t,r,i,n,s,a=this._bindingsIndicesByPath,o=a[e];void 0!==o&&(t=this._paths,r=this._parsedPaths,s=(i=this._bindings)[n=i.length-1],i[a[e[n]]=o]=s,i.pop(),r[o]=r[n],r.pop(),t[o]=t[n],t.pop())}}Ud.prototype.isAnimationObjectGroup=!0;class Bd{constructor(e,t,r=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=i;var n=t.tracks,s=n.length,a=new Array(s),o={endingStart:vr,endingEnd:vr};for(let e=0;e!==s;++e){const t=n[e].createInterpolant(null);(a[e]=t).settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=dr,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&&0!==this.timeScale&&null===this._startTime&&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,r){if(e.fadeOut(t),this.fadeIn(t),r){const r=this._clip.duration,i=e._clip.duration,n=i/r,s=r/i;e.warp(1,n,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}stopFading(){var e=this._weightInterpolant;return null!==e&&(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,r){var i=this._mixer,n=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);var i=a.parameterPositions,o=a.sampleValues;return i[0]=n,i[1]=n+r,o[0]=e/s,o[1]=t/s,this}stopWarping(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(r,i,e,n){if(this.enabled){var t=this._startTime;if(null!==t){const n=(r-t)*e;if(n<0||0===e)return;this._startTime=null,i=e*n}i*=this._updateTimeScale(r);var s=this._updateTime(i),a=this._updateWeight(r);if(0<a){const r=this._interpolants,i=this._propertyBindings;if(this.blendMode===br)for(let e=0,t=r.length;e!==t;++e)r[e].evaluate(s),i[e].accumulateAdditive(a);else{_r;for(let e=0,t=r.length;e!==t;++e)r[e].evaluate(s),i[e].accumulate(n,a)}}}else this._updateWeight(r)}_updateWeight(e){let t=0;var r,i;return this.enabled&&(t=this.weight,null!==(r=this._weightInterpolant))&&(i=r.evaluate(e)[0],t*=i,e>r.parameterPositions[1])&&(this.stopFading(),0===i)&&(this.enabled=!1),this._effectiveWeight=t}_updateTimeScale(e){let t=0;var r;return this.paused||(t=this.timeScale,null!==(r=this._timeScaleInterpolant)&&(t*=r.evaluate(e)[0],e>r.parameterPositions[1])&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)),this._effectiveTimeScale=t}_updateTime(e){const t=this._clip.duration,r=this.loop;let i=this.time+e,n=this._loopCount;var s=r===fr;if(0===e)return-1!==n&&s&&1==(1&n)?t-i:i;if(r===cr){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===n&&(0<=e?(n=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const r=Math.floor(i/t);i-=t*r,n+=Math.abs(r);var a=this.repetitions-n;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=0<e?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<e?1:-1});else{if(1==a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=n,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=i;if(s&&1==(1&n))return t-i}return i}_setEndings(e,t,r){var i=this._interpolantSettings;r?(i.endingStart=yr,i.endingEnd=yr):(i.endingStart=e?this.zeroSlopeAtStart?yr:vr:xr,i.endingEnd=t?this.zeroSlopeAtEnd?yr:vr:xr)}_scheduleFading(e,t,r){var i=this._mixer,n=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);var i=s.parameterPositions,a=s.sampleValues;return i[0]=n,a[0]=t,i[1]=n+e,a[1]=r,this}}class Gd extends hi{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,r){const i=e._localRoot||this._root,n=e._clip.tracks,s=n.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,h=this._bindingsByRootAndName;let u=h[l];void 0===u&&(u={},h[l]=u);for(let t=0;t!==s;++t){const s=n[t],h=s.name;let e=u[h];if(void 0===e){if(void 0!==(e=a[t])){null===e._cacheIndex&&(++e.referenceCount,this._addInactiveBinding(e,l,h));continue}const n=r&&r._propertyBindings[t].binding.parsedPath;++(e=new Rd(x.create(i,h,n),s.ValueTypeName,s.getValueSize())).referenceCount,this._addInactiveBinding(e,l,h)}a[t]=e,o[t].resultBuffer=e.buffer}}_activateAction(e){if(!this._isActiveAction(e)){null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,r=e._clip.uuid,i=this._actionsByClip[r],this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,r,t));var t,r,i,n=e._propertyBindings;for(let e=0,t=n.length;e!==t;++e){var s=n[e];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){var r=e._propertyBindings;for(let e=0,t=r.length;e!==t;++e){var i=r[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){e=e._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(e,t,r){var i=this._actions,n=this._actionsByClip;let s=n[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[r]=e}_removeInactiveAction(e){var t=this._actions,r=t[t.length-1],i=e._cacheIndex,i=(t[r._cacheIndex=i]=r,t.pop(),e._cacheIndex=null,e._clip.uuid),r=this._actionsByClip,t=r[i],n=t.knownActions,s=n[n.length-1],a=e._byClipCacheIndex;n[s._byClipCacheIndex=a]=s,n.pop(),e._byClipCacheIndex=null,delete t.actionByRoot[(e._localRoot||this._root).uuid],0===n.length&&delete r[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){var r=e._propertyBindings;for(let e=0,t=r.length;e!==t;++e){var i=r[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){var t=this._actions,r=e._cacheIndex,i=this._nActiveActions++,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_takeBackAction(e){var t=this._actions,r=e._cacheIndex,i=--this._nActiveActions,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_addInactiveBinding(e,t,r){var i=this._bindingsByRootAndName,n=this._bindings;let s=i[t];void 0===s&&(s={},i[t]=s),(s[r]=e)._cacheIndex=n.length,n.push(e)}_removeInactiveBinding(e){var t=this._bindings,r=e.binding,i=r.rootNode.uuid,r=r.path,n=this._bindingsByRootAndName,s=n[i],a=t[t.length-1],e=e._cacheIndex;t[a._cacheIndex=e]=a,t.pop(),delete s[r],0===Object.keys(s).length&&delete n[i]}_lendBinding(e){var t=this._bindings,r=e._cacheIndex,i=this._nActiveBindings++,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_takeBackBinding(e){var t=this._bindings,r=e._cacheIndex,i=--this._nActiveBindings,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_lendControlInterpolant(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let r=e[t];return void 0===r&&(e[(r=new uc(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t]=r),r}_takeBackControlInterpolant(e){var t=this._controlInterpolants,r=e.__cacheIndex,i=--this._nActiveControlInterpolants,n=t[i];t[e.__cacheIndex=i]=e,t[n.__cacheIndex=r]=n}clipAction(e,t,r){var i=t||this._root,n=i.uuid;let s="string"==typeof e?_c.findByName(i,e):e;var i=null!==s?s.uuid:e,a=this._actionsByClip[i];let o=null;if(void 0===r&&(r=null!==s?s.blendMode:_r),void 0!==a){const e=a.actionByRoot[n];if(void 0!==e&&e.blendMode===r)return e;o=a.knownActions[0],null===s&&(s=o._clip)}return null===s?null:(e=new Bd(this,s,t,r),this._bindAction(e,o),this._addInactiveAction(e,i,n),e)}existingAction(e,t){var t=t||this._root,r=t.uuid,t="string"==typeof e?_c.findByName(t,e):e,t=t?t.uuid:e,e=this._actionsByClip[t];return void 0!==e&&e.actionByRoot[r]||null}stopAllAction(){var t=this._actions;for(let e=this._nActiveActions-1;0<=e;--e)t[e].stop();return this}update(t){t*=this.timeScale;var r=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let e=0;e!==i;++e)r[e]._update(n,t,s,a);var o=this._bindings,l=this._nActiveBindings;for(let e=0;e!==l;++e)o[e].apply(a);return this}setTime(e){for(let e=this.time=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(r){const i=this._actions,e=r.uuid,n=this._actionsByClip,s=n[e];if(void 0!==s){const r=s.knownActions;for(let e=0,t=r.length;e!==t;++e){const n=r[e],s=(this._deactivateAction(n),n._cacheIndex),a=i[i.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,a._cacheIndex=s,i[s]=a,i.pop(),this._removeInactiveBindingsForAction(n)}delete n[e]}}uncacheRoot(e){const t=e.uuid,r=this._actionsByClip;for(const e in r){const i=r[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){e=this.existingAction(e,t);null!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}}Gd.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Hd{constructor(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Hd(void 0===this.value.clone?this.value:this.value.clone())}}class zd extends kl{constructor(e,t,r=1){super(e,t),this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){e=super.clone(e);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(e){e=super.toJSON(e);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}zd.prototype.isInstancedInterleavedBuffer=!0;class Vd{constructor(e,t,r,i,n){this.buffer=e,this.type=t,this.itemSize=r,this.elementSize=i,this.count=n,this.version=0}set needsUpdate(e){!0===e&&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}}Vd.prototype.isGLBufferAttribute=!0;class Wd{constructor(e,t,r=0,i=1/0){this.ray=new cn(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new Tn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){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&&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)}intersectObject(e,t=!0,r=[]){return Yd(e,this,r,t),r.sort(jd),r}intersectObjects(r,i=!0,n=[]){for(let e=0,t=r.length;e<t;e++)Yd(r[e],this,n,i);return n.sort(jd),n}}function jd(e,t){return e.distance-t.distance}function Yd(e,r,i,n){if(e.layers.test(r.layers)&&e.raycast(r,i),!0===n){const n=e.children;for(let e=0,t=n.length;e<t;e++)Yd(n[e],r,i,!0)}}class $d{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,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,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mi(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class qd{constructor(e=1,t=0,r=0){return this.radius=e,this.theta=t,this.y=r,this}set(e,t,r){return this.radius=e,this.theta=t,this.y=r,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,r){return this.radius=Math.sqrt(e*e+r*r),this.theta=Math.atan2(e,r),this.y=t,this}clone(){return(new this.constructor).copy(this)}}const Kd=new z;class Xd{constructor(e=new z(1/0,1/0),t=new z(-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(r){this.makeEmpty();for(let e=0,t=r.length;e<t;e++)this.expandByPoint(r[e]);return this}setFromCenterAndSize(e,t){t=Kd.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),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 Kd.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),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)}}Xd.prototype.isBox2=!0;const Jd=new Pe,Zd=new Pe;class Qd{constructor(e=new Pe,t=new Pe){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){Jd.subVectors(e,this.start),Zd.subVectors(this.end,this.start);e=Zd.dot(Zd);let r=Zd.dot(Jd)/e;return r=t?mi(r,0,1):r}closestPointToPoint(e,t,r){e=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(e).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)}}const ef=new Pe;class tf extends c{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;var e=new S,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 e=0,t=1;e<32;e++,t++){const i=e/32*Math.PI*2,n=t/32*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(n),Math.sin(n),1)}e.setAttribute("position",new V(r,3));const i=new y({fog:!1,toneMapped:!1});this.cone=new Mh(e,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();var e=this.light.distance||1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ef.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ef),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const rf=new Pe,nf=new ke,sf=new ke;class af extends Mh{constructor(e){const t=function t(r){var i=[];r&&r.isBone&&i.push(r);for(let e=0;e<r.children.length;e++)i.push.apply(i,t(r.children[e]));return i}(e),r=new S,i=[],n=[],s=new g(0,0,1),a=new g(0,1,0);for(let e=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),n.push(s.r,s.g,s.b),n.push(a.r,a.g,a.b))}r.setAttribute("position",new V(i,3)),r.setAttribute("color",new V(n,3)),super(r,new y({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){var r=this.bones,t=this.geometry,i=t.getAttribute("position");sf.copy(this.root.matrixWorld).invert();for(let e=0,t=0;e<r.length;e++){var n=r[e];n.parent&&n.parent.isBone&&(nf.multiplyMatrices(sf,n.matrixWorld),rf.setFromMatrixPosition(nf),i.setXYZ(t,rf.x,rf.y,rf.z),nf.multiplyMatrices(sf,n.parent.matrixWorld),rf.setFromMatrixPosition(nf),i.setXYZ(t+1,rf.x,rf.y,rf.z),t+=2)}t.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}class of extends E{constructor(e,t,r){super(new Wu(t,4,2),new Qn({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const lf=new Pe,hf=new g,uf=new g;class cf extends c{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r;e=new Hu(t),e.rotateY(.5*Math.PI),this.material=new Qn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0),r=e.getAttribute("position"),t=new Float32Array(3*r.count);e.setAttribute("color",new w(t,3)),this.add(new E(e,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var r=e.geometry.getAttribute("color");hf.copy(this.light.color),uf.copy(this.light.groundColor);for(let e=0,t=r.count;e<t;e++){var i=e<t/2?hf:uf;r.setXYZ(e,i.r,i.g,i.b)}r.needsUpdate=!0}e.lookAt(lf.setFromMatrixPosition(this.light.matrixWorld).negate())}}class df extends Mh{constructor(e=10,i=10,n=4473924,s=8947848){n=new g(n),s=new g(s);var a=i/2,o=e/i,l=e/2,h=[],u=[];for(let e=0,t=0,r=-l;e<=i;e++,r+=o){h.push(-l,0,r,l,0,r),h.push(r,0,-l,r,0,l);const i=e===a?n:s;i.toArray(u,t),t+=3,i.toArray(u,t),t+=3,i.toArray(u,t),t+=3,i.toArray(u,t),t+=3}e=new S;e.setAttribute("position",new V(h,3)),e.setAttribute("color",new V(u,3)),super(e,new y({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class ff extends Mh{constructor(t=10,r=16,i=8,n=64,s=4473924,a=8947848){s=new g(s),a=new g(a);var o=[],l=[];for(let e=0;e<=r;e++){const n=e/r*(2*Math.PI),f=Math.sin(n)*t,p=Math.cos(n)*t;o.push(0,0,0),o.push(f,0,p);var h=1&e?s:a;l.push(h.r,h.g,h.b),l.push(h.r,h.g,h.b)}for(let e=0;e<=i;e++){const f=1&e?s:a,m=t-t/i*e;for(let e=0;e<n;e++){var u=e/n*(2*Math.PI),c=Math.sin(u)*m,d=Math.cos(u)*m;o.push(c,0,d),l.push(f.r,f.g,f.b),u=(e+1)/n*(2*Math.PI),c=Math.sin(u)*m,d=Math.cos(u)*m,o.push(c,0,d),l.push(f.r,f.g,f.b)}}const f=new S;f.setAttribute("position",new V(o,3)),f.setAttribute("color",new V(l,3)),super(f,new y({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const pf=new Pe,mf=new Pe,gf=new Pe;class vf extends c{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,void 0===t&&(t=1);let i=new S;i.setAttribute("position",new V([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));e=new y({fog:!1,toneMapped:!1});this.lightPlane=new Sh(i,e),this.add(this.lightPlane),(i=new S).setAttribute("position",new V([0,0,0,0,0,1],3)),this.targetLine=new Sh(i,e),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){pf.setFromMatrixPosition(this.light.matrixWorld),mf.setFromMatrixPosition(this.light.target.matrixWorld),gf.subVectors(mf,pf),this.lightPlane.lookAt(mf),void 0!==this.color?(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(mf),this.targetLine.scale.z=gf.length()}}const yf=new Pe,o=new Bs;class xf extends Mh{constructor(e){const t=new S,r=new y({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],n=[],s={},a=new g(16755200),o=new g(16711680),l=new g(43775),h=new g(16777215),u=new g(3355443);function c(e,t,r){d(e,r),d(t,r)}function d(e,t){i.push(0,0,0),n.push(t.r,t.g,t.b),void 0===s[e]&&(s[e]=[]),s[e].push(i.length/3-1)}c("n1","n2",a),c("n2","n4",a),c("n4","n3",a),c("n3","n1",a),c("f1","f2",a),c("f2","f4",a),c("f4","f3",a),c("f3","f1",a),c("n1","f1",a),c("n2","f2",a),c("n3","f3",a),c("n4","f4",a),c("p","n1",o),c("p","n2",o),c("p","n3",o),c("p","n4",o),c("u1","u2",l),c("u2","u3",l),c("u3","u1",l),c("c","t",h),c("p","c",u),c("cn1","cn2",u),c("cn3","cn4",u),c("cf1","cf2",u),c("cf3","cf4",u),t.setAttribute("position",new V(i,3)),t.setAttribute("color",new V(n,3)),super(t,r),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){var e=this.geometry,t=this.pointMap;o.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),l("c",t,e,o,0,0,-1),l("t",t,e,o,0,0,1),l("n1",t,e,o,-1,-1,-1),l("n2",t,e,o,1,-1,-1),l("n3",t,e,o,-1,1,-1),l("n4",t,e,o,1,1,-1),l("f1",t,e,o,-1,-1,1),l("f2",t,e,o,1,-1,1),l("f3",t,e,o,-1,1,1),l("f4",t,e,o,1,1,1),l("u1",t,e,o,.7,1.1,-1),l("u2",t,e,o,-.7,1.1,-1),l("u3",t,e,o,0,2,-1),l("cf1",t,e,o,-1,0,1),l("cf2",t,e,o,1,0,1),l("cf3",t,e,o,0,-1,1),l("cf4",t,e,o,0,1,1),l("cn1",t,e,o,-1,0,-1),l("cn2",t,e,o,1,0,-1),l("cn3",t,e,o,0,-1,-1),l("cn4",t,e,o,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function l(r,e,t,i,n,s,a){yf.set(n,s,a).unproject(i);var o=e[r];if(void 0!==o){const r=t.getAttribute("position");for(let e=0,t=o.length;e<t;e++)r.setXYZ(o[e],yf.x,yf.y,yf.z)}}const _f=new Ni;class bf extends Mh{constructor(e,t=16776960){var r=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]),i=new Float32Array(24),n=new S;n.setIndex(new w(r,1)),n.setAttribute("position",new w(i,3)),super(n,new y({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){var t,r,i;void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&_f.setFromObject(this.object),_f.isEmpty()||(e=_f.min,t=_f.max,(i=(r=this.geometry.attributes.position).array)[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere())}setFromObject(e){return this.object=e,this.update(),this}copy(e){return Mh.prototype.copy.call(this,e),this.object=e.object,this}}class Tf extends Mh{constructor(e,t=16776960){var r=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]),i=new S;i.setIndex(new w(r,1)),i.setAttribute("position",new V([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new y({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class Sf extends Sh{constructor(e,t=1,r=16776960){var i=new S,i=(i.setAttribute("position",new V([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,0,1,0,0,0],3)),i.computeBoundingSphere(),super(i,new y({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t,new S);i.setAttribute("position",new V([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),i.computeBoundingSphere(),this.add(new E(i,new Qn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?Ae:Oe,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}}const Ef=new Pe;let wf,Mf;class Af extends c{constructor(e=new Pe(0,0,1),t=new Pe(0,0,0),r=1,i=16776960,n=.2*r,s=.2*n){super(),this.type="ArrowHelper",void 0===wf&&((wf=new S).setAttribute("position",new V([0,0,0,0,1,0],3)),(Mf=new Gh(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Sh(wf,new y({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new E(Mf,new Qn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(r,n,s)}setDirection(e){.99999<e.y?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(Ef.set(e.z,0,-e.x).normalize(),e=Math.acos(e.y),this.quaternion.setFromAxisAngle(Ef,e))}setLength(e,t=.2*e,r=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),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}}class Lf extends Mh{constructor(e=1){var e=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],t=new S;t.setAttribute("position",new V(e,3)),t.setAttribute("color",new V([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,new y({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,r){var i=new g,n=this.geometry.attributes.color.array;return i.set(e),i.toArray(n,0),i.toArray(n,3),i.set(t),i.toArray(n,6),i.toArray(n,9),i.set(r),i.toArray(n,12),i.toArray(n,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rf{constructor(){this.type="ShapePath",this.color=new g,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new gu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,n,s){return this.currentPath.bezierCurveTo(e,t,r,i,n,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(a,o){function e(r){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e],s=new vu;s.curves=n.curves,i.push(s)}return i}const l=ku.isClockWise,h=this.subPaths;if(0===h.length)return[];if(!0===o)return e(h);let u,c,d;var t=[];if(1===h.length)c=h[0],(d=new vu).curves=c.curves,t.push(d);else{var f=!l(h[0].getPoints()),f=a?!f:f,p=[],m=[];let r,i,s=[],n=0;m[n]=void 0,s[n]=[];for(let e=0,t=h.length;e<t;e++)r=(c=h[e]).getPoints(),u=l(r),(u=a?!u:u)?(!f&&m[n]&&n++,m[n]={s:new vu,p:r},m[n].s.curves=c.curves,f&&n++,s[n]=[]):s[n].push({h:c,p:r[0]});if(!m[0])return e(h);if(1<m.length){let n=!1;const o=[];for(let e=0,t=m.length;e<t;e++)p[e]=[];for(let i=0,e=m.length;i<e;i++){const l=s[i];for(let r=0;r<l.length;r++){const u=l[r];let t=!0;for(let e=0;e<m.length;e++)!function(a,o){var e=o.length;let l=!1;for(let n=e-1,s=0;s<e;n=s++){let e=o[n],t=o[s],r=t.x-e.x,i=t.y-e.y;if(Math.abs(i)>Number.EPSILON){if(i<0&&(e=o[s],r=-r,t=o[n],i=-i),!(a.y<e.y||a.y>t.y))if(a.y===e.y){if(a.x===e.x)return 1}else{const o=i*(a.x-e.x)-r*(a.y-e.y);if(0==o)return 1;o<0||(l=!l)}}else if(a.y===e.y&&(t.x<=a.x&&a.x<=e.x||e.x<=a.x&&a.x<=t.x))return 1}return l}(u.p,m[e].p)||(i!==e&&o.push({froms:i,tos:e,hole:r}),t?(t=!1,p[e].push(u)):n=!0);t&&p[i].push(u)}}0<o.length&&(n||(s=p))}for(let r=0,e=m.length;r<e;r++){d=m[r].s,t.push(d);for(let e=0,t=(i=s[r]).length;e<t;e++)d.holes.push(i[e].h)}}return t}}const Cf=new Float32Array(1),Df=new Int32Array(Cf.buffer);class If{static toHalfFloat(e){65504<e&&(console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."),e=65504),Cf[0]=e;e=Df[0];let t=e>>16&32768,r=e>>12&2047;var i=e>>23&255;return i<103||(142<i?t=t|31744|((255==i?0:1)&&8388607&e):i<113?(r|=2048,t|=(r>>114-i)+(r>>113-i&1)):t=(t|=i-112<<10|r>>1)+(1&r)),t}}const Pf=0,kf=1,Of=0,Ff=1,Nf=2;function Uf(e){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),e}function Bf(e=[]){return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,(e.materials=e).clone=function(){return e.slice()},e}function Gf(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new Ph(e,t)}function Hf(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Xl(e)}function zf(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new Ph(e,t)}function Vf(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function Wf(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function jf(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function Yf(e,t,r){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Pe(e,t,r)}function $f(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new w(e,t).setUsage(Qr)}function qf(e,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ts(e,t)}function Kf(e,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new rs(e,t)}function Xf(e,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new is(e,t)}function Jf(e,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new ns(e,t)}function Zf(e,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ss(e,t)}function Qf(e,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new as(e,t)}function ep(e,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new os(e,t)}function tp(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new V(e,t)}function rp(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new hs(e,t)}function ip(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Lf(e)}function np(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new bf(e,t)}function sp(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Mh(new qh(e.geometry),new y({color:void 0!==t?t:16777215}))}function ap(e,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new Mh(new Ku(e.geometry),new y({color:void 0!==t?t:16777215}))}function op(e){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Mc(e)}function lp(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Dc(e)}function hp(e,t,r){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new zs(e,r)}function up(){console.error("THREE.CanvasRenderer has been removed")}function cp(){console.error("THREE.JSONLoader has been removed.")}Kh.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Kh.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},gu.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},df.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},af.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Ec.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Qc.extractUrlBase(e)},Ec.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Xd.prototype.center=function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Xd.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Xd.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Xd.prototype.size=function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},Ni.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Ni.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ni.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Ni.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Ni.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},rn.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ks.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Qd.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},v.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},v.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},v.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},v.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},v.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},v.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},ke.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},ke.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},ke.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Pe).setFromMatrixColumn(this,3)},ke.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},ke.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},ke.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},ke.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},ke.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},ke.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},ke.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},ke.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},ke.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},ke.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},ke.prototype.makeFrustum=function(e,t,r,i,n,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,i,r,n,s)},ke.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Ys.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},ki.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},ki.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},cn.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},cn.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},cn.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},f.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},f.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},f.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},f.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},f.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},f.barycoordFromPoint=function(e,t,r,i,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),f.getBarycoord(e,t,r,i,n)},f.normal=function(e,t,r,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),f.getNormal(e,t,r,i)},vu.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},vu.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Nu(this,e)},vu.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Vu(this,e)},z.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},z.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},z.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Pe.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Pe.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Pe.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Pe.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Pe.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Pe.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Pe.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},Pe.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Pe.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ie.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},Ie.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},c.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},c.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},c.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},c.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},c.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(c.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),E.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(E.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Tr},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),ah.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},N.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Pc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(w.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Qr},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Qr)}}}),w.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Qr:Zr),this},w.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},w.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},S.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},S.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new w(t,arguments[2])))},S.prototype.addDrawCall=function(e,t,r){void 0!==r&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},S.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},S.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},S.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},S.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(S.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),kl.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Qr:Zr),this},kl.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Nu.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},Nu.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},Nu.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Pl.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Hd.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(r.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new g}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===P}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(Us.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),s.prototype.clearTarget=function(e,t,r,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,r,i)},s.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},s.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},s.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},s.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},s.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},s.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},s.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},s.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},s.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},s.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},s.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},s.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},s.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},s.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},s.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},s.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},s.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},s.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},s.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},s.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},s.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},s.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},s.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},s.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(s.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?wr:De}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(_l.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Di.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Td.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new hd).load(e,function(e){t.setBuffer(e)}),this},Ld.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Gs.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},Gs.prototype.clear=function(e,t,r,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,r,i)},Li.crossOrigin=void 0,Li.loadTexture=function(e,t,r,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var n=new Ic,n=(n.setCrossOrigin(this.crossOrigin),n.load(e,r,void 0,i));return t&&(n.mapping=t),n},Li.loadTextureCube=function(e,t,r,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var n=new Cc,n=(n.setCrossOrigin(this.crossOrigin),n.load(e,r,void 0,i));return t&&(n.mapping=t),n},Li.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Li.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const dp={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};function fp(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")}function pp(){return console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),new S}function mp(){return console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),new S}function gp(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function vp(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function yp(){console.error("THREE.ImmediateRenderObject has been removed.")}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_)},550:function(e,C,D){"use strict";!function(e){var E=D(759),s=D(760),l=D(761);function r(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(e=null===e?new c(t):e).length=t,e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"!=typeof e)return i(this,e,t,r);if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return a(this,e)}function i(e,t,r,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var n=e,s=t,a=r;if(s.byteLength,a<0||s.byteLength<a)throw new RangeError("'offset' is out of bounds");if(s.byteLength<a+(i||0))throw new RangeError("'length' is out of bounds");return s=void 0===a&&void 0===i?new Uint8Array(s):void 0===i?new Uint8Array(s,a):new Uint8Array(s,a,i),c.TYPED_ARRAY_SUPPORT?(n=s).__proto__=c.prototype:n=u(n,s),n}if("string"==typeof t){a=e,i=t,s=r;if(c.isEncoding(s="string"==typeof s&&""!==s?s:"utf8"))return(i=(a=h(a,n=0|f(i,s))).write(i,s))!==n?a.slice(0,i):a;throw new TypeError('"encoding" must be a valid string encoding')}var o,r=e,i=t;if(c.isBuffer(i))return 0!==(r=h(r,o=0|d(i.length))).length&&i.copy(r,0,0,o),r;if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||(o=i.length)!=o?h(r,0):u(r,i);if("Buffer"===i.type&&l(i.data))return u(r,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function n(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function a(e,t){if(n(t),e=h(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function u(e,t){var r=t.length<0?0:0|d(t.length);e=h(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function d(e){if(e>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var r=(e="string"!=typeof e?""+e:e).length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return A(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(e).length;default:if(i)return A(e).length;t=(""+t).toLowerCase(),i=!0}}function t(e,t,r){var i,n=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var s=this,a=t,o=r,l=s.length;(!o||o<0||l<o)&&(o=l);for(var h="",u=a=!a||a<0?0:a;u<o;++u)h+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(s[u]);return h;case"utf8":case"utf-8":return w(this,t,r);case"ascii":var c=this,l=t,d=r,f="";d=Math.min(c.length,d);for(var p=l;p<d;++p)f+=String.fromCharCode(127&c[p]);return f;case"latin1":case"binary":var m=this,a=t,g=r,v="";g=Math.min(m.length,g);for(var y=a;y<g;++y)v+=String.fromCharCode(m[y]);return v;case"base64":return x=this,i=r,0===(_=t)&&i===x.length?E.fromByteArray(x):E.fromByteArray(x.slice(_,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var x=t,_=r,b=this.slice(x,_),T="",S=0;S<b.length;S+=2)T+=String.fromCharCode(b[S]+256*b[S+1]);return T;default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function o(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function p(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,(r=(r=isNaN(r)?n?0:e.length-1:r)<0?e.length+r:r)>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,i,n);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(n?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,r):m(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,i,n){var s=1,a=e.length,o=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a/=s=2,o/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n)for(var h=-1,u=r;u<a;u++)if(l(e,u)===l(t,-1===h?0:u-h)){if(u-(h=-1===h?u:h)+1===o)return h*s}else-1!==h&&(u-=u-h),h=-1;else for(u=r=a<r+o?a-o:r;0<=u;u--){for(var c=!0,d=0;d<o;d++)if(l(e,u+d)!==l(t,d)){c=!1;break}if(c)return u}return-1}function y(e,t,r,i){return R(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function w(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var s,a,o,l,h=e[n],u=null,c=239<h?4:223<h?3:191<h?2:1;if(n+c<=r)switch(c){case 1:h<128&&(u=h);break;case 2:128==(192&(s=e[n+1]))&&127<(l=(31&h)<<6|63&s)&&(u=l);break;case 3:s=e[n+1],a=e[n+2],128==(192&s)&&128==(192&a)&&2047<(l=(15&h)<<12|(63&s)<<6|63&a)&&(l<55296||57343<l)&&(u=l);break;case 4:s=e[n+1],a=e[n+2],o=e[n+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&65535<(l=(15&h)<<18|(63&s)<<12|(63&a)<<6|63&o)&&l<1114112&&(u=l)}null===u?(u=65533,c=1):65535<u&&(i.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),i.push(u),n+=c}var d=i,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",m=0;m<f;)p+=String.fromCharCode.apply(String,d.slice(m,m+=4096));return p}function g(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(r<e+t)throw new RangeError("Trying to access beyond buffer length")}function v(e,t,r,i,n,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n<t||t<s)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function x(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,s=Math.min(e.length-r,2);n<s;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function _(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,s=Math.min(e.length-r,4);n<s;++n)e[r+n]=t>>>8*(i?n:3-n)&255}function b(e,t,r,i){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(e,t,r,i,n){return n||b(e,0,r,4),s.write(e,t,r,i,23,4),r+4}function S(e,t,r,i,n){return n||b(e,0,r,8),s.write(e,t,r,i,52,8),r+8}C.Buffer=c,C.SlowBuffer=function(e){return c.alloc(+(e=+e!=e?0:e))},C.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),C.kMaxLength=r(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return i(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol)&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0}),c.alloc=function(e,t,r){return t=t,r=r,n(e=e),!(e<=0)&&void 0!==t?"string"==typeof r?h(null,e).fill(t,r):h(null,e).fill(t):h(null,e)},c.allocUnsafe=function(e){return a(null,e)},c.allocUnsafeSlow=function(e){return a(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,s=Math.min(r,i);n<s;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!l(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);if(void 0===t)for(n=t=0;n<e.length;++n)t+=e[n].length;for(var r=c.allocUnsafe(t),i=0,n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)o(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)o(this,t,t+3),o(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)o(this,t,t+7),o(this,t+1,t+6),o(this,t+2,t+5),o(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0==e?"":0===arguments.length?w(this,0,e):t.apply(this,arguments)},c.prototype.equals=function(e){if(c.isBuffer(e))return this===e||0===c.compare(this,e);throw new TypeError("Argument must be a Buffer")},c.prototype.inspect=function(){var e="",t=C.INSPECT_MAX_BYTES;return 0<this.length&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t)&&(e+=" ... "),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,i,n){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),(t=void 0===t?0:t)<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(n<=i&&r<=t)return 0;if(n<=i)return-1;if(r<=t)return 1;if(this===e)return 0;for(var s=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),o=Math.min(s,a),l=this.slice(i,n),h=e.slice(t,r),u=0;u<o;++u)if(l[u]!==h[u]){s=l[u],a=h[u];break}return s<a?-1:a<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return p(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return p(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||n<r)&&(r=n),0<e.length&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i=i||"utf8";for(var s,a,o,l,h,u=!1;;)switch(i){case"hex":var c=this,d=e,f=t,p=r,m=(f=Number(f)||0,c.length-f);if((!p||(p=Number(p))>m)&&(p=m),(m=d.length)%2!=0)throw new TypeError("Invalid hex string");m/2<p&&(p=m/2);for(var g=0;g<p;++g){var v=parseInt(d.substr(2*g,2),16);if(isNaN(v))return g;c[f+g]=v}return g;case"utf8":case"utf-8":return m=t,h=r,R(A(e,(l=this).length-m),l,m,h);case"ascii":return y(this,e,t,r);case"latin1":case"binary":return y(this,e,t,r);case"base64":return l=this,h=t,o=r,R(L(e),l,h,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o=t,a=r,R(function(e,t){for(var r,i,n=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n.push(r%256),n.push(i);return n}(e,(s=this).length-o),s,o,a);default:if(u)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),u=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(e,t){var r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else for(var i=t-e,n=new c(i,void 0),s=0;s<i;++s)n[s]=this[s+e];return n},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e+--t],n=1;0<t&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUInt8=function(e,t){return t||g(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||g(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||g(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||g(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||g(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=t,n=1,s=this[e+--i];0<i&&(n*=256);)s+=this[e+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||g(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||g(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt16BE=function(e,t){t||g(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt32LE=function(e,t){return t||g(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||g(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||g(e,4,this.length),s.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||g(e,4,this.length),s.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||g(e,8,this.length),s.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||g(e,8,this.length),s.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,i){e=+e,t|=0,r|=0,i||v(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[t]=255&e;++s<r&&(n*=256);)this[t+s]=e/n&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,i){e=+e,t|=0,r|=0,i||v(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,s=1;for(this[t+n]=255&e;0<=--n&&(s*=256);)this[t+n]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):_(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,i){e=+e,t|=0,i||v(this,e,t,r,(i=Math.pow(2,8*r-1))-1,-i);var n=0,s=1,a=0;for(this[t]=255&e;++n<r&&(s*=256);)e<0&&0===a&&0!==this[t+n-1]&&(a=1),this[t+n]=(e/s>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){e=+e,t|=0,i||v(this,e,t,r,(i=Math.pow(2,8*r-1))-1,-i);var n=r-1,s=1,a=0;for(this[t+n]=255&e;0<=--n&&(s*=256);)e<0&&0===a&&0!==this[t+n+1]&&(a=1),this[t+n]=(e/s>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):_(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return T(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return T(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return S(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return S(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(r=r||0,i||0===i||(i=this.length),t>=e.length&&(t=e.length),(i=0<i&&i<r?r:i)===r)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length);var n,s=(i=e.length-t<i-r?e.length-t+r:i)-r;if(this===e&&r<t&&t<i)for(n=s-1;0<=n;--n)e[n+t]=this[n+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(n=0;n<s;++n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){var n;if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===e.length&&(n=e.charCodeAt(0))<256&&(e=n),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(!(r<=t))if(t>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(e=e||0))for(o=t;o<r;++o)this[o]=e;else for(var s=c.isBuffer(e)?e:A(new c(e,i).toString()),a=s.length,o=0;o<r-t;++o)this[o+t]=s[o%a];return this};var M=/[^+\/0-9A-Za-z-_]/g;function A(e,t){var r;t=t||1/0;for(var i=e.length,n=null,s=[],a=0;a<i;++a){if(55295<(r=e.charCodeAt(a))&&r<57344){if(!n){if(56319<r){-1<(t-=3)&&s.push(239,191,189);continue}if(a+1===i){-1<(t-=3)&&s.push(239,191,189);continue}n=r;continue}if(r<56320){-1<(t-=3)&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&-1<(t-=3)&&s.push(239,191,189);if(n=null,r<128){if(--t<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function L(e){return E.toByteArray(function(e){if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(M,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function R(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}}.call(this,D(30))},555:function(e,t){function r(){return e.exports=r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,r.apply(this,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},561:function(e,t,r){var i=r(694);e.exports=function(e){return null==e?"":i(e)}},562:function(e,t,r){"use strict";var{default:r,DraggableCore:i}=r(716);e.exports=r,e.exports.default=r,e.exports.DraggableCore=i},564:function(e,n,s){!function(e){var t=void 0!==e&&e||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new i(r.call(setTimeout,t,arguments),clearTimeout)},n.setInterval=function(){return new i(r.call(setInterval,t,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(t,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},s(756),n.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,n.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}.call(this,s(30))},570:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},t.findInArray=function(r,i){for(let e=0,t=r.length;e<t;e++)if(i.apply(i,[r[e],e,r]))return r[e]},t.int=function(e){return parseInt(e,10)},t.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},t.isNum=function(e){return"number"==typeof e&&!isNaN(e)}},575:function(e,t,r){"use strict";e.exports=r(659)},578:function(e,t){e.exports=function(e,t){if(null==e)return{};var r,i={};for(r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(0<=t.indexOf(r))continue;i[r]=e[r]}return i},e.exports.__esModule=!0,e.exports.default=e.exports},582:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addClassName=h,t.addEvent=function(e,t,r,i){e&&(i={capture:!0,...i},e.addEventListener?e.addEventListener(t,r,i):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r)},t.addUserSelectStyles=function(e){var t;e&&((t=e.getElementById("react-draggable-style-el"))||((t=e.createElement("style")).type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t)),e.body)&&h(e.body,"react-draggable-transparent-selection")},t.createCSSTransform=function(e,t){e=l(e,t,"px");return{[(0,n.browserPrefixToKey)("transform",n.default)]:e}},t.createSVGTransform=function(e,t){return l(e,t,"")},t.getTouch=function(e,t){return e.targetTouches&&(0,i.findInArray)(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&(0,i.findInArray)(e.changedTouches,e=>t===e.identifier)},t.getTouchIdentifier=function(e){return e.targetTouches&&e.targetTouches[0]?e.targetTouches[0].identifier:e.changedTouches&&e.changedTouches[0]?e.changedTouches[0].identifier:void 0},t.getTranslation=l,t.innerHeight=function(e){var t=e.clientHeight,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t-=(0,i.int)(e.paddingTop))-(0,i.int)(e.paddingBottom)},t.innerWidth=function(e){var t=e.clientWidth,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t-=(0,i.int)(e.paddingLeft))-(0,i.int)(e.paddingRight)},t.matchesSelector=o,t.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(o(i,t))return!0;if(i===r)return!1}while(i=i.parentNode);return!1},t.offsetXYFromParent=function(e,t,r){var i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-i.left)/r,y:(e.clientY+t.scrollTop-i.top)/r}},t.outerHeight=function(e){var t=e.clientHeight,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t+=(0,i.int)(e.borderTopWidth))+(0,i.int)(e.borderBottomWidth)},t.outerWidth=function(e){var t=e.clientWidth,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t+=(0,i.int)(e.borderLeftWidth))+(0,i.int)(e.borderRightWidth)},t.removeClassName=u,t.removeEvent=function(e,t,r,i){e&&(i={capture:!0,...i},e.removeEventListener?e.removeEventListener(t,r,i):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null)},t.removeUserSelectStyles=function(e){if(e)try{var t;e.body&&u(e.body,"react-draggable-transparent-selection"),e.selection?e.selection.empty():(t=(e.defaultView||window).getSelection())&&"Caret"!==t.type&&t.removeAllRanges()}catch(e){}};var i=r(570),n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=a(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(717));function a(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(a=function(e){return e?r:t})(e))}let s="";function o(t,e){return s=s||(0,i.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(e){return(0,i.isFunction)(t[e])}),!!(0,i.isFunction)(t[s])&&t[s](e)}function l(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);s="translate(".concat(e,", ").concat(i,")")+s}return s}function h(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function u(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}},597:function(e,t,r){"use strict";t.a={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},598:function(e,t,r){"use strict";r.r(t),t.default=function(t){var r={};return function(e){return void 0===r[e]&&(r[e]=t(e)),r[e]}}},601:function(e,t){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}},609:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},t.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},t.createCoreData=function(e,t,r){var i=!(0,l.isNum)(e.lastX),n=u(e);return i?{node:n,deltaX:0,deltaY:0,lastX:t,lastY:r,x:t,y:r}:{node:n,deltaX:t-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:r}},t.createDraggableData=function(e,t){var r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},t.getBoundPosition=function(t,r,i){if(t.props.bounds){let e=t.props["bounds"];e="string"==typeof e?e:{left:(n=e).left,top:n.top,right:n.right,bottom:n.bottom};var n=u(t);if("string"==typeof e){const t=n["ownerDocument"],r=t.defaultView;var s="parent"===e?n.parentNode:t.querySelector(e);if(!(s instanceof r.HTMLElement))throw new Error('Bounds selector "'+e+'" could not find an element.');const u=s,a=r.getComputedStyle(n),o=r.getComputedStyle(u);e={left:-n.offsetLeft+(0,l.int)(o.paddingLeft)+(0,l.int)(a.marginLeft),top:-n.offsetTop+(0,l.int)(o.paddingTop)+(0,l.int)(a.marginTop),right:(0,h.innerWidth)(u)-(0,h.outerWidth)(n)-n.offsetLeft+(0,l.int)(o.paddingRight)-(0,l.int)(a.marginRight),bottom:(0,h.innerHeight)(u)-(0,h.outerHeight)(n)-n.offsetTop+(0,l.int)(o.paddingBottom)-(0,l.int)(a.marginBottom)}}(0,l.isNum)(e.right)&&(r=Math.min(r,e.right)),(0,l.isNum)(e.bottom)&&(i=Math.min(i,e.bottom)),(0,l.isNum)(e.left)&&(r=Math.max(r,e.left)),(0,l.isNum)(e.top)&&(i=Math.max(i,e.top))}return[r,i]},t.getControlPosition=function(e,t,r){var i="number"==typeof t?(0,h.getTouch)(e,t):null;return"number"!=typeof t||i?(t=u(r),t=r.props.offsetParent||t.offsetParent||t.ownerDocument.body,(0,h.offsetXYFromParent)(i||e,t,r.props.scale)):null},t.snapToGrid=function(e,t,r){return[Math.round(t/e[0])*e[0],Math.round(r/e[1])*e[1]]};var l=r(570),h=r(582);function u(e){e=e.findDOMNode();if(e)return e;throw new Error("<DraggableCore>: Unmounted during event!")}},610:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){}},615:function(e,t,r){"use strict";r.d(t,"a",function(){return n});var i=r(616);function n(r){return function e(t){return 0===arguments.length||Object(i.a)(t)?e:r.apply(this,arguments)}}},616:function(e,t,r){"use strict";function i(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}r.d(t,"a",function(){return i})},643:function(i,e,t){"use strict";t.d(e,"a",function(){return In});n=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,o=/^(?=([^\/?#]*))\1([^]*)$/,l=/(?:\/|^)\.(?=\/)/g,h=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=s.parseURL(e);if(i)return i.path=s.normalizePath(i.path),s.buildURLFromParts(i);throw new Error("Error trying to parse base URL.")}i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):t;t=s.parseURL(e);if(!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=o.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var n,e={scheme:t.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(e.netLoc=t.netLoc,"/"===i.path[0])||(i.path?(n=(n=t.path).substring(0,n.lastIndexOf("/")+1)+i.path,e.path=s.normalizePath(n)):(e.path=t.path,i.params||(e.params=t.params,i.query)||(e.query=t.query))),null===e.path&&(e.path=r.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(e)},parseURL:function(e){e=n.exec(e);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(l,"");e.length!==(e=e.replace(h,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var n,o,l,h,s,H=s;function z(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function m(i){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?z(Object(n),!0).forEach(function(e){var t,r;t=i,e=n[r=e],(r=function(){var e=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r);return"symbol"==typeof e?e:String(e)}())in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(n,e))})}return i}function L(){return(L=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}const M=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};(t={}).MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached";let R=t,C=((e={}).NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e),D=((t={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t);function V(){}const W={trace:V,debug:V,log:V,warn:V,info:V,error:V};let j=W;function Y(r,...e){e.forEach(function(e){var t;j[e]=r[e]?r[e].bind(r):(t=self.console[e])?t.bind(self.console,`[${e}] >`):V})}const I=j,$=/^(\d+)x(\d+)$/,q=/(.+?)=(".*?"|.*?)(?:,|$)/g;class A{constructor(e){for(const t in e="string"==typeof e?A.parseAttrList(e):e)e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){e=parseInt(this[e],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(e){if(this[e]){var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){e=parseInt(this[e],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){e=this[e];return e?parseFloat(e):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){e=$.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(e){var t,r={};for(q.lastIndex=0;null!==(t=q.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),r[t[1].trim()]=e}return r}}class K{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){I.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=L(new A({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);M(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var e;return this._endDate||(null!==(e=this.duration)?new Date(this._startDate.getTime()+1e3*e):null)}get duration(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(M(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&M(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class X{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var b="audio",S="video",J="audiovideo";class Z{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={audio:null,video:null,audiovideo:null},this.baseurl=e}setByteRange(e,t){var e=e.split("@",2),r=[];1===e.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(e[1]),r[1]=parseInt(e[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=H.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Q extends Z{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new X,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const e=this["levelkeys"];if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var e;return null!==this.programDateTime&&M(this.programDateTime)?(e=M(this.duration)?this.duration:0,this.programDateTime+1e3*e):null}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(1<t||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){this.levelkeys&&(e=this.levelkeys[e])&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}abortRequests(){var e;null!=(e=this.loader)&&e.abort(),null!=(e=this.keyLoader)&&e.abort()}setElementaryStreamInfo(e,t,r,i,n,s=!1){var a=this["elementaryStreams"],o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}clearElementaryStreamInfo(){var e=this["elementaryStreams"];e[b]=null,e[S]=null,e[J]=null}}class ee extends Z{constructor(e,t,r,i,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new X,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;r=e.enumeratedString("BYTERANGE");r&&this.setByteRange(r,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){var e=this["elementaryStreams"];return!!(e.audio||e.video||e.audiovideo)}}class te{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){var t,r;e?(t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex,this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||0<t||0==t&&0<r,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay):(this.advanced=!0,this.updated=!0)}get hasProgramDateTime(){return!!this.fragments.length&&M(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){var e=this.driftEndTime-this.driftStartTime;return 0<e?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function re(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function ie(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}var c={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ne="org.w3.clearkey",se="com.apple.streamingkeydelivery",ae="com.microsoft.playready",oe="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function le(e){switch(e){case se:return c.FAIRPLAY;case ae:return c.PLAYREADY;case oe:return c.WIDEVINE;case ne:return c.CLEARKEY}}var he="edef8ba979d64acea3c827dcd51d21ed";function ue(e){switch(e){case c.FAIRPLAY:return se;case c.PLAYREADY:return ae;case c.WIDEVINE:return oe;case c.CLEARKEY:return ne}}function ce(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[c.FAIRPLAY,c.WIDEVINE,c.PLAYREADY,c.CLEARKEY].filter(e=>!!t[e]):[];return!i[c.WIDEVINE]&&r&&i.push(c.WIDEVINE),i}const de="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function fe(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}const pe=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,me=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,ge=(e,t)=>{var r=t;let i=0;for(;pe(e,t);)i=(i+=10)+ve(e,t+6),me(e,t+10)&&(i+=10),t+=i;if(0<i)return e.subarray(r,r+i)},ve=(e,t)=>{var r=(127&e[t])<<21;return(r|=(127&e[t+1])<<14)|(127&e[t+2])<<7|127&e[t+3]},ye=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,xe=e=>{let t=0;for(var r,i=[];pe(e,t);){for(var n=ve(e,t+6),s=(t+=10)+n;t+8<s;){r=e.subarray(t),o=a=void 0,a=String.fromCharCode(r[0],r[1],r[2],r[3]),o=ve(r,4);var a={type:a,size:o,data:r.subarray(10,10+o)},o=("PRIV"===(r=a).type?_e:"W"===r.type[0]?Te:be)(r);o&&i.push(o),t+=a.size+10}me(e,t)&&(t+=10)}return i},_e=e=>{var t,r;if(!(e.size<2))return t=E(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:r.buffer}},be=e=>{var t,r;if(!(e.size<2))return"TXXX"===e.type?(t=1,t+=(r=E(e.data.subarray(1),!0)).length+1,t=E(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=E(e.data.subarray(1)),{key:e.type,data:r})},Te=e=>{var t,r;return"WXXX"===e.type?e.size<2?void 0:(t=1,t+=(r=E(e.data.subarray(1),!0)).length+1,t=E(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=E(e.data),{key:e.type,data:r})},E=(e,t=!1)=>{var r=Se=Se||void 0===self.TextDecoder?Se:new self.TextDecoder("utf-8");if(r){const i=r.decode(e);if(t){const e=i.indexOf("\0");return-1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}const i=e.length;let n,s,a,o="",l=0;for(;l<i;){if(0===(n=e[l++])&&t)return o;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(n);break;case 12:case 13:s=e[l++],o+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[l++],a=e[l++],o+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&a)<<0)}}return o};let Se;function d(r){let i="";for(let t=0;t<r.length;t++){let e=r[t].toString(16);e.length<2&&(e="0"+e),i+=e}return i}const Ee=Math.pow(2,32)-1,we=[].push,Me={video:1,audio:2,id3:3,text:4};function f(e){return String.fromCharCode.apply(null,e)}function Ae(e,t){e=e[t]<<8|e[t+1];return e<0?65536+e:e}function w(e,t){e=Le(e,t);return e<0?4294967296+e:e}function Le(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Re(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function P(t,r){var i=[];if(r.length){const s=t.byteLength;for(let e=0;e<s;){var n=w(t,e),n=1<n?e+n:s;if(f(t.subarray(e+4,e+8))===r[0])if(1===r.length)i.push(t.subarray(e+8,n));else{const s=P(t.subarray(e+8,n),r.slice(1));s.length&&we.apply(i,s)}e=n}}return i}function Ce(t){const r=[],i=P(t,["moov","trak"]);for(let e=0;e<i.length;e++){var n=i[e],s=P(n,["tkhd"])[0];if(s){var s=w(s,0===s[0]?12:20),a=P(n,["mdia","mdhd"])[0];if(a){var a=w(a,0===a[0]?12:20),o=P(n,["mdia","hdlr"])[0];if(o){const t=f(o.subarray(8,12)),i={soun:b,vide:S}[t];if(i){const t=P(n,["mdia","minf","stbl","stsd"])[0];let e;t&&(e=f(t.subarray(12,16))),r[s]={timescale:a,type:i},r[i]={timescale:a,id:s,codec:e}}}}}}return P(t,["moov","mvex","trex"]).forEach(e=>{var t=w(e,4),t=r[t];t&&(t.default={duration:w(e,12),flags:w(e,20)})}),r}function De(e){var t=P(e,["schm"])[0];if(t){t=f(t.subarray(4,8));if("cbcs"===t||"cenc"===t)return P(e,["schi","tenc"])[0]}return I.error("[eme] missing 'schm' box"),null}function Ie(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Pe(v,y){const x=[],_=y.samples,b=y.timescale,o=y.id;let T=!1;return P(_,["moof"]).map(e=>{const g=e.byteOffset-8;P(e,["traf"]).map(a=>{var e=P(a,["tfdt"]).map(e=>{var t=e[0];let r=w(e,4);return(r=1===t?(r*=Math.pow(2,32))+w(e,8):r)/b})[0];return void 0!==e&&(v=e),P(a,["tfhd"]).map(e=>{var t=w(e,4),r=16777215&w(e,0);let p=0;var i=0!=(16&r);let m=0;var n=0!=(32&r);let s=8;t===o&&(0!=(1&r)&&(s+=8),0!=(2&r)&&(s+=4),0!=(8&r)&&(p=w(e,s),s+=4),i&&(m=w(e,s),s+=4),n&&(s+=4),"video"===y.type&&(T=!!(t=y.codec)&&("hvc1"===(t=(r=t.indexOf("."))<0?t:t.substring(0,r))||"hev1"===t||"dvh1"===t||"dvhe"===t)),P(a,["trun"]).map(t=>{var r=t[0],e=16777215&w(t,0);let i=0;var n=0!=(256&e);let s=0;var a=0!=(512&e);let o=0;var l=0!=(1024&e),h=0!=(2048&e);let u=0;var c=w(t,4);let d=8,f=(0!=(1&e)&&(i=w(t,d),d+=4),0!=(4&e)&&(d+=4),i+g);for(let e=0;e<c;e++){if(n?(s=w(t,d),d+=4):s=p,a?(o=w(t,d),d+=4):o=m,l&&(d+=4),h&&(u=(0===r?w:Le)(t,d),d+=4),y.type===S){let e=0;for(;e<o;){const t=w(_,f);f+=4,function(e,t){if(e){const e=t>>1&63;return 39==e||40==e}return 6==(31&t)}(T,_[f])&&ke(_.subarray(f,f+t),T?2:1,v+u/b,x),f+=t,e+=t+4}}v+=s/b}}))})})}),x}function ke(t,r,i,e){var n=Oe(t);let s=0,a=(s+=r,0),o=0,l=!1,h=0;for(;s<n.length;){for(a=0;!(s>=n.length)&&(h=n[s++],a+=h,255===h););for(o=0;!(s>=n.length)&&(h=n[s++],o+=h,255===h););const t=n.length-s;if(!l&&4===a&&s<n.length){if(l=!0,181===n[s++]){const t=Ae(n,s);if(s+=2,49===t){const t=w(n,s);if(s+=4,1195456820===t){const t=n[s++];if(3===t){const r=n[s++],o=31&r,l=64&r,h=l?2+3*o:0,u=new Uint8Array(h);if(l){u[0]=r;for(let e=1;e<h;e++)u[e]=n[s++]}e.push({type:t,payloadType:a,pts:i,bytes:u})}}}}}else if(5===a&&o<t){if(l=!0,16<o){const t=[];for(let e=0;e<16;e++){const i=n[s++].toString(16);t.push(1==i.length?"0"+i:i),3!==e&&5!==e&&7!==e&&9!==e||t.push("-")}const r=o-16,l=new Uint8Array(r);for(let e=0;e<r;e++)l[e]=n[s++];e.push({payloadType:a,pts:i,uuid:t.join(""),userData:E(l),userDataBytes:l})}}else if(o<t)s+=o;else if(o>t)break}}function Oe(e){var t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}let Fe={};class Ne{static clearKeyUriToKeyIdMap(){Fe={}}constructor(e,t,r,i=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case se:case oe:case ae:case ne:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(t){var r=new Uint8Array(16);for(let e=12;e<16;e++)r[e]=t>>8*(15-e)&255;return r}(e);return new Ne(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=function(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),s=e[e.length-1].split(",");if(2===s.length){const t="base64"===s[0],a=s[1];r=t?(e.splice(-1,1),re(a)):(i=ie(a).subarray(0,16),(n=new Uint8Array(16)).set(i,16-i.length),n)}}var i,n;return r}(this.uri);if(t)switch(this.keyFormat){case oe:22<=(this.pssh=t).length&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case ae:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(r,t,i){if(16!==r.byteLength)throw new RangeError("Invalid system id");let n,s,a;if(t){n=1,s=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const i=t[e];if(16!==i.byteLength)throw new RangeError("Invalid key");s.set(i,16*e)}}else n=0,s=new Uint8Array;0<n?(a=new Uint8Array(4),0<t.length&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var o=new Uint8Array(4);i&&0<i.byteLength&&new DataView(o.buffer).setUint32(0,i.byteLength,!1);{var l=[new Uint8Array([n,0,0,0]),r,a,s,o,i||new Uint8Array],h=l.length;let e=8,t=h;for(;t--;)e+=l[t].byteLength;var u=new Uint8Array(e);for(u[0]=e>>24&255,u[1]=e>>16&255,u[2]=e>>8&255,u[3]=255&e,u.set([112,115,115,104],4),t=0,e=8;t<h;t++)u.set(l[t],e),e+=l[t].byteLength;return u}}(e,null,t);var r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),r=String.fromCharCode.apply(null,Array.from(r)),r=r.substring(r.indexOf("<"),r.length),r=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(r){const e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){const t=re(e).subarray(0,16);r=t,i(r,0,3),i(r,1,2),i(r,4,5),i(r,6,7),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}function i(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}if(!this.keyId||16!==this.keyId.byteLength){let e=Fe[this.uri];if(!e){const t=Object.keys(Fe).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16),new DataView(e.buffer,12,4).setUint32(0,t),Fe[this.uri]=e}this.keyId=e}return this}}const Ue=/\{\$([a-zA-Z0-9-_]+)\}/g;function Be(e){return Ue.test(e)}function k(t,r,i){if(null!==t.variableList||t.hasVariableRefs)for(let e=i.length;e--;){var n=i[e],s=r[n];s&&(r[n]=Ge(t,s))}}function Ge(i,e){if(null!==i.variableList||i.hasVariableRefs){const n=i.variableList;return e.replace(Ue,e=>{var t=e.substring(2,e.length-1),r=null==n?void 0:n[t];return void 0===r?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${t}"`)),e):r})}return e}function He(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function ze(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Ve={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},We=ze();function je(e,t){return null!=(t=null==We?void 0:We.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&t}const Ye=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,$e=/#EXT-X-MEDIA:(.*)/g,qe=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ke=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Xe=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class p{static findGroup(t,r){for(let e=0;e<t.length;e++){var i=t[e];if(i.id===r)return i}}static convertAVC1ToAVCOTI(e){var t,r=e.split(".");return 2<r.length?(t=r.shift()+".",(t+=parseInt(r.shift()).toString(16))+("000"+parseInt(r.shift()).toString(16)).slice(-4)):e}static resolve(e,t){return H.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return qe.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Be(e)},i=[];var n,s;for(Ye.lastIndex=0;null!=(n=Ye.exec(e));)if(n[1]){const e=new A(n[1]),a=(k(r,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]),Ge(r,n[2])),o={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:p.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),function(i,n){["video","audio","text"].forEach(r=>{const t=i.filter(e=>{var t=r;return!!(t=Ve[t])&&!0===t[e.slice(0,4)]});var e;t.length&&(e=t.filter(e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)),n[r+"Codec"]=(0<e.length?e:t)[0],i=i.filter(e=>-1===t.indexOf(e)))}),n.unknownCodecs=i}((e.CODECS||"").split(/[ ,]+/).filter(e=>e),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=p.convertAVC1ToAVCOTI(o.videoCodec)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new A(i),t=(k(r,e,["DATA-ID","LANGUAGE","VALUE","URI"]),e["DATA-ID"]);t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Je(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const e=new A(i);k(r,e,["NAME","VALUE","QUERYPARAM"]),He(r,e,t)}break;case"CONTENT-STEERING":{const e=new A(i);k(r,e,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:p.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Ze(i)}}const a=0<i.length&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for($e.lastIndex=0;null!==(i=$e.exec(e));){const e=new A(i[1]),s=e.TYPE;if(s){const i=a[s],h=n[s]||[];n[s]=h,k(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var l={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?p.resolve(e.URI,t):""};if(null!=i&&i.length){const e=p.findGroup(i,l.groupId)||i[0];Qe(l,e,"audioCodec"),Qe(l,e,"textCodec")}h.push(l)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){const a=new te(t),o=a.fragments;let l,h,u,c=null,d=0,f=0,p=0,m=0,g=null,v=new Q(i,t),y=-1,x=!1;for(Ke.lastIndex=0,a.m3u8=e,a.hasVariableRefs=Be(e);null!==(l=Ke.exec(e));){x&&(x=!1,(v=new Q(i,t)).start=p,v.sn=d,v.cc=m,v.level=r,c)&&(v.initSegment=c,v.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null);const e=l[1];if(e){v.duration=parseFloat(e);const t=(" "+l[2]).slice(1);v.title=t||null,v.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(M(v.duration)){v.start=p,u&&rt(v,u,a),v.sn=d,v.level=r,v.cc=m,v.urlId=n,o.push(v);const e=(" "+l[3]).slice(1);v.relurl=Ge(a,e),et(v,g),g=v,p+=v.duration,d++,f=0,x=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);g?v.setByteRange(e,g):v.setByteRange(e)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else if(l=l[0].match(Xe)){for(h=1;h<l.length&&void 0===l[h];h++);const e=(" "+l[h]).slice(1),n=(" "+l[h+1]).slice(1),p=l[h+2]?(" "+l[h+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":a.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(n);break;case"SKIP":{const e=new A(n),t=(k(a,e,["RECENTLY-REMOVED-DATERANGES"]),e.decimalInteger("SKIPPED-SEGMENTS"));if(M(t)){for(let e=a.skippedSegments=t;e--;)o.unshift(null);d+=t}const r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(a.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(n),1);break;case"VERSION":a.version=parseInt(n);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(n||p)&&v.tagList.push(p?[n,p]:[n]);break;case"DISCONTINUITY":m++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([e]);break;case"BITRATE":v.tagList.push([e,n]);break;case"DATERANGE":{const e=new A(n),t=(k(a,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),k(a,e,e.clientAttrs),new K(e,a.dateRanges[e.ID]));t.isValid||a.skippedSegments?a.dateRanges[t.id]=t:I.warn(`Ignoring invalid DATERANGE tag: "${n}"`),v.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new A(n);if(k(a,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e){_=void 0;b=void 0;T=void 0;var _=a;var b=e;var T=s;if(b=b.IMPORT,T&&b in T){let e=_.variableList;e||(_.variableList=e={}),e[b]=T[b]}else _.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${b}"`))}else He(a,e,t)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(n);break;case"KEY":{const e=Je(n,t,a);if(e.isSupported()){if("NONE"===e.method){u=void 0;break}(u=(u=u||{})[e.keyFormat]?L({},u):u)[e.keyFormat]=e}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${n}"`);break}case"START":a.startTimeOffset=Ze(n);break;case"MAP":{const e=new A(n);if(k(a,e,["BYTERANGE","URI"]),v.duration){const n=new Q(i,t);tt(n,e,r,u),c=n,(v.initSegment=c).rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=c.rawProgramDateTime)}else tt(v,e,r,u),c=v,x=!0;break}case"SERVER-CONTROL":{const e=new A(n);a.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=0<a.canSkipUntil&&e.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),a.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new A(n);a.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=a.partList;e=e||(a.partList=[]);const r=0<f?e[e.length-1]:void 0,i=f++,s=new A(n),o=(k(a,s,["BYTERANGE","URI"]),new ee(s,v,t,i,r));e.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const e=new A(n);k(a,e,["URI"]),a.preloadHint=e;break}case"RENDITION-REPORT":{const e=new A(n);k(a,e,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(e);break}default:I.warn("line parsed but not handled: "+l)}}else I.warn("No matches on slow regex match for level playlist!")}g&&!g.relurl?(o.pop(),p-=g.duration,a.partList&&(a.fragmentHint=g)):a.partList&&(et(v,g),v.cc=m,a.fragmentHint=v,u)&&rt(v,u,a);var S=o.length,E=o[0],w=o[S-1];if(0<(p+=a.skippedSegments*a.targetduration)&&S&&w){a.averagetargetduration=p/S;const e=w.sn;a.endSN="initSegment"!==e?e:0,a.live||(w.endList=!0),E&&(a.startCC=E.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(p+=a.fragmentHint.duration),a.totalduration=p,a.endCC=m,0<y&&function(t,r){let i=t[r];for(let e=r;e--;){const r=t[e];if(!r)return;r.programDateTime=i.programDateTime-1e3*r.duration,i=r}}(o,y),a}}function Je(e,t,r){var e=new A(e),r=(k(r,e,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]),null!=(r=e.METHOD)?r:""),i=e.URI,n=e.hexadecimalInteger("IV"),s=e.KEYFORMATVERSIONS,a=null!=(a=e.KEYFORMAT)?a:"identity",e=(i&&e.IV&&!n&&I.error("Invalid IV: "+e.IV),i?p.resolve(i,t):""),i=(s||"1").split("/").map(Number).filter(Number.isFinite);return new Ne(r,e,a,i,n)}function Ze(e){e=new A(e).decimalFloatingPoint("TIME-OFFSET");return M(e)?e:null}function Qe(e,t,r){t=t[r];t&&(e[r]=t)}function et(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),M(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function tt(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function rt(e,t,r){e.levelkeys=t;r=r.encryptedFragments;r.length&&r[r.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||r.push(e)}var it="manifest",nt="level",g="audioTrack",v="subtitleTrack",y="main",T="audio",st="subtitle";function at(e){e=e.type;switch(e){case g:return T;case v:return st;default:return y}}function ot(e,t){let r=e.url;return r=void 0!==r&&0!==r.indexOf("data:")?r:t.url}class lt{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){var t=this.hls.config,r=t.pLoader,i=t.loader,r=new(r||i)(t);return this.loaders[e.type]=r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){t=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:it,url:t,deliveryDirectives:null})}onLevelLoading(e,t){var{id:t,level:r,url:i,deliveryDirectives:n}=t;this.load({id:t,level:r,responseType:"text",type:nt,url:i,deliveryDirectives:n})}onAudioTrackLoading(e,t){var{id:t,groupId:r,url:i,deliveryDirectives:n}=t;this.load({id:t,groupId:r,level:null,responseType:"text",type:g,url:i,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){var{id:t,groupId:r,url:i,deliveryDirectives:n}=t;this.load({id:t,groupId:r,level:null,responseType:"text",type:v,url:i,deliveryDirectives:n})}load(t){const r=this.hls.config;let i,e=this.getInternalLoader(t);if(e){const n=e.context;if(n&&n.url===t.url)return void I.trace("[playlist-loader]: playlist request ongoing");I.log("[playlist-loader]: aborting previous loader for type: "+t.type),e.abort()}if(i=t.type===it?r.manifestLoadPolicy.default:L({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),e=this.createInternalLoader(t),null!=(n=t.deliveryDirectives)&&n.part){let e;if(t.type===nt&&null!==t.level?e=this.hls.levels[t.level].details:t.type===g&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===v&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,r=e.targetduration;if(t&&r){const n=1e3*Math.max(3*t,.8*r);i=L({},i,{maxTimeToFirstByteMs:Math.min(n,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(n,i.maxTimeToFirstByteMs)})}}}var n=i.errorRetry||i.timeoutRetry||{},n={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};e.load(t,n,{onSuccess:(e,t,r,i)=>{var n=this.getInternalLoader(r),s=(this.resetInternalLoader(r.type),e.data);0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),p.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}})}handleMasterPlaylist(e,t,r,i){var n,s,a,o,l,h=this.hls,u=e.data,c=ot(e,r),d=p.parseMasterPlaylist(u,c);d.playlistParsingError?this.handleManifestParsingError(e,r,d.playlistParsingError,i,t):({contentSteering:e,levels:r,sessionData:n,sessionKeys:s,startTimeOffset:a,variableList:o}=d,{AUDIO:u=[],SUBTITLES:d,"CLOSED-CAPTIONS":l}=(this.variableList=o,p.parseMasterPlaylistMedia(u,c,d)),u.length&&!u.some(e=>!e.url)&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),u.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new A({}),bitrate:0,url:""})),h.trigger(R.MANIFEST_LOADED,{levels:r,audioTracks:u,subtitles:d,captions:l,contentSteering:e,url:c,stats:t,networkDetails:i,sessionData:n,sessionKeys:s,startTimeOffset:a,variableList:o}))}handleTrackOrLevelPlaylist(e,t,r,i,n){var s=this.hls,{id:a,level:o,type:l}=r,h=ot(e,r),a=M(a)?a:0,o=M(o)?o:a,u=at(r),o=p.parseLevelPlaylist(e.data,h,o,u,a,this.variableList);if(l===it){const e={attrs:new A({}),bitrate:0,details:o,name:"",url:h};s.trigger(R.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:h,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=o,this.handlePlaylistLoaded(o,e,t,r,i,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===it,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading `+e.type;e.type===nt?s+=`: ${e.level} id: `+e.id:e.type!==g&&e.type!==v||(s+=` id: ${e.id} group-id: "${e.groupId}"`);var a=new Error(s);I.warn("[playlist-loader]: "+s);let o=D.UNKNOWN,l=!1;var h=this.getInternalLoader(e);switch(e.type){case it:o=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,l=!0;break;case nt:o=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,l=!1;break;case g:o=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case v:o=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(e.type);h={type:C.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:h,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;h.response=m({url:r,data:void 0},i)}this.hls.trigger(R.ERROR,h)}handlePlaylistLoaded(e,t,r,i,n,s){var a=this.hls,{type:o,level:l,id:h,groupId:u,deliveryDirectives:c}=i,d=ot(t,i),f=at(i),p="number"==typeof i.level&&f===y?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));l=e.playlistParsingError;if(l)a.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:l,reason:l.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r});else switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case it:case nt:a.trigger(R.LEVEL_LOADED,{details:e,level:p||0,id:h||0,stats:r,networkDetails:n,deliveryDirectives:c});break;case g:a.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:c});break;case v:a.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:c})}}else{const e=new Error("No Segments found in Playlist");void a.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:e,reason:e.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r})}}}function ht(e,t){let r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ut(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){I.debug("[texttrack-utils]: "+r);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){I.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===r&&(e.mode=r)}function ct(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function dt(t,e,r,i){const n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&0<t.cues.length){const n=function(r,i,n){const s=[],a=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;let i=0,n=r;for(;i<=n;){var s=Math.floor((n+i)/2);if(t<e[s].startTime)n=s-1;else{if(!(t>e[s].startTime&&i<r))return s;i=s+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(r,i);if(-1<a)for(let e=a,t=r.length;e<t;e++){const a=r[e];if(a.startTime>=i&&a.endTime<=n)s.push(a);else if(a.startTime>n)return s}return s}(t.cues,e,r);for(let e=0;e<n.length;e++)i&&!i(n[e])||t.removeCue(n[e])}"disabled"===n&&(t.mode=n)}var ft="org.id3",pt="https://aomedia.org/emsg/ID3";function mt(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const gt=(()=>{var e=mt();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function vt(e,t){return e.getTime()/1e3-t}class yt{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(ct(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){e=this.getID3Track(e.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(r,i){if(this.media){const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:t}}=this["hls"];if(a||t){const o=i["samples"];this.id3Track||(this.id3Track=this.createTrack(this.media));var n=mt();for(let e=0;e<o.length;e++){const i=o[e].type;if((i!==pt||a)&&t){var s=xe(o[e].data);if(s){const a=o[e].pts;let t=a+o[e].duration;(t=t>gt?gt:t)-a<=0&&(t=a+.25);for(let e=0;e<s.length;e++){const o=s[e];if(!ye(o)){this.updateId3CueEnds(a,i);const r=new n(a,t,"");r.value=o,i&&(r.type=i),this.id3Track.addCue(r)}}}}}}}}updateId3CueEnds(t,r){var e,i=null==(e=this.id3Track)?void 0:e.cues;if(i)for(let e=i.length;e--;){var n=i[e];n.type===r&&n.startTime<t&&n.endTime===gt&&(n.endTime=t)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){var{id3Track:n,hls:s}=this;if(s){const{enableEmsgMetadataCues:a,enableID3MetadataCues:o}=s["config"];n&&(a||o)&&dt(n,t,r,"audio"===i?e=>e.type===ft&&o:"video"===i?e=>e.type===pt&&a:e=>e.type===ft&&o||e.type===pt&&a)}}onLevelUpdated(t,{details:n}){if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:c,id3Track:d}=this,f=n["dateRanges"],p=Object.keys(f);if(d){const t=Object.keys(c).filter(e=>!p.includes(e));for(let e=t.length;e--;){const f=t[e];Object.keys(c[f].cues).forEach(e=>{d.removeCue(c[f].cues[e])}),delete c[f]}}const m=n.fragments[n.fragments.length-1];if(0!==p.length&&M(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var s,a=m.programDateTime/1e3-m.start,o=mt();for(let e=0;e<p.length;e++){const n=p[e],d=f[n],m=c[n],M=(null==m?void 0:m.cues)||{};let r=(null==m?void 0:m.durationKnown)||!1;var l=vt(d.startDate,a);let i=gt;var h=d.endDate;if(h)i=vt(h,a),r=!0;else if(d.endOnNext&&!r){const t=p.reduce((e,t)=>{var r=f[t];return r.class===d.class&&r.id!==t&&r.startDate>d.startDate&&e.push(r),e},[]).sort((e,t)=>e.startDate.getTime()-t.startDate.getTime())[0];t&&(i=vt(t.startDate,a),r=!0)}var u=Object.keys(d.attr);for(let e=0;e<u.length;e++){const c=u[e];if("ID"!==(s=c)&&"CLASS"!==s&&"START-DATE"!==s&&"DURATION"!==s&&"END-DATE"!==s&&"END-ON-NEXT"!==s){let t=M[c];if(t)r&&!m.durationKnown&&(t.endTime=i);else{let e=d.attr[c];t=new o(l,i,""),"SCTE35-OUT"!==(s=c)&&"SCTE35-IN"!==s||(s=e,e=Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),t.value={key:c,data:e},t.type="com.apple.quicktime.HLS",t.id=n,this.id3Track.addCue(t),M[c]=t}}}c[n]={cues:M,dateRange:d,durationKnown:r}}}}}}class xt{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){var e=this["levelDetails"];if(null===e)return null;var{holdBack:e,partHoldBack:t,targetduration:r}=e,{liveSyncDuration:i,liveSyncDurationCount:n,lowLatencyMode:s}=this.config,a=this.hls.userConfig;let o=s&&t||e;return(o=a.liveSyncDuration||a.liveSyncDurationCount||0===o?void 0!==i?i:n*r:o)+Math.min(+this.stallCount,r)}get liveSyncPosition(){var e,t=this.estimateLiveEdge(),r=this.targetLatency,i=this.levelDetails;return null===t||null===r||null===i?null:(e=i.edge,t=t-r-this.edgeStalled,r=e-i.totalduration,e=e-(this.config.lowLatencyMode&&i.partTarget||i.targetduration),Math.min(Math.max(r,t),e))}get drift(){var e=this["levelDetails"];return null===e?1:e.drift}get edgeStalled(){var e,t=this["levelDetails"];return null===t?0:(e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),Math.max(t.age-e,0))}get forwardBufferLength(){var e,{media:t,levelDetails:r}=this;return t&&r?((e=t.buffered.length)?t.buffered.end(e-1):r.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){(this.levelDetails=t).advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(t=this.levelDetails))&&t.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){const{media:e,levelDetails:t}=this;if(e&&t){this.currentTime=e.currentTime;const s=this.computeLatency();if(null!==s){this._latency=s;var{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(r&&1!==i){r=this.targetLatency;if(null!==r){var n=s-r,r=n<Math.min(this.maxLatency,r+t.targetduration);if(t.live&&r&&.05<n&&1<this.forwardBufferLength){const t=Math.min(2,Math.max(1,i)),s=Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,s))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}}estimateLiveEdge(){var e=this["levelDetails"];return null===e?null:e.edge+e.age}computeLatency(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const _t=["NONE","TYPE-0","TYPE-1",null];class bt{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){e=new self.URL(e);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Tt{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){e%=this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function St(r,i){var n=i.startPTS;if(M(n)){let e,t=0;(e=i.sn>r.sn?(t=n-r.start,r):(t=r.start-n,i)).duration!==t&&(e.duration=t)}else i.sn>r.sn?r.cc===i.cc&&r.minEndPTS?i.start=r.start+(r.minEndPTS-r.start):i.start=r.start+r.duration:i.start=Math.max(r.start-i.duration,0)}function Et(e,t,r,i,n,s){i-r<=0&&(I.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let a=r,o=i;var l=t.startPTS,h=t.endPTS;if(M(l)){const e=Math.abs(l-r);M(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,a=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,h),i=Math.max(i,h),s=Math.max(s,t.endDTS)}l=r-t.start,0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=a,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=s,h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let u;var r=h-e.startSN,c=e.fragments;for(c[r]=t,u=r;0<u;u--)St(c[u],c[u-1]);for(u=r;u<c.length-1;u++)St(c[u],c[u+1]);return e.fragmentHint&&St(c[c.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,l}function wt(e,r){let i=null;var t=e.fragments;for(let e=t.length-1;0<=e;e--){const r=t[e].initSegment;if(r){i=r;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let n,s=0;{var a,o,l=e,h=r;const m=h.skippedSegments,g=Math.max(l.startSN,h.startSN)-h.startSN,v=(l.fragmentHint?1:0)+(m?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,y=h.startSN-l.startSN,x=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,_=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;for(let t=g;t<=v;t++){const g=_[y+t];let e=x[t];m&&!e&&t<m&&(e=h.fragments[t]=g),g&&e&&(a=g,o=e,a.relurl&&(s=a.cc-o.cc),M(a.startPTS)&&M(a.endPTS)&&(o.start=o.startPTS=a.startPTS,o.startDTS=a.startDTS,o.maxStartPTS=a.maxStartPTS,o.endPTS=a.endPTS,o.endDTS=a.endDTS,o.minEndPTS=a.minEndPTS,o.duration=a.endPTS-a.startPTS,o.duration&&(n=o),r.PTSKnown=r.alignedSliding=!0),o.elementaryStreams=a.elementaryStreams,o.loader=a.loader,o.stats=a.stats,o.urlId=a.urlId,a.initSegment)&&(o.initSegment=a.initSegment,i=a.initSegment)}}if(i&&(r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments).forEach(e=>{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(e=>!e),r.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=r.skippedSegments;e--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(e,r,t){const i=L({},e);return t&&t.forEach(e=>{delete i[e]}),Object.keys(r).forEach(e=>{var t=new K(r[e].attr,i[e]);t.isValid?i[e]=t:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(r[e].attr)}"`)}),i}(e.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var u=r.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<u.length;e++)u[e].cc+=s}r.skippedSegments&&(r.startCC=r.fragments[0].cc);var c=e.partList,d=r.partList;if(c&&d){let r=0;for(let e=0,t=c.length;e<=t;e++){var f=c[e],p=d[e+r];f&&p&&f.index===p.index&&f.fragment.sn===p.fragment.sn?(f=f,(p=p).elementaryStreams=f.elementaryStreams,p.stats=f.stats):r--}}n?Et(r,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Mt(e,r),u.length&&(r.totalduration=r.edge-u[0].start),r.driftStartTime=e.driftStartTime,r.driftStart=e.driftStart;l=r.advancedDateTime;if(r.advanced&&l){const e=r.edge;r.driftStart||(r.driftStartTime=l,r.driftStart=e),r.driftEndTime=l,r.driftEnd=e}else r.driftEndTime=e.driftEndTime,r.driftEnd=e.driftEnd,r.advancedDateTime=e.advancedDateTime}function Mt(e,t){var r=t.startSN+t.skippedSegments-e.startSN,e=e.fragments;r<0||r>=e.length||At(t,e[r].start)}function At(t,r){if(r){var i=t.fragments;for(let e=t.skippedSegments;e<i.length;e++)i[e].start+=r;t.fragmentHint&&(t.fragmentHint.start+=r)}}function Lt(e,t,r){return null!=e&&e.details?Rt(null==(e=e.details)?void 0:e.partList,t,r):null}function Rt(t,r,i){if(t)for(let e=t.length;e--;){var n=t[e];if(n.index===i&&n.fragment.sn===r)return n}return null}function Ct(e){switch(e.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Dt(e,t){t=Ct(t);return e.default[(t?"timeout":"error")+"Retry"]}function It(e,t){t="linear"===e.backoff?1:Math.pow(2,t);return Math.min(t*e.retryDelayMs,e.maxRetryDelayMs)}function Pt(e){return m(m({},e),{errorRetry:null,timeoutRetry:null})}function kt(e,t,r,i){return e&&t<e.maxNumRetry&&(0===i&&!1===navigator.onLine||i&&(i<400||499<i)||r)}function Ot(e,t){let r=0,i=e.length-1,n,s;for(;r<=i;){var a=t(s=e[n=(r+i)/2|0]);if(0<a)r=1+n;else{if(!(a<0))return s;i=n-1}}return null}function Ft(e,t,r=0,i=0){let n=null;return e?n=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(n=t[0]),n&&0===Nt(r,i,n)||!(t=Ot(t,Nt.bind(null,r,i)))||t===e&&n?n:t}function Nt(e=0,t=0,r){return r.start<=e&&r.start+r.duration>e?0:(t=Math.min(t,r.duration+(r.deltaPTS||0)),r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0)}class Ut{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,t+":"),this.warn=I.warn.bind(I,t+":"),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(i,n){var s=null==n?void 0:n.renditionReports;if(s){let r=-1;for(let t=0;t<s.length;t++){var a=s[t];let e;try{e=new self.URL(a.URI,n.url).href}catch(i){I.warn("Could not construct new URL for Rendition Report: "+i),e=a.URI||""}if(e===i){r=t;break}e===i.substring(0,e.length)&&(r=t)}if(-1!==r){const i=s[r],t=parseInt(i["LAST-MSN"])||(null==n?void 0:n.lastPartSn);let e=parseInt(i["LAST-PART"])||(null==n?void 0:n.lastPartIndex);if(this.hls.config.lowLatencyMode){const i=Math.min(n.age-n.partTarget,n.targetduration);0<=e&&i>n.partTarget&&(e+=1)}return new bt(t,0<=e?e:void 0,"")}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(n,s,a){const{details:o,stats:l}=s,h=self.performance.now(),e=l.loading.first?Math.max(0,h-l.loading.first):0;if(o.advancedDateTime=Date.now()-e,o.live||null!=a&&a.live){if(o.reloaded(a),a&&this.log(`live playlist ${n} `+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),a&&0<o.fragments.length&&wt(a,o),this.canLoad&&o.live){let t,r=void 0,i=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){const n=this.hls.config.lowLatencyMode,l=o.lastPartSn,h=o.endSN,d=o.lastPartIndex,f=l===h,p=n?0:d;-1!==d?(r=f?h+1:l,i=f?p:d+1):r=h+1;var u=o.age,c=u+o.ageHeader;let e=Math.min(c-o.partTarget,1.5*o.targetduration);if(0<e){if(a&&e>a.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${a.tuneInGoal} to: ${e} with playlist age: `+o.age),e=0;else{const n=Math.floor(e/o.targetduration);r+=n,void 0!==i&&(i+=Math.round(e%o.targetduration/o.partTarget)),this.log(`CDN Tune-in age: ${o.ageHeader}s last advanced ${u.toFixed(2)}s goal: ${e} skip sn ${n} to part `+i)}o.tuneInGoal=e}if(t=this.getDeliveryDirectives(o,s.deliveryDirectives,r,i),n||!f)return void this.loadPlaylist(t)}else(o.canBlockReload||o.canSkipUntil)&&(t=this.getDeliveryDirectives(o,s.deliveryDirectives,r,i));c=this.hls.mainForwardBufferInfo,a=c?c.end-c.len:0,u=function(e,t){let r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}(o,1e3*(o.edge-a)),s=(o.updated&&h>this.requestScheduled+u&&(this.requestScheduled=l.loading.start),void 0!==r&&o.canBlockReload?this.requestScheduled=l.loading.first+u-(1e3*o.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<h?this.requestScheduled=h:this.requestScheduled-h<=0&&(this.requestScheduled+=u),this.requestScheduled-h),s=Math.max(0,s);this.log(`reload live playlist ${n} in ${Math.round(s)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(t),s)}}else this.clearTimer()}getDeliveryDirectives(i,e,n,t){let r=function(){var{canSkipUntil:e,canSkipDateRanges:t,endSN:r}=i;return e&&(void 0!==n?n-r:0)<e?t?"v2":"YES":""}();return null!=e&&e.skip&&i.deltaUpdateFailed&&(n=e.msn,t=e.part,r=""),new bt(n,t,r)}checkRetry(e){var t=e.details,r=Ct(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},n=!!i&&!!a&&(5===n||!i.resolved&&2===n);if(n){if(this.requestScheduled=-1,s>=a.maxNumRetry)return!1;if(r&&null!=(r=e.context)&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=It(a,s);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return n}}let Bt;class Gt extends Ut{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.ERROR,this.onError,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const o=[],l={};let h;t.levels.forEach(e=>{var t=e.attrs,{AUDIO:r,CODECS:t,"FRAME-RATE":i,"PATHWAY-ID":n,RESOLUTION:s,SUBTITLES:a}=(-1!==(null==(r=e.audioCodec)?void 0:r.indexOf("mp4a.40.34"))&&(Bt=Bt||/chrome|firefox/i.test(navigator.userAgent))&&(e.audioCodec=void 0),t),n=(n||".")+"-"+e.bitrate+`-${s}-${i}-`+t;(h=l[n])?h.addFallback(e):(h=new Tt(e),l[n]=h,o.push(h)),Ht(h,"audio",r),Ht(h,"text",a)}),this.filterAndSortMediaOptions(o,t)}filterAndSortMediaOptions(e,r){let i=[],n=[],s=!1,a=!1,o=!1,l=e.filter(({audioCodec:e,videoCodec:t,width:r,height:i,unknownCodecs:n})=>(s=s||!(!r||!i),a=a||!!t,o=o||!!e,!(null!=n&&n.length)&&(!e||je(e,"audio"))&&(!t||je(t,"video"))));if(0===(l=(s||a)&&o?l.filter(({videoCodec:e,width:t,height:r})=>!!e||!(!t||!r)):l).length)Promise.resolve().then(()=>{var e;this.hls&&(e=new Error("no level with compatible codecs found in manifest"),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:e,reason:e.message}))});else{r.audioTracks&&zt(i=r.audioTracks.filter(e=>!e.audioCodec||je(e.audioCodec,"audio"))),r.subtitles&&zt(n=r.subtitles);var h=l.slice(0);l.sort((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):s&&e.height!==t.height?e.height-t.height:0);let t=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(let e=0;e<h.length;e++)if(h[e].pathwayId===l[0].pathwayId){t=h[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===t){this._firstLevel=e,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: `+t.bitrate);break}e=o&&!a,e={levels:l,audioTracks:i,subtitleTracks:n,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:a,altAudio:!e&&i.some(e=>!!e.url)};this.hls.trigger(R.MANIFEST_PARSED,e),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r!==e||!s.details||!i||n!==a){this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level `+r+(n?" with Pathway "+n:""));t=L({},s,{level:e,maxBitrate:s.maxBitrate,attrs:s.attrs,uri:s.uri,urlId:s.urlId}),e=(delete t._attrs,delete t._urlId,this.hls.trigger(R.LEVEL_SWITCHING,t),s.details);if(!e||e.live){const e=this.switchParams(s.uri,null==i?void 0:i.details);this.loadPlaylist(e)}}}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===nt&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(void 0!==t&&t.type===y){const e=this._levels[t.level];void 0!==e&&(e.loadError=0)}}onLevelLoaded(e,t){var{level:r,details:i}=t,n=this._levels[r];n?r===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(r,t,n.details)):null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0):(this.warn("Invalid level index "+r),null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0))}onAudioTrackSwitched(e,t){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let t=-1;for(let e=0;e<r.audioGroupIds.length;e++)if(r.audioGroupIds[e]===i){t=e;break}-1!==t&&t!==r.urlId&&(r.urlId=t,this.canLoad)&&this.startLoad()}}}loadPlaylist(t){super.loadPlaylist();var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.urlId;let e=i.uri;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}var s=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${r}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""} with${s?" Pathway "+s:""} URI ${n+1}/${i.url.length} `+e),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:e,level:r,id:n,deliveryDirectives:t||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(r,i){const n=(e,t)=>t!==i,e=this._levels.filter((e,t)=>t!==r||(1<e.url.length&&void 0!==i?(e.url=e.url.filter(n),e.audioGroupIds&&(e.audioGroupIds=e.audioGroupIds.filter(n)),e.textGroupIds&&(e.textGroupIds=e.textGroupIds.filter(n)),!(e.urlId=0)):(this.steering&&this.steering.removeLevel(e),!1)));this.hls.trigger(R.LEVELS_UPDATED,{levels:e})}onLevelsUpdated(e,{levels:t}){t.forEach((e,t)=>{e=e.details;null!=e&&e.fragments&&e.fragments.forEach(e=>{e.level=t})}),this._levels=t}}function Ht(e,t,r){r&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=r):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=r))}function zt(e){const r={};e.forEach(e=>{var t=e.groupId||"";e.id=r[t]=r[t]||0,r[t]++})}var Vt="NOT_LOADED",Wt="PARTIAL";class jt{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var e=this["hls"];e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){var r=this.activePartLists[e];if(r)for(let e=r.length;e--;){var i=r[e];if(!i)break;var n=i.end;if(i.start<=t&&null!==n&&t<=n)return i}return this.getBufferedFrag(t,e)}getBufferedFrag(t,r){var i=this["fragments"],n=Object.keys(i);for(let e=n.length;e--;){var s=i[n[e]];if((null==s?void 0:s.body.type)===r&&s.buffered){const r=s.body;if(r.start<=t&&t<=r.end)return r}}return null}detectEvictedFragments(r,i,n,e){this.timeRanges&&(this.timeRanges[r]=i);const s=(null==e?void 0:e.fragment.sn)||-1;Object.keys(this.fragments).forEach(e=>{const t=this.fragments[e];!t||s>=t.body.sn||(t.buffered||t.loaded?(e=t.range[r])&&e.time.some(e=>{e=!this.isTimeBuffered(e.startPTS,e.endPTS,i);return e&&this.removeFragment(t.body),e}):t.body.type===n&&this.removeFragment(t.body))})}detectPartialFragments(e){const i=this.timeRanges,{frag:n,part:s}=e;if(i&&"initSegment"!==n.sn){const t=$t(n),a=this.fragments[t];if(!(!a||a.buffered&&n.gap)){const o=!n.relurl;Object.keys(i).forEach(e=>{var t,r=n.elementaryStreams[e];r&&(t=i[e],r=o||!0===r.partial,a.range[e]=this.getBufferedTimes(n,s,r,t))}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=n.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Yt(a)||this.removeParts(n.sn-1,n.type)):this.removeFragment(a.body)}}}removeParts(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(e=>e.fragment.sn>=t))}fragBuffered(e,t){var r=$t(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap)&&(this.hasGaps=!0),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,r,i){var n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t)n.partial=!0,n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});else if(a<=t)break}return n}getPartialFragment(t){let r,i,n,s=null,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(e=>{e=l[e];e&&Yt(e)&&(i=e.body.start-o,n=e.body.end+o,t>=i)&&t<=n&&(r=Math.min(t-i,n-t),a<=r)&&(s=e.body,a=r)}),s}isEndListAppended(e){e=this.endListFragments[e];return void 0!==e&&(e.buffered||Yt(e))}getState(e){e=$t(e),e=this.fragments[e];return e?e.buffered?Yt(e)?Wt:"OK":"APPENDING":Vt}isTimeBuffered(t,r,i){var n,s;for(let e=0;e<i.length;e++){if(n=i.start(e)-this.bufferPadding,s=i.end(e)+this.bufferPadding,n<=t&&r<=s)return!0;if(r<=n)return!1}return!1}onFragLoaded(e,t){var r,{frag:i,part:n}=t;"initSegment"===i.sn||i.bitrateTest||(r=$t(i),this.fragments[r]={body:i,appendedPTS:null,loaded:n?null:t,buffered:!1,range:Object.create(null)})}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n}=t;if("initSegment"!==r.sn){const s=r.type;if(i){let e=this.activePartLists[s];e||(this.activePartLists[s]=e=[]),e.push(i)}this.timeRanges=n,Object.keys(n).forEach(e=>{var t=n[e];this.detectEvictedFragments(e,t,s,i)})}}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){e=$t(e);return!!this.fragments[e]}hasParts(e){return!(null==(e=this.activePartLists[e])||!e.length)}removeFragmentsInRange(r,i,n,s,a){s&&!this.hasGaps||Object.keys(this.fragments).forEach(e=>{var t,e=this.fragments[e];!e||(t=e.body).type!==n||s&&!t.gap||t.start<i&&t.end>r&&(e.buffered||a)&&this.removeFragment(t)})}removeFragment(e){const t=$t(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=r.filter(e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Yt(e){var t;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(t=e.range.audio)?void 0:t.partial)||(null==(t=e.range.audiovideo)?void 0:t.partial))}function $t(e){return`${e.type}_${e.level}_${e.urlId}_`+e.sn}const qt=Math.pow(2,17);class Kt{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const h=o.url;if(!h)return Promise.reject(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(h?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,u=r.fLoader,c=r.loader;return new Promise((s,n)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(e=>"GAP"===e[0]))return void n(Jt(o));o.gap=!1}const a=this.loader=o.loader=new(u||c)(r),e=Xt(o),t=Pt(r.fragLoadPolicy.default),i={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:qt};o.stats=a.stats,a.load(e,i,{onSuccess:(e,t,r,i)=>{this.resetLoader(o,a);let n=e.data;r.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),s({frag:o,part:null,payload:n,networkDetails:i})},onError:(e,t,r,i)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:m({url:h,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:r,stats:i}))},onAbort:(e,t,r)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,t,r)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:e}))},onProgress:(e,t,r,i)=>{l&&l({frag:o,part:null,payload:r,networkDetails:i})}})})}loadPart(l,h,u){this.abort();const t=this.config,r=t.fLoader,c=t.loader;return new Promise((n,s)=>{if(this.loader&&this.loader.destroy(),l.gap||h.gap)s(Jt(l,h));else{const a=this.loader=l.loader=new(r||c)(t),o=Xt(l,h),e=Pt(t.fragLoadPolicy.default),i={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qt};h.stats=a.stats,a.load(o,i,{onSuccess:(e,t,r,i)=>{this.resetLoader(l,a),this.updateStatsFromPart(l,h);e={frag:l,part:h,payload:e.data,networkDetails:i};u(e),n(e)},onError:(e,t,r,i)=>{this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:h,response:m({url:o.url,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:r,stats:i}))},onAbort:(e,t,r)=>{l.stats.aborted=h.stats.aborted,this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:l,part:h,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,t,r)=>{this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:h,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:e}))}})}})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Xt(r,i=null){var n=i||r,i={frag:r,part:i,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,n=n.byteRangeEndOffset;if(M(s)&&M(n)){let e=s,t=n;if("initSegment"===r.sn&&"AES-128"===(null==(r=r.decryptdata)?void 0:r.method)){const r=n-s;r%16&&(t=n+(16-r%16)),0!==s&&(i.resetIV=!0,e=s-16)}i.rangeStart=e,i.rangeEnd=t}return i}function Jt(e,t){var r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),r={type:C.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new x(r)}class x extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Zt{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[r].loader;if(t){if(e&&e!==t.context.frag.type)return;t.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,i,n){return new x({type:C.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){var{sn:r,cc:i}=e;for(let e=0;e<t.length;e++){const n=t[e];if(i<=n.cc&&("initSegment"===r||"initSegment"===n.sn||r<n.sn)){this.emeController.selectKeySystemFormat(n).then(e=>{n.setKeyFormat(e)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const i=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,i))}var i,e=r.uri;if(!e)return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${e}"`)));let n=this.keyUriToKeyInfo[e];if(null!=(i=n)&&i.decryptdata.key)return r.key=n.decryptdata.key,Promise.resolve({frag:t,keyInfo:n});if(null!=(i=n)&&i.keyLoadPromise)switch(null==(i=n.mediaKeySessionContext)?void 0:i.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return n.keyLoadPromise.then(e=>(r.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:n}))}switch(n=this.keyUriToKeyInfo[e]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(n,t):this.loadKeyEME(n,t);case"AES-128":return this.loadKeyHTTP(n,t);default:return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(t,e){const r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(r);if(e)return(t.keyLoadPromise=e.then(e=>(t.mediaKeySessionContext=e,r))).catch(e=>{throw t.keyLoadPromise=null,e})}return Promise.resolve(r)}loadKeyHTTP(i,s){const l=this.config,h=new l.loader(l);return s.keyLoader=i.loader=h,i.keyLoadPromise=new Promise((a,o)=>{const n={keyInfo:i,frag:s,responseType:"arraybuffer",url:i.decryptdata.uri},e=l.keyLoadPolicy.default,t={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},r={onSuccess:(e,t,r,i)=>{var{frag:r,keyInfo:n,url:s}=r;if(!r.decryptdata||n!==this.keyUriToKeyInfo[s])return o(this.createKeyLoadError(r,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));n.decryptdata.key=r.decryptdata.key=new Uint8Array(e.data),r.keyLoader=null,n.loader=null,a({frag:r,keyInfo:n})},onError:(e,t,r,i)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key `+e.text),r,m({url:n.url,data:void 0},e)))},onTimeout:(e,t,r)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(e,t,r)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};h.load(n,t,r)})}resetLoader(e){var{frag:e,keyInfo:t,url:r}=e,i=t.loader;e.keyLoader===i&&(e.keyLoader=null,t.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const Qt={length:0,start:()=>0,end:()=>0};class _{static isBuffered(e,t){try{if(e){var r=_.getBuffered(e);for(let e=0;e<r.length;e++)if(t>=r.start(e)&&t<=r.end(e))return!0}}catch(e){}return!1}static bufferInfo(t,r,i){try{if(t){var n=_.getBuffered(t),s=[];let e;for(e=0;e<n.length;e++)s.push({start:n.start(e),end:n.end(e)});return this.bufferedInfo(s,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}}static bufferedInfo(t,r,i){r=Math.max(0,r),t.sort(function(e,t){return e.start-t.start||t.end-e.end});let n=[];if(i)for(let e=0;e<t.length;e++){const s=n.length;if(s){const a=n[s-1].end;t[e].start-a<i?t[e].end>a&&(n[s-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;let s,a=0,o=r,l=r;for(let e=0;e<n.length;e++){var h=n[e].start,u=n[e].end;if(h<=r+i&&r<u)o=h,l=u,a=l-r;else if(r+i<h){s=h;break}}return{len:a,start:o||0,end:l||0,nextStart:s}}static getBuffered(e){try{return e.buffered}catch(e){return I.log("failed to get media.buffered",e),Qt}}}class er{constructor(e,t,r,i=0,n=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=s}}function tr(r,i){let n=null;for(let e=0,t=r.length;e<t;e++){var s=r[e];if(s&&s.cc===i){n=s;break}}return n}function rr(e,t){e&&(t=e.start+t,e.start=e.startPTS=t,e.endPTS=t+e.duration)}function ir(r,e){var i=e.fragments;for(let e=0,t=i.length;e<t;e++)rr(i[e],r);e.fragmentHint&&rr(e.fragmentHint,r),e.alignedSliding=!0}function nr(e,t){var r,i,n;e.hasProgramDateTime&&t.hasProgramDateTime&&(r=e.fragments,t=t.fragments,r.length)&&t.length&&(r=tr(r,(t=t[Math.round(t.length/2)-1]).cc)||r[Math.round(r.length/2)-1],i=t.programDateTime,n=r.programDateTime,null!==i)&&null!==n&&ir((n-i)/1e3-(r.start-t.start),e)}class sr{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class ar{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class or{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){var t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],h=o[1],u=o[2],c=o[3],d=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)d[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var g=(g=p^p<<1^p<<2^p<<3^p<<4)>>>8^255&g^99;e[f]=g,t[g]=f;const o=d[f],m=d[o],y=d[m];var v=257*d[g]^16843008*g;i[f]=v<<24|v>>>8,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*y^65537*m^257*o^16843008*f,l[g]=v<<24|v>>>8,h[g]=v<<16|v>>>16,u[g]=v<<8|v>>>24,c[g]=v,f?(f=o^d[d[d[y^o]]],p^=d[d[p]]):f=p=1}}expandKey(n){var s=this.uint8ArrayToUint32Array_(n);let e=!0,t=0;for(;t<s.length&&e;)e=s[t]===this.key[t],t++;if(!e){this.key=s;var a=this.keySize=s.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var o=this.ksRows=4*(a+6+1);let e,t;var l=this.keySchedule=new Uint32Array(o),h=this.invKeySchedule=new Uint32Array(o),u=this.sBox,c=this.rcon,n=this.invSubMix,d=n[0],f=n[1],p=n[2],m=n[3];let r,i;for(e=0;e<o;e++)e<a?r=l[e]=s[e]:(i=r,e%a==0?(i=u[(i=i<<8|i>>>24)>>>24]<<24|u[i>>>16&255]<<16|u[i>>>8&255]<<8|u[255&i],i^=c[e/a|0]<<24):6<a&&e%a==4&&(i=u[i>>>24]<<24|u[i>>>16&255]<<16|u[i>>>8&255]<<8|u[255&i]),l[e]=r=(l[e-a]^i)>>>0);for(t=0;t<o;t++)e=o-t,i=3&t?l[e]:l[e-4],h[t]=t<4||e<=4?i:d[u[i>>>24]]^f[u[i>>>16&255]]^p[u[i>>>8&255]]^m[u[255&i]],h[t]=h[t]>>>0}}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){var i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],h=a[2],u=a[3],a=this.uint8ArrayToUint32Array_(r);let c=a[0],d=a[1],f=a[2],p=a[3];var m=new Int32Array(e),g=new Int32Array(m.length);let v,y,x,_,b,T,S,E,w,M,A,L,R,C;for(var D=this.networkToHostOrderSwap;t<m.length;){for(w=D(m[t]),M=D(m[t+1]),A=D(m[t+2]),L=D(m[t+3]),b=w^n[0],T=L^n[1],S=A^n[2],E=M^n[3],R=4,C=1;C<i;C++)v=o[b>>>24]^l[T>>16&255]^h[S>>8&255]^u[255&E]^n[R],y=o[T>>>24]^l[S>>16&255]^h[E>>8&255]^u[255&b]^n[R+1],x=o[S>>>24]^l[E>>16&255]^h[b>>8&255]^u[255&T]^n[R+2],_=o[E>>>24]^l[b>>16&255]^h[T>>8&255]^u[255&S]^n[R+3],b=v,T=y,S=x,E=_,R+=4;v=s[b>>>24]<<24^s[T>>16&255]<<16^s[S>>8&255]<<8^s[255&E]^n[R],y=s[T>>>24]<<24^s[S>>16&255]<<16^s[E>>8&255]<<8^s[255&b]^n[R+1],x=s[S>>>24]<<24^s[E>>16&255]<<16^s[b>>8&255]<<8^s[255&T]^n[R+2],_=s[E>>>24]<<24^s[b>>16&255]<<16^s[T>>8&255]<<8^s[255&S]^n[R+3],g[t]=D(v^c),g[t+1]=D(_^d),g[t+2]=D(x^f),g[t+3]=D(y^p),c=w,d=M,f=A,p=L,t+=4}return g.buffer}}class lr{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){var e,t,{currentResult:r,remainderData:i}=this;return!r||i?(this.reset(),null):(i=new Uint8Array(r),this.reset(),this.removePKCS7Padding?(e=(r=i).byteLength,(t=e&&new DataView(r.buffer).getUint8(e-1))?fe(r,0,e-t):r):i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(i,n,s){return this.useSoftware?new Promise((e,t)=>{this.softwareDecrypt(new Uint8Array(i),n,s);var r=this.flush();r?e(r.buffer):t(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(i),n,s)}softwareDecrypt(e,t,r){var{currentIV:i,currentResult:n,remainderData:s}=this,s=(this.logOnce("JS AES decrypt"),s&&(e=Ie(s,e),this.remainderData=null),this.getValidChunk(e));if(!s.length)return null;i&&(r=i);let a=this.softwareDecrypter;(a=a||(this.softwareDecrypter=new or)).expandKey(t);e=n;return this.currentResult=a.decrypt(s.buffer,0,r),this.currentIV=fe(s,-16).buffer,e||null}webCryptoDecrypt(t,r,i){const n=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new ar(n,r)),this.fastAesKey.expandKey().then(e=>n?(this.logOnce("WebCrypto AES decrypt"),new sr(n,new Uint8Array(i)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))).catch(e=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${e.name}: `+e.message),this.onWebCryptoError(t,r,i)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);e=this.flush();if(e)return e.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;var r=e.length-e.length%16;return r!==e.length&&(t=fe(e,0,r),this.remainderData=fe(e,r)),t}logOnce(e){this.logEnabled&&(I.log("[decrypter]: "+e),this.logEnabled=!1)}}const a="STOPPED",u="IDLE",hr="KEY_LOADING",ur="FRAG_LOADING",cr="FRAG_LOADING_WAITING_RETRY",dr="WAITING_TRACK",O="PARSING",fr="PARSED",pr="ENDED",mr="ERROR",gr="WAITING_INIT_PTS",vr="WAITING_LEVEL";class yr extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(e,t,r,i,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=a,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=i,this.log=I.log.bind(I,i+":"),this.warn=I.warn.bind(I,i+":"),this.hls=e,this.fragmentLoader=new Kt(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new lr(e.config),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=a}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){const e=r[r.length-1];return _.isBuffered(this.media,e.start+e.duration/2)}e=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(e)}getLevelDetails(){var e;return!this.levels||null===this.levelLastLoaded||null==(e=this.levels[this.levelLastLoaded])?void 0:e.details}onMediaAttached(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config;this.levels&&t.autoStartLoad&&this.state===a&&this.startLoad(t.startPosition)}onMediaDetaching(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:n}=this,s=r?r.currentTime:0,a=_.bufferInfo(i||r,s,e.maxBufferHole);if(this.log(`media seeking to ${M(s)?s.toFixed(3):s}, state: `+n),this.state===pr)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(!a.len||n<a.start||i>a.end){const e=s>n;(s<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),this.lastCurrentTime=s),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=a,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(r,e,t){this._doFragLoad(r,e,t,e=>{this.fragContextChanged(r)?(this.warn(`Fragment ${r.sn}${e.part?" p: "+e.part.index:""} of level ${r.level} was dropped during download.`),this.fragmentTracker.removeFragment(r)):(r.stats.chunkCount++,this._handleFragmentLoadProgress(e))}).then(e=>{var t;e&&(t=this.state,this.fragContextChanged(r)?t!==ur&&(this.fragCurrent||t!==O)||(this.fragmentTracker.removeFragment(r),this.state=u):("payload"in e&&(this.log(`Loaded fragment ${r.sn} of level `+r.level),this.hls.trigger(R.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)))}).catch(e=>{this.state!==a&&this.state!==mr&&(this.warn(e),this.resetFragmentLoading(r))})}clearTrackerIfNeeded(e){var t,r=this["fragmentTracker"];if("APPENDING"===r.getState(e)){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(n)&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Wt)&&r.removeFragment(e)}checkLiveUpdate(e){var t;e.updated&&!e.live&&(t=e.fragments[e.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})),e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){e-t&&(e={startOffset:e,endOffset:t,type:r},this.hls.trigger(R.BUFFER_FLUSHING,e))}_loadInitSegment(s,n){this._doFragLoad(s,n).then(e=>{if(e&&!this.fragContextChanged(s)&&this.levels)return e;throw new Error("init load aborted")}).then(r=>{const i=this["hls"],e=r["payload"],t=s.decryptdata;if(e&&0<e.byteLength&&t&&t.key&&t.iv&&"AES-128"===t.method){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(e),t.key.buffer,t.iv.buffer).catch(e=>{throw i.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:s}),e}).then(e=>{var t=self.performance.now();return i.trigger(R.FRAG_DECRYPTED,{frag:s,payload:e,stats:{tstart:n,tdecrypt:t}}),r.payload=e,r})}return r}).then(e=>{var{fragCurrent:t,hls:r,levels:i}=this;if(!i)throw new Error("init load aborted, missing levels");i=s.stats;this.state=u,n.fragmentError=0,s.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),e.frag===t&&r.trigger(R.FRAG_BUFFERED,{stats:i,frag:t,part:null,id:s.type}),this.tick()}).catch(e=>{this.state!==a&&this.state!==mr&&(this.warn(e),this.resetFragmentLoading(s))})}fragContextChanged(e){var t=this["fragCurrent"];return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r=this.mediaBuffer||this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===y?"level":"track"} ${e.level} (frag:[${(null!=(t=e.startPTS)?t:NaN).toFixed(3)}-${(null!=(t=e.endPTS)?t:NaN).toFixed(3)}] > buffer:${r?function(t){let r="";var i=t.length;for(let e=0;e<i;e++)r+=`[${t.start(e).toFixed(3)}-${t.end(e).toFixed(3)}]`;return r}(_.getBuffered(r)):"(detached)"})`),this.state=u,r&&(!this.loadedmetadata&&e.type==y&&r.buffered.length&&(null==(t=this.fragCurrent)?void 0:t.sn)===(null==(e=this.fragPrevious)?void 0:e.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){var t,r,i=this["transmuxer"];i&&({frag:e,part:t,partsLoaded:r}=e,r=!r||0===r.length||r.some(e=>!e),e=new er(e.level,e.sn,e.stats.chunkCount+1,0,t?t.index:-1,!r),i.flush(e))}_handleFragmentLoadProgress(e){}_doFragLoad(t,r,e=null,i){var n,s,a=null==r?void 0:r.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key?!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+t.level),this.state=hr,this.fragCurrent=t,o=this.keyLoader.load(t).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(R.KEY_LOADED,e),this.state===hr&&(this.state=u),e}),this.hls.trigger(R.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),e=Math.max(t.start,e||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const n=a.partList;if(n&&i){e>t.end&&a.fragmentHint&&(t=a.fragmentHint);const l=this.getNextPart(n,t,e);if(-1<l){const h=n[l];return this.log(`Loading part sn: ${t.sn} p: ${h.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${l}-${n.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: `+parseFloat(e.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ur,s=o?o.then(e=>!e||this.fragContextChanged(e.frag)?null:this.doFragPartsLoad(t,h,r,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(t,h,r,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:h,targetBufferTime:e}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):s}if(!t.url||this.loadedEndOfParts(n,e))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: `+parseFloat(e.toFixed(3))),M(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ur;const l=this.config.progressive;let h;return h=l&&o?o.then(e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(t,l?i:void 0),o]).then(([e])=>(!l&&e&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:e}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(o,r,l,h){return new Promise((i,e)=>{var t;const n=[],s=null==(t=l.details)?void 0:t.partList,a=r=>{this.fragmentLoader.loadPart(o,r,h).then(e=>{var t=(n[r.index]=e).part,e=(this.hls.trigger(R.FRAG_LOADED,e),Lt(l,o.sn,r.index+1)||Rt(s,o.sn,r.index+1));if(!e)return i({frag:o,part:t,partsLoaded:n});a(e)}).catch(e)};a(r)})}handleFragLoadError(e){var t;return"data"in e?(t=e.data,e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(R.ERROR,t)):this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0}),null}_handleTransmuxerFlush(e){var t,r,i,n=this.getCurrentContext(e);n&&this.state===O?({frag:n,part:t,level:r}=n,i=self.performance.now(),n.stats.parsing.end=i,t&&(t.stats.parsing.end=i),this.updateLevelTiming(n,t,r,e.partial)):this.fragCurrent||this.state===a||this.state===mr||(this.state=u)}getCurrentContext(e){var{levels:t,fragCurrent:r}=this,{level:e,sn:i,part:n}=e;if(null==t||!t[e])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${e}. The current chunk will not be buffered.`),null;const s=t[e],a=-1<n?Lt(s,i,n):null,o=a?a.fragment:null!=s&&s.details?(t=s.details).fragments[i-t.startSN]||((e=t.fragmentHint)&&e.sn===i?e:i<t.startSN&&r&&r.sn===i?r:null):null;return o?(r&&r!==o&&(o.stats=r.stats),{frag:o,part:a,level:s}):null}bufferFragmentData(t,r,i,n,s){if(t&&this.state===O){var{data1:a,data2:o}=t;let e=a;null!=(a=e=a&&o?Ie(a,o):e)&&a.length&&(o={type:t.type,frag:r,part:i,chunkMeta:n,parent:r.type,data:e},this.hls.trigger(R.BUFFER_APPENDING,o),t.dropped)&&t.independent&&!i&&!s&&this.flushBufferGap(r)}}flushBufferGap(e){var t,r,i=this.media;i&&(_.isBuffered(i,i.currentTime)?(t=i.currentTime,i=_.bufferInfo(i,t,0),r=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),i=Math.max(Math.min(e.start-r,i.end-r),t+r),e.start-i>r&&this.flushMainBuffer(i,e.start)):this.flushMainBuffer(0,e.start))}getFwdBufferInfo(e,t){var r=this.getLoadPosition();return M(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){var i=this["config"]["maxBufferHole"],n=_.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){r=this.fragmentTracker.getBufferedFrag(t,r);if(r&&n.nextStart<r.end)return _.bufferInfo(e,t,Math.max(n.nextStart,i))}return n}getMaxBufferLength(e){var t=this["config"],e=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength;return Math.min(e,t.maxMaxBufferLength)}reduceMaxBufferLength(e){var t=this.config,e=e||t.maxBufferLength;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=0){e=this.fragmentTracker.getAppendedFrag(e,y);return e&&"fragment"in e?e.fragment:e}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const n=this["config"],s=r[0].start;let a;if(t.live){const s=n.initialLiveManifestSize;if(i<s)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${s})`),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(t,r),this.startPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=s&&(a=r[0]);if(!a){const r=n.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,r,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){var r=this.fragmentTracker.getState(e);return("OK"===r||r===Wt&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){var s=e.gap,t=this.getNextFragment(this.nextLoadPosition,t);if(null===t)return t;if(e=t,s&&e&&!e.gap&&r.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,r.nextStart,i);if(null!==t&&r.len+t.len>=n)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: `+e.sn),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(r,i,n){let s=-1,a=!1,o=!0;for(let e=0,t=r.length;e<t;e++){var l=r[e];if(o=o&&!l.independent,-1<s&&n<l.start)break;var h=l.loaded;h?s=-1:(a||l.independent||o)&&l.fragment===i&&(s=e),a=h}return s}loadedEndOfParts(e,t){e=e[e.length-1];return e&&t>e.start&&e.loaded}getInitialLiveFragment(e,t){var r,i,n=this.fragPrevious;let s=null;if(n)e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),s=function(t,r,i){if(null!==r&&Array.isArray(t)&&t.length&&M(r)&&!(r<(t[0].programDateTime||0)||r>=(t[t.length-1].endProgramDateTime||0))){i=i||0;for(let e=0;e<t.length;++e){var n=t[e];if(s=r,a=i,o=n,a=1e3*Math.min(i,o.duration+(o.deltaPTS||0)),(o.endProgramDateTime||0)-a>s)return n}var s,a,o}return null}(t,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),s||((r=n.sn+1)>=e.startSN&&r<=e.endSN&&(r=t[r-e.startSN],n.cc===r.cc)&&(s=r,this.log("Live playlist, switching playlist, load frag with next SN: "+s.sn)),s)||(s=(r=t,i=n.cc,Ot(r,e=>e.cc<i?1:e.cc>i?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+s.sn);else{const t=this.hls.liveSyncPosition;null!==t&&(s=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){var i=this["config"];let n=this["fragPrevious"],{fragments:s,endSN:a}=r;var o=r["fragmentHint"],l=i.maxFragLookUpTolerance,h=r.partList,i=!!(i.lowLatencyMode&&null!=h&&h.length&&o);let u;if(i&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),u=e<t?Ft(n,s,e,t-l<e?0:l):s[s.length-1]){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((n="OK"===t||t===Wt&&u.gap?u:n)&&u.sn===n.sn&&(!i||h[0].fragment.sn>u.sn)&&n&&u.level===n.level){const t=s[1+e];u=u.sn<a&&"OK"!==this.fragmentTracker.getState(t)?t:null}}return u}synchronizeToLiveEdge(e){var{config:t,media:r}=this;if(r){const i=this.hls.liveSyncPosition,n=r.currentTime,s=e.fragments[0].start,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<a-s)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState)&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : `+i.toFixed(3)),r.currentTime=i)}}}alignPlaylists(e,t){const{levels:r,levelLastLoaded:i,fragPrevious:n}=this,s=null!==i?r[i]:null,a=e.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=e.fragments[0].start,l=!t,h=e.alignedSliding&&M(o);if(l||!h&&!o){var u,l=n,h=s,c=e;if(h){var d=l,f=(l=c,h);if(f.details&&(l.endCC>l.startCC||d&&d.cc<l.startCC)){f=f.details.fragments;const d=(u=l.fragments).length&&f.length?(f=tr(f,u[0].cc))&&f.startPTS?f:void I.log("No frag in previous level to align on"):void I.log("No fragments to align");d&&M(d.start)&&(I.log("Adjusting PTS using last level due to CC increase within current level "+l.url),ir(d.start,l))}!c.alignedSliding&&h.details&&(d=c,(u=h.details).fragments.length)&&d.hasProgramDateTime&&u.hasProgramDateTime&&(f=u.fragments[0].programDateTime,u=((l=d.fragments[0].programDateTime)-f)/1e3+u.fragments[0].start)&&M(u)&&(I.log(`Adjusting PTS using programDateTime delta ${l-f}ms, sliding:${u.toFixed(3)} ${d.url} `),ir(u,d)),c.alignedSliding||!h.details||c.skippedSegments||Mt(h.details,c)}const r=e.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: `+a),r}return o}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;var i,n;-1!==(r=r<t?-1:r)&&-1!==this.lastCurrentTime||(null!==(n=((i=null!==this.startTimeOffset)?this:e).startTimeOffset)&&M(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${i?"multivariant":"media"} playlist, adjust startPosition to `+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r),this.nextLoadPosition=r}getLoadPosition(){var e=this["media"];let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===cr)||(this.state=u)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}var r=t.frag;if(r&&r.type===e&&this.levels)if(this.fragContextChanged(r))this.warn(`Frag load error must match current frag to retry ${r.url} > `+(null==(i=this.fragCurrent)?void 0:i.url));else{var i=t.details===D.FRAG_GAP,n=(i&&this.fragmentTracker.fragBuffered(r,!0),t.errorAction),{action:s,retryCount:a=0,retryConfig:o}=n||{};if(n&&5===s&&o){this.resetStartWhenNotLoaded(null!=(s=this.levelLastLoaded)?s:r.level);const i=It(o,a);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${a+1}/${o.maxNumRetry} in ${i}ms`),n.resolved=!0,this.retryDate=self.performance.now()+i,this.state=cr}else o&&n?(this.resetFragmentErrors(e),a<o.maxNumRetry?i||(n.resolved=!0):I.warn(t.details+` reached or exceeded max retry (${a})`)):2===(null==n?void 0:n.action)?this.state=vr:this.state=mr;this.tickImmediate()}}reduceLengthAndFlushBuffer(e){var t,r,i;return(this.state===O||this.state===fr)&&(t=e.parent,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,t))&&.5<i.len)&&this.reduceMaxBufferLength(i.len),(i=!r)&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),i)}resetFragmentErrors(e){e===T&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==a&&(this.state=u)}afterBufferFlushed(e,t,r){e&&(e=_.getBuffered(e),this.fragmentTracker.detectEvictedFragments(t,e,r),this.state===pr)&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=u}resetStartWhenNotLoaded(e){this.loadedmetadata||(this.startFragRequested=!1,null!=(e=this.levels?this.levels[e].details:null)&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition)}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(n,e,s,a){var t;const o=s.details;if(o){if(Object.keys(n.elementaryStreams).reduce((e,t)=>{var r,i=n.elementaryStreams[t];return i?(r=i.endPTS-i.startPTS)<=0?(this.warn(`Could not parse fragment ${n.sn} ${t} duration reliably (${r})`),e||!1):(r=a?0:Et(o,n,i.startPTS,i.endPTS,i.startDTS,i.endDTS),this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:o,level:s,drift:r,type:t,frag:n,start:i.startPTS,end:i.endPTS}),!0):e},!1))s.fragmentError=0;else if(null===(null==(t=this.transmuxer)?void 0:t.error)){const e=new Error(`Found no media in fragment ${n.sn} of level ${n.level} resetting transmuxer to fallback to playlist timing`);if(0===s.fragmentError&&(s.fragmentError++,n.gap=!0,this.fragmentTracker.removeFragment(n),this.fragmentTracker.fragBuffered(n,!0)),this.warn(e.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:n,reason:`Found no media in msn ${n.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=fr,this.hls.trigger(R.FRAG_PARSED,{frag:n,part:e})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(e=this.levelLastLoaded)?e:null==(e=this.fragCurrent)?void 0:e.level)?e:0),this.resetLoadingState())}set state(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}get state(){return this._state}}function xr(){return self.SourceBuffer||self.WebKitSourceBuffer}function F(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class _r{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Ie(this.cachedData,e),this.cachedData=null);let r,i=ge(e,0),n=i?i.length:0;var s,a,o=this._audioTrack,l=this._id3Track,h=i?(e=>{var t=xe(e);for(let e=0;e<t.length;e++){var r=t[e];if(ye(r)){if(8===r.data.byteLength){var r=new Uint8Array(r.data),i=1&r[3];let e=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];return e/=45,i&&(e+=47721858.84),Math.round(e)}return}}})(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&M(h))&&(this.basePTS=br(h,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&0<i.length&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(e,n)){const t=this.appendFrame(o,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=u}else s=e,a=n,pe(s,a)&&ve(s,a+6)+10<=s.length-a?(i=ge(e,n),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===u&&r!==u){const t=fe(e,r);this.cachedData?this.cachedData=Ie(this.cachedData,t):this.cachedData=t}}return{audioTrack:o,videoTrack:F(),id3Track:l,textTrack:F()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:F(),id3Track:this._id3Track,textTrack:F()}}destroy(){}}const br=(e,t,r)=>M(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0);function Tr(e,t){return 255===e[t]&&240==(246&e[t+1])}function Sr(e,t){return 1&e[t+1]?7:9}function Er(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function wr(e,t){return t+1<e.length&&Tr(e,t)}function Mr(e,t,r,i,n){e.samplerate||(t=function(e,t,r,i){let n,s,a,o;var l=navigator.userAgent.toLowerCase(),h=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],c=(n=1+((192&t[r+2])>>>6),(60&t[r+2])>>>2);if(!(u.length-1<c))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,I.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:`+c),s=/firefox/i.test(l)?6<=c?(n=5,o=new Array(4),c-3):(n=2,o=new Array(2),c):-1!==l.indexOf("android")?(n=2,o=new Array(2),c):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=c?c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=c&&1==a||/vivaldi/i.test(l))||!i&&1==a)&&(n=2,o=new Array(2)),c)),o[0]=n<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=a<<3,5===n&&(o[1]|=(14&s)>>1,o[2]=(1&s)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+n,manifestCodec:h};e.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(t,r,i,n))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,I.log(`parsed codec:${e.codec}, rate:${t.samplerate}, channels:`+t.channelCount))}function Ar(e){return 9216e4/e}function Lr(e,r,i,t,n){var s=t+n*Ar(e.samplerate),a=function(){var e=Sr(r,i);if(i+e<=r.length){var t=Er(r,i)-e;if(0<t)return{headerLength:e,frameLength:t}}}();let o;if(a){const{frameLength:t,headerLength:n}=a,l=n+t,h=Math.max(0,i+l-r.length);h?(o=new Uint8Array(l-n)).set(r.subarray(i+n,r.length),0):o=r.subarray(i+n,i+l);a={unit:o,pts:s};return h||e.samples.push(a),{sample:a,length:l,missing:h}}const l=r.length-i;return(o=new Uint8Array(l)).set(r.subarray(i,r.length),0),{sample:{unit:o,pts:s},length:l,missing:-1}}const Rr=/\/emsg[-/]ID3/i;let Cr=null;const Dr=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Ir=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Pr=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],kr=[0,1,1,4];function Or(e,t,r,i,n){var s;return!(r+24>t.length)&&(s=Fr(t,r))&&r+s.frameLength<=t.length?(i=i+n*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:t.subarray(r,r+s.frameLength),pts:i,dts:i},e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(n),{sample:n,length:s.frameLength,missing:0}):void 0}function Fr(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!=r&&0!=n&&15!=n&&3!=s){var a=e[t+2]>>1&1,o=e[t+3]>>6,n=1e3*Dr[14*(3==r?3-i:3==i?3:4)+n-1],s=Ir[3*(3==r?0:2==r?1:2)+s],l=3==o?1:2,r=Pr[r][i],h=kr[i],u=8*r*h,r=Math.floor(r*n/s+a)*h;if(null===Cr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cr=e?parseInt(e[1]):0}return Cr&&Cr<=87&&2==i&&224e3<=n&&0==o&&(e[t+3]=128|e[t+3]),{sampleRate:s,channelCount:l,frameLength:r,samplesPerFrame:u}}}function Nr(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Ur(e,t){return t+1<e.length&&Nr(e,t)}class Br{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),t=Math.min(4,t);if(0===t)throw new Error("no bytes available");i.set(e.subarray(r,r+t)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*t,this.bytesAvailable-=t}skipBits(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(32<e&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable)this.word<<=t;else{if(!(0<this.bytesAvailable))throw new Error("no bits available");this.loadWord()}return 0<(t=e-t)&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var e=this.skipLZ();return this.readBits(e+1)-1}readEG(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let r,i=8,n=8;for(let e=0;e<t;e++)0!==n&&(r=this.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(){let e,t,r,i=0,n=0,s=0,a=0;var o=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),u=this.readBoolean.bind(this),c=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this),m=(o(),o());if(l(5),c(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=h();if(3===e&&c(1),f(),f(),c(1),u())for(t=3!==e?8:12,r=0;r<t;r++)u()&&p(r<6?16:64)}f();m=h();if(0===m)h();else if(1===m)for(c(1),d(),d(),e=h(),r=0;r<e;r++)d();f(),c(1);m=h(),f=h(),l=l(1);0===l&&c(1),c(1),u()&&(i=h(),n=h(),s=h(),a=h());let g=[1,1];if(u()&&u())switch(o()){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:g=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(m+1)-2*i-2*n),height:(2-l)*(f+1)*16-(l?2:4)*(s+a),pixelRatio:g}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Gr{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new lr(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,r,i){const n=t[r].unit;var e;n.length<=16||(e=(e=n.subarray(16,n.length-n.length%16)).buffer.slice(e.byteOffset,e.byteOffset+e.length),this.decryptBuffer(e).then(e=>{e=new Uint8Array(e);n.set(e,16),this.decrypter.isSync()||this.decryptAacSamples(t,r+1,i)}))}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}}getAvcEncryptedData(t){var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)r.set(t.subarray(e,e+16),i);return r}getAvcDecryptedUnit(t,e){var r=new Uint8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)t.set(r.subarray(i,i+16),e);return t}decryptAvcSample(t,r,i,n,s){const a=Oe(s.data),e=this.getAvcEncryptedData(a);this.decryptBuffer(e.buffer).then(e=>{s.data=this.getAvcDecryptedUnit(a,e),this.decrypter.isSync()||this.decryptAvcSamples(t,r,i+1,n)})}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class Hr{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}static probe(e){e=Hr.syncOffset(e);return 0<e&&I.warn("MPEG2-TS detected but first sync word found @ offset "+e),-1!==e}static syncOffset(n){var s=n.length;let a=Math.min(940,n.length-188)+1,o=0;for(;o<a;){let t=!1,r=-1,i=0;for(let e=o;e<s;e+=188){if(71!==n[e]){if(i)return-1;break}if(i++,-1===r&&0!==(r=e)&&(a=Math.min(r+18612,n.length-188)+1),(t=t||0===Vr(n,e))&&1<i&&(0===r&&2<i||e+188>a))return r}o++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Me[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Hr.createTrack("video"),this._audioTrack=Hr.createTrack("audio",i),this._id3Track=Hr.createTrack("id3"),this._txtTrack=Hr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){var{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(r,e,i=!1,n=!1){let s;i||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let u=a.pid,c=a.pesData,d=o.pid,f=l.pid,p=o.pesData,m=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,x=r.length;if(this.remainderData&&(x=(r=Ie(this.remainderData,r)).length,this.remainderData=null),x<188&&!n)return this.remainderData=r,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};var _,b,T=Math.max(0,Hr.syncOffset(r));(x-=(x-T)%188)<r.byteLength&&!n&&(this.remainderData=new Uint8Array(r.buffer,x,r.buffer.byteLength-x));let S=0;for(let t=T;t<x;t+=188)if(71===r[t]){const n=!!(64&r[t+1]),R=Vr(r,t);let e;if(1<(48&r[t+3])>>4){if((e=t+5+r[t+4])===t+188)continue}else e=t+4;switch(R){case u:n&&(c&&(s=Wr(c))&&this.parseAVCPES(a,h,s,!1),c={data:[],size:0}),c&&(c.data.push(r.subarray(e,t+188)),c.size+=t+188-e);break;case d:if(n){if(p&&(s=Wr(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,s);break;case"mp3":this.parseMPEGPES(o,s)}p={data:[],size:0}}p&&(p.data.push(r.subarray(e,t+188)),p.size+=t+188-e);break;case f:n&&(m&&(s=Wr(m))&&this.parseID3PES(l,s),m={data:[],size:0}),m&&(m.data.push(r.subarray(e,t+188)),m.size+=t+188-e);break;case 0:n&&(e+=r[e]+1),y=this._pmtId=(_=r,b=e,(31&_[b+10])<<8|_[b+11]);break;case y:{n&&(e+=r[e]+1);const s=function(e,t,r,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){const s=Vr(e,t);switch(e[t]){case 207:if(!i){I.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){I.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?I.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=s,n.segmentCodec="mp3");break;case 36:I.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return n}(r,e,this.typeSupported,i);0<(u=s.avc)&&(a.pid=u),0<(d=s.audio)&&(o.pid=d,o.segmentCodec=s.segmentCodec),0<(f=s.id3)&&(l.pid=f),null===g||v||(I.warn(`MPEG-TS PMT found at ${t} after unknown PID '${g}'. Backtracking to sync byte @${T} to parse all TS packets.`),g=null,t=T-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=R}}else S++;if(0<S){const r=new Error(`Found ${S} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:r,reason:r.message})}a.pesData=c,o.pesData=p,l.pesData=m;var t={audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};return n&&this.extractRemainingSamples(t),t}flush(){var e=this["remainderData"];return this.remainderData=null,e=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(e){var{audioTrack:t,videoTrack:e,id3Track:r,textTrack:i}=e,n=e.pesData,s=t.pesData,a=r.pesData;let o;if(n&&(o=Wr(n))?(this.parseAVCPES(e,i,o,!0),e.pesData=null):e.pesData=n,s&&(o=Wr(s))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,o);break;case"mp3":this.parseMPEGPES(t,o)}t.pesData=null}else null!=s&&s.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=s;a&&(o=Wr(a))?(this.parseID3PES(r,o),r.pesData=null):r.pesData=a}demuxSampleAes(e,t,r){e=this.demux(e,r,!0,!this.config.progressive),r=this.sampleAes=new Gr(this.observer,this.config,t);return this.decrypt(e,r)}decrypt(i,n){return new Promise(e=>{const{audioTrack:t,videoTrack:r}=i;t.samples&&"aac"===t.segmentCodec?n.decryptAacSamples(t.samples,0,()=>{r.samples?n.decryptAvcSamples(r.samples,0,0,()=>{e(i)}):e(i)}):r.samples&&n.decryptAvcSamples(r.samples,0,0,()=>{e(i)})})}destroy(){this._duration=0}parseAVCPES(n,e,s,t){var r=this.parseAVCNALu(n,s.data);let a,o=this.avcSample,l=!1;s.data=null,o&&r.length&&!n.audFound&&(jr(o,n),o=this.avcSample=zr(!1,s.pts,s.dts,"")),r.forEach(t=>{var i,r;switch(t.type){case 1:{let e=!1;a=!0;const i=t.data;if(l&&4<i.length){const n=new Br(i).readSliceType();2!==n&&4!==n&&7!==n&&9!==n||(e=!0)}e&&null!=(r=o)&&r.frame&&!o.key&&(jr(o,n),o=this.avcSample=null),(o=o||(this.avcSample=zr(!0,s.pts,s.dts,""))).frame=!0,o.key=e;break}case 5:a=!0,null!=(i=o)&&i.frame&&!o.key&&(jr(o,n),o=this.avcSample=null),(o=o||(this.avcSample=zr(!0,s.pts,s.dts,""))).key=!0,o.frame=!0;break;case 6:a=!0,ke(t.data,1,s.pts,e.samples);break;case 7:if(a=!0,l=!0,!n.sps){const e=t.data,s=new Br(e).readSPS(),i=(n.width=s.width,n.height=s.height,n.pixelRatio=s.pixelRatio,n.sps=[e],n.duration=this._duration,e.subarray(1,4));let r="avc1.";for(let t=0;t<3;t++){let e=i[t].toString(16);e.length<2&&(e="0"+e),r+=e}n.codec=r}break;case 8:a=!0,n.pps||(n.pps=[t.data]);break;case 9:a=!1,n.audFound=!0,o&&jr(o,n),o=this.avcSample=zr(!1,s.pts,s.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+t.type+" ")}o&&a&&o.units.push(t)}),t&&o&&(jr(o,n),this.avcSample=null)}getLastNalUnit(e){let t,r=this.avcSample;if(null!=(e=r=r&&0!==r.units.length?r:e[e.length-1])&&e.units){const e=r.units;t=e[e.length-1]}return t}parseAVCNALu(e,t){const r=t.byteLength;let i=e.naluState||0;var n=i,s=[];let a,o,l,h=0,u=-1,c=0;for(-1===i&&(u=0,c=31&t[0],i=0,h=1);h<r;)if(a=t[h++],i)if(1!==i)if(a)if(1===a){if(0<=u){const e={data:t.subarray(u,h-i-1),type:c};s.push(e)}else{const r=this.getLastNalUnit(e.samples);if(r&&(n&&h<=4-n&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-n)),0<(o=h-i-1))){const e=new Uint8Array(r.data.byteLength+o);e.set(r.data,0),e.set(t.subarray(0,o),r.data.byteLength),r.data=e,r.state=0}}i=h<r?(l=31&t[h],u=h,c=l,0):-1}else i=0;else i=3;else i=a?0:2;else i=a?0:1;if(0<=u&&0<=i){const e={data:t.subarray(u,r),type:c,state:i};s.push(e)}if(0===s.length){const r=this.getLastNalUnit(e.samples);if(r){const e=new Uint8Array(r.data.byteLength+t.byteLength);e.set(r.data,0),e.set(t,r.data.byteLength),r.data=e}}return e.naluState=i,s}parseAACPES(e,t){let r=0;var i,n=this.aacOverFlow;let s,a,o,l=t.data;if(n){this.aacOverFlow=null;const t=n.missing,s=n.sample.unit.byteLength;if(-1===t){const e=new Uint8Array(s+l.byteLength);e.set(n.sample.unit,0),e.set(l,s),l=e}else{const a=s-t;n.sample.unit.set(l.subarray(0,t),a),e.samples.push(n.sample),r=n.missing}}for(s=r,a=l.length;s<a-1&&!wr(l,s);s++);if(s!==r){const t=s<a-1,r=(i=t?"AAC PES did not start with ADTS header,offset:"+s:"No ADTS header found in AAC PES",new Error(i));if(I.warn("parsing error: "+i),this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:r,reason:i}),!t)return}if(Mr(e,this.observer,l,s,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!n)return void I.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=Ar(e.samplerate);o=n.sample.pts+t}}let h,u=0;for(;s<a;){if(h=Lr(e,l,s,o,u),s+=h.length,h.missing){this.aacOverFlow=h;break}for(u++;s<a-1&&!wr(l,s);s++);}}parseMPEGPES(e,t){var r=t.data,i=r.length;let n=0,s=0;var a=t.pts;if(void 0!==a)for(;s<i;)if(Ur(r,s)){const t=Or(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;else I.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(e,t){void 0===t.pts?I.warn("[tsdemuxer]: ID3 PES unknown PTS"):(t=L({},t,{type:this._avcTrack?pt:ft,duration:Number.POSITIVE_INFINITY}),e.samples.push(t))}}function zr(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function Vr(e,t){return((31&e[t+1])<<8)+e[t+2]}function Wr(e){let i,t,n,s,a,o=0;var l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&1<l.length;){const e=new Uint8Array(l[0].length+l[1].length);e.set(l[0]),e.set(l[1],l[0].length),l[0]=e,l.splice(1,1)}if(1!==((i=l[0])[0]<<16)+(i[1]<<8)+i[2])return null;{if((t=(i[4]<<8)+i[5])&&t>e.size-6)return null;var h=i[7];192&h&&(s=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&h?(a=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,54e5<s-a&&(I.warn(Math.round((s-a)/9e4)+"s delta between PTS and DTS, align them"),s=a)):a=s);let r=(n=i[8])+9;if(e.size<=r)return null;e.size-=r;var u=new Uint8Array(e.size);for(let t=0,e=l.length;t<e;t++){let e=(i=l[t]).byteLength;if(r){if(r>e){r-=e;continue}i=i.subarray(r),e-=r,r=0}u.set(i,o),o+=e}return t&&(t-=n+3),{data:u,pts:s,dts:a,len:t}}}function jr(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}class Yr{static getSilentFrame(e,t){return"mp4a.40.2"===e?1===t?new Uint8Array([0,200,0,128,35,128]):2===t?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]):void 0:1===t?new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]):2===t||3===t?new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]):void 0}}const $r=Math.pow(2,32)-1;class N{static init(){let e;for(e in N.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},N.types)N.types.hasOwnProperty(e)&&(N.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t=(N.HDLR_TYPES={video:t,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(N.STTS=N.STSC=N.STCO=r,N.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),N.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),N.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),N.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);N.FTYP=N.box(N.types.ftyp,r,n,r,i),N.DINF=N.box(N.types.dinf,N.box(N.types.dref,t))}static box(e,...t){let r=8,i=t.length;for(var n=i;i--;)r+=t[i].byteLength;var s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return N.box(N.types.hdlr,N.HDLR_TYPES[e])}static mdat(e){return N.box(N.types.mdat,e)}static mdhd(e,t){t*=e;var r=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r));return N.box(N.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))}static mdia(e){return N.box(N.types.mdia,N.mdhd(e.timescale,e.duration),N.hdlr(e.type),N.minf(e))}static mfhd(e){return N.box(N.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?N.box(N.types.minf,N.box(N.types.smhd,N.SMHD),N.DINF,N.stbl(e)):N.box(N.types.minf,N.box(N.types.vmhd,N.VMHD),N.DINF,N.stbl(e))}static moof(e,t,r){return N.box(N.types.moof,N.mfhd(e),N.traf(r,t))}static moov(e){let t=e.length;for(var r=[];t--;)r[t]=N.trak(e[t]);return N.box.apply(null,[N.types.moov,N.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(N.mvex(e)))}static mvex(e){let t=e.length;for(var r=[];t--;)r[t]=N.trex(e[t]);return N.box.apply(null,[N.types.mvex,...r])}static mvhd(e,t){t*=e;var r=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return N.box(N.types.mvhd,e)}static sdtp(e){var t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return N.box(N.types.sdtp,r)}static stbl(e){return N.box(N.types.stbl,N.stsd(e),N.box(N.types.stts,N.STTS),N.box(N.types.stsc,N.STSC),N.box(N.types.stsz,N.STSZ),N.box(N.types.stco,N.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));var a=N.box(N.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,h=e.pixelRatio[0],u=e.pixelRatio[1];return N.box(N.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,N.box(N.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),N.box(N.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){var t=e.samplerate;return N.box(N.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),N.box(N.types.esds,N.esds(e)))}static mp3(e){var t=e.samplerate;return N.box(N.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?N.box(N.types.stsd,N.STSD,N.mp3(e)):N.box(N.types.stsd,N.STSD,N.mp4a(e)):N.box(N.types.stsd,N.STSD,N.avc1(e))}static tkhd(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,n=Math.floor(r/(1+$r)),r=Math.floor(r%(1+$r));return N.box(N.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))}static traf(e,t){var r=N.sdtp(e),i=e.id,n=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r));return N.box(N.types.traf,N.box(N.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),N.box(N.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t])),N.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,N.box(N.types.trak,N.tkhd(e),N.mdia(e))}static trex(e){e=e.id;return N.box(N.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){var r=e.samples||[],i=r.length,n=12+16*i,s=new Uint8Array(n);let a,o,l,h,u,c;for(s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,(t+=8+n)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)l=(o=r[a]).duration,h=o.size,u=o.flags,c=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*a);return N.box(N.types.trun,s)}static initSegment(e){N.types||N.init();var e=N.moov(e),t=new Uint8Array(N.FTYP.byteLength+e.byteLength);return t.set(N.FTYP),t.set(e,N.FTYP.byteLength),t}}function qr(e,t,r=1,i=!1){e=e*t*r;return i?Math.round(e):e}function Kr(e,t=!1){return qr(e,1e3,1/9e4,t)}N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0;let Xr,Jr=null,Zr=null;class Qr{constructor(e,t,r,i=0){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Jr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Jr=e?parseInt(e[1]):0}if(null===Zr){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Zr=e?parseInt(e[1]):0}}destroy(){}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let i=!1;e=e.reduce((e,t)=>{var r=t.pts-e;return r<-4294967296?(i=!0,U(e,t.pts)):0<r?e:t.pts},e[0].pts);return i&&I.debug("PTS rollover detected"),e}remux(r,i,n,s,a,o,e,l){let h,u,c,t,d,f,p=a,m=a;var g=-1<r.pid,v=-1<i.pid,y=i.samples.length,x=0<r.samples.length,_=e&&0<y||1<y;if((!g||x)&&(!v||_)||this.ISGenerated||e){this.ISGenerated||(c=this.generateIS(r,i,a,o));const n=this.isVideoContiguous;let e,t=-1;if(_&&(t=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(i.samples),!n)&&this.config.forceKeyFrameOnDiscontinuity)if(f=!0,0<t){I.warn(`[mp4-remuxer]: Dropped ${t} out of ${y} video samples due to a missing keyframe`);const r=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(t),i.dropped+=t,m+=(i.samples[0].pts-r)/i.inputTimeScale,e=m}else-1===t&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(x&&_){const n=this.getVideoStartPts(i.samples),s=(U(r.samples[0].pts,n)-n)/i.inputTimeScale;p+=Math.max(0,s),m+=Math.max(0,-s)}if(x){if(r.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(r,i,a,o)),u=this.remuxAudio(r,p,this.isAudioContiguous,o,v||_||l===T?m:void 0),_){const s=u?u.endPTS-u.startPTS:0;i.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(r,i,a,o)),h=this.remuxVideo(i,m,n,s)}}else _&&(h=this.remuxVideo(i,m,n,0));h&&(h.firstKeyFrame=t,h.independent=-1!==t,h.firstKeyFramePTS=e)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(d=ei(n,a,this._initPTS,this._initDTS)),s.samples.length)&&(t=ti(s,a,this._initPTS)),{audio:u,video:h,initSegment:c,independent:f,text:t,id3:d}}generateIS(e,t,r,i){var n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let h,u,c,d=!l||i,f="audio/mp4";if(d&&(h=u=1/0),e.config&&n.length&&("mp3"===(e.timescale=e.samplerate,e.segmentCodec)&&(a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3")),o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):N.initSegment([e]),metadata:{channelCount:e.channelCount}},d)&&(c=e.inputTimeScale,l&&c===l.timescale?d=!1:h=u=n[0].pts-Math.round(c*r)),t.sps&&t.pps&&s.length&&(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:N.initSegment([t]),metadata:{width:t.width,height:t.height}},d))if(c=t.inputTimeScale,l&&c===l.timescale)d=!1;else{const e=this.getVideoStartPts(s),t=Math.round(c*r);u=Math.min(u,U(s[0].dts,e)-t),h=Math.min(h,e-t)}if(Object.keys(o).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:h,timescale:c},this._initDTS={baseTime:u,timescale:c}):h=c=void 0,{tracks:o,initPTS:h,timescale:c}}remuxVideo(i,n,s,a){const o=i.inputTimeScale,l=i.samples,h=[],u=l.length,e=this._initPTS;let c,t,r=this.nextAvcDts,d=8,f=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=!1;s&&null!==r||(r=n*o-(l[0].pts-U(l[0].dts,l[0].pts)));var v=e.baseTime*o/e.timescale;for(let e=0;e<u;e++){const n=l[e];n.pts=U(n.pts-v,r),n.dts=U(n.dts-v,r),n.dts<l[0<e?e-1:e].dts&&(g=!0)}g&&l.sort(function(e,t){var r=e.dts-t.dts,e=e.pts-t.pts;return r||e}),c=l[0].dts;var n=l[l.length-1].dts-c,y=n?Math.round(n/(u-1)):f||i.inputTimeScale/30;if(s){const i=c-r,n=i>y,s=i<-1;if((n||s)&&(n?I.warn(`AVC: ${Kr(i,!0)} ms (${i}dts) hole between fragments detected, filling it`):I.warn(`AVC: ${Kr(-i,!0)} ms (${i}dts) overlapping between fragments detected`),!s||r>=l[0].pts)){c=r;const n=l[0].pts-i;l[0].dts=c,l[0].pts=n,I.log(`Video: First PTS/DTS adjusted: ${Kr(n,!0)}/${Kr(c,!0)}, delta: ${Kr(i,!0)} ms`)}}c=Math.max(0,c);let x=0,_=0;for(let e=0;e<u;e++){const n=l[e],s=n.units,a=s.length;let t=0;for(let e=0;e<a;e++)t+=s[e].data.length;_+=t,x+=a,n.length=t,n.dts=Math.max(n.dts,c),p=Math.min(n.pts,p),m=Math.max(n.pts,m)}t=l[u-1].dts;n=_+4*x+8;let b;try{b=new Uint8Array(n)}catch(i){return void this.observer.emit(R.ERROR,R.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:i,bytes:n,reason:"fail allocating video mdat "+n})}var T=new DataView(b.buffer);T.setUint32(0,n),b.set(N.types.mdat,4);let S=!1,E=Number.POSITIVE_INFINITY,w=Number.POSITIVE_INFINITY,M=Number.NEGATIVE_INFINITY,A=Number.NEGATIVE_INFINITY;for(let t=0;t<u;t++){const n=l[t],s=n.units;let e,r=0;for(let e=0,t=s.length;e<t;e++){const n=s[e],a=n.data,o=n.data.byteLength;T.setUint32(d,o),d+=4,b.set(a,d),d+=o,r+=4+o}if(t<u-1)f=l[t+1].dts-n.dts,e=l[t+1].pts-n.pts;else{const s=this.config,h=0<t?n.dts-l[t-1].dts:y;if(e=0<t?n.pts-l[t-1].pts:y,s.stretchShortVideoTrack&&null!==this.nextAudioPts){const i=Math.floor(s.maxBufferHole*o),l=(a?p+a*o:this.nextAudioPts)-n.pts;l>i?((f=l-h)<0?f=h:S=!0,I.log(`[mp4-remuxer]: It is approximately ${l/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=h}else f=h}const c=Math.round(n.pts-n.dts);E=Math.min(E,f),M=Math.max(M,f),w=Math.min(w,e),A=Math.max(A,e),h.push(new ri(n.key,f,r,c))}if(h.length)if(Jr){if(Jr<70){const i=h[0].flags;i.dependsOn=2,i.isNonSync=0}}else if(Zr&&A-w<M-E&&y/M<.025&&0===h[0].cts){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let r=c;for(let e=0,t=h.length;e<t;e++){const a=r+h[e].duration,o=r+h[e].cts;if(e<t-1){const i=a+h[e+1].cts;h[e].duration=i-o}else h[e].duration=e?h[e-1].duration:y;h[e].cts=0,r=a}}f=S||!f?y:f,this.nextAvcDts=r=t+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;s={data1:N.moof(i.sequenceNumber++,c,L({},i,{samples:h})),data2:b,startPTS:p/o,endPTS:(m+f)/o,startDTS:c/o,endDTS:r/o,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:i.dropped};return i.samples=[],i.dropped=0,s}remuxAudio(n,s,r,i,a){const e=n.inputTimeScale,o=e/(n.samplerate||e),l="aac"===n.segmentCodec?1024:1152,h=l*o,t=this._initPTS,u="mp3"===n.segmentCodec&&this.typeSupported.mpeg,c=[],d=void 0!==a;let f=n.samples,p=u?0:8,m=this.nextAudioPts||-1;const g=s*e,v=t.baseTime*e/t.timescale;if(this.isAudioContiguous=r=r||f.length&&0<m&&(i&&Math.abs(g-m)<9e3||Math.abs(U(f[0].pts-v,g)-m)<20*h),f.forEach(function(e){e.pts=U(e.pts-v,g)}),!r||m<0){if(!(f=f.filter(e=>0<=e.pts)).length)return;m=0===a?0:i&&!d?Math.max(0,g):f[0].pts}if("aac"===n.segmentCodec){const s=this.config.maxAudioFramesDrift;for(let r=0,i=m;r<f.length;r++){const a=f[r],o=a.pts,l=o-i,L=Math.abs(1e3*l/e);if(l<=-s*h&&d)0===r&&(I.warn(`Audio frame @ ${(o/e).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*l/e)} ms.`),this.nextAudioPts=m=i=o);else if(l>=s*h&&L<1e4&&d){let t=Math.round(l/h);(i=o-t*h)<0&&(t--,i+=h),0===r&&(this.nextAudioPts=m=i),I.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/e).toFixed(3)}s due to ${Math.round(1e3*l/e)} ms gap.`);for(let e=0;e<t;e++){const s=Math.max(i,0);let e=Yr.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);e||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),e=a.unit.subarray()),f.splice(r,0,{unit:e,pts:s}),i+=h,r++}}a.pts=i,i+=h}}let y,x=null,_=null,b=0,T=f.length;for(;T--;)b+=f[T].unit.byteLength;for(let t=0,e=f.length;t<e;t++){const i=f[t],a=i.unit;let e=i.pts;if(null!==_)c[t-1].duration=Math.round((e-_)/o);else{if(r&&"aac"===n.segmentCodec&&(e=m),x=e,!(0<b))return;b+=p;try{y=new Uint8Array(b)}catch(n){return void this.observer.emit(R.ERROR,R.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:n,bytes:b,reason:"fail allocating audio mdat "+b})}u||(new DataView(y.buffer).setUint32(0,b),y.set(N.types.mdat,4))}y.set(a,p);const h=a.byteLength;p+=h,c.push(new ri(!0,l,h,0)),_=e}var S,s=c.length;if(s)return this.nextAudioPts=m=_+o*c[c.length-1].duration,a=u?new Uint8Array(0):N.moof(n.sequenceNumber++,x/o,L({},n,{samples:c})),n.samples=[],i=x/e,S=m/e,a={data1:a,data2:y,startPTS:i,endPTS:S,startDTS:i,endDTS:S,type:"audio",hasAudio:!0,hasVideo:!1,nb:s},this.isAudioContiguous=!0,a}remuxEmptyAudio(e,t,r,i){var n=e.inputTimeScale,s=n/(e.samplerate||n),a=this.nextAudioPts,o=this._initDTS,o=9e4*o.baseTime/o.timescale,l=(null!==a?a:i.startDTS*n)+o,a=i.endDTS*n+o,h=1024*s,u=Math.ceil((a-l)/h),c=Yr.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),c){var d=[];for(let e=0;e<u;e++){const t=l+e*h;d.push({unit:c,pts:t,dts:t})}return e.samples=d,this.remuxAudio(e,t,r,!1)}I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")}}function U(e,t){var r;if(null!==t)for(r=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=r;return e}function ei(t,r,i,n){const s=t.samples.length;if(s){var a=t.inputTimeScale;for(let e=0;e<s;e++){const s=t.samples[e];s.pts=U(s.pts-i.baseTime*a/i.timescale,r*a)/a,s.dts=U(s.dts-n.baseTime*a/n.timescale,r*a)/a}var e=t.samples;return t.samples=[],{samples:e}}}function ti(t,r,i){const n=t.samples.length;if(n){var s=t.inputTimeScale;for(let e=0;e<n;e++){const n=t.samples[e];n.pts=U(n.pts-i.baseTime*s/i.timescale,r*s)/s}t.samples.sort((e,t)=>e.pts-t.pts);var e=t.samples;return t.samples=[],{samples:e}}}class ri{constructor(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new ii(e)}}class ii{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}function ni(e,t){e=null==e?void 0:e.codec;return e&&4<e.length?e:"hvc1"===e||"hev1"===e?"hvc1.1.6.L120.90":"av01"===e?"av01.0.04M.08":"avc1"===e||t===S?"avc1.42e01e":"mp4a.40.5"}try{Xr=self.performance.now.bind(self.performance)}catch(i){I.debug("Unable to use Performance API on this environment"),Xr="undefined"!=typeof self&&self.Date.now}const si=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){var n=this.videoTrack=F("video",1),s=this.audioTrack=F("audio",1),a=this.txtTrack=F("text",1);if(this.id3Track=F("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=Ce(e);if(o.video){const{id:e,timescale:t,codec:r}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=Me.text,n.sampleDuration=0,n.duration=s.duration=i}}resetContiguity(){this.remainderData=null}static probe(e){return 0<P(e=16384<e.length?e.subarray(0,16384):e,["moof"]).length}demux(e,t){this.timeOffset=t;let r=e;var i,n,s=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ie(this.remainderData,e));e=r,i={valid:null,remainder:null},(n=P(e,["moof"]))&&(n.length<2?i.remainder=e:(n=n[n.length-1],i.valid=fe(e,0,n.byteOffset-8),i.remainder=fe(e,n.byteOffset-8)));const t=i;this.remainderData=t.remainder,s.samples=t.valid||new Uint8Array}else s.samples=r;e=this.extractID3Track(s,t);return a.samples=Pe(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:e,textTrack:this.txtTrack}}flush(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack,i=(t.samples=this.remainderData||new Uint8Array,this.remainderData=null,this.extractID3Track(t,this.timeOffset));return r.samples=Pe(e,t),{videoTrack:t,audioTrack:F(),id3Track:i,textTrack:F()}}extractID3Track(e,i){const n=this.id3Track;return e.samples.length&&(e=P(e.samples,["emsg"]))&&e.forEach(t=>{var r=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,h=0;if(0===t){for(;"\0"!==f(e.subarray(h,h+1));)r+=f(e.subarray(h,h+1)),h+=1;for(r+=f(e.subarray(h,h+1)),h+=1;"\0"!==f(e.subarray(h,h+1));)i+=f(e.subarray(h,h+1)),h+=1;i+=f(e.subarray(h,h+1)),h+=1,n=w(e,12),s=w(e,16),o=w(e,20),l=w(e,24),h=28}else if(1===t){h+=4,n=w(e,h);const t=w(e,h+=4),s=w(e,h+=4);for(h+=4,a=2**32*t+s,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=w(e,h),h+=4,l=w(e,h),h+=4;"\0"!==f(e.subarray(h,h+1));)r+=f(e.subarray(h,h+1)),h+=1;for(r+=f(e.subarray(h,h+1)),h+=1;"\0"!==f(e.subarray(h,h+1));)i+=f(e.subarray(h,h+1)),h+=1;i+=f(e.subarray(h,h+1)),h+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(h,e.byteLength)}}(t);if(Rr.test(r.schemeIdUri)){const t=M(r.presentationTime)?r.presentationTime/r.timeScale:i+r.presentationTimeDelta/r.timeScale;let e=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;e<=.001&&(e=Number.POSITIVE_INFINITY);r=r.payload;n.samples.push({data:r,len:r.byteLength,dts:t,pts:t,type:pt,duration:e})}}),n}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(e&&t){const i=t.keyId;i&&t.isCommonEncryption&&P(e,["moov","trak"]).forEach(e=>{e=P(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let t=P(e,["enca"]);const r=0<t.length;(t=r?t:P(e,["encv"])).forEach(e=>{P(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var t=De(e);if(t){const e=t.subarray(8,24);e.some(e=>0!==e)||(I.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${d(e)} -> `+d(i)),t.set(i,8))}})})})}return e}(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;var i,n;null!=e&&e.byteLength?(i=this.initData=Ce(e),t=t||ni(i.audio,b),r=r||ni(i.video,S),n={},i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n):(this.initTracks=void 0,this.initData=void 0)}remux(r,i,n,s,a,o){let{initPTS:l,lastEndTime:h}=this;var u={audio:void 0,video:void 0,text:s,id3:n,initSegment:void 0},i=(M(h)||(h=this.lastEndTime=a||0),i.samples);if(null!=i&&i.length){var c={initPTS:void 0,timescale:1};let t=this.initData;if(null!=(m=t)&&m.length||(this.generateInitSegment(i),t=this.initData),null!=(m=t)&&m.length){this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var d,f,p,m=function(e,t){let r=0,i=0,n=0;var s=P(e,["moof","traf"]);for(let e=0;e<s.length;e++){var a=s[e],o=P(a,["tfhd"])[0],l=t[w(o,4)];if(l){var h=l.default,u=w(o,0)|(null==h?void 0:h.flags);let t=null==h?void 0:h.duration;8&u&&(t=w(o,2&u?12:8));var c=l.timescale||9e4,d=P(a,["trun"]);for(let e=0;e<d.length;e++)!(r=function(t){var r=w(t,0);let i=8,n=(1&r&&(i+=4),4&r&&(i+=4),0);var s=w(t,4);for(let e=0;e<s;e++)256&r&&(n+=w(t,i),i+=4),512&r&&(i+=4),1024&r&&(i+=4),2048&r&&(i+=4);return n}(d[e]))&&t&&(r=t*w(d[e],4)),l.type===S?i+=r/c:l.type===b&&(n+=r/c)}}if(0!==i||0!==n)return i||n;{let t=0;const r=P(e,["sidx"]);for(let e=0;e<r.length;e++){const i=function(t){var r=[],e=t[0];let i=8;var n=w(t,i);i=(i+=4)+(0===e?8:16)+2;let s=t.length+0;const a=Ae(t,i);i+=2;for(let e=0;e<a;e++){var o=i;const a=w(t,o);o+=4;var l=2147483647&a;if(1==(2147483648&a)>>>31)return I.warn("SIDX has hierarchical references (not supported)"),null;var h=w(t,o);o+=4,r.push({referenceSize:l,subsegmentDuration:h,info:{duration:h/n,start:s,end:s+l-1}}),s+=l,o+=4,i=o}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:a,references:r}}(r[e]);null!=i&&i.references&&(t+=i.references.reduce((e,t)=>e+t.info.duration||0,0))}return t}}(i,t),g=(d=t,P(i,["moof","traf"]).reduce((e,t)=>{const n=P(t,["tfdt"])[0],s=n[0],r=P(t,["tfhd"]).reduce((t,r)=>{var r=w(r,4),i=d[r];if(i){let e=w(n,4);if(1===s){if(e===Ee)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e=(e*=1+Ee)+w(n,8)}const r=e/(i.timescale||9e4);if(isFinite(r)&&(null===t||r<t))return r}return t},null);return null!==r&&isFinite(r)&&(null===e||r<e)?r:e},null)),g=null===g?a:g,v=(v=l,y=g,x=a,(null===v||(_=Math.max(m,1),y=y-v.baseTime/v.timescale,Math.abs(y-x)>_)||c.timescale!==l.timescale&&o)&&(c.initPTS=g-a,l&&1===l.timescale&&I.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1}),r?g-l.baseTime/l.timescale:h),y=v+m,x=(f=t,p=l.baseTime/l.timescale,P(i,["moof","traf"]).forEach(t=>{P(t,["tfhd"]).forEach(e=>{e=w(e,4),e=f[e];if(e){const n=e.timescale||9e4;P(t,["tfdt"]).forEach(e=>{const t=e[0];let r=w(e,4);if(0===t)r-=p*n,Re(e,4,r=Math.max(r,0));else{r=(r=(r*=Math.pow(2,32))+w(e,8))-p*n,r=Math.max(r,0);const t=Math.floor(r/(1+Ee)),i=Math.floor(r%(1+Ee));Re(e,4,t),Re(e,8,i)}})}})}),0<m?this.lastEndTime=y:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp()),!!t.audio),_=!!t.video;let e="";x&&(e+="audio"),_&&(e+="video");o={data1:i,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:e,hasAudio:x,hasVideo:_,nb:1,dropped:0};u.audio="audio"===o.type?o:void 0,u.video="audio"!==o.type?o:void 0,u.initSegment=c,u.id3=ei(n,a,l,l),s.samples.length&&(u.text=ti(s,a,l))}else I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment.")}return u}}},{demux:Hr,remux:Qr},{demux:class extends _r{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(t){let e=(ge(t,0)||[]).length;for(var r,i,n,s,a=t.length;e<a;e++)if(r=t,i=e,s=n=void 0,!wr(r,i)||i+(s=Sr(r,i))>=r.length?void 0:!((n=Er(r,i))<=s)&&((s=i+n)===r.length||wr(r,s)))return I.log("ADTS sync word found !"),!0}return!1}canParse(e,t){return(t=t)+5<(e=e).length&&Tr(e,t)&&Er(e,t)<=e.length-t}appendFrame(e,t,r){Mr(e,this.observer,t,r,e.manifestCodec);e=Lr(e,t,r,this.basePTS,this.frameIndex);if(e&&0===e.missing)return e}},remux:Qr},{demux:class extends _r{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(t){let e=(ge(t,0)||[]).length;for(var r=t.length;e<r;e++)if(function(t,r){if(r+1<t.length&&Nr(t,r)){var i=Fr(t,r);let e=4;r=r+(e=null!=i&&i.frameLength?i.frameLength:e);return r===t.length||Ur(t,r)}}(t,e))return I.log("MPEG Audio sync word found !"),!0}return!1}canParse(e,t){return Nr(e,t)&&4<=e.length-t}appendFrame(e,t,r){if(null!==this.basePTS)return Or(e,t,r,this.basePTS,this.frameIndex)}},remux:Qr}];class ai{constructor(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(t,r,i,e){var n=i.transmuxing;n.executeStart=Xr();let s=new Uint8Array(t);var{currentTransmuxState:t,transmuxConfig:a}=this,{contiguous:e,discontinuity:t,trackSwitch:o,accurateTimeOffset:l,timeOffset:h,initSegmentChange:u}=(e&&(this.currentTransmuxState=e),e||t),{audioCodec:a,videoCodec:c,defaultInitPts:d,duration:f,initSegmentData:p}=a,m=function(e){let t=null;return t=0<e.byteLength&&null!=r&&null!=r.key&&null!==r.iv&&null!=r.method?r:t}(s);if(m&&"AES-128"===m.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(s,m.key.buffer,m.iv.buffer).then(e=>{e=this.push(e,null,i);return this.decryptionPromise=null,e}),this.decryptionPromise;{let e=t.softwareDecrypt(s,m.key.buffer,m.iv.buffer);if(!(e=-1<i.part?t.flush():e))return n.executeEnd=Xr(),oi(i);s=new Uint8Array(e)}}var g=this.needsProbing(t,o);if(g){const t=this.configureTransmuxer(s);if(t)return I.warn("[transmuxer] "+t.message),this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),n.executeEnd=Xr(),oi(i)}(t||o||u||g)&&this.resetInitSegment(p,a,c,f,r),(t||u||g)&&this.resetInitialTimestamp(d),e||this.resetContiguity();o=this.transmux(s,m,h,l,i),p=this.currentTransmuxState;return p.contiguous=!0,p.discontinuity=!1,p.trackSwitch=!1,n.executeEnd=Xr(),o}flush(t){const e=t.transmuxing;e.executeStart=Xr();var{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(t));const s=[],a=i["timeOffset"];if(r){const e=r.flush();e&&s.push(this.push(e,null,t))}var{demuxer:n,remuxer:i}=this;return n&&i?li(r=n.flush(a))?r.then(e=>(this.flushRemux(s,e,t),s)):(this.flushRemux(s,r,t),s):(e.executeEnd=Xr(),[oi(t)])}flushRemux(e,t,r){var{audioTrack:t,videoTrack:i,id3Track:n,textTrack:s}=t,{accurateTimeOffset:a,timeOffset:o}=this.currentTransmuxState,t=(I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${-1<r.part?" p: "+r.part:""} of level `+r.level),this.remuxer.remux(t,i,n,s,o,a,!0,this.id));e.push({remuxResult:t,chunkMeta:r}),r.transmuxing.executeEnd=Xr()}resetInitialTimestamp(e){var{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){var{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,n){var{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)}transmuxUnencrypted(e,t,r,i){var{audioTrack:e,videoTrack:n,id3Track:s,textTrack:a}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(e,n,s,a,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:n}))}configureTransmuxer(r){var{config:e,observer:t,typeSupported:i,vendor:n}=this;let s;for(let e=0,t=si.length;e<t;e++)if(si[e].demux.probe(r)){s=si[e];break}if(!s)return new Error("Failed to find demuxer by probing fragment data");var a=this.demuxer,o=this.remuxer,l=s.remux,h=s.demux;o&&o instanceof l||(this.remuxer=new l(t,e,i,n)),a&&a instanceof h||(this.demuxer=new h(t,e,i),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e=e||(this.decrypter=new lr(this.config))}}const oi=e=>({remuxResult:{},chunkMeta:e});function li(e){return"then"in e&&e.then instanceof Function}class hi{constructor(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null}}class ui{constructor(e,t,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}}var ci,B,e={exports:{}};function di(){}function fi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function pi(e,t,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new fi(r,i||e,n),i=B?B+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function mi(e,t){0==--e._eventsCount?e._events=new di:delete e._events[t]}function r(){this._events=new di,this._eventsCount=0}t=e,ci=Object.prototype.hasOwnProperty,B="~",Object.create&&(di.prototype=Object.create(null),(new di).__proto__||(B=!1)),r.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)ci.call(e,t)&&r.push(B?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},r.prototype.listeners=function(e){var e=B?B+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,n=new Array(i);r<i;r++)n[r]=t[r].fn;return n},r.prototype.listenerCount=function(e){e=B?B+e:e,e=this._events[e];return e?e.fn?1:e.length:0},r.prototype.emit=function(e,t,r,i,n,s){var a=B?B+e:e;if(!this._events[a])return!1;var o,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,n),!0;case 6:return l.fn.call(l.context,t,r,i,n,s),!0}for(d=1,o=new Array(h-1);d<h;d++)o[d-1]=arguments[d];l.fn.apply(l.context,o)}else for(var u,c=l.length,d=0;d<c;d++)switch(l[d].once&&this.removeListener(e,l[d].fn,void 0,!0),h){case 1:l[d].fn.call(l[d].context);break;case 2:l[d].fn.call(l[d].context,t);break;case 3:l[d].fn.call(l[d].context,t,r);break;case 4:l[d].fn.call(l[d].context,t,r,i);break;default:if(!o)for(u=1,o=new Array(h-1);u<h;u++)o[u-1]=arguments[u];l[d].fn.apply(l[d].context,o)}return!0},r.prototype.on=function(e,t,r){return pi(this,e,t,r,!1)},r.prototype.once=function(e,t,r){return pi(this,e,t,r,!0)},r.prototype.removeListener=function(e,t,r,i){e=B?B+e:e;if(this._events[e])if(t){var n=this._events[e];if(n.fn)n.fn!==t||i&&!n.once||r&&n.context!==r||mi(this,e);else{for(var s=0,a=[],o=n.length;s<o;s++)(n[s].fn!==t||i&&!n[s].once||r&&n[s].context!==r)&&a.push(n[s]);a.length?this._events[e]=1===a.length?a[0]:a:mi(this,e)}}else mi(this,e);return this},r.prototype.removeAllListeners=function(e){return e?(e=B?B+e:e,this._events[e]&&mi(this,e)):(this._events=new di,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=B,t.exports=r.EventEmitter=r;var gi=(t=e.exports)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;const vi=ze()||{isTypeSupported:()=>!1};class yi{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var s,r=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===R.ERROR&&(this.error=t.error),this.hls.trigger(e,t)},i=(this.observer=new gi,this.observer.on(R.FRAG_DECRYPTED,r),this.observer.on(R.ERROR,r),{mp4:vi.isTypeSupported("video/mp4"),mpeg:vi.isTypeSupported("audio/mpeg"),mp3:vi.isTypeSupported('audio/mp4; codecs="mp3"')}),r=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__))try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){e=new self.URL(e,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=(s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),s=self.URL.createObjectURL(s),{worker:new self.Worker(s),objectURL:s})),this.onwmsg=e=>this.onWorkerMessage(e);const e=this.workerContext["worker"];e.addEventListener("message",this.onwmsg),e.onerror=e=>{e=new Error(`${e.message} (${e.filename}:${e.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})},e.postMessage({cmd:"init",typeSupported:i,vendor:r,id:t,config:JSON.stringify(n)})}catch(e){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new ai(this.observer,i,n,r,t)}else this.transmuxer=new ai(this.observer,i,n,r,t)}resetWorker(){var e,t;this.workerContext&&({worker:e,objectURL:t}=this.workerContext,t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null)}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,i,n,s,a,o,l,h){var u=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],c=(s||n).start,d=n.decryptdata,f=this.frag,p=!(f&&n.cc===f.cc),m=!(f&&l.level===f.level),g=f?l.sn-f.sn:-1,v=this.part?l.part-this.part.index:-1,y=0==g&&1<l.id&&l.id===(null==f?void 0:f.stats.chunkCount),y=!m&&(1==g||0==g&&(1==v||y&&v<=0)),x=self.performance.now(),x=((m||g||0===n.stats.parsing.start)&&(n.stats.parsing.start=x),!s||!v&&y||(s.stats.parsing.start=x),!(f&&(null==(g=n.initSegment)?void 0:g.url)===(null==(v=f.initSegment)?void 0:v.url))),g=new ui(p,y,o,m,c,x);if(!y||p||x){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}
|
|
121
|
+
`,blending:q,depthTest:!1,depthWrite:!1})}function Ma(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Aa(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include <encodings_pars_fragment>\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function La(n){let s=new WeakMap,a=null;function o(e){var e=e.target,t=(e.removeEventListener("dispose",o),s.get(e));void 0!==t&&(s.delete(e),t.dispose())}return{get:function(e){if(e&&e.isTexture&&!1===e.isRenderTargetTexture){var t,r=e.mapping,i=r===Ge||r===He,r=r===Ue||r===Be;if(i||r)return s.has(e)?s.get(e).texture:(t=e.image,i&&t&&0<t.height||r&&t&&function(t){let r=0;for(let e=0;e<6;e++)void 0!==t[e]&&r++;return 6===r}(t)?(r=n.getRenderTarget(),null===a&&(a=new ba(n)),t=i?a.fromEquirectangular(e):a.fromCubemap(e),s.set(e,t),n.setRenderTarget(r),e.addEventListener("dispose",o),t.texture):null)}return e},dispose:function(){s=new WeakMap,null!==a&&(a.dispose(),a=null)}}}function Ra(r){const i={};function n(e){if(void 0!==i[e])return i[e];let t;switch(e){case"WEBGL_depth_texture":t=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":t=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":t=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":t=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:t=r.getExtension(e)}return i[e]=t}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(e){var t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Ca(e,o,r,i){const n={},l=new WeakMap;function s(e){var t=e.target;null!==t.index&&o.remove(t.index);for(const e in t.attributes)o.remove(t.attributes[e]);t.removeEventListener("dispose",s),delete n[t.id];e=l.get(t);e&&(o.remove(e),l.delete(t)),i.releaseStatesOfGeometry(t),!0===t.isInstancedBufferGeometry&&delete t._maxInstanceCount,r.memory.geometries--}function a(r){const i=[],n=r.index,s=r.attributes.position;let e=0;if(null!==n){const r=n.array;e=n.version;for(let e=0,t=r.length;e<t;e+=3){const n=r[e+0],s=r[e+1],l=r[e+2];i.push(n,s,s,l,l,n)}}else{const r=s.array;e=s.version;for(let e=0,t=r.length/3-1;e<t;e+=3){const r=e+0,n=e+1,s=e+2;i.push(r,n,n,s,s,r)}}var t=new(65535<Ti(i)?os:ss)(i,1),a=(t.version=e,l.get(r));a&&o.remove(a),l.set(r,t)}return{get:function(e,t){return!0!==n[t.id]&&(t.addEventListener("dispose",s),n[t.id]=!0,r.memory.geometries++),t},update:function(e){const r=e.attributes;for(const e in r)o.update(r[e],34962);var t=e.morphAttributes;for(const e in t){const r=t[e];for(let e=0,t=r.length;e<t;e++)o.update(r[e],34962)}},getWireframeAttribute:function(e){var t,r=l.get(e);return(!r||null!==(t=e.index)&&r.version<t.version)&&a(e),l.get(e)}}}function Da(s,a,o,e){const l=e.isWebGL2;let h,u,c;this.setMode=function(e){h=e},this.setIndex=function(e){u=e.type,c=e.bytesPerElement},this.render=function(e,t){s.drawElements(h,t,u,e*c),o.update(t,h,1)},this.renderInstances=function(r,i,n){if(0!==n){let e,t;if(l)e=s,t="drawElementsInstanced";else if(e=a.get("ANGLE_instanced_arrays"),t="drawElementsInstancedANGLE",null===e)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");e[t](h,i,u,r*c,n),o.update(i,h,n)}}}function Ia(e){const i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:i,programs:null,autoReset:!0,reset:function(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0},update:function(e,t,r){switch(i.calls++,t){case 4:i.triangles+=r*(e/3);break;case 1:i.lines+=r*(e/2);break;case 3:i.lines+=r*(e-1);break;case 2:i.lines+=r*e;break;case 0:i.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",t)}}}}class Pa extends u{constructor(e=null,t=1,r=1,i=1){super(null),this.image={data:e,width:t,height:r,depth:i},this.magFilter=Re,this.minFilter=Re,this.wrapR=Le,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}function ka(e,t){return e[0]-t[0]}function Oa(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Fa(e,t){let r=1;t=(t.isInterleavedBufferAttribute?t.data:t).array;t instanceof Int8Array?r=127:t instanceof Int16Array?r=32767:t instanceof Int32Array?r=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",t),e.divideScalar(r)}function Na(h,u,c){const d={},f=new Float32Array(8),p=new WeakMap,m=new Pe,g=[];for(let e=0;e<8;e++)g[e]=[e,0];return{update:function(i,n,e,s){const a=i.morphTargetInfluences;if(!0===u.isWebGL2){const d=n.morphAttributes.position.length;let e=p.get(n);if(void 0===e||e.count!==d){void 0!==e&&e.texture.dispose();const h=void 0!==n.morphAttributes.normal,c=n.morphAttributes.position,g=n.morphAttributes.normal||[],i=!0==h?2:1;let t=n.attributes.position.count*i,r=1;t>u.maxTextureSize&&(r=Math.ceil(t/u.maxTextureSize),t=u.maxTextureSize);const a=new Float32Array(t*r*4*d),l=new Pa(a,t,r,d);l.format=Ce,l.type=at;var o=4*i;for(let e=0;e<d;e++){const d=c[e],f=g[e],p=t*r*4*e;for(let e=0;e<d.count;e++){m.fromBufferAttribute(d,e),!0===d.normalized&&Fa(m,d);const c=e*o;a[p+c]=m.x,a[p+c+1]=m.y,a[p+c+2]=m.z,!(a[p+c+3]=0)==h&&(m.fromBufferAttribute(f,e),!0===f.normalized&&Fa(m,f),a[p+c+4]=m.x,a[p+c+5]=m.y,a[p+c+6]=m.z,a[p+c+7]=0)}}e={count:d,texture:l,size:new z(t,r)},p.set(n,e)}let t=0;for(let e=0;e<a.length;e++)t+=a[e];const i=n.morphTargetsRelative?1:1-t;s.getUniforms().setValue(h,"morphTargetBaseInfluence",i),s.getUniforms().setValue(h,"morphTargetInfluences",a),s.getUniforms().setValue(h,"morphTargetsTexture",e.texture,c),s.getUniforms().setValue(h,"morphTargetsTextureSize",e.size)}else{const u=void 0===a?0:a.length;let t=d[n.id];if(void 0===t||t.length!==u){t=[];for(let e=0;e<u;e++)t[e]=[e,0];d[n.id]=t}for(let e=0;e<u;e++){const u=t[e];u[0]=e,u[1]=a[e]}t.sort(Oa);for(let e=0;e<8;e++)e<u&&t[e][1]?(g[e][0]=t[e][0],g[e][1]=t[e][1]):(g[e][0]=Number.MAX_SAFE_INTEGER,g[e][1]=0);g.sort(ka);const p=n.morphAttributes.position,m=n.morphAttributes.normal;let r=0;for(let e=0;e<8;e++){const u=g[e],c=u[0],d=u[1];c!==Number.MAX_SAFE_INTEGER&&d?(p&&n.getAttribute("morphTarget"+e)!==p[c]&&n.setAttribute("morphTarget"+e,p[c]),m&&n.getAttribute("morphNormal"+e)!==m[c]&&n.setAttribute("morphNormal"+e,m[c]),f[e]=d,r+=d):(p&&!0===n.hasAttribute("morphTarget"+e)&&n.deleteAttribute("morphTarget"+e),m&&!0===n.hasAttribute("morphNormal"+e)&&n.deleteAttribute("morphNormal"+e),f[e]=0)}const e=n.morphTargetsRelative?1:1-r;s.getUniforms().setValue(h,"morphTargetBaseInfluence",e),s.getUniforms().setValue(h,"morphTargetInfluences",f)}}}}function Ua(e,i,n,s){let a=new WeakMap;function o(e){e=e.target;e.removeEventListener("dispose",o),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(e){var t=s.render.frame,r=e.geometry,r=i.get(e,r);return a.get(r)!==t&&(i.update(r),a.set(r,t)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",o)&&e.addEventListener("dispose",o),n.update(e.instanceMatrix,34962),null!==e.instanceColor)&&n.update(e.instanceColor,34962),r},dispose:function(){a=new WeakMap}}}Pa.prototype.isDataTexture2DArray=!0;class Ba extends u{constructor(e=null,t=1,r=1,i=1){super(null),this.image={data:e,width:t,height:r,depth:i},this.magFilter=Re,this.minFilter=Re,this.wrapR=Le,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Ba.prototype.isDataTexture3D=!0;const Ga=new u,Ha=new Pa,za=new Ba,Va=new Hs,Wa=[],ja=[],Ya=new Float32Array(16),$a=new Float32Array(9),qa=new Float32Array(4);function Ka(r,i,n){var e=r[0];if(e<=0||0<e)return r;var t=i*n;let s=Wa[t];if(void 0===s&&(s=new Float32Array(t),Wa[t]=s),0!==i){e.toArray(s,0);for(let e=1,t=0;e!==i;++e)t+=n,r[e].toArray(s,t)}return s}function Xa(r,i){if(r.length===i.length){for(let e=0,t=r.length;e<t;e++)if(r[e]!==i[e])return;return 1}}function Ja(r,i){for(let e=0,t=i.length;e<t;e++)r[e]=i[e]}function Za(t,r){let i=ja[r];void 0===i&&(i=new Int32Array(r),ja[r]=i);for(let e=0;e!==r;++e)i[e]=t.allocateTextureUnit();return i}function Qa(e,t){var r=this.cache;r[0]!==t&&(e.uniform1f(this.addr,t),r[0]=t)}function eo(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),r[0]=t.x,r[1]=t.y):Xa(r,t)||(e.uniform2fv(this.addr,t),Ja(r,t))}function to(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y&&r[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),r[0]=t.x,r[1]=t.y,r[2]=t.z):void 0!==t.r?r[0]===t.r&&r[1]===t.g&&r[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),r[0]=t.r,r[1]=t.g,r[2]=t.b):Xa(r,t)||(e.uniform3fv(this.addr,t),Ja(r,t))}function ro(e,t){var r=this.cache;void 0!==t.x?r[0]===t.x&&r[1]===t.y&&r[2]===t.z&&r[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=t.w):Xa(r,t)||(e.uniform4fv(this.addr,t),Ja(r,t))}function io(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix2fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||(qa.set(i),e.uniformMatrix2fv(this.addr,!1,qa),Ja(r,i))}function no(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix3fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||($a.set(i),e.uniformMatrix3fv(this.addr,!1,$a),Ja(r,i))}function so(e,t){var r=this.cache,i=t.elements;void 0===i?Xa(r,t)||(e.uniformMatrix4fv(this.addr,!1,t),Ja(r,t)):Xa(r,i)||(Ya.set(i),e.uniformMatrix4fv(this.addr,!1,Ya),Ja(r,i))}function ao(e,t){var r=this.cache;r[0]!==t&&(e.uniform1i(this.addr,t),r[0]=t)}function oo(e,t){var r=this.cache;Xa(r,t)||(e.uniform2iv(this.addr,t),Ja(r,t))}function lo(e,t){var r=this.cache;Xa(r,t)||(e.uniform3iv(this.addr,t),Ja(r,t))}function ho(e,t){var r=this.cache;Xa(r,t)||(e.uniform4iv(this.addr,t),Ja(r,t))}function uo(e,t){var r=this.cache;r[0]!==t&&(e.uniform1ui(this.addr,t),r[0]=t)}function co(e,t){var r=this.cache;Xa(r,t)||(e.uniform2uiv(this.addr,t),Ja(r,t))}function fo(e,t){var r=this.cache;Xa(r,t)||(e.uniform3uiv(this.addr,t),Ja(r,t))}function po(e,t){var r=this.cache;Xa(r,t)||(e.uniform4uiv(this.addr,t),Ja(r,t))}function mo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.safeSetTexture2D(t||Ga,n)}function go(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTexture3D(t||za,n)}function vo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.safeSetTextureCube(t||Va,n)}function yo(e,t,r){var i=this.cache,n=r.allocateTextureUnit();i[0]!==n&&(e.uniform1i(this.addr,n),i[0]=n),r.setTexture2DArray(t||Ha,n)}function xo(e,t){e.uniform1fv(this.addr,t)}function _o(e,t){t=Ka(t,this.size,2);e.uniform2fv(this.addr,t)}function bo(e,t){t=Ka(t,this.size,3);e.uniform3fv(this.addr,t)}function To(e,t){t=Ka(t,this.size,4);e.uniform4fv(this.addr,t)}function So(e,t){t=Ka(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,t)}function Eo(e,t){t=Ka(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,t)}function wo(e,t){t=Ka(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,t)}function Mo(e,t){e.uniform1iv(this.addr,t)}function Ao(e,t){e.uniform2iv(this.addr,t)}function Lo(e,t){e.uniform3iv(this.addr,t)}function Ro(e,t){e.uniform4iv(this.addr,t)}function Co(e,t){e.uniform1uiv(this.addr,t)}function Do(e,t){e.uniform2uiv(this.addr,t)}function Io(e,t){e.uniform3uiv(this.addr,t)}function Po(e,t){e.uniform4uiv(this.addr,t)}function ko(e,t,r){var i=t.length,n=Za(r,i);e.uniform1iv(this.addr,n);for(let e=0;e!==i;++e)r.safeSetTexture2D(t[e]||Ga,n[e])}function Oo(e,t,r){var i=t.length,n=Za(r,i);e.uniform1iv(this.addr,n);for(let e=0;e!==i;++e)r.safeSetTextureCube(t[e]||Va,n[e])}function Fo(e,t,r){this.id=e,this.addr=r,this.cache=[],this.setValue=function(){switch(t.type){case 5126:return Qa;case 35664:return eo;case 35665:return to;case 35666:return ro;case 35674:return io;case 35675:return no;case 35676:return so;case 5124:case 35670:return ao;case 35667:case 35671:return oo;case 35668:case 35672:return lo;case 35669:case 35673:return ho;case 5125:return uo;case 36294:return co;case 36295:return fo;case 36296:return po;case 35678:case 36198:case 36298:case 36306:case 35682:return mo;case 35679:case 36299:case 36307:return go;case 35680:case 36300:case 36308:case 36293:return vo;case 36289:case 36303:case 36311:case 36292:return yo}}()}function No(e,t,r){this.id=e,this.addr=r,this.cache=[],this.size=t.size,this.setValue=function(){switch(t.type){case 5126:return xo;case 35664:return _o;case 35665:return bo;case 35666:return To;case 35674:return So;case 35675:return Eo;case 35676:return wo;case 5124:case 35670:return Mo;case 35667:case 35671:return Ao;case 35668:case 35672:return Lo;case 35669:case 35673:return Ro;case 5125:return Co;case 36294:return Do;case 36295:return Io;case 36296:return Po;case 35678:case 36198:case 36298:case 36306:case 35682:return ko;case 35680:case 36300:case 36308:case 36293:return Oo}}()}function Uo(e){this.id=e,this.seq=[],this.map={}}No.prototype.updateCache=function(e){var t=this.cache;e instanceof Float32Array&&t.length!==e.length&&(this.cache=new Float32Array(e.length)),Ja(t,e)},Uo.prototype.setValue=function(r,i,n){var s=this.seq;for(let e=0,t=s.length;e!==t;++e){var a=s[e];a.setValue(r,i[a.id],n)}};const Bo=/(\w+)(\])?(\[|\.)?/g;function Go(e,t){e.seq.push(t),e.map[t.id]=t}function Ho(t,r){this.seq=[],this.map={};const i=t.getProgramParameter(r,35718);for(let e=0;e<i;++e){const i=t.getActiveUniform(r,e);c=u=h=l=o=a=s=n=void 0;var n=i,s=t.getUniformLocation(r,i.name),a=this,o=n.name,l=o.length;for(Bo.lastIndex=0;;){var h=Bo.exec(o),u=Bo.lastIndex;let t=h[1];var c="]"===h[2],h=h[3];if(c&&(t|=0),void 0===h||"["===h&&u+2===l){Go(a,new(void 0===h?Fo:No)(t,n,s));break}{let e=a.map[t];void 0===e&&Go(a,e=new Uo(t)),a=e}}}}function zo(e,t,r){t=e.createShader(t);return e.shaderSource(t,r),e.compileShader(t),t}Ho.prototype.setValue=function(e,t,r,i){t=this.map[t];void 0!==t&&t.setValue(e,r,i)},Ho.prototype.setOptional=function(e,t,r){t=t[r];void 0!==t&&this.setValue(e,r,t)},Ho.upload=function(r,i,n,s){for(let e=0,t=i.length;e!==t;++e){var a=i[e],o=n[a.id];!1!==o.needsUpdate&&a.setValue(r,o.value,s)}},Ho.seqWithValue=function(r,i){var n=[];for(let e=0,t=r.length;e!==t;++e){var s=r[e];s.id in i&&n.push(s)}return n};let Vo=0;function Wo(e){switch(e){case De:return["Linear","( value )"];case wr:return["sRGB","( value )"];case Ar:return["RGBE","( value )"];case Rr:return["RGBM","( value, 7.0 )"];case Cr:return["RGBM","( value, 16.0 )"];case Dr:return["RGBD","( value, 256.0 )"];case Mr:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case Lr:return["LogLuv","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}function jo(e,r,t){var i=e.getShaderParameter(r,35713),n=e.getShaderInfoLog(r).trim();return i&&""===n?"":t.toUpperCase()+"\n\n"+n+"\n\n"+function(){var t=e.getShaderSource(r).split("\n");for(let e=0;e<t.length;e++)t[e]=e+1+": "+t[e];return t.join("\n")}()}function Yo(e,t){t=Wo(t);return"vec4 "+e+"( vec4 value ) { return "+t[0]+"ToLinear"+t[1]+"; }"}function $o(e){return""!==e}function qo(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ko(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Xo=/^[ \t]*#include +<([\w\d./]+)>/gm;function Jo(e){return e.replace(Xo,Zo)}function Zo(e,t){var r=M[t];if(void 0===r)throw new Error("Can not resolve #include <"+t+">");return Jo(r)}const Qo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,el=/#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;function tl(e){return e.replace(el,il).replace(Qo,rl)}function rl(e,t,r,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),il(0,t,r,i)}function il(e,t,r,i){let n="";for(let e=parseInt(t);e<parseInt(r);e++)n+=i.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return n}function nl(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function sl(r,i,n,e){const s=r.getContext(),t=n.defines;var a=n.vertexShader,o=n.fragmentShader;const l=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===C?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===D?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===I&&(t="SHADOWMAP_TYPE_VSM"),t}(n),h=function(){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Ue:case Be:e="ENVMAP_TYPE_CUBE";break;case ze:case Ve:e="ENVMAP_TYPE_CUBE_UV"}return e}(),u=function(){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Be:case Ve:e="ENVMAP_MODE_REFRACTION"}return e}(),c=function(){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case O:e="ENVMAP_BLENDING_MULTIPLY";break;case F:e="ENVMAP_BLENDING_MIX";break;case B:e="ENVMAP_BLENDING_ADD"}return e}(),d=0<r.gammaFactor?r.gammaFactor:1,f=n.isWebGL2?"":[n.extensionDerivatives||n.envMapCubeUV||n.bumpMap||n.tangentSpaceNormalMap||n.clearcoatNormalMap||n.flatShading||"physical"===n.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter($o).join("\n"),p=function(e){var t=[];for(const i in e){var r=e[i];!1!==r&&t.push("#define "+i+" "+r)}return t.join("\n")}(t),m=s.createProgram();let g,v,y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(0<(g=[p].filter($o).join("\n")).length&&(g+="\n"),0<(v=[f,p].filter($o).join("\n")).length&&(v+="\n")):(g=[nl(n),"#define SHADER_NAME "+n.shaderName,p,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+d,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter($o).join("\n"),v=[f,nl(n),"#define SHADER_NAME "+n.shaderName,p,"#define GAMMA_FACTOR "+d,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+u:"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Ne?"#define TONE_MAPPING":"",n.toneMapping!==Ne?M.tonemapping_pars_fragment:"",n.toneMapping!==Ne?function(e,t){let r;switch(t){case G:r="Linear";break;case H:r="Reinhard";break;case W:r="OptimizedCineon";break;case Ee:r="ACESFilmic";break;case we:r="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),r="Linear"}return"vec3 "+e+"( vec3 color ) { return "+r+"ToneMapping( color ); }"}("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===ft?"#define OPAQUE":"",M.encodings_pars_fragment,n.map?Yo("mapTexelToLinear",n.mapEncoding):"",n.matcap?Yo("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Yo("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Yo("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularColorMap?Yo("specularColorMapTexelToLinear",n.specularColorMapEncoding):"",n.sheenColorMap?Yo("sheenColorMapTexelToLinear",n.sheenColorMapEncoding):"",n.lightMap?Yo("lightMapTexelToLinear",n.lightMapEncoding):"",(x="linearToOutputTexel",_=Wo(_=n.outputEncoding),"vec4 "+x+"( vec4 value ) { return LinearTo"+_[0]+_[1]+"; }"),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter($o).join("\n")),a=Ko(qo(Jo(a),n),n),o=Ko(qo(Jo(o),n),n),a=tl(a),o=tl(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===li?"":"out highp vec4 pc_fragColor;",n.glslVersion===li?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);var x=y+v+o,_=zo(s,35633,y+g+a),o=zo(s,35632,x);if(s.attachShader(m,_),s.attachShader(m,o),void 0!==n.index0AttributeName?s.bindAttribLocation(m,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(m,0,"position"),s.linkProgram(m),r.debug.checkShaderErrors){const r=s.getProgramInfoLog(m).trim(),i=s.getShaderInfoLog(_).trim(),n=s.getShaderInfoLog(o).trim();let e=!0,t=!0;if(!1===s.getProgramParameter(m,35714)){e=!1;const i=jo(s,_,"vertex"),n=jo(s,o,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(m,35715)+"\n\nProgram Info Log: "+r+"\n"+i+"\n"+n)}else""!==r?console.warn("THREE.WebGLProgram: Program Info Log:",r):""!==i&&""!==n||(t=!1);t&&(this.diagnostics={runnable:e,programLog:r,vertexShader:{log:i,prefix:g},fragmentShader:{log:n,prefix:v}})}let b,T;return s.deleteShader(_),s.deleteShader(o),this.getUniforms=function(){return b=void 0===b?new Ho(s,m):b},this.getAttributes=function(){return T=void 0===T?function(r,i){const n={},s=r.getProgramParameter(i,35721);for(let t=0;t<s;t++){const s=r.getActiveAttrib(i,t),a=s.name;let e=1;35674===s.type&&(e=2),35675===s.type&&(e=3),35676===s.type&&(e=4),n[a]={type:s.type,location:r.getAttribLocation(i,a),locationSize:e}}return n}(s,m):T},this.destroy=function(){e.releaseStatesOfProgram(this),s.deleteProgram(m),this.program=void 0},this.name=n.shaderName,this.id=Vo++,this.cacheKey=i,this.usedTimes=1,this.program=m,this.vertexShader=_,this.fragmentShader=o,this}function al(f,p,m,g,v,e,y){const s=[],x=v.isWebGL2,_=v.logarithmicDepthBuffer,b=v.floatVertexTextures,T=v.maxVertexUniforms,S=v.vertexTextures;let E=v.precision;const w={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"},i=["precision","isWebGL2","supportsVertexTextures","outputEncoding","instancing","instancingColor","map","mapEncoding","matcap","matcapEncoding","envMap","envMapMode","envMapEncoding","envMapCubeUV","lightMap","lightMapEncoding","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","objectSpaceNormalMap","tangentSpaceNormalMap","clearcoat","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","displacementMap","specularMap",,"roughnessMap","metalnessMap","gradientMap","alphaMap","alphaTest","combine","vertexColors","vertexAlphas","vertexTangents","vertexUvs","uvsVertexOnly","fog","useFog","fogExp2","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","morphTargetsCount","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","numDirLightShadows","numPointLightShadows","numSpotLightShadows","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering","format","specularIntensityMap","specularColorMap","specularColorMapEncoding","transmission","transmissionMap","thicknessMap","sheen","sheenColorMap","sheenColorMapEncoding","sheenRoughnessMap"];function M(e){let t;return t=e&&e.isTexture?e.encoding:e&&e.isWebGLRenderTarget?(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),e.texture.encoding):De,t=x&&e&&e.isTexture&&e.format===Ce&&e.type===et&&e.encoding===wr?De:t}return{getParameters:function(e,t,r,i,n){var s=i.fog,i=e.isMeshStandardMaterial?i.environment:null,i=(e.isMeshStandardMaterial?m:p).get(e.envMap||i),a=w[e.type],o=n.isSkinnedMesh?function(e){var t=e.skeleton.bones;if(b)return 1024;{const e=T,r=Math.floor((e-20)/4),i=Math.min(r,t.length);return i<t.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+t.length+" bones. This GPU supports "+i+"."),0):i}}(n):0;let l,h;if(null!==e.precision&&(E=v.getMaxPrecision(e.precision))!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",E,"instead."),a){const f=Qs[a];l=f.vertexShader,h=f.fragmentShader}else l=e.vertexShader,h=e.fragmentShader;var u=f.getRenderTarget(),c=0<e.alphaTest,d=0<e.clearcoat;return{isWebGL2:x,shaderID:a,shaderName:e.type,vertexShader:l,fragmentShader:h,defines:e.defines,isRawShaderMaterial:!0===e.isRawShaderMaterial,glslVersion:e.glslVersion,precision:E,instancing:!0===n.isInstancedMesh,instancingColor:!0===n.isInstancedMesh&&null!==n.instanceColor,supportsVertexTextures:S,outputEncoding:null!==u?M(u.texture):f.outputEncoding,map:!!e.map,mapEncoding:M(e.map),matcap:!!e.matcap,matcapEncoding:M(e.matcap),envMap:!!i,envMapMode:i&&i.mapping,envMapEncoding:M(i),envMapCubeUV:!!i&&(i.mapping===ze||i.mapping===Ve),lightMap:!!e.lightMap,lightMapEncoding:M(e.lightMap),aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:M(e.emissiveMap),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,objectSpaceNormalMap:e.normalMapType===Or,tangentSpaceNormalMap:e.normalMapType===kr,clearcoat:d,clearcoatMap:d&&!!e.clearcoatMap,clearcoatRoughnessMap:d&&!!e.clearcoatRoughnessMap,clearcoatNormalMap:d&&!!e.clearcoatNormalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,specularIntensityMap:!!e.specularIntensityMap,specularColorMap:!!e.specularColorMap,specularColorMapEncoding:M(e.specularColorMap),alphaMap:!!e.alphaMap,alphaTest:c,gradientMap:!!e.gradientMap,sheen:0<e.sheen,sheenColorMap:!!e.sheenColorMap,sheenColorMapEncoding:M(e.sheenColorMap),sheenRoughnessMap:!!e.sheenRoughnessMap,transmission:0<e.transmission,transmissionMap:!!e.transmissionMap,thicknessMap:!!e.thicknessMap,combine:e.combine,vertexTangents:!!e.normalMap&&!!n.geometry&&!!n.geometry.attributes.tangent,vertexColors:e.vertexColors,vertexAlphas:!0===e.vertexColors&&!!n.geometry&&!!n.geometry.attributes.color&&4===n.geometry.attributes.color.itemSize,vertexUvs:!!e.map||!!e.bumpMap||!!e.normalMap||!!e.specularMap||!!e.alphaMap||!!e.emissiveMap||!!e.roughnessMap||!!e.metalnessMap||!!e.clearcoatMap||!!e.clearcoatRoughnessMap||!!e.clearcoatNormalMap||!!e.displacementMap||!!e.transmissionMap||!!e.thicknessMap||!!e.specularIntensityMap||!!e.specularColorMap||!!e.sheenColorMap||e.sheenRoughnessMap,uvsVertexOnly:!(e.map||e.bumpMap||e.normalMap||e.specularMap||e.alphaMap||e.emissiveMap||e.roughnessMap||e.metalnessMap||e.clearcoatNormalMap||0<e.transmission||e.transmissionMap||e.thicknessMap||e.specularIntensityMap||e.specularColorMap||0<!!e.sheen||e.sheenColorMap||e.sheenRoughnessMap||!e.displacementMap),fog:!!s,useFog:e.fog,fogExp2:s&&s.isFogExp2,flatShading:!!e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:_,skinning:!0===n.isSkinnedMesh&&0<o,maxBones:o,useVertexTexture:b,morphTargets:!!n.geometry&&!!n.geometry.morphAttributes.position,morphNormals:!!n.geometry&&!!n.geometry.morphAttributes.normal,morphTargetsCount:n.geometry&&n.geometry.morphAttributes.position?n.geometry.morphAttributes.position.length:0,numDirLights:t.directional.length,numPointLights:t.point.length,numSpotLights:t.spot.length,numRectAreaLights:t.rectArea.length,numHemiLights:t.hemi.length,numDirLightShadows:t.directionalShadowMap.length,numPointLightShadows:t.pointShadowMap.length,numSpotLightShadows:t.spotShadowMap.length,numClippingPlanes:y.numPlanes,numClipIntersection:y.numIntersection,format:e.format,dithering:e.dithering,shadowMapEnabled:f.shadowMap.enabled&&0<r.length,shadowMapType:f.shadowMap.type,toneMapping:e.toneMapped?f.toneMapping:Ne,physicallyCorrectLights:f.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,doubleSided:e.side===Fe,flipSided:e.side===Ae,depthPacking:void 0!==e.depthPacking&&e.depthPacking,index0AttributeName:e.index0AttributeName,extensionDerivatives:e.extensions&&e.extensions.derivatives,extensionFragDepth:e.extensions&&e.extensions.fragDepth,extensionDrawBuffers:e.extensions&&e.extensions.drawBuffers,extensionShaderTextureLOD:e.extensions&&e.extensions.shaderTextureLOD,rendererExtensionFragDepth:x||g.has("EXT_frag_depth"),rendererExtensionDrawBuffers:x||g.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:x||g.has("EXT_shader_texture_lod"),customProgramCacheKey:e.customProgramCacheKey()}},getProgramCacheKey:function(t){var r=[];if(t.shaderID?r.push(t.shaderID):(r.push(Mi(t.fragmentShader)),r.push(Mi(t.vertexShader))),void 0!==t.defines)for(const f in t.defines)r.push(f),r.push(t.defines[f]);if(!1===t.isRawShaderMaterial){for(let e=0;e<i.length;e++)r.push(t[i[e]]);r.push(f.outputEncoding),r.push(f.gammaFactor)}return r.push(t.customProgramCacheKey),r.join()},getUniforms:function(e){var t=w[e.type];let r;if(t){const e=Qs[t];r=Ns.clone(e.uniforms)}else r=e.uniforms;return r},acquireProgram:function(r,i){let n;for(let e=0,t=s.length;e<t;e++){const r=s[e];if(r.cacheKey===i){++(n=r).usedTimes;break}}return void 0===n&&(n=new sl(f,i,r,e),s.push(n)),n},releaseProgram:function(e){var t;0==--e.usedTimes&&(t=s.indexOf(e),s[t]=s[s.length-1],s.pop(),e.destroy())},programs:s}}function ol(){let i=new WeakMap;return{get:function(e){let t=i.get(e);return void 0===t&&(t={},i.set(e,t)),t},remove:function(e){i.delete(e)},update:function(e,t,r){i.get(e)[t]=r},dispose:function(){i=new WeakMap}}}function ll(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.program!==t.program?e.program.id-t.program.id:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function hl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function ul(l){const h=[];let u=0;const a=[],o=[],c=[],d={id:-1};function f(e,t,r,i,n,s){let a=h[u];var o=l.get(r);return void 0===a?(a={id:e.id,object:e,geometry:t,material:r,program:o.program||d,groupOrder:i,renderOrder:e.renderOrder,z:n,group:s},h[u]=a):(a.id=e.id,a.object=e,a.geometry=t,a.material=r,a.program=o.program||d,a.groupOrder=i,a.renderOrder=e.renderOrder,a.z=n,a.group=s),u++,a}return{opaque:a,transmissive:o,transparent:c,init:function(){u=0,a.length=0,o.length=0,c.length=0},push:function(e,t,r,i,n,s){e=f(e,t,r,i,n,s);(0<r.transmission?o:!0===r.transparent?c:a).push(e)},unshift:function(e,t,r,i,n,s){e=f(e,t,r,i,n,s);(0<r.transmission?o:!0===r.transparent?c:a).unshift(e)},finish:function(){for(let e=u,t=h.length;e<t;e++){const u=h[e];if(null===u.id)break;u.id=null,u.object=null,u.geometry=null,u.material=null,u.program=null,u.group=null}},sort:function(e,t){1<a.length&&a.sort(e||ll),1<o.length&&o.sort(t||hl),1<c.length&&c.sort(t||hl)}}}function cl(i){let n=new WeakMap;return{get:function(e,t){let r;return!1===n.has(e)?(r=new ul(i),n.set(e,[r])):t>=n.get(e).length?(r=new ul(i),n.get(e).push(r)):r=n.get(e)[t],r},dispose:function(){n=new WeakMap}}}function dl(){const r={};return{get:function(e){if(void 0!==r[e.id])return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Pe,color:new g};break;case"SpotLight":t={position:new Pe,direction:new Pe,color:new g,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Pe,color:new g,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Pe,skyColor:new g,groundColor:new g};break;case"RectAreaLight":t={color:new g,position:new Pe,halfWidth:new Pe,halfHeight:new Pe}}return r[e.id]=t}}}let fl=0;function pl(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function ml(x,_){const b=new dl,T=function(){const r={};return{get:function(e){if(void 0!==r[e.id])return r[e.id];let t;switch(e.type){case"DirectionalLight":case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new z,shadowCameraNear:1,shadowCameraFar:1e3}}return r[e.id]=t}}}(),S={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let e=0;e<9;e++)S.probe.push(new Pe);const u=new Pe,c=new ke,d=new ke;return{setup:function(r,i){let n=0,s=0,a=0;for(let e=0;e<9;e++)S.probe[e].set(0,0,0);let o=0,l=0,h=0,u=0,c=0,d=0,f=0,p=0;r.sort(pl);var m=!0!==i?Math.PI:1;for(let e=0,t=r.length;e<t;e++){const _=r[e],i=_.color,g=_.intensity,v=_.distance,y=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)n+=i.r*g*m,s+=i.g*g*m,a+=i.b*g*m;else if(_.isLightProbe)for(let e=0;e<9;e++)S.probe[e].addScaledVector(_.sh.coefficients[e],g);else if(_.isDirectionalLight){const x=b.get(_);if(x.color.copy(_.color).multiplyScalar(_.intensity*m),_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,S.directionalShadow[o]=b,S.directionalShadowMap[o]=y,S.directionalShadowMatrix[o]=_.shadow.matrix,d++}S.directional[o]=x,o++}else if(_.isSpotLight){const x=b.get(_);if(x.position.setFromMatrixPosition(_.matrixWorld),x.color.copy(i).multiplyScalar(g*m),x.distance=v,x.coneCos=Math.cos(_.angle),x.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),x.decay=_.decay,_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,S.spotShadow[h]=b,S.spotShadowMap[h]=y,S.spotShadowMatrix[h]=_.shadow.matrix,p++}S.spot[h]=x,h++}else if(_.isRectAreaLight){const x=b.get(_);x.color.copy(i).multiplyScalar(g),x.halfWidth.set(.5*_.width,0,0),x.halfHeight.set(0,.5*_.height,0),S.rectArea[u]=x,u++}else if(_.isPointLight){const x=b.get(_);if(x.color.copy(_.color).multiplyScalar(_.intensity*m),x.distance=_.distance,x.decay=_.decay,_.castShadow){const x=_.shadow,b=T.get(_);b.shadowBias=x.bias,b.shadowNormalBias=x.normalBias,b.shadowRadius=x.radius,b.shadowMapSize=x.mapSize,b.shadowCameraNear=x.camera.near,b.shadowCameraFar=x.camera.far,S.pointShadow[l]=b,S.pointShadowMap[l]=y,S.pointShadowMatrix[l]=_.shadow.matrix,f++}S.point[l]=x,l++}else if(_.isHemisphereLight){const x=b.get(_);x.skyColor.copy(_.color).multiplyScalar(g*m),x.groundColor.copy(_.groundColor).multiplyScalar(g*m),S.hemi[c]=x,c++}}0<u&&(_.isWebGL2||!0===x.has("OES_texture_float_linear")?(S.rectAreaLTC1=A.LTC_FLOAT_1,S.rectAreaLTC2=A.LTC_FLOAT_2):!0===x.has("OES_texture_half_float_linear")?(S.rectAreaLTC1=A.LTC_HALF_1,S.rectAreaLTC2=A.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),S.ambient[0]=n,S.ambient[1]=s,S.ambient[2]=a;const g=S.hash;g.directionalLength===o&&g.pointLength===l&&g.spotLength===h&&g.rectAreaLength===u&&g.hemiLength===c&&g.numDirectionalShadows===d&&g.numPointShadows===f&&g.numSpotShadows===p||(S.directional.length=o,S.spot.length=h,S.rectArea.length=u,S.point.length=l,S.hemi.length=c,S.directionalShadow.length=d,S.directionalShadowMap.length=d,S.pointShadow.length=f,S.pointShadowMap.length=f,S.spotShadow.length=p,S.spotShadowMap.length=p,S.directionalShadowMatrix.length=d,S.pointShadowMatrix.length=f,S.spotShadowMatrix.length=p,g.directionalLength=o,g.pointLength=l,g.spotLength=h,g.rectAreaLength=u,g.hemiLength=c,g.numDirectionalShadows=d,g.numPointShadows=f,g.numSpotShadows=p,S.version=fl++)},setupView:function(r,e){let i=0,n=0,s=0,a=0,o=0;var l=e.matrixWorldInverse;for(let e=0,t=r.length;e<t;e++){var h=r[e];if(h.isDirectionalLight){const r=S.directional[i];r.direction.setFromMatrixPosition(h.matrixWorld),u.setFromMatrixPosition(h.target.matrixWorld),r.direction.sub(u),r.direction.transformDirection(l),i++}else if(h.isSpotLight){const r=S.spot[s];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),r.direction.setFromMatrixPosition(h.matrixWorld),u.setFromMatrixPosition(h.target.matrixWorld),r.direction.sub(u),r.direction.transformDirection(l),s++}else if(h.isRectAreaLight){const r=S.rectArea[a];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),d.identity(),c.copy(h.matrixWorld),c.premultiply(l),d.extractRotation(c),r.halfWidth.set(.5*h.width,0,0),r.halfHeight.set(0,.5*h.height,0),r.halfWidth.applyMatrix4(d),r.halfHeight.applyMatrix4(d),a++}else if(h.isPointLight){const r=S.point[n];r.position.setFromMatrixPosition(h.matrixWorld),r.position.applyMatrix4(l),n++}else if(h.isHemisphereLight){const r=S.hemi[o];r.direction.setFromMatrixPosition(h.matrixWorld),r.direction.transformDirection(l),r.direction.normalize(),o++}}},state:S}}function gl(e,t){const r=new ml(e,t),i=[],n=[];return{init:function(){i.length=0,n.length=0},state:{lightsArray:i,shadowsArray:n,lights:r},setupLights:function(e){r.setup(i,e)},setupLightsView:function(e){r.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){n.push(e)}}}function vl(i,n){let s=new WeakMap;return{get:function(e,t=0){let r;return!1===s.has(e)?(r=new gl(i,n),s.set(e,[r])):t>=s.get(e).length?(r=new gl(i,n),s.get(e).push(r)):r=s.get(e)[t],r},dispose:function(){s=new WeakMap}}}class yl extends r{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=Ir,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}yl.prototype.isMeshDepthMaterial=!0;class xl extends r{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Pe,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function _l(d,f,e){let p=new Ks;const m=new z,g=new z,v=new Ie,l=new yl({depthPacking:Pr}),h=new xl,u={},y=e.maxTextureSize,c={0:Ae,1:Oe,2:Fe},x=new Us({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new z},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),_=x.clone();_.defines.HORIZONTAL_PASS=1;e=new S;e.setAttribute("position",new w(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new E(e,x),t=this;function T(r,e,i,t,n,s,a){let o=null;r=!0===t.isPointLight?r.customDistanceMaterial:r.customDepthMaterial;if(o=void 0!==r?r:!0===t.isPointLight?h:l,d.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&0<i.alphaTest){const d=o.uuid,r=i.uuid;let e=u[d],t=(void 0===e&&(e={},u[d]=e),e[r]);void 0===t&&(t=o.clone(),e[r]=t),o=t}return o.visible=i.visible,o.wireframe=i.wireframe,o.side=a===I?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:c[i.side],o.alphaMap=i.alphaMap,o.alphaTest=i.alphaTest,o.clipShadows=i.clipShadows,o.clippingPlanes=i.clippingPlanes,o.clipIntersection=i.clipIntersection,o.displacementMap=i.displacementMap,o.displacementScale=i.displacementScale,o.displacementBias=i.displacementBias,o.wireframeLinewidth=i.wireframeLinewidth,o.linewidth=i.linewidth,!0===t.isPointLight&&!0===o.isMeshDistanceMaterial&&(o.referencePosition.setFromMatrixPosition(t.matrixWorld),o.nearDistance=n,o.farDistance=s),o}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=C,this.render=function(r,i,n){if(!1!==t.enabled&&(!1!==t.autoUpdate||!1!==t.needsUpdate)&&0!==r.length){const e=d.getRenderTarget(),h=d.getActiveCubeFace(),u=d.getActiveMipmapLevel(),c=d.state;c.setBlending(q),c.buffers.color.setClear(1,1,1,1),c.buffers.depth.setTest(!0),c.setScissorTest(!1);for(let e=0,t=r.length;e<t;e++){const h=r[e],u=h.shadow;if(void 0===u)console.warn("THREE.WebGLShadowMap:",h,"has no shadow.");else if(!1!==u.autoUpdate||!1!==u.needsUpdate){m.copy(u.mapSize);var s=u.getFrameExtents();if(m.multiply(s),g.copy(u.mapSize),(m.x>y||m.y>y)&&(m.x>y&&(g.x=Math.floor(y/s.x),m.x=g.x*s.x,u.mapSize.x=g.x),m.y>y)&&(g.y=Math.floor(y/s.y),m.y=g.y*s.y,u.mapSize.y=g.y),null===u.map&&!u.isPointLightShadow&&this.type===I){const d={minFilter:U,magFilter:U,format:Ce};u.map=new Di(m.x,m.y,d),u.map.texture.name=h.name+".shadowMap",u.mapPass=new Di(m.x,m.y,d),u.camera.updateProjectionMatrix()}if(null===u.map){const d={minFilter:Re,magFilter:Re,format:Ce};u.map=new Di(m.x,m.y,d),u.map.texture.name=h.name+".shadowMap",u.camera.updateProjectionMatrix()}d.setRenderTarget(u.map),d.clear();var a=u.getViewportCount();for(let e=0;e<a;e++){const r=u.getViewport(e);v.set(g.x*r.x,g.y*r.y,g.x*r.z,g.y*r.w),c.viewport(v),u.updateMatrices(h,e),p=u.getFrustum(),function r(i,n,s,a,o){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&o===I)&&(!i.frustumCulled||p.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const p=f.update(i),n=i.material;if(Array.isArray(n)){const f=p.groups;for(let e=0,t=f.length;e<t;e++){var l=f[e],h=n[l.materialIndex];if(h&&h.visible){const f=T(i,0,h,a,s.near,s.far,o);d.renderBufferDirect(s,null,p,f,i,l)}}}else if(n.visible){const f=T(i,0,n,a,s.near,s.far,o);d.renderBufferDirect(s,null,p,f,i,null)}}var u=i.children;for(let e=0,t=u.length;e<t;e++)r(u[e],n,s,a,o)}}(i,n,u.camera,h,this.type)}u.isPointLightShadow||this.type!==I||(s=u,o=n,l=void 0,l=f.update(b),x.defines.VSM_SAMPLES!==s.blurSamples&&(x.defines.VSM_SAMPLES=s.blurSamples,_.defines.VSM_SAMPLES=s.blurSamples,x.needsUpdate=!0,_.needsUpdate=!0),x.uniforms.shadow_pass.value=s.map.texture,x.uniforms.resolution.value=s.mapSize,x.uniforms.radius.value=s.radius,d.setRenderTarget(s.mapPass),d.clear(),d.renderBufferDirect(o,null,l,x,b,null),_.uniforms.shadow_pass.value=s.mapPass.texture,_.uniforms.resolution.value=s.mapSize,_.uniforms.radius.value=s.radius,d.setRenderTarget(s.map),d.clear(),d.renderBufferDirect(o,null,l,_,b,null)),u.needsUpdate=!1}}var o,l;t.needsUpdate=!1,d.setRenderTarget(e,h,u)}}}function bl(u,F,e){const r=e.isWebGL2,i=new function(){let t=!1;const s=new Ie;let r=null;const a=new Ie(0,0,0,0);return{setMask:function(e){r===e||t||(u.colorMask(e,e,e,e),r=e)},setLocked:function(e){t=e},setClear:function(e,t,r,i,n){!0===n&&(e*=i,t*=i,r*=i),s.set(e,t,r,i),!1===a.equals(s)&&(u.clearColor(e,t,r,i),a.copy(s))},reset:function(){t=!1,r=null,a.set(-1,0,0,0)}}},n=new function(){let t=!1,r=null,i=null,n=null;return{setTest:function(e){(e?D:I)(2929)},setMask:function(e){r===e||t||(u.depthMask(e),r=e)},setFunc:function(e){if(i!==e){if(e)switch(e){case ge:u.depthFunc(512);break;case ve:u.depthFunc(519);break;case ye:u.depthFunc(513);break;case xe:u.depthFunc(515);break;case _e:u.depthFunc(514);break;case be:u.depthFunc(518);break;case Te:u.depthFunc(516);break;case Se:u.depthFunc(517);break;default:u.depthFunc(515)}else u.depthFunc(515);i=e}},setLocked:function(e){t=e},setClear:function(e){n!==e&&(u.clearDepth(e),n=e)},reset:function(){t=!1,r=null,i=null,n=null}}},s=new function(){let t=!1,r=null,i=null,n=null,s=null,a=null,o=null,l=null,h=null;return{setTest:function(e){t||(e?D:I)(2960)},setMask:function(e){r===e||t||(u.stencilMask(e),r=e)},setFunc:function(e,t,r){i===e&&n===t&&s===r||(u.stencilFunc(e,t,r),i=e,n=t,s=r)},setOp:function(e,t,r){a===e&&o===t&&l===r||(u.stencilOp(e,t,r),a=e,o=t,l=r)},setLocked:function(e){t=e},setClear:function(e){h!==e&&(u.clearStencil(e),h=e)},reset:function(){t=!1,r=null,i=null,n=null,s=null,a=null,o=null,l=null,h=null}}};let t={},a=null,o={},l=null,h=!1,c=null,d=null,f=null,p=null,m=null,g=null,v=null,y=!1,x=null,_=null,b=null,T=null,S=null;const N=u.getParameter(35661);let E=!1,w=0;e=u.getParameter(7938);-1!==e.indexOf("WebGL")?(w=parseFloat(/^WebGL (\d)/.exec(e)[1]),E=1<=w):-1!==e.indexOf("OpenGL ES")&&(w=parseFloat(/^OpenGL ES (\d)/.exec(e)[1]),E=2<=w);let M=null,A={};const U=u.getParameter(3088),B=u.getParameter(2978),L=(new Ie).fromArray(U),R=(new Ie).fromArray(B);function G(e,t,r){var i=new Uint8Array(4),n=u.createTexture();u.bindTexture(e,n),u.texParameteri(e,10241,9728),u.texParameteri(e,10240,9728);for(let e=0;e<r;e++)u.texImage2D(t+e,0,6408,1,1,0,6408,5121,i);return n}const C={};function D(e){!0!==t[e]&&(u.enable(e),t[e]=!0)}function I(e){!1!==t[e]&&(u.disable(e),t[e]=!1)}C[3553]=G(3553,3553,1),C[34067]=G(34067,34069,6),i.setClear(0,0,0,1),n.setClear(1),s.setClear(0),D(2929),n.setFunc(xe),H(!1),z(Y),D(2884),O(q);const P={[ee]:32774,[te]:32778,[re]:32779};if(r)P[ie]=32775,P[ne]=32776;else{const u=F.get("EXT_blend_minmax");null!==u&&(P[ie]=u.MIN_EXT,P[ne]=u.MAX_EXT)}const k={[se]:0,[ae]:1,[oe]:768,[he]:770,[me]:776,[fe]:774,[ce]:772,[le]:769,[ue]:771,[pe]:775,[de]:773};function O(e,t,r,i,n,s,a,o){if(e!==q){if(!1===h&&(D(3042),h=!0),e===Q)n=n||t,s=s||r,a=a||i,t===d&&n===m||(u.blendEquationSeparate(P[t],P[n]),d=t,m=n),r===f&&i===p&&s===g&&a===v||(u.blendFuncSeparate(k[r],k[i],k[s],k[a]),f=r,p=i,g=s,v=a),c=e,y=null;else if(e!==c||o!==y){if(d===ee&&m===ee||(u.blendEquation(32774),d=ee,m=ee),o)switch(e){case K:u.blendFuncSeparate(1,771,1,771);break;case X:u.blendFunc(1,1);break;case J:u.blendFuncSeparate(0,0,769,771);break;case Z:u.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case K:u.blendFuncSeparate(770,771,1,771);break;case X:u.blendFunc(770,1);break;case J:u.blendFunc(0,769);break;case Z:u.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}f=null,p=null,g=null,v=null,c=e,y=o}}else!0===h&&(I(3042),h=!1)}function H(e){x!==e&&(e?u.frontFace(2304):u.frontFace(2305),x=e)}function z(e){e!==j?(D(2884),e!==_&&(e===Y?u.cullFace(1029):e===$?u.cullFace(1028):u.cullFace(1032))):I(2884),_=e}function V(e,t,r){e?(D(32823),T===t&&S===r||(u.polygonOffset(t,r),T=t,S=r)):I(32823)}function W(e){void 0===e&&(e=33984+N-1),M!==e&&(u.activeTexture(e),M=e)}return{buffers:{color:i,depth:n,stencil:s},enable:D,disable:I,bindFramebuffer:function(e,t){return null===t&&null!==a&&(t=a),o[e]!==t&&(u.bindFramebuffer(e,t),o[e]=t,r&&(36009===e&&(o[36160]=t),36160===e)&&(o[36009]=t),!0)},bindXRFramebuffer:function(e){e!==a&&(u.bindFramebuffer(36160,e),a=e)},useProgram:function(e){return l!==e&&(u.useProgram(e),l=e,!0)},setBlending:O,setMaterial:function(e,t){(e.side===Fe?I:D)(2884);let r=e.side===Ae;H(r=t?!r:r),e.blending===K&&!1===e.transparent?O(q):O(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),n.setFunc(e.depthFunc),n.setTest(e.depthTest),n.setMask(e.depthWrite),i.setMask(e.colorWrite);t=e.stencilWrite;s.setTest(t),t&&(s.setMask(e.stencilWriteMask),s.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),s.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),V(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),(!0===e.alphaToCoverage?D:I)(32926)},setFlipSided:H,setCullFace:z,setLineWidth:function(e){e!==b&&(E&&u.lineWidth(e),b=e)},setPolygonOffset:V,setScissorTest:function(e){(e?D:I)(3089)},activeTexture:W,bindTexture:function(e,t){null===M&&W();let r=A[M];void 0===r&&(r={type:void 0,texture:void 0},A[M]=r),r.type===e&&r.texture===t||(u.bindTexture(e,t||C[e]),r.type=e,r.texture=t)},unbindTexture:function(){var e=A[M];void 0!==e&&void 0!==e.type&&(u.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{u.compressedTexImage2D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{u.texImage2D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{u.texImage3D.apply(u,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(e){!1===L.equals(e)&&(u.scissor(e.x,e.y,e.z,e.w),L.copy(e))},viewport:function(e){!1===R.equals(e)&&(u.viewport(e.x,e.y,e.z,e.w),R.copy(e))},reset:function(){u.disable(3042),u.disable(2884),u.disable(2929),u.disable(32823),u.disable(3089),u.disable(2960),u.disable(32926),u.blendEquation(32774),u.blendFunc(1,0),u.blendFuncSeparate(1,0,1,0),u.colorMask(!0,!0,!0,!0),u.clearColor(0,0,0,0),u.depthMask(!0),u.depthFunc(513),u.clearDepth(1),u.stencilMask(4294967295),u.stencilFunc(519,0,4294967295),u.stencilOp(7680,7680,7680),u.clearStencil(0),u.cullFace(1029),u.frontFace(2305),u.polygonOffset(0,0),u.activeTexture(33984),u.bindFramebuffer(36160,null),!0===r&&(u.bindFramebuffer(36009,null),u.bindFramebuffer(36008,null)),u.useProgram(null),u.lineWidth(1),u.scissor(0,0,u.canvas.width,u.canvas.height),u.viewport(0,0,u.canvas.width,u.canvas.height),t={},M=null,A={},a=null,o={},l=null,h=!1,c=null,d=null,f=null,p=null,m=null,g=null,v=null,y=!1,x=null,_=null,b=null,T=null,S=null,L.set(0,0,u.canvas.width,u.canvas.height),R.set(0,0,u.canvas.width,u.canvas.height),i.reset(),n.reset(),s.reset()}}}function Tl(d,s,f,p,c,m,g){const v=c.isWebGL2,t=c.maxTextures,y=c.maxCubemapSize,u=c.maxTextureSize,N=c.maxSamples,a=new WeakMap;let o,r=!1;try{r="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(d){}function l(e,t){return r?new OffscreenCanvas(e,t):wi("canvas")}function x(e,t,r,i){let n=1;if((n=e.width>i||e.height>i?i/Math.max(e.width,e.height):n)<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?_i:Math.floor,s=i(n*e.width),a=i(n*e.height);void 0===o&&(o=l(s,a));t=r?l(s,a):o;return t.width=s,t.height=a,t.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),t}"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+").")}return e}function _(e){return yi(e.width)&&yi(e.height)}function b(e,t){return e.generateMipmaps&&t&&e.minFilter!==Re&&e.minFilter!==U}function T(e,t,r,i,n=1){d.generateMipmap(e),p.get(t).__maxMipLevel=Math.log2(Math.max(r,i,n))}function S(e,t,r,i){if(!1===v)return t;if(null!==e){if(void 0!==d[e])return d[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let n=t;return 6403===t&&(5126===r&&(n=33326),5131===r&&(n=33325),5121===r)&&(n=33321),6407===t&&(5126===r&&(n=34837),5131===r&&(n=34843),5121===r)&&(n=32849),33325!==(n=6408===t&&(5126===r&&(n=34836),5131===r&&(n=34842),5121===r)?i===wr?35907:32856:n)&&33326!==n&&34842!==n&&34836!==n||s.get("EXT_color_buffer_float"),n}function i(e){return e===Re||e===Ye||e===qe?9728:9729}function n(e){var t,r,e=e.target;e.removeEventListener("dispose",n),t=e,void 0!==(r=p.get(t)).__webglInit&&(d.deleteTexture(r.__webglTexture),p.remove(t)),e.isVideoTexture&&a.delete(e),g.memory.textures--}function E(e){e=e.target;e.removeEventListener("dispose",E);{const r=e.texture,i=p.get(e),t=p.get(r);if(e){if(void 0!==t.__webglTexture&&(d.deleteTexture(t.__webglTexture),g.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)d.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&d.deleteRenderbuffer(i.__webglDepthbuffer[e]);else d.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&d.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&d.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer&&d.deleteRenderbuffer(i.__webglColorRenderbuffer),i.__webglDepthRenderbuffer&&d.deleteRenderbuffer(i.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,t=r.length;e<t;e++){const i=p.get(r[e]);i.__webglTexture&&(d.deleteTexture(i.__webglTexture),g.memory.textures--),p.remove(r[e])}p.remove(r),p.remove(e)}}}let h=0;function w(e,t){var r,i,n=p.get(e);if(e.isVideoTexture&&(r=e,i=g.render.frame,a.get(r)!==i&&(a.set(r,i),r.update())),0<e.version&&n.__version!==e.version){const f=e.image;if(void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==f.complete)return void D(n,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}f.activeTexture(33984+t),f.bindTexture(3553,n.__webglTexture)}function M(e,t){var r=p.get(e);if(0<e.version&&r.__version!==e.version){var i=r,n=e,s=t;if(6===n.image.length){C(i,n),f.activeTexture(33984+s),f.bindTexture(34067,i.__webglTexture),d.pixelStorei(37440,n.flipY),d.pixelStorei(37441,n.premultiplyAlpha),d.pixelStorei(3317,n.unpackAlignment),d.pixelStorei(37443,0);var a=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),o=n.image[0]&&n.image[0].isDataTexture,l=[];for(let e=0;e<6;e++)l[e]=a||o?o?n.image[e].image:n.image[e]:x(n.image[e],!1,!0,y);var s=l[0],e=_(s)||v,h=m.convert(n.format),u=m.convert(n.type),c=S(n.internalFormat,h,u,n.encoding);let r;if(R(34067,n,e),a){for(let t=0;t<6;t++){r=l[t].mipmaps;for(let e=0;e<r.length;e++){const s=r[e];n.format!==Ce&&n.format!==ft?null!==h?f.compressedTexImage2D(34069+t,e,c,s.width,s.height,0,s.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):f.texImage2D(34069+t,e,c,s.width,s.height,0,h,u,s.data)}}i.__maxMipLevel=r.length-1}else{r=n.mipmaps;for(let t=0;t<6;t++)if(o){f.texImage2D(34069+t,0,c,l[t].width,l[t].height,0,h,u,l[t].data);for(let e=0;e<r.length;e++){const n=r[e].image[t].image;f.texImage2D(34069+t,e+1,c,n.width,n.height,0,h,u,n.data)}}else{f.texImage2D(34069+t,0,c,h,u,l[t]);for(let e=0;e<r.length;e++){const n=r[e];f.texImage2D(34069+t,e+1,c,h,u,n.image[t])}}i.__maxMipLevel=r.length}b(n,e)&&T(34067,n,s.width,s.height),i.__version=n.version,n.onUpdate&&n.onUpdate(n)}}else f.activeTexture(33984+t),f.bindTexture(34067,r.__webglTexture)}const A={[We]:10497,[Le]:33071,[je]:33648},L={[Re]:9728,[Ye]:9984,[qe]:9986,[U]:9729,[Xe]:9985,[Ze]:9987};function R(e,t,r){if(r?(d.texParameteri(e,10242,A[t.wrapS]),d.texParameteri(e,10243,A[t.wrapT]),32879!==e&&35866!==e||d.texParameteri(e,32882,A[t.wrapR]),d.texParameteri(e,10240,L[t.magFilter]),d.texParameteri(e,10241,L[t.minFilter])):(d.texParameteri(e,10242,33071),d.texParameteri(e,10243,33071),32879!==e&&35866!==e||d.texParameteri(e,32882,33071),t.wrapS===Le&&t.wrapT===Le||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),d.texParameteri(e,10240,i(t.magFilter)),d.texParameteri(e,10241,i(t.minFilter)),t.minFilter!==Re&&t.minFilter!==U&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===s.has("EXT_texture_filter_anisotropic")){const r=s.get("EXT_texture_filter_anisotropic");t.type===at&&!1===s.has("OES_texture_float_linear")||!1===v&&t.type===ot&&!1===s.has("OES_texture_half_float_linear")||(1<t.anisotropy||p.get(t).__currentAnisotropy)&&(d.texParameterf(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,c.getMaxAnisotropy())),p.get(t).__currentAnisotropy=t.anisotropy)}}function C(e,t){void 0===e.__webglInit&&(e.__webglInit=!0,t.addEventListener("dispose",n),e.__webglTexture=d.createTexture(),g.memory.textures++)}function D(e,r,t){let i=3553;r.isDataTexture2DArray&&(i=35866),r.isDataTexture3D&&(i=32879),C(e,r),f.activeTexture(33984+t),f.bindTexture(i,e.__webglTexture),d.pixelStorei(37440,r.flipY),d.pixelStorei(37441,r.premultiplyAlpha),d.pixelStorei(3317,r.unpackAlignment),d.pixelStorei(37443,0);t=r;var t=!v&&(t.wrapS!==Le||t.wrapT!==Le||t.minFilter!==Re&&t.minFilter!==U)&&!1===_(r.image),t=x(r.image,t,!1,u),n=_(t)||v,s=m.convert(r.format);let a,o=m.convert(r.type),l=S(r.internalFormat,s,o,r.encoding);R(i,r,n);var h=r.mipmaps;if(r.isDepthTexture)l=6402,v?l=r.type===at?36012:r.type===st?33190:r.type===ct?35056:33189:r.type===at&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===vt&&6402===l&&r.type!==it&&r.type!==st&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=it,o=m.convert(r.type)),r.format===yt&&6402===l&&(l=34041,r.type!==ct)&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ct,o=m.convert(r.type)),f.texImage2D(3553,0,l,t.width,t.height,0,s,o,null);else if(r.isDataTexture)if(0<h.length&&n){for(let e=0,t=h.length;e<t;e++)a=h[e],f.texImage2D(3553,e,l,a.width,a.height,0,s,o,a.data);r.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else f.texImage2D(3553,0,l,t.width,t.height,0,s,o,t.data),e.__maxMipLevel=0;else if(r.isCompressedTexture){for(let e=0,t=h.length;e<t;e++)a=h[e],r.format!==Ce&&r.format!==ft?null!==s?f.compressedTexImage2D(3553,e,l,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):f.texImage2D(3553,e,l,a.width,a.height,0,s,o,a.data);e.__maxMipLevel=h.length-1}else if(r.isDataTexture2DArray)f.texImage3D(35866,0,l,t.width,t.height,t.depth,0,s,o,t.data),e.__maxMipLevel=0;else if(r.isDataTexture3D)f.texImage3D(32879,0,l,t.width,t.height,t.depth,0,s,o,t.data),e.__maxMipLevel=0;else if(0<h.length&&n){for(let e=0,t=h.length;e<t;e++)a=h[e],f.texImage2D(3553,e,l,s,o,a);r.generateMipmaps=!1,e.__maxMipLevel=h.length-1}else f.texImage2D(3553,0,l,s,o,t),e.__maxMipLevel=0;b(r,n)&&T(i,r,t.width,t.height),e.__version=r.version,r.onUpdate&&r.onUpdate(r)}function I(e,t,r,i,n){var s=m.convert(r.format),a=m.convert(r.type),o=S(r.internalFormat,s,a,r.encoding);32879===n||35866===n?f.texImage3D(n,0,o,t.width,t.height,t.depth,0,s,a,null):f.texImage2D(n,0,o,t.width,t.height,0,s,a,null),f.bindFramebuffer(36160,e),d.framebufferTexture2D(36160,i,n,p.get(r).__webglTexture,0),f.bindFramebuffer(36160,null)}function P(t,r,i){if(d.bindRenderbuffer(36161,t),r.depthBuffer&&!r.stencilBuffer){let e=33189;if(i){const t=r.depthTexture,i=(t&&t.isDepthTexture&&(t.type===at?e=36012:t.type===st&&(e=33190)),k(r));d.renderbufferStorageMultisample(36161,i,e,r.width,r.height)}else d.renderbufferStorage(36161,e,r.width,r.height);d.framebufferRenderbuffer(36160,36096,36161,t)}else if(r.depthBuffer&&r.stencilBuffer){if(i){const t=k(r);d.renderbufferStorageMultisample(36161,t,35056,r.width,r.height)}else d.renderbufferStorage(36161,34041,r.width,r.height);d.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===r.isWebGLMultipleRenderTargets?r.texture[0]:r.texture,e=m.convert(t.format),n=m.convert(t.type),s=S(t.internalFormat,e,n,t.encoding);if(i){const t=k(r);d.renderbufferStorageMultisample(36161,t,s,r.width,r.height)}else d.renderbufferStorage(36161,s,r.width,r.height)}d.bindRenderbuffer(36161,null)}function k(e){return v&&e.isWebGLMultisampleRenderTarget?Math.min(N,e.samples):0}let O=!1,F=!1;this.allocateTextureUnit=function(){var e=h;return e>=t&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+t),h+=1,e},this.resetTextureUnits=function(){h=0},this.setTexture2D=w,this.setTexture2DArray=function(e,t){var r=p.get(e);0<e.version&&r.__version!==e.version?D(r,e,t):(f.activeTexture(33984+t),f.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){var r=p.get(e);0<e.version&&r.__version!==e.version?D(r,e,t):(f.activeTexture(33984+t),f.bindTexture(32879,r.__webglTexture))},this.setTextureCube=M,this.setupRenderTarget=function(r){var t=r.texture,i=p.get(r),n=p.get(t),e=(r.addEventListener("dispose",E),!0!==r.isWebGLMultipleRenderTargets&&(n.__webglTexture=d.createTexture(),n.__version=t.version,g.memory.textures++),!0===r.isWebGLCubeRenderTarget),s=!0===r.isWebGLMultipleRenderTargets,a=!0===r.isWebGLMultisampleRenderTarget,o=t.isDataTexture3D||t.isDataTexture2DArray,l=_(r)||v;if(!v||t.format!==ft||t.type!==at&&t.type!==ot||(t.format=Ce,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),e){i.__webglFramebuffer=[];for(let e=0;e<6;e++)i.__webglFramebuffer[e]=d.createFramebuffer()}else if(i.__webglFramebuffer=d.createFramebuffer(),s)if(c.drawBuffers){const f=r.texture;for(let e=0,t=f.length;e<t;e++){const c=p.get(f[e]);void 0===c.__webglTexture&&(c.__webglTexture=d.createTexture(),g.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(a)if(v){i.__webglMultisampledFramebuffer=d.createFramebuffer(),i.__webglColorRenderbuffer=d.createRenderbuffer(),d.bindRenderbuffer(36161,i.__webglColorRenderbuffer);const p=m.convert(t.format),c=m.convert(t.type),g=S(t.internalFormat,p,c,t.encoding),v=k(r);d.renderbufferStorageMultisample(36161,v,g,r.width,r.height),f.bindFramebuffer(36160,i.__webglMultisampledFramebuffer),d.framebufferRenderbuffer(36160,36064,36161,i.__webglColorRenderbuffer),d.bindRenderbuffer(36161,null),r.depthBuffer&&(i.__webglDepthRenderbuffer=d.createRenderbuffer(),P(i.__webglDepthRenderbuffer,r,!0)),f.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(e){f.bindTexture(34067,n.__webglTexture),R(34067,t,l);for(let e=0;e<6;e++)I(i.__webglFramebuffer[e],r,t,36064,34069+e);b(t,l)&&T(34067,t,r.width,r.height)}else if(s){const d=r.texture;for(let e=0,t=d.length;e<t;e++){const m=d[e],g=p.get(m);f.bindTexture(3553,g.__webglTexture),R(3553,m,l),I(i.__webglFramebuffer,r,m,36064+e,3553),b(m,l)&&T(3553,m,r.width,r.height)}}else{let e=3553;o&&(v?e=t.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),f.bindTexture(e,n.__webglTexture),R(e,t,l),I(i.__webglFramebuffer,r,t,36064,e),b(t,l)&&T(e,t,r.width,r.height,r.depth)}if(f.unbindTexture(),r.depthBuffer){var h=r,u=p.get(h),a=!0===h.isWebGLCubeRenderTarget;if(h.depthTexture){if(a)throw new Error("target.depthTexture not supported in Cube render targets");e=u.__webglFramebuffer,s=h;if(s&&s.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(f.bindFramebuffer(36160,e),!s.depthTexture||!s.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");if(p.get(s.depthTexture).__webglTexture&&s.depthTexture.image.width===s.width&&s.depthTexture.image.height===s.height||(s.depthTexture.image.width=s.width,s.depthTexture.image.height=s.height,s.depthTexture.needsUpdate=!0),w(s.depthTexture,0),e=p.get(s.depthTexture).__webglTexture,s.depthTexture.format===vt)d.framebufferTexture2D(36160,36096,3553,e,0);else{if(s.depthTexture.format!==yt)throw new Error("Unknown depthTexture format");d.framebufferTexture2D(36160,33306,3553,e,0)}}else if(a){u.__webglDepthbuffer=[];for(let e=0;e<6;e++)f.bindFramebuffer(36160,u.__webglFramebuffer[e]),u.__webglDepthbuffer[e]=d.createRenderbuffer(),P(u.__webglDepthbuffer[e],h,!1)}else f.bindFramebuffer(36160,u.__webglFramebuffer),u.__webglDepthbuffer=d.createRenderbuffer(),P(u.__webglDepthbuffer,h,!1);f.bindFramebuffer(36160,null)}},this.updateRenderTargetMipmap=function(r){const i=_(r)||v,n=!0===r.isWebGLMultipleRenderTargets?r.texture:[r.texture];for(let e=0,t=n.length;e<t;e++){var s=n[e];if(b(s,i)){const i=r.isWebGLCubeRenderTarget?34067:3553,n=p.get(s).__webglTexture;f.bindTexture(i,n),T(i,s,r.width,r.height),f.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(v){var r=t.width,i=t.height;let e=16384;t.depthBuffer&&(e|=256),t.stencilBuffer&&(e|=1024);const v=p.get(t);f.bindFramebuffer(36008,v.__webglMultisampledFramebuffer),f.bindFramebuffer(36009,v.__webglFramebuffer),d.blitFramebuffer(0,0,r,i,0,0,r,i,e,9728),f.bindFramebuffer(36008,null),f.bindFramebuffer(36009,v.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===O&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),O=!0),e=e.texture),w(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===F&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),e=e.texture),M(e,t)}}function Sl(e,r,t){const i=t.isWebGL2;return{convert:function(e){let t;if(e===et)return 5121;if(e===lt)return 32819;if(e===ht)return 32820;if(e===ut)return 33635;if(e===tt)return 5120;if(e===rt)return 5122;if(e===it)return 5123;if(e===nt)return 5124;if(e===st)return 5125;if(e===at)return 5126;if(e===ot)return i?5131:null!==(t=r.get("OES_texture_half_float"))?t.HALF_FLOAT_OES:null;if(e===dt)return 6406;if(e===ft)return 6407;if(e===Ce)return 6408;if(e===pt)return 6409;if(e===mt)return 6410;if(e===vt)return 6402;if(e===yt)return 34041;if(e===xt)return 6403;if(e===_t)return 36244;if(e===bt)return 33319;if(e===Tt)return 33320;if(e===St)return 36248;if(e===Et)return 36249;if(e===wt||e===Mt||e===At||e===Lt){if(null===(t=r.get("WEBGL_compressed_texture_s3tc")))return null;if(e===wt)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Mt)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===At)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Lt)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===Rt||e===Ct||e===Dt||e===It){if(null===(t=r.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===Rt)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Ct)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===Dt)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===It)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===Pt)return null!==(t=r.get("WEBGL_compressed_texture_etc1"))?t.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===kt||e===Ot)&&null!==(t=r.get("WEBGL_compressed_texture_etc"))){if(e===kt)return t.COMPRESSED_RGB8_ETC2;if(e===Ot)return t.COMPRESSED_RGBA8_ETC2_EAC}return e===Ft||e===Nt||e===Ut||e===Bt||e===Gt||e===Ht||e===zt||e===Vt||e===Wt||e===jt||e===Yt||e===$t||e===qt||e===Kt||e===Jt||e===Zt||e===Qt||e===er||e===tr||e===rr||e===ir||e===nr||e===sr||e===ar||e===or||e===lr||e===hr||e===ur?null!==(t=r.get("WEBGL_compressed_texture_astc"))?e:null:e===Xt?null!==(t=r.get("EXT_texture_compression_bptc"))?e:null:e===ct?i?34042:null!==(t=r.get("WEBGL_depth_texture"))?t.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}xl.prototype.isMeshDistanceMaterial=!0;class El extends N{constructor(e=[]){super(),this.cameras=e}}El.prototype.isArrayCamera=!0;class wl extends c{constructor(){super(),this.type="Group"}}wl.prototype.isGroup=!0;const Ml={type:"move"};class Al{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new wl,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new wl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Pe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Pe),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new wl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Pe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Pe),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let i=null,n=null,s=null;const a=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==a&&null!==(i=t.getPose(e.targetRaySpace,r))&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Ml)),l&&e.hand){s=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,r);if(void 0===l.joints[i.jointName]){const e=new wl;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[i.jointName]=e,l.add(e)}const n=l.joints[i.jointName];null!==e&&(n.matrix.fromArray(e.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.jointRadius=e.radius),n.visible=null!==e}const i=l.joints["index-finger-tip"],n=l.joints["thumb-tip"],a=i.position.distanceTo(n.position),o=.02;l.inputState.pinching&&.025<a?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(n=t.getPose(e.gripSpace,r))&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1);return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==n),null!==l&&(l.visible=null!==s),this}}class Ll extends hi{constructor(e,a){super();const r=this,o=e.state;let p=null,i=1,l=null,n="local-floor",h,u=null,c=null,d=null,f=null,m=!1,g=null,s=null,v=null,y=null,x=null,_=null;const b=[],T=new Map,S=new N,E=(S.layers.enable(1),S.viewport=new Ie,new N),w=(E.layers.enable(2),E.viewport=new Ie,[S,E]),M=new El;M.layers.enable(1),M.layers.enable(2);let A=null,L=null;function R(e){var t=T.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function C(){T.forEach(function(e,t){e.disconnect(t)}),T.clear(),A=null,L=null,o.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),c&&a.deleteFramebuffer(c),g&&a.deleteFramebuffer(g),s&&a.deleteRenderbuffer(s),v&&a.deleteRenderbuffer(v),c=null,g=null,s=null,v=null,f=null,d=null,u=null,p=null,F.stop(),r.isPresenting=!1,r.dispatchEvent({type:"sessionend"})}function D(t){var r=p.inputSources;for(let e=0;e<b.length;e++)T.set(r[e],b[e]);for(let e=0;e<t.removed.length;e++){var i=t.removed[e],n=T.get(i);n&&(n.dispatchEvent({type:"disconnected",data:i}),T.delete(i))}for(let e=0;e<t.added.length;e++){var s=t.added[e],a=T.get(s);a&&a.dispatchEvent({type:"connected",data:s})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return void 0===t&&(t=new Al,b[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){n=e,!0===r.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l},this.getBaseLayer=function(){return null!==d?d:f},this.getBinding=function(){return u},this.getFrame=function(){return y},this.getSession=function(){return p},this.setSession=async function(t){if(null!==(p=t)){p.addEventListener("select",R),p.addEventListener("selectstart",R),p.addEventListener("selectend",R),p.addEventListener("squeeze",R),p.addEventListener("squeezestart",R),p.addEventListener("squeezeend",R),p.addEventListener("end",C),p.addEventListener("inputsourceschange",D);const t=a.getContextAttributes();if(!0!==t.xrCompatible&&await a.makeXRCompatible(),void 0===p.renderState.layers){const r={antialias:t.antialias,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(p,a,r),p.updateRenderState({baseLayer:f})}else if(a instanceof WebGLRenderingContext){const r={antialias:!0,alpha:t.alpha,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(p,a,r),p.updateRenderState({layers:[f]})}else{m=t.antialias;let e=null;t.depth&&(_=256,t.stencil&&(_|=1024),x=t.stencil?33306:36096,e=t.stencil?35056:33190);const l={colorFormat:t.alpha?32856:32849,depthFormat:e,scaleFactor:i};u=new XRWebGLBinding(p,a),d=u.createProjectionLayer(l),c=a.createFramebuffer(),p.updateRenderState({layers:[d]}),m&&(g=a.createFramebuffer(),s=a.createRenderbuffer(),a.bindRenderbuffer(36161,s),a.renderbufferStorageMultisample(36161,4,32856,d.textureWidth,d.textureHeight),o.bindFramebuffer(36160,g),a.framebufferRenderbuffer(36160,36064,36161,s),a.bindRenderbuffer(36161,null),null!==e&&(v=a.createRenderbuffer(),a.bindRenderbuffer(36161,v),a.renderbufferStorageMultisample(36161,4,e,d.textureWidth,d.textureHeight),a.framebufferRenderbuffer(36160,x,36161,v),a.bindRenderbuffer(36161,null)),o.bindFramebuffer(36160,null))}l=await p.requestReferenceSpace(n),F.setContext(p),F.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}};const I=new Pe,P=new Pe;function k(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null!==p){M.near=E.near=S.near=e.near,M.far=E.far=S.far=e.far,A===M.near&&L===M.far||(p.updateRenderState({depthNear:M.near,depthFar:M.far}),A=M.near,L=M.far);var t=e.parent,r=M.cameras;k(M,t);for(let e=0;e<r.length;e++)k(r[e],t);M.matrixWorld.decompose(M.position,M.quaternion,M.scale),e.position.copy(M.position),e.quaternion.copy(M.quaternion),e.scale.copy(M.scale),e.matrix.copy(M.matrix),e.matrixWorld.copy(M.matrixWorld);var i,n,s,a,o,l,h,u,c,d,f=e.children;for(let e=0,t=f.length;e<t;e++)f[e].updateMatrixWorld(!0);2===r.length?(e=M,i=S,n=E,I.setFromMatrixPosition(i.matrixWorld),P.setFromMatrixPosition(n.matrixWorld),s=I.distanceTo(P),a=i.projectionMatrix.elements,n=n.projectionMatrix.elements,o=a[14]/(a[10]-1),l=a[14]/(a[10]+1),h=(a[9]+1)/a[5],u=(a[9]-1)/a[5],a=(a[8]-1)/a[0],n=(n[8]+1)/n[0],c=o*a,d=o*n,a=(n=s/(n-a))*-a,i.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(a),e.translateZ(n),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i=o+n,o=l+n,e.projectionMatrix.makePerspective(c-a,s-a+d,h*l/o*i,u*l/o*i,i,o)):M.projectionMatrix.copy(S.projectionMatrix)}},this.getCamera=function(){return M},this.getFoveation=function(){return null!==d?d.fixedFoveation:null!==f?f.fixedFoveation:void 0},this.setFoveation=function(e){null!==d&&(d.fixedFoveation=e),null!==f&&void 0!==f.fixedFoveation&&(f.fixedFoveation=e)};let O=null;const F=new Xs;F.setAnimationLoop(function(i,t){if(h=t.getViewerPose(l),y=t,null!==h){const i=h.views;null!==f&&o.bindXRFramebuffer(f.framebuffer);let r=!1;i.length!==M.cameras.length&&(M.cameras.length=0,r=!0);for(let t=0;t<i.length;t++){const s=i[t];let e=null;if(null!==f)e=f.getViewport(s);else{const i=u.getViewSubImage(d,s);o.bindXRFramebuffer(c),void 0!==i.depthStencilTexture&&a.framebufferTexture2D(36160,x,3553,i.depthStencilTexture,0),a.framebufferTexture2D(36160,36064,3553,i.colorTexture,0),e=i.viewport}var n=w[t];n.matrix.fromArray(s.transform.matrix),n.projectionMatrix.fromArray(s.projectionMatrix),n.viewport.set(e.x,e.y,e.width,e.height),0===t&&M.matrix.copy(n.matrix),!0===r&&M.cameras.push(n)}m&&(o.bindXRFramebuffer(g),null!==_)&&a.clear(_)}const s=p.inputSources;for(let e=0;e<b.length;e++){const a=b[e],o=s[e];a.update(o,t,l)}if(O&&O(i,t),m){const i=d.textureWidth,t=d.textureHeight;o.bindFramebuffer(36008,g),o.bindFramebuffer(36009,c),a.invalidateFramebuffer(36008,[x]),a.invalidateFramebuffer(36009,[x]),a.blitFramebuffer(0,0,i,t,0,0,i,t,16384,9728),a.invalidateFramebuffer(36008,[36064]),o.bindFramebuffer(36008,null),o.bindFramebuffer(36009,null),o.bindFramebuffer(36160,g)}y=null}),this.setAnimationLoop=function(e){O=e},this.dispose=function(){}}}function Rl(s){function d(e,t){e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),0<t.alphaTest&&(e.alphaTest.value=t.alphaTest);var r=s.get(t).envMap;if(r){e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=t.reflectivity,e.ior.value=t.ior,e.refractionRatio.value=t.refractionRatio;const i=s.get(r).__maxMipLevel;void 0!==i&&(e.maxMipLevel.value=i)}let i,n;t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap?i=t.emissiveMap:t.clearcoatMap?i=t.clearcoatMap:t.clearcoatNormalMap?i=t.clearcoatNormalMap:t.clearcoatRoughnessMap?i=t.clearcoatRoughnessMap:t.specularIntensityMap?i=t.specularIntensityMap:t.specularColorMap?i=t.specularColorMap:t.transmissionMap?i=t.transmissionMap:t.thicknessMap?i=t.thicknessMap:t.sheenColorMap?i=t.sheenColorMap:t.sheenRoughnessMap&&(i=t.sheenRoughnessMap),void 0!==i&&(!0===(i=i.isWebGLRenderTarget?i.texture:i).matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix)),t.aoMap?n=t.aoMap:t.lightMap&&(n=t.lightMap),void 0!==n&&(!0===(n=n.isWebGLRenderTarget?n.texture:n).matrixAutoUpdate&&n.updateMatrix(),e.uv2Transform.value.copy(n.matrix))}function f(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Ae)&&(e.bumpScale.value*=-1),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Ae)&&e.normalScale.value.negate(),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),s.get(t).envMap&&(e.envMapIntensity.value=t.envMapIntensity)}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(t,r,i,n,s){if(r.isMeshBasicMaterial)d(t,r);else if(r.isMeshLambertMaterial)d(t,r),c=t,r.emissiveMap&&(c.emissiveMap.value=r.emissiveMap);else if(r.isMeshToonMaterial)d(t,r),c=t,(u=r).gradientMap&&(c.gradientMap.value=u.gradientMap),u.emissiveMap&&(c.emissiveMap.value=u.emissiveMap),u.bumpMap&&(c.bumpMap.value=u.bumpMap,c.bumpScale.value=u.bumpScale,u.side===Ae)&&(c.bumpScale.value*=-1),u.normalMap&&(c.normalMap.value=u.normalMap,c.normalScale.value.copy(u.normalScale),u.side===Ae)&&c.normalScale.value.negate(),u.displacementMap&&(c.displacementMap.value=u.displacementMap,c.displacementScale.value=u.displacementScale,c.displacementBias.value=u.displacementBias);else if(r.isMeshPhongMaterial)d(t,r),u=r,(h=t).specular.value.copy(u.specular),h.shininess.value=Math.max(u.shininess,1e-4),u.emissiveMap&&(h.emissiveMap.value=u.emissiveMap),u.bumpMap&&(h.bumpMap.value=u.bumpMap,h.bumpScale.value=u.bumpScale,u.side===Ae)&&(h.bumpScale.value*=-1),u.normalMap&&(h.normalMap.value=u.normalMap,h.normalScale.value.copy(u.normalScale),u.side===Ae)&&h.normalScale.value.negate(),u.displacementMap&&(h.displacementMap.value=u.displacementMap,h.displacementScale.value=u.displacementScale,h.displacementBias.value=u.displacementBias);else if(r.isMeshStandardMaterial)d(t,r),r.isMeshPhysicalMaterial?(h=s,f(s=t,l=r),s.ior.value=l.ior,0<l.sheen&&(s.sheenColor.value.copy(l.sheenColor).multiplyScalar(l.sheen),s.sheenRoughness.value=l.sheenRoughness,l.sheenColorMap&&(s.sheenColorMap.value=l.sheenColorMap),l.sheenRoughnessMap)&&(s.sheenRoughnessMap.value=l.sheenRoughnessMap),0<l.clearcoat&&(s.clearcoat.value=l.clearcoat,s.clearcoatRoughness.value=l.clearcoatRoughness,l.clearcoatMap&&(s.clearcoatMap.value=l.clearcoatMap),l.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap.value=l.clearcoatRoughnessMap),l.clearcoatNormalMap)&&(s.clearcoatNormalScale.value.copy(l.clearcoatNormalScale),s.clearcoatNormalMap.value=l.clearcoatNormalMap,l.side===Ae)&&s.clearcoatNormalScale.value.negate(),0<l.transmission&&(s.transmission.value=l.transmission,s.transmissionSamplerMap.value=h.texture,s.transmissionSamplerSize.value.set(h.width,h.height),l.transmissionMap&&(s.transmissionMap.value=l.transmissionMap),s.thickness.value=l.thickness,l.thicknessMap&&(s.thicknessMap.value=l.thicknessMap),s.attenuationDistance.value=l.attenuationDistance,s.attenuationColor.value.copy(l.attenuationColor)),s.specularIntensity.value=l.specularIntensity,s.specularColor.value.copy(l.specularColor),l.specularIntensityMap&&(s.specularIntensityMap.value=l.specularIntensityMap),l.specularColorMap&&(s.specularColorMap.value=l.specularColorMap)):f(t,r);else if(r.isMeshMatcapMaterial)d(t,r),s=t,(l=r).matcap&&(s.matcap.value=l.matcap),l.bumpMap&&(s.bumpMap.value=l.bumpMap,s.bumpScale.value=l.bumpScale,l.side===Ae)&&(s.bumpScale.value*=-1),l.normalMap&&(s.normalMap.value=l.normalMap,s.normalScale.value.copy(l.normalScale),l.side===Ae)&&s.normalScale.value.negate(),l.displacementMap&&(s.displacementMap.value=l.displacementMap,s.displacementScale.value=l.displacementScale,s.displacementBias.value=l.displacementBias);else if(r.isMeshDepthMaterial)d(t,r),s=t,(o=r).displacementMap&&(s.displacementMap.value=o.displacementMap,s.displacementScale.value=o.displacementScale,s.displacementBias.value=o.displacementBias);else if(r.isMeshDistanceMaterial)d(t,r),s=t,(o=r).displacementMap&&(s.displacementMap.value=o.displacementMap,s.displacementScale.value=o.displacementScale,s.displacementBias.value=o.displacementBias),s.referencePosition.value.copy(o.referencePosition),s.nearDistance.value=o.nearDistance,s.farDistance.value=o.farDistance;else if(r.isMeshNormalMaterial)d(t,r),s=t,(e=r).bumpMap&&(s.bumpMap.value=e.bumpMap,s.bumpScale.value=e.bumpScale,e.side===Ae)&&(s.bumpScale.value*=-1),e.normalMap&&(s.normalMap.value=e.normalMap,s.normalScale.value.copy(e.normalScale),e.side===Ae)&&s.normalScale.value.negate(),e.displacementMap&&(s.displacementMap.value=e.displacementMap,s.displacementScale.value=e.displacementScale,s.displacementBias.value=e.displacementBias);else if(r.isLineBasicMaterial)s=r,(e=t).diffuse.value.copy(s.color),e.opacity.value=s.opacity,r.isLineDashedMaterial&&(s=r,(a=t).dashSize.value=s.dashSize,a.totalSize.value=s.dashSize+s.gapSize,a.scale.value=s.scale);else if(r.isPointsMaterial){s=r,(a=t).diffuse.value.copy(s.color),a.opacity.value=s.opacity,a.size.value=s.size*i,a.scale.value=.5*n,s.map&&(a.map.value=s.map),s.alphaMap&&(a.alphaMap.value=s.alphaMap),0<s.alphaTest&&(a.alphaTest.value=s.alphaTest);let e;s.map?e=s.map:s.alphaMap&&(e=s.alphaMap),void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),a.uvTransform.value.copy(e.matrix))}else if(r.isSpriteMaterial){n=r,(i=t).diffuse.value.copy(n.color),i.opacity.value=n.opacity,i.rotation.value=n.rotation,n.map&&(i.map.value=n.map),n.alphaMap&&(i.alphaMap.value=n.alphaMap),0<n.alphaTest&&(i.alphaTest.value=n.alphaTest);let e;n.map?e=n.map:n.alphaMap&&(e=n.alphaMap),void 0!==e&&(!0===e.matrixAutoUpdate&&e.updateMatrix(),i.uvTransform.value.copy(e.matrix))}else r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1);var a,e,o,l,h,u,c}}}function s(e={}){const n=void 0!==e.canvas?e.canvas:((j=wi("canvas")).style.display="block",j),F=void 0!==e.context?e.context:null,N=void 0!==e.alpha&&e.alpha,U=void 0===e.depth||e.depth,B=void 0===e.stencil||e.stencil,G=void 0!==e.antialias&&e.antialias,H=void 0===e.premultipliedAlpha||e.premultipliedAlpha,z=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,V=void 0!==e.powerPreference?e.powerPreference:"default",W=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;var j;let u=null,_=null;const t=[],s=[],b=(this.domElement=n,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.outputEncoding=De,this.physicallyCorrectLights=!1,this.toneMapping=Ne,this.toneMappingExposure=1,this);let Y=!1,$=0,q=0,T=null,S=-1,E=null;const c=new Ie,K=new Ie;let X=null,i=n.width,w=n.height,M=1,J=null,Z=null;const o=new Ie(0,0,i,w),l=new Ie(0,0,i,w);let Q=!1;const h=[],ee=new Ks;let te=!1,re=!1,A=null;const ie=new ke,L=new Pe,ne={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function se(){return null===T?M:1}let d,R,C,f,D,I,P,ae,oe,le,p,m,he,ue,ce,k,a,g,de,fe,pe,v,y,O=F;function me(t,r){for(let e=0;e<t.length;e++){var i=t[e],i=n.getContext(i,r);if(null!==i)return i}return null}try{const e={alpha:N,depth:U,stencil:B,antialias:G,premultipliedAlpha:H,preserveDrawingBuffer:z,powerPreference:V,failIfMajorPerformanceCaveat:W};if(n.addEventListener("webglcontextlost",ve,!1),n.addEventListener("webglcontextrestored",ye,!1),null===O){const n=["webgl2","webgl","experimental-webgl"];if(!0===b.isWebGL1Renderer&&n.shift(),null===(O=me(n,e)))throw me(n)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===O.getShaderPrecisionFormat&&(O.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function ge(){d=new Ra(O),R=new ia(O,d,e),d.init(R),v=new Sl(O,d,R),C=new bl(O,d,R),h[0]=1029,f=new Ia(O),D=new ol,I=new Tl(O,d,C,D,R,v,f),P=new sa(b),ae=new La(b),oe=new Js(O,R),y=new ta(O,d,oe,R),le=new Ca(O,oe,f,y),p=new Ua(O,le,oe,f),de=new Na(O,R,I),k=new na(D),m=new al(b,P,ae,d,R,y,k),he=new Rl(D),ue=new cl(D),ce=new vl(d,R),g=new ea(b,P,C,p,H),a=new _l(b,p,R),fe=new ra(O,d,f,R),pe=new Da(O,d,f,R),f.programs=m.programs,b.capabilities=R,b.extensions=d,b.properties=D,b.renderLists=ue,b.shadowMap=a,b.state=C,b.info=f}ge();const x=new Ll(b,O);function ve(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),Y=!0}function ye(){console.log("THREE.WebGLRenderer: Context Restored."),Y=!1;var e=f.autoReset,t=a.enabled,r=a.autoUpdate,i=a.needsUpdate,n=a.type;ge(),f.autoReset=e,a.enabled=t,a.autoUpdate=r,a.needsUpdate=i,a.type=n}function xe(e){var t,e=e.target;e.removeEventListener("dispose",xe),t=e=e,void 0!==(t=D.get(t).programs)&&t.forEach(function(e){m.releaseProgram(e)}),D.remove(e)}this.xr=x,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){var e=d.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=d.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return M},this.setPixelRatio=function(e){void 0!==e&&(M=e,this.setSize(i,w,!1))},this.getSize=function(e){return e.set(i,w)},this.setSize=function(e,t,r){x.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(i=e,w=t,n.width=Math.floor(e*M),n.height=Math.floor(t*M),!1!==r&&(n.style.width=e+"px",n.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(i*M,w*M).floor()},this.setDrawingBufferSize=function(e,t,r){i=e,w=t,M=r,n.width=Math.floor(e*r),n.height=Math.floor(t*r),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(c)},this.getViewport=function(e){return e.copy(o)},this.setViewport=function(e,t,r,i){e.isVector4?o.set(e.x,e.y,e.z,e.w):o.set(e,t,r,i),C.viewport(c.copy(o).multiplyScalar(M).floor())},this.getScissor=function(e){return e.copy(l)},this.setScissor=function(e,t,r,i){e.isVector4?l.set(e.x,e.y,e.z,e.w):l.set(e,t,r,i),C.scissor(K.copy(l).multiplyScalar(M).floor())},this.getScissorTest=function(){return Q},this.setScissorTest=function(e){C.setScissorTest(Q=e)},this.setOpaqueSort=function(e){J=e},this.setTransparentSort=function(e){Z=e},this.getClearColor=function(e){return e.copy(g.getClearColor())},this.setClearColor=function(){g.setClearColor.apply(g,arguments)},this.getClearAlpha=function(){return g.getClearAlpha()},this.setClearAlpha=function(){g.setClearAlpha.apply(g,arguments)},this.clear=function(e,t,r){let i=0;void 0!==e&&!e||(i|=16384),void 0!==t&&!t||(i|=256),void 0!==r&&!r||(i|=1024),O.clear(i)},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(){n.removeEventListener("webglcontextlost",ve,!1),n.removeEventListener("webglcontextrestored",ye,!1),ue.dispose(),ce.dispose(),D.dispose(),P.dispose(),ae.dispose(),p.dispose(),y.dispose(),x.dispose(),x.removeEventListener("sessionstart",be),x.removeEventListener("sessionend",Te),A&&(A.dispose(),A=null),r.stop()},this.renderBufferDirect=function(e,t,r,i,n,s){null===t&&(t=ne);var a=n.isMesh&&n.matrixWorld.determinant()<0,e=function(e,t,r,i,n){!0!==t.isScene&&(t=ne),I.resetTextureUnits();var s=t.fog,a=i.isMeshStandardMaterial?t.environment:null,o=null===T?b.outputEncoding:T.texture.encoding,a=(i.isMeshStandardMaterial?ae:P).get(i.envMap||a),l=!0===i.vertexColors&&!!r.attributes.color&&4===r.attributes.color.itemSize,h=!!i.normalMap&&!!r.attributes.tangent,u=!!r.morphAttributes.position,c=!!r.morphAttributes.normal,d=r.morphAttributes.position?r.morphAttributes.position.length:0,f=D.get(i),p=_.state.lights;if(!0===te&&(!0===re||e!==E)){const t=e===E&&i.id===S;k.setState(i,e,t)}let m=!1,g=(i.version===f.__version?(f.needsLights&&f.lightsStateVersion!==p.state.version||f.outputEncoding!==o||n.isInstancedMesh&&!1===f.instancing||!n.isInstancedMesh&&!0===f.instancing||n.isSkinnedMesh&&!1===f.skinning||!n.isSkinnedMesh&&!0===f.skinning||f.envMap!==a||i.fog&&f.fog!==s||void 0!==f.numClippingPlanes&&(f.numClippingPlanes!==k.numPlanes||f.numIntersection!==k.numIntersection)||f.vertexAlphas!==l||f.vertexTangents!==h||f.morphTargets!==u||f.morphNormals!==c||!0===R.isWebGL2&&f.morphTargetsCount!==d)&&(m=!0):(m=!0,f.__version=i.version),f.currentProgram),v=!1,y=!1,x=!1;p=(g=!0===m?we(i,t,n):g).getUniforms(),o=f.uniforms;if(C.useProgram(g.program)&&(v=!0,y=!0,x=!0),i.id!==S&&(S=i.id,y=!0),v||E!==e){if(p.setValue(O,"projectionMatrix",e.projectionMatrix),R.logarithmicDepthBuffer&&p.setValue(O,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),E!==e&&(E=e,y=!0,x=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=p.map.cameraPosition;void 0!==t&&t.setValue(O,L.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&p.setValue(O,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||n.isSkinnedMesh)&&p.setValue(O,"viewMatrix",e.matrixWorldInverse)}if(n.isSkinnedMesh){p.setOptional(O,n,"bindMatrix"),p.setOptional(O,n,"bindMatrixInverse");const e=n.skeleton;e&&(R.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),p.setValue(O,"boneTexture",e.boneTexture,I),p.setValue(O,"boneTextureSize",e.boneTextureSize)):p.setOptional(O,e,"boneMatrices"))}return!r||void 0===r.morphAttributes.position&&void 0===r.morphAttributes.normal||de.update(n,r,i,g),!y&&f.receiveShadow===n.receiveShadow||(f.receiveShadow=n.receiveShadow,p.setValue(O,"receiveShadow",n.receiveShadow)),y&&(p.setValue(O,"toneMappingExposure",b.toneMappingExposure),f.needsLights&&(a=x,(l=o).ambientLightColor.needsUpdate=a,l.lightProbe.needsUpdate=a,l.directionalLights.needsUpdate=a,l.directionalLightShadows.needsUpdate=a,l.pointLights.needsUpdate=a,l.pointLightShadows.needsUpdate=a,l.spotLights.needsUpdate=a,l.spotLightShadows.needsUpdate=a,l.rectAreaLights.needsUpdate=a,l.hemisphereLights.needsUpdate=a),s&&i.fog&&he.refreshFogUniforms(o,s),he.refreshMaterialUniforms(o,i,M,w,A),Ho.upload(O,f.uniformsList,o,I)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Ho.upload(O,f.uniformsList,o,I),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&p.setValue(O,"center",n.center),p.setValue(O,"modelViewMatrix",n.modelViewMatrix),p.setValue(O,"normalMatrix",n.normalMatrix),p.setValue(O,"modelMatrix",n.matrixWorld),g}(e,t,r,i,n);C.setMaterial(i,a);let o=r.index;t=r.attributes.position;if(null===o){if(void 0===t||0===t.count)return}else if(0===o.count)return;let l,h=1,u=(!0===i.wireframe&&(o=le.getWireframeAttribute(r),h=2),y.setup(n,i,e,r,o),fe);null!==o&&(l=oe.get(o),(u=pe).setIndex(l));var a=(null!==o?o:t).count,e=r.drawRange.start*h,t=r.drawRange.count*h,c=null!==s?s.start*h:0,s=null!==s?s.count*h:1/0,d=Math.max(e,c),a=Math.min(a,e+t,c+s)-1,t=Math.max(0,a-d+1);if(0!==t){if(n.isMesh)!0===i.wireframe?(C.setLineWidth(i.wireframeLinewidth*se()),u.setMode(1)):u.setMode(4);else if(n.isLine){let e=i.linewidth;void 0===e&&(e=1),C.setLineWidth(e*se()),n.isLineSegments?u.setMode(1):n.isLineLoop?u.setMode(2):u.setMode(3)}else n.isPoints?u.setMode(0):n.isSprite&&u.setMode(4);if(n.isInstancedMesh)u.renderInstances(d,t,n.count);else if(r.isInstancedBufferGeometry){const e=Math.min(r.instanceCount,r._maxInstanceCount);u.renderInstances(d,t,e)}else u.render(d,t)}},this.compile=function(i,t){(_=ce.get(i)).init(),s.push(_),i.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow)&&_.pushShadow(e)}),_.setupLights(b.physicallyCorrectLights),i.traverse(function(t){var r=t.material;if(r)if(Array.isArray(r))for(let e=0;e<r.length;e++)we(r[e],i,t);else we(r,i,t)}),s.pop(),_=null};let _e=null;function be(){r.stop()}function Te(){r.start()}const r=new Xs;function Se(e,t,r,i){var n=e.opaque,s=e.transmissive,e=e.transparent;if(_.setupLightsView(r),0<s.length){var a=n,o=t,l=r;if(null===A){const a=!0===G&&!0===R.isWebGL2;A=new(a?Pi:Di)(1024,1024,{generateMipmaps:!0,type:null!==v.convert(ot)?ot:et,minFilter:Ze,magFilter:Re,wrapS:Le,wrapT:Le})}var h=b.getRenderTarget(),u=(b.setRenderTarget(A),b.clear(),b.toneMapping);b.toneMapping=Ne,Ee(a,o,l),b.toneMapping=u,I.updateMultisampleRenderTarget(A),I.updateRenderTargetMipmap(A),b.setRenderTarget(h)}i&&C.viewport(c.copy(i)),0<n.length&&Ee(n,t,r),0<s.length&&Ee(s,t,r),0<e.length&&Ee(e,t,r)}function Ee(r,i,n){var s,a,o=!0===i.isScene?i.overrideMaterial:null;for(let e=0,t=r.length;e<t;e++){var l=r[e],h=l.object,u=l.geometry,c=null===o?l.material:o,l=l.group;h.layers.test(n.layers)&&(s=i,a=n,u=u,c=c,l=l,(h=h).onBeforeRender(b,s,a,u,c,l),h.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,h.matrixWorld),h.normalMatrix.getNormalMatrix(h.modelViewMatrix),c.onBeforeRender(b,s,a,u,h,l),!0===c.transparent&&c.side===Fe?(c.side=Ae,c.needsUpdate=!0,b.renderBufferDirect(a,s,u,c,h,l),c.side=Oe,c.needsUpdate=!0,b.renderBufferDirect(a,s,u,c,h,l),c.side=Fe):b.renderBufferDirect(a,s,u,c,h,l),h.onAfterRender(b,s,a,u,c,l))}}function we(e,t,r){!0!==t.isScene&&(t=ne);var i=D.get(e),n=_.state.lights,s=_.state.shadowsArray,a=n.state.version,s=m.getParameters(e,n.state,s,t,r),o=m.getProgramCacheKey(s);let l=i.programs,h=(i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?ae:P).get(e.envMap||i.environment),void 0===l&&(e.addEventListener("dispose",xe),l=new Map,i.programs=l),l.get(o));if(void 0!==h){if(i.currentProgram===h&&i.lightsStateVersion===a)return Me(e,s),h}else s.uniforms=m.getUniforms(e),e.onBuild(r,s,b),e.onBeforeCompile(s,b),h=m.acquireProgram(s,o),l.set(o,h),i.uniforms=s.uniforms;t=i.uniforms,(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(t.clippingPlanes=k.uniform),Me(e,s),i.needsLights=e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights,i.lightsStateVersion=a,i.needsLights&&(t.ambientLightColor.value=n.state.ambient,t.lightProbe.value=n.state.probe,t.directionalLights.value=n.state.directional,t.directionalLightShadows.value=n.state.directionalShadow,t.spotLights.value=n.state.spot,t.spotLightShadows.value=n.state.spotShadow,t.rectAreaLights.value=n.state.rectArea,t.ltc_1.value=n.state.rectAreaLTC1,t.ltc_2.value=n.state.rectAreaLTC2,t.pointLights.value=n.state.point,t.pointLightShadows.value=n.state.pointShadow,t.hemisphereLights.value=n.state.hemi,t.directionalShadowMap.value=n.state.directionalShadowMap,t.directionalShadowMatrix.value=n.state.directionalShadowMatrix,t.spotShadowMap.value=n.state.spotShadowMap,t.spotShadowMatrix.value=n.state.spotShadowMatrix,t.pointShadowMap.value=n.state.pointShadowMap,t.pointShadowMatrix.value=n.state.pointShadowMatrix),r=h.getUniforms(),o=Ho.seqWithValue(r.seq,t);return i.currentProgram=h,i.uniformsList=o,h}function Me(e,t){e=D.get(e);e.outputEncoding=t.outputEncoding,e.instancing=t.instancing,e.skinning=t.skinning,e.morphTargets=t.morphTargets,e.morphNormals=t.morphNormals,e.morphTargetsCount=t.morphTargetsCount,e.numClippingPlanes=t.numClippingPlanes,e.numIntersection=t.numClipIntersection,e.vertexAlphas=t.vertexAlphas,e.vertexTangents=t.vertexTangents}r.setAnimationLoop(function(e){_e&&_e(e)}),"undefined"!=typeof window&&r.setContext(window),this.setAnimationLoop=function(e){_e=e,x.setAnimationLoop(e),null===e?r.stop():r.start()},x.addEventListener("sessionstart",be),x.addEventListener("sessionend",Te),this.render=function(r,e){if(void 0!==e&&!0!==e.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else if(!0!==Y){!0===r.autoUpdate&&r.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),!0===x.enabled&&!0===x.isPresenting&&(!0===x.cameraAutoUpdate&&x.updateCamera(e),e=x.getCamera()),!0===r.isScene&&r.onBeforeRender(b,r,e,T),(_=ce.get(r,s.length)).init(),s.push(_),ie.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),ee.setFromProjectionMatrix(ie),re=this.localClippingEnabled,te=k.init(this.clippingPlanes,re,e),(u=ue.get(r,t.length)).init(),t.push(u),function r(i,n,s,a){if(!1!==i.visible){if(i.layers.test(n.layers))if(i.isGroup)s=i.renderOrder;else if(i.isLOD)!0===i.autoUpdate&&i.update(n);else if(i.isLight)_.pushLight(i),i.castShadow&&_.pushShadow(i);else if(i.isSprite){if(!i.frustumCulled||ee.intersectsSprite(i)){a&&L.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ie);const r=p.update(i),n=i.material;n.visible&&u.push(i,r,n,s,L.z,null)}}else if((i.isMesh||i.isLine||i.isPoints)&&(i.isSkinnedMesh&&i.skeleton.frame!==f.render.frame&&(i.skeleton.update(),i.skeleton.frame=f.render.frame),!i.frustumCulled||ee.intersectsObject(i))){a&&L.setFromMatrixPosition(i.matrixWorld).applyMatrix4(ie);const r=p.update(i),n=i.material;if(Array.isArray(n)){const a=r.groups;for(let e=0,t=a.length;e<t;e++){var o=a[e],l=n[o.materialIndex];l&&l.visible&&u.push(i,r,l,s,L.z,o)}}else n.visible&&u.push(i,r,n,s,L.z,null)}var h=i.children;for(let e=0,t=h.length;e<t;e++)r(h[e],n,s,a)}}(r,e,0,b.sortObjects),u.finish(),!0===b.sortObjects&&u.sort(J,Z),!0===te&&k.beginShadows();const n=_.state.shadowsArray;if(a.render(n,r,e),!0===te&&k.endShadows(),!0===this.info.autoReset&&this.info.reset(),g.render(u,r),_.setupLights(b.physicallyCorrectLights),e.isArrayCamera){const n=e.cameras;for(let e=0,t=n.length;e<t;e++){var i=n[e];Se(u,r,i,i.viewport)}}else Se(u,r,e);null!==T&&(I.updateMultisampleRenderTarget(T),I.updateRenderTargetMipmap(T)),!0===r.isScene&&r.onAfterRender(b,r,e),C.buffers.depth.setTest(!0),C.buffers.depth.setMask(!0),C.buffers.color.setMask(!0),C.setPolygonOffset(!1),y.resetDefaultState(),S=-1,E=null,s.pop(),_=0<s.length?s[s.length-1]:null,t.pop(),u=0<t.length?t[t.length-1]:null}},this.getActiveCubeFace=function(){return $},this.getActiveMipmapLevel=function(){return q},this.getRenderTarget=function(){return T},this.setRenderTarget=function(t,e=0,r=0){T=t,$=e,q=r,t&&void 0===D.get(t).__webglFramebuffer&&I.setupRenderTarget(t);let i=null,n=!1,s=!1;if(t){const r=t.texture;(r.isDataTexture3D||r.isDataTexture2DArray)&&(s=!0);var a=D.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=a[e],n=!0):i=t.isWebGLMultisampleRenderTarget?D.get(t).__webglMultisampledFramebuffer:a,c.copy(t.viewport),K.copy(t.scissor),X=t.scissorTest}else c.copy(o).multiplyScalar(M).floor(),K.copy(l).multiplyScalar(M).floor(),X=Q;if(C.bindFramebuffer(36160,i)&&R.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const r=t.texture;if(h.length!==r.length||36064!==h[0]){for(let e=0,t=r.length;e<t;e++)h[e]=36064+e;h.length=r.length,e=!0}}else 1===h.length&&36064===h[0]||(h[0]=36064,h.length=1,e=!0);else 1===h.length&&1029===h[0]||(h[0]=1029,h.length=1,e=!0);e&&(R.isWebGL2?O.drawBuffers(h):d.get("WEBGL_draw_buffers").drawBuffersWEBGL(h))}if(C.viewport(c),C.scissor(K),C.setScissorTest(X),n){const i=D.get(t.texture);O.framebufferTexture2D(36160,36064,34069+e,i.__webglTexture,r)}else if(s){const i=D.get(t.texture),n=e||0;O.framebufferTextureLayer(36160,36064,i.__webglTexture,r||0,n)}S=-1},this.readRenderTargetPixels=function(t,r,i,n,s,a,o){if(t&&t.isWebGLRenderTarget){let e=D.get(t).__webglFramebuffer;if(e=t.isWebGLCubeRenderTarget&&void 0!==o?e[o]:e){C.bindFramebuffer(36160,e);try{const o=t.texture,e=o.format,h=o.type;var l;e!==Ce&&v.convert(e)!==O.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):(l=h===ot&&(d.has("EXT_color_buffer_half_float")||R.isWebGL2&&d.has("EXT_color_buffer_float")),h===et||v.convert(h)===O.getParameter(35738)||h===at&&(R.isWebGL2||d.has("OES_texture_float")||d.has("WEBGL_color_buffer_float"))||l?36053===O.checkFramebufferStatus(36160)?0<=r&&r<=t.width-n&&0<=i&&i<=t.height-s&&O.readPixels(r,i,n,s,v.convert(e),v.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."))}finally{const t=null!==T?D.get(T).__webglFramebuffer:null;C.bindFramebuffer(36160,t)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,r=0){var i=Math.pow(2,-r),n=Math.floor(t.image.width*i),i=Math.floor(t.image.height*i);let s=v.convert(t.format);R.isWebGL2&&6408===(s=6407===s?32849:s)&&(s=32856),I.setTexture2D(t,0),O.copyTexImage2D(3553,r,s,e.x,e.y,n,i,0),C.unbindTexture()},this.copyTextureToTexture=function(e,t,r,i=0){var n=t.image.width,s=t.image.height,a=v.convert(r.format),o=v.convert(r.type);I.setTexture2D(r,0),O.pixelStorei(37440,r.flipY),O.pixelStorei(37441,r.premultiplyAlpha),O.pixelStorei(3317,r.unpackAlignment),t.isDataTexture?O.texSubImage2D(3553,i,e.x,e.y,n,s,a,o,t.image.data):t.isCompressedTexture?O.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):O.texSubImage2D(3553,i,e.x,e.y,a,o,t.image),0===i&&r.generateMipmaps&&O.generateMipmap(3553),C.unbindTexture()},this.copyTextureToTexture3D=function(t,r,i,n,s=0){if(b.isWebGL1Renderer)console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var a=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,l=t.max.z-t.min.z+1,h=v.convert(n.format),u=v.convert(n.type);let e;if(n.isDataTexture3D)I.setTexture3D(n,0),e=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");I.setTexture2DArray(n,0),e=35866}O.pixelStorei(37440,n.flipY),O.pixelStorei(37441,n.premultiplyAlpha),O.pixelStorei(3317,n.unpackAlignment);var c=O.getParameter(3314),d=O.getParameter(32878),f=O.getParameter(3316),p=O.getParameter(3315),m=O.getParameter(32877),g=i.isCompressedTexture?i.mipmaps[0]:i.image;O.pixelStorei(3314,g.width),O.pixelStorei(32878,g.height),O.pixelStorei(3316,t.min.x),O.pixelStorei(3315,t.min.y),O.pixelStorei(32877,t.min.z),i.isDataTexture||i.isDataTexture3D?O.texSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,u,g.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),O.compressedTexSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,g.data)):O.texSubImage3D(e,s,r.x,r.y,r.z,a,o,l,h,u,g),O.pixelStorei(3314,c),O.pixelStorei(32878,d),O.pixelStorei(3316,f),O.pixelStorei(3315,p),O.pixelStorei(32877,m),0===s&&n.generateMipmaps&&O.generateMipmap(e),C.unbindTexture()}},this.initTexture=function(e){I.setTexture2D(e,0),C.unbindTexture()},this.resetState=function(){$=0,q=0,T=null,C.reset(),y.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}s.prototype.isWebGLRenderer=!0;class Cl extends s{}Cl.prototype.isWebGL1Renderer=!0;class Dl{constructor(e,t=25e-5){this.name="",this.color=new g(e),this.density=t}clone(){return new Dl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Dl.prototype.isFogExp2=!0;class Il{constructor(e,t=1,r=1e3){this.name="",this.color=new g(e),this.near=t,this.far=r}clone(){return new Il(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Il.prototype.isFog=!0;class Pl extends c{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){e=super.toJSON(e);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}Pl.prototype.isScene=!0;class kl{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Zr,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}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(r,i,n){r*=this.stride,n*=i.stride;for(let e=0,t=this.stride;e<t;e++)this.array[r+e]=i.array[n+e];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);e=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),e=new this.constructor(e,this.stride);return e.setUsage(this.usage),e}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=pi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}kl.prototype.isInterleavedBuffer=!0;const a=new Pe;class Ol{constructor(e,t,r,i=!1){this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=!0===i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(r){for(let e=0,t=this.data.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.applyMatrix4(r),this.setXYZ(e,a.x,a.y,a.z);return this}applyNormalMatrix(r){for(let e=0,t=this.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.applyNormalMatrix(r),this.setXYZ(e,a.x,a.y,a.z);return this}transformDirection(r){for(let e=0,t=this.count;e<t;e++)a.x=this.getX(e),a.y=this.getY(e),a.z=this.getZ(e),a.transformDirection(r),this.setXYZ(e,a.x,a.y,a.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=n,this}clone(t){if(void 0!==t)return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Ol(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);{console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){var r=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[r+e])}return new w(new this.array.constructor(t),this.itemSize,this.normalized)}}toJSON(t){if(void 0!==t)return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized};{console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){var r=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[r+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}}}Ol.prototype.isInterleavedBufferAttribute=!0;class Fl extends r{constructor(e){super(),this.type="SpriteMaterial",this.color=new g(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!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}}let Nl;Fl.prototype.isSpriteMaterial=!0;const Ul=new Pe,Bl=new Pe,Gl=new Pe,Hl=new z,zl=new z,Vl=new ke,Wl=new Pe,jl=new Pe,Yl=new Pe,$l=new z,ql=new z,Kl=new z;class Xl extends c{constructor(e){if(super(),this.type="Sprite",void 0===Nl){Nl=new S;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new kl(e,5);Nl.setIndex([0,1,2,0,2,3]),Nl.setAttribute("position",new Ol(t,3,0,!1)),Nl.setAttribute("uv",new Ol(t,2,3,!1))}this.geometry=Nl,this.material=void 0!==e?e:new Fl,this.center=new z(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Bl.setFromMatrixScale(this.matrixWorld),Vl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Gl.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Bl.multiplyScalar(-Gl.z);var r=this.material.rotation;let i,n;0!==r&&(n=Math.cos(r),i=Math.sin(r));var r=this.center,s=(Jl(Wl.set(-.5,-.5,0),Gl,r,Bl,i,n),Jl(jl.set(.5,-.5,0),Gl,r,Bl,i,n),Jl(Yl.set(.5,.5,0),Gl,r,Bl,i,n),$l.set(0,0),ql.set(1,0),Kl.set(1,1),e.ray.intersectTriangle(Wl,jl,Yl,!1,Ul));null===s&&(Jl(jl.set(-.5,.5,0),Gl,r,Bl,i,n),ql.set(0,1),null===(s=e.ray.intersectTriangle(Wl,Yl,jl,!1,Ul)))||(r=e.ray.origin.distanceTo(Ul))<e.near||r>e.far||t.push({distance:r,point:Ul.clone(),uv:f.getUV(Ul,Wl,jl,Yl,$l,ql,Kl,new z),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Jl(e,t,r,i,n,s){Hl.subVectors(e,r).addScalar(.5).multiply(i),void 0!==n?(zl.x=s*Hl.x-n*Hl.y,zl.y=n*Hl.x+s*Hl.y):zl.copy(Hl),e.copy(t),e.x+=zl.x,e.y+=zl.y,e.applyMatrix4(Vl)}Xl.prototype.isSprite=!0;const Zl=new Pe,Ql=new Pe;class eh extends c{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);var r=e.levels;for(let e=0,t=r.length;e<t;e++){var i=r[e];this.addLevel(i.object.clone(),i.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);var r=this.levels;let i;for(i=0;i<r.length&&!(t<r[i].distance);i++);return r.splice(i,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(r){var i=this.levels;if(0<i.length){let e,t;for(e=1,t=i.length;e<t&&!(r<i[e].distance);e++);return i[e-1].object}return null}raycast(e,t){var r;0<this.levels.length&&(Zl.setFromMatrixPosition(this.matrixWorld),r=e.ray.origin.distanceTo(Zl),this.getObjectForDistance(r).raycast(e,t))}update(r){var i=this.levels;if(1<i.length){Zl.setFromMatrixPosition(r.matrixWorld),Ql.setFromMatrixPosition(this.matrixWorld);var n=Zl.distanceTo(Ql)/r.zoom;let e,t;for(i[0].object.visible=!0,e=1,t=i.length;e<t&&n>=i[e].distance;e++)i[e-1].object.visible=!1,i[e].object.visible=!0;for(this._currentLevel=e-1;e<t;e++)i[e].object.visible=!1}}toJSON(e){var r=super.toJSON(e),i=(!1===this.autoUpdate&&(r.object.autoUpdate=!1),r.object.levels=[],this.levels);for(let e=0,t=i.length;e<t;e++){var n=i[e];r.object.levels.push({object:n.object.uuid,distance:n.distance})}return r}}const th=new Pe,rh=new Ie,ih=new Ie,nh=new Pe,sh=new ke;class ah extends E{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ke,this.bindMatrixInverse=new ke}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){var r=new Ie,i=this.geometry.attributes.skinWeight;for(let e=0,t=i.count;e<t;e++){r.x=i.getX(e),r.y=i.getY(e),r.z=i.getZ(e),r.w=i.getW(e);var n=1/r.manhattanLength();n!=1/0?r.multiplyScalar(n):r.set(1,0,0,0),i.setXYZW(e,r.x,r.y,r.z,r.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const r=this.skeleton,i=this.geometry;rh.fromBufferAttribute(i.attributes.skinIndex,e),ih.fromBufferAttribute(i.attributes.skinWeight,e),th.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=ih.getComponent(e);var n;0!==i&&(n=rh.getComponent(e),sh.multiplyMatrices(r.bones[n].matrixWorld,r.boneInverses[n]),t.addScaledVector(nh.copy(th).applyMatrix4(sh),i))}return t.applyMatrix4(this.bindMatrixInverse)}}ah.prototype.isSkinnedMesh=!0;class oh extends c{constructor(){super(),this.type="Bone"}}oh.prototype.isBone=!0;class lh extends u{constructor(e=null,t=1,r=1,i,n,s,a,o,l=Re,h=Re,u,c){super(null,s,a,o,l,h,i,n,u,c),this.image={data:e,width:t,height:r},this.magFilter=l,this.minFilter=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}lh.prototype.isDataTexture=!0;const hh=new ke,uh=new ke;class ch{constructor(e=[],t=[]){this.uuid=pi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){var e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)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 e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new ke)}}calculateInverses(){for(let e=this.boneInverses.length=0,t=this.bones.length;e<t;e++){var r=new ke;this.bones[e]&&r.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(r)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){var r=this.bones[e];r&&r.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){var 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(){var r=this.bones,i=this.boneInverses,n=this.boneMatrices,e=this.boneTexture;for(let e=0,t=r.length;e<t;e++){var s=r[e]?r[e].matrixWorld:uh;hh.multiplyMatrices(s,i[e]),hh.toArray(n,16*e)}null!==e&&(e.needsUpdate=!0)}clone(){return new ch(this.bones,this.boneInverses)}computeBoneTexture(){var e=xi(Math.sqrt(4*this.bones.length)),t=(e=Math.max(e,4),new Float32Array(e*e*4)),r=(t.set(this.boneMatrices),new lh(t,e,e,Ce,at));return this.boneMatrices=t,this.boneTexture=r,this.boneTextureSize=e,this}getBoneByName(r){for(let e=0,t=this.bones.length;e<t;e++){var i=this.bones[e];if(i.name===r)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(r,i){this.uuid=r.uuid;for(let t=0,e=r.bones.length;t<e;t++){var n=r.bones[t];let e=i[n];void 0===e&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),e=new oh),this.bones.push(e),this.boneInverses.push((new ke).fromArray(r.boneInverses[t]))}return this.init(),this}toJSON(){var r={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]},i=(r.uuid=this.uuid,this.bones),n=this.boneInverses;for(let e=0,t=i.length;e<t;e++){var s=i[e],s=(r.bones.push(s.uuid),n[e]);r.boneInverses.push(s.toArray())}return r}}class dh extends w{constructor(e,t,r,i=1){"number"==typeof r&&(i=r,r=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,r),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){var e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}dh.prototype.isInstancedBufferAttribute=!0;const fh=new ke,ph=new ke,mh=[],gh=new E;class vh extends E{constructor(e,t,r){super(e,t),this.instanceMatrix=new dh(new Float32Array(16*r),16),this.instanceColor=null,this.count=r,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,i){const n=this.matrixWorld,t=this.count;if(gh.geometry=this.geometry,gh.material=this.material,void 0!==gh.material)for(let r=0;r<t;r++){this.getMatrixAt(r,fh),ph.multiplyMatrices(n,fh),gh.matrixWorld=ph,gh.raycast(e,mh);for(let e=0,t=mh.length;e<t;e++){const n=mh[e];n.instanceId=r,n.object=this,i.push(n)}mh.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new dh(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}vh.prototype.isInstancedMesh=!0;class y extends r{constructor(e){super(),this.type="LineBasicMaterial",this.color=new g(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}y.prototype.isLineBasicMaterial=!0;const yh=new Pe,xh=new Pe,_h=new ke,bh=new cn,Th=new rn;class Sh extends c{constructor(e=new S,t=new y){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var r=e.attributes.position,i=[0];for(let e=1,t=r.count;e<t;e++)yh.fromBufferAttribute(r,e-1),xh.fromBufferAttribute(r,e),i[e]=i[e-1],i[e]+=yh.distanceTo(xh);e.setAttribute("lineDistance",new V(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(r,i){const e=this.geometry,n=this.matrixWorld,s=r.params.Line.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),Th.copy(e.boundingSphere),Th.applyMatrix4(n),Th.radius+=s,!1!==r.ray.intersectsSphere(Th)){_h.copy(n).invert(),bh.copy(r.ray).applyMatrix4(_h);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,h=new Pe,u=new Pe,c=new Pe,d=new Pe,f=this.isLineSegments?2:1;if(e.isBufferGeometry){const n=e.index,s=e.attributes.position;if(null!==n)for(let e=Math.max(0,a.start),t=Math.min(n.count,a.start+a.count)-1;e<t;e+=f){const a=n.getX(e),o=n.getX(e+1);if(h.fromBufferAttribute(s,a),u.fromBufferAttribute(s,o),!(bh.distanceSqToSegment(h,u,d,c)>l)){d.applyMatrix4(this.matrixWorld);const f=r.ray.origin.distanceTo(d);f<r.near||f>r.far||i.push({distance:f,point:c.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this})}}else for(let e=Math.max(0,a.start),t=Math.min(s.count,a.start+a.count)-1;e<t;e+=f)if(h.fromBufferAttribute(s,e),u.fromBufferAttribute(s,e+1),!(bh.distanceSqToSegment(h,u,d,c)>l)){d.applyMatrix4(this.matrixWorld);const n=r.ray.origin.distanceTo(d);n<r.near||n>r.far||i.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:e,face:null,faceIndex:null,object:this})}}else e.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Sh.prototype.isLine=!0;const Eh=new Pe,wh=new Pe;class Mh extends Sh{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){var r=e.attributes.position,i=[];for(let e=0,t=r.count;e<t;e+=2)Eh.fromBufferAttribute(r,e),wh.fromBufferAttribute(r,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Eh.distanceTo(wh);e.setAttribute("lineDistance",new V(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}Mh.prototype.isLineSegments=!0;class Ah extends Sh{constructor(e,t){super(e,t),this.type="LineLoop"}}Ah.prototype.isLineLoop=!0;class Lh extends r{constructor(e){super(),this.type="PointsMaterial",this.color=new g(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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}}Lh.prototype.isPointsMaterial=!0;const Rh=new ke,Ch=new cn,Dh=new rn,Ih=new Pe;class Ph extends c{constructor(e=new S,t=new Lh){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(r,i){const e=this.geometry,n=this.matrixWorld,s=r.params.Points.threshold,a=e.drawRange;if(null===e.boundingSphere&&e.computeBoundingSphere(),Dh.copy(e.boundingSphere),Dh.applyMatrix4(n),Dh.radius+=s,!1!==r.ray.intersectsSphere(Dh)){Rh.copy(n).invert(),Ch.copy(r.ray).applyMatrix4(Rh);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o;if(e.isBufferGeometry){const s=e.index,o=e.attributes.position;if(null!==s)for(let e=Math.max(0,a.start),t=Math.min(s.count,a.start+a.count);e<t;e++){const a=s.getX(e);Ih.fromBufferAttribute(o,a),kh(Ih,a,l,n,r,i,this)}else for(let e=Math.max(0,a.start),t=Math.min(o.count,a.start+a.count);e<t;e++)Ih.fromBufferAttribute(o,e),kh(Ih,e,l,n,r,i,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}updateMorphTargets(){const r=this.geometry;if(r.isBufferGeometry){var e=r.morphAttributes,t=Object.keys(e);if(0<t.length){const r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){var i=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=e}}}}else{e=r.morphTargets;void 0!==e&&0<e.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function kh(e,t,r,i,n,s,a){var o=Ch.distanceSqToPoint(e);if(o<r){const r=new Pe;Ch.closestPointToPoint(e,r),r.applyMatrix4(i);e=n.ray.origin.distanceTo(r);e<n.near||e>n.far||s.push({distance:e,distanceToRay:Math.sqrt(o),point:r,index:t,face:null,object:a})}}Ph.prototype.isPoints=!0;class Oh extends u{constructor(t,e,r,i,n,s,a,o,l){super(t,e,r,i,n,s,a,o,l),this.format=void 0!==a?a:ft,this.minFilter=void 0!==s?s:U,this.magFilter=void 0!==n?n:U,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(function e(){h.needsUpdate=!0,t.requestVideoFrameCallback(e)})}clone(){return new this.constructor(this.image).copy(this)}update(){var e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Oh.prototype.isVideoTexture=!0;class Fh extends u{constructor(e,t,r,i,n,s,a,o,l,h,u,c){super(null,s,a,o,l,h,i,n,u,c),this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Fh.prototype.isCompressedTexture=!0;class Nh extends u{constructor(e,t,r,i,n,s,a,o,l){super(e,t,r,i,n,s,a,o,l),this.needsUpdate=!0}}Nh.prototype.isCanvasTexture=!0;class Uh extends u{constructor(e,t,r,i,n,s,a,o,l,h){if((h=void 0!==h?h:vt)!==vt&&h!==yt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,i,n,s,a,o,h,r=void 0===(r=void 0===r&&h===vt?it:r)&&h===yt?ct:r,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:Re,this.minFilter=void 0!==o?o:Re,this.flipY=!1,this.generateMipmaps=!1}}Uh.prototype.isDepthTexture=!0;class Bh extends S{constructor(r=1,i=8,n=0,s=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:r,segments:i,thetaStart:n,thetaLength:s},i=Math.max(3,i);var t=[],a=[],o=[],l=[],h=new Pe,u=new z;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let e=0,t=3;e<=i;e++,t+=3){var c=n+e/i*s;h.x=r*Math.cos(c),h.y=r*Math.sin(c),a.push(h.x,h.y,h.z),o.push(0,0,1),u.x=(a[t]/r+1)/2,u.y=(a[t+1]/r+1)/2,l.push(u.x,u.y)}for(let e=1;e<=i;e++)t.push(e,e+1,0);this.setIndex(t),this.setAttribute("position",new V(a,3)),this.setAttribute("normal",new V(o,3)),this.setAttribute("uv",new V(l,2))}static fromJSON(e){return new Bh(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Gh extends S{constructor(h=1,u=1,i=1,c=8,n=1,e=!1,d=0,f=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:h,radiusBottom:u,height:i,radialSegments:c,heightSegments:n,openEnded:e,thetaStart:d,thetaLength:f};const p=this,m=(c=Math.floor(c),n=Math.floor(n),[]),g=[],v=[],y=[];let x=0;const s=[],_=i/2;let b=0;function t(t){const r=x,i=new z,n=new Pe;let s=0;var a=!0===t?h:u,o=!0===t?1:-1;for(let e=1;e<=c;e++)g.push(0,_*o,0),v.push(0,o,0),y.push(.5,.5),x++;var l=x;for(let e=0;e<=c;e++){const u=e/c*f+d,t=Math.cos(u),r=Math.sin(u);n.x=a*r,n.y=_*o,n.z=a*t,g.push(n.x,n.y,n.z),v.push(0,o,0),i.x=.5*t+.5,i.y=.5*r*o+.5,y.push(i.x,i.y),x++}for(let e=0;e<c;e++){const u=r+e,c=l+e;!0===t?m.push(c,c+1,u):m.push(c+1,c,u),s+=3}p.addGroup(b,s,!0===t?1:2),b+=s}{const o=new Pe,l=new Pe;let r=0;var a=(u-h)/i;for(let e=0;e<=n;e++){const m=[],b=e/n,t=b*(u-h)+h;for(let e=0;e<=c;e++){const u=e/c,n=u*f+d,p=Math.sin(n),s=Math.cos(n);l.x=t*p,l.y=-b*i+_,l.z=t*s,g.push(l.x,l.y,l.z),o.set(p,a,s).normalize(),v.push(o.x,o.y,o.z),y.push(u,1-b),m.push(x++)}s.push(m)}for(let t=0;t<c;t++)for(let e=0;e<n;e++){const i=s[e][t],c=s[e+1][t],n=s[e+1][t+1],o=s[e][t+1];m.push(i,c,o),m.push(c,n,o),r+=6}p.addGroup(b,r,0),b+=r}!1===e&&(0<h&&t(!0),0<u)&&t(!1),this.setIndex(m),this.setAttribute("position",new V(g,3)),this.setAttribute("normal",new V(v,3)),this.setAttribute("uv",new V(y,2))}static fromJSON(e){return new Gh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Hh extends Gh{constructor(e=1,t=1,r=8,i=1,n=!1,s=0,a=2*Math.PI){super(0,e,t,r,i,n,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:r,heightSegments:i,openEnded:n,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Hh(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class zh extends S{constructor(r=[],t=[],e=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:r,indices:t,radius:e,detail:i};const n=[],s=[];function a(e){n.push(e.x,e.y,e.z)}function o(e,t){e*=3;t.x=r[0+e],t.y=r[1+e],t.z=r[2+e]}function l(e,t,r,i){i<0&&1===e.x&&(s[t]=e.x-1),0===r.x&&0===r.z&&(s[t]=i/2/Math.PI+.5)}function h(e){return Math.atan2(e.z,-e.x)}var u=i,c=new Pe,d=new Pe,f=new Pe;for(let e=0;e<t.length;e+=3){o(t[e+0],c),o(t[e+1],d),o(t[e+2],f);{p=void 0;m=void 0;g=void 0;v=void 0;y=void 0;x=void 0;var p=c;var m=d;var g=f;var v=u;var y=v+1,x=[];for(let t=0;t<=y;t++){x[t]=[];const k=p.clone().lerp(g,t/y),a=m.clone().lerp(g,t/y),O=y-t;for(let e=0;e<=O;e++)x[t][e]=0===e&&t===y?k:k.clone().lerp(a,e/O)}for(let t=0;t<y;t++)for(let e=0;e<2*(y-t)-1;e++){const g=Math.floor(e/2);e%2==0?(a(x[t][g+1]),a(x[t+1][g]),a(x[t][g])):(a(x[t][g+1]),a(x[t+1][g+1]),a(x[t+1][g]))}}}var _=e,b=new Pe;for(let e=0;e<n.length;e+=3)b.x=n[e+0],b.y=n[e+1],b.z=n[e+2],b.normalize().multiplyScalar(_),n[e+0]=b.x,n[e+1]=b.y,n[e+2]=b.z;var T=new Pe;for(let e=0;e<n.length;e+=3){T.x=n[e+0],T.y=n[e+1],T.z=n[e+2];var F=h(T)/2/Math.PI+.5,N=Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))/Math.PI+.5;s.push(F,1-N)}var S=new Pe,E=new Pe,w=new Pe,M=new Pe,A=new z,L=new z,R=new z;for(let e=0,t=0;e<n.length;e+=9,t+=6){S.set(n[e+0],n[e+1],n[e+2]),E.set(n[e+3],n[e+4],n[e+5]),w.set(n[e+6],n[e+7],n[e+8]),A.set(s[t+0],s[t+1]),L.set(s[t+2],s[t+3]),R.set(s[t+4],s[t+5]),M.copy(S).add(E).add(w).divideScalar(3);var C=h(M);l(A,t+0,S,C),l(L,t+2,E,C),l(R,t+4,w,C)}for(let e=0;e<s.length;e+=6){var D=s[e+0],I=s[e+2],P=s[e+4],U=Math.max(D,I,P),B=Math.min(D,I,P);.9<U&&B<.1&&(D<.2&&(s[e+0]+=1),I<.2&&(s[e+2]+=1),P<.2)&&(s[e+4]+=1)}this.setAttribute("position",new V(n,3)),this.setAttribute("normal",new V(n.slice(),3)),this.setAttribute("uv",new V(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new zh(e.vertices,e.indices,e.radius,e.details)}}class Vh extends zh{constructor(e=1,t=0){var r=(1+Math.sqrt(5))/2,i=1/r;super([-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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],[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],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Vh(e.radius,e.detail)}}const Wh=new Pe,jh=new Pe,Yh=new Pe,$h=new f;class qh extends S{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){var r=Math.pow(10,4),i=Math.cos(ci*t),n=e.getIndex(),s=e.getAttribute("position"),a=(n||s).count,o=[0,0,0],l=["a","b","c"],h=new Array(3),u={},c=[];for(let e=0;e<a;e+=3){n?(o[0]=n.getX(e),o[1]=n.getX(e+1),o[2]=n.getX(e+2)):(o[0]=e,o[1]=e+1,o[2]=e+2);const{a:t,b:d,c:f}=$h;if(t.fromBufferAttribute(s,o[0]),d.fromBufferAttribute(s,o[1]),f.fromBufferAttribute(s,o[2]),$h.getNormal(Yh),h[0]=`${Math.round(t.x*r)},${Math.round(t.y*r)},`+Math.round(t.z*r),h[1]=`${Math.round(d.x*r)},${Math.round(d.y*r)},`+Math.round(d.z*r),h[2]=`${Math.round(f.x*r)},${Math.round(f.y*r)},`+Math.round(f.z*r),h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let e=0;e<3;e++){const t=(e+1)%3,p=h[e],m=h[t],g=$h[l[e]],v=$h[l[t]],y=p+"_"+m,x=m+"_"+p;x in u&&u[x]?(Yh.dot(u[x].normal)<=i&&(c.push(g.x,g.y,g.z),c.push(v.x,v.y,v.z)),u[x]=null):y in u||(u[y]={index0:o[e],index1:o[t],normal:Yh.clone()})}}for(const e in u)if(u[e]){const{index0:t,index1:_}=u[e];Wh.fromBufferAttribute(s,t),jh.fromBufferAttribute(s,_),c.push(Wh.x,Wh.y,Wh.z),c.push(jh.x,jh.y,jh.z)}this.setAttribute("position",new V(c,3))}}}class Kh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){e=this.getUtoTmapping(e);return this.getPoint(e,t)}getPoints(t=5){var r=[];for(let e=0;e<=t;e++)r.push(this.getPoint(e/t));return r}getSpacedPoints(t=5){var r=[];for(let e=0;e<=t;e++)r.push(this.getPointAt(e/t));return r}getLength(){var e=this.getLengths();return e[e.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var r=[];let i,n=this.getPoint(0),s=0;r.push(0);for(let e=1;e<=t;e++)i=this.getPoint(e/t),s+=i.distanceTo(n),r.push(s),n=i;return this.cacheArcLengths=r}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){var r=this.getLengths();let i=0;var n=r.length,s=t||e*r[n-1];let a,o=0,l=n-1;for(;o<=l;)if((a=r[i=Math.floor(o+(l-o)/2)]-s)<0)o=i+1;else{if(!(0<a)){l=i;break}l=i-1}return r[i=l]===s?i/(n-1):(t=r[i],(i+(s-t)/(r[i+1]-t))/(n-1))}getTangent(e,t){let r=e-1e-4,i=e+1e-4;r<0&&(r=0),1<i&&(i=1);var e=this.getPoint(r),n=this.getPoint(i),t=t||new(e.isVector2?z:Pe);return t.copy(n).sub(e).normalize(),t}getTangentAt(e,t){e=this.getUtoTmapping(e);return this.getTangent(e,t)}computeFrenetFrames(r,e){const t=new Pe,i=[],n=[],s=[],a=new Pe,o=new ke;for(let e=0;e<=r;e++){const t=e/r;i[e]=this.getTangentAt(t,new Pe)}n[0]=new Pe,s[0]=new Pe;let l=Number.MAX_VALUE;var h=Math.abs(i[0].x),u=Math.abs(i[0].y),c=Math.abs(i[0].z);h<=l&&(l=h,t.set(1,0,0)),u<=l&&(l=u,t.set(0,1,0)),c<=l&&t.set(0,0,1),a.crossVectors(i[0],t).normalize(),n[0].crossVectors(i[0],a),s[0].crossVectors(i[0],n[0]);for(let e=1;e<=r;e++){if(n[e]=n[e-1].clone(),s[e]=s[e-1].clone(),a.crossVectors(i[e-1],i[e]),a.length()>Number.EPSILON){a.normalize();const r=Math.acos(mi(i[e-1].dot(i[e]),-1,1));n[e].applyMatrix4(o.makeRotationAxis(a,r))}s[e].crossVectors(i[e],n[e])}if(!0===e){let t=Math.acos(mi(n[0].dot(n[r]),-1,1));t/=r,0<i[0].dot(a.crossVectors(n[0],n[r]))&&(t=-t);for(let e=1;e<=r;e++)n[e].applyMatrix4(o.makeRotationAxis(i[e],t*e)),s[e].crossVectors(i[e],n[e])}return{tangents:i,normals:n,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xh extends Kh{constructor(e=0,t=0,r=1,i=1,n=0,s=2*Math.PI,a=!1,o=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const r=t||new z,i=2*Math.PI;let n=this.aEndAngle-this.aStartAngle;for(t=Math.abs(n)<Number.EPSILON;n<0;)n+=i;for(;n>i;)n-=i;n<Number.EPSILON&&(n=t?0:i),!0!==this.aClockwise||t||(n===i?n=-i:n-=i);t=this.aStartAngle+e*n;let s=this.aX+this.xRadius*Math.cos(t),a=this.aY+this.yRadius*Math.sin(t);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),r=s-this.aX,i=a-this.aY;s=r*e-i*t+this.aX,a=r*t+i*e+this.aY}return r.set(s,a)}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(){var 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}}Xh.prototype.isEllipseCurve=!0;class Jh extends Xh{constructor(e,t,r,i,n,s){super(e,t,r,r,i,n,s),this.type="ArcCurve"}}function Zh(){let n=0,s=0,a=0,o=0;function l(e,t,r,i){n=e,s=r,a=-3*e+3*t-2*r-i,o=2*e-2*t+r+i}return{initCatmullRom:function(e,t,r,i,n){l(t,r,n*(r-e),n*(i-t))},initNonuniformCatmullRom:function(e,t,r,i,n,s,a){e=(t-e)/n-(r-e)/(n+s)+(r-t)/s,n=(r-t)/s-(i-t)/(s+a)+(i-r)/a;l(t,r,e*=s,n*=s)},calc:function(e){var t=e*e;return n+s*e+a*t+o*(t*e)}}}Jh.prototype.isArcCurve=!0;const Qh=new Pe,eu=new Zh,tu=new Zh,ru=new Zh;class iu extends Kh{constructor(e=[],t=!1,r="centripetal",i=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=r,this.tension=i}getPoint(i,e=new Pe){var t=this.points,r=t.length,i=(r-(this.closed?0:1))*i;let n,s,a=Math.floor(i),o=i-a;this.closed?a+=0<a?0:(Math.floor(Math.abs(a)/r)+1)*r:0===o&&a===r-1&&(a=r-2,o=1),n=this.closed||0<a?t[(a-1)%r]:(Qh.subVectors(t[0],t[1]).add(t[0]),Qh);var l=t[a%r],h=t[(a+1)%r];if(s=this.closed||a+2<r?t[(a+2)%r]:(Qh.subVectors(t[r-1],t[r-2]).add(t[r-1]),Qh),"centripetal"===this.curveType||"chordal"===this.curveType){const i="chordal"===this.curveType?.5:.25;let e=Math.pow(n.distanceToSquared(l),i),t=Math.pow(l.distanceToSquared(h),i),r=Math.pow(h.distanceToSquared(s),i);t<1e-4&&(t=1),e<1e-4&&(e=t),r<1e-4&&(r=t),eu.initNonuniformCatmullRom(n.x,l.x,h.x,s.x,e,t,r),tu.initNonuniformCatmullRom(n.y,l.y,h.y,s.y,e,t,r),ru.initNonuniformCatmullRom(n.z,l.z,h.z,s.z,e,t,r)}else"catmullrom"===this.curveType&&(eu.initCatmullRom(n.x,l.x,h.x,s.x,this.tension),tu.initCatmullRom(n.y,l.y,h.y,s.y,this.tension),ru.initCatmullRom(n.z,l.z,h.z,s.z,this.tension));return e.set(eu.calc(o),tu.calc(o),ru.calc(o)),e}copy(r){super.copy(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push(i.clone())}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}toJSON(){var r=super.toJSON();r.points=[];for(let e=0,t=this.points.length;e<t;e++){var i=this.points[e];r.points.push(i.toArray())}return r.closed=this.closed,r.curveType=this.curveType,r.tension=this.tension,r}fromJSON(r){super.fromJSON(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push((new Pe).fromArray(i))}return this.closed=r.closed,this.curveType=r.curveType,this.tension=r.tension,this}}function nu(e,t,r,i,n){var t=.5*(i-t),n=.5*(n-r),s=e*e;return e*s*(2*r-2*i+t+n)+(-3*r+3*i-2*t-n)*s+t*e+r}function su(e,t,r,i){return(n=1-e)*n*t+2*(1-e)*e*r+e*e*i;var n}function au(e,t,r,i,n){return(s=1-e)*s*s*t+3*(s=1-e)*s*e*r+3*(1-e)*e*e*i+e*e*e*n;var s}iu.prototype.isCatmullRomCurve3=!0;class ou extends Kh{constructor(e=new z,t=new z,r=new z,i=new z){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new z){var r=this.v0,i=this.v1,n=this.v2,s=this.v3;return t.set(au(e,r.x,i.x,n.x,s.x),au(e,r.y,i.y,n.y,s.y)),t}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(){var 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}}ou.prototype.isCubicBezierCurve=!0;class lu extends Kh{constructor(e=new Pe,t=new Pe,r=new Pe,i=new Pe){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=r,this.v3=i}getPoint(e,t=new Pe){var r=this.v0,i=this.v1,n=this.v2,s=this.v3;return t.set(au(e,r.x,i.x,n.x,s.x),au(e,r.y,i.y,n.y,s.y),au(e,r.z,i.z,n.z,s.z)),t}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(){var 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}}lu.prototype.isCubicBezierCurve3=!0;class hu extends Kh{constructor(e=new z,t=new z){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new z){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){t=t||new z;return t.copy(this.v2).sub(this.v1).normalize(),t}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}hu.prototype.isLineCurve=!0;class uu extends Kh{constructor(e=new Pe,t=new Pe){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new Pe){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}class cu extends Kh{constructor(e=new z,t=new z,r=new z){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new z){var r=this.v0,i=this.v1,n=this.v2;return t.set(su(e,r.x,i.x,n.x),su(e,r.y,i.y,n.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}cu.prototype.isQuadraticBezierCurve=!0;class du extends Kh{constructor(e=new Pe,t=new Pe,r=new Pe){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=r}getPoint(e,t=new Pe){var r=this.v0,i=this.v1,n=this.v2;return t.set(su(e,r.x,i.x,n.x),su(e,r.y,i.y,n.y),su(e,r.z,i.z,n.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var 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}}du.prototype.isQuadraticBezierCurve3=!0;class fu extends Kh{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new z){var r=this.points,e=(r.length-1)*e,i=Math.floor(e),e=e-i,n=r[0===i?i:i-1],s=r[i],a=r[i>r.length-2?r.length-1:i+1],r=r[i>r.length-3?r.length-1:i+2];return t.set(nu(e,n.x,s.x,a.x,r.x),nu(e,n.y,s.y,a.y,r.y)),t}copy(r){super.copy(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push(i.clone())}return this}toJSON(){var r=super.toJSON();r.points=[];for(let e=0,t=this.points.length;e<t;e++){var i=this.points[e];r.points.push(i.toArray())}return r}fromJSON(r){super.fromJSON(r),this.points=[];for(let e=0,t=r.points.length;e<t;e++){var i=r.points[e];this.points.push((new z).fromArray(i))}return this}}fu.prototype.isSplineCurve=!0;var pu=Object.freeze({__proto__:null,ArcCurve:Jh,CatmullRomCurve3:iu,CubicBezierCurve:ou,CubicBezierCurve3:lu,EllipseCurve:Xh,LineCurve:hu,LineCurve3:uu,QuadraticBezierCurve:cu,QuadraticBezierCurve3:du,SplineCurve:fu});class mu extends Kh{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new hu(t,e))}getPoint(e,t){var r=e*this.getLength(),i=this.getCurveLengths();let n=0;for(;n<i.length;){if(i[n]>=r){const e=i[n]-r,s=this.curves[n],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}n++}return null}getLength(){var 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;var r=[];let i=0;for(let e=0,t=this.curves.length;e<t;e++)i+=this.curves[e].getLength(),r.push(i);return this.cacheLengths=r}getSpacedPoints(t=40){var r=[];for(let e=0;e<=t;e++)r.push(this.getPoint(e/t));return this.autoClose&&r.push(r[0]),r}getPoints(r=12){var i=[];let n;for(let e=0,t=this.curves;e<t.length;e++){var s=t[e],a=s&&s.isEllipseCurve?2*r:s&&(s.isLineCurve||s.isLineCurve3)?1:s&&s.isSplineCurve?r*s.points.length:r,o=s.getPoints(a);for(let e=0;e<o.length;e++){var l=o[e];n&&n.equals(l)||(i.push(l),n=l)}}return this.autoClose&&1<i.length&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(r){super.copy(r),this.curves=[];for(let e=0,t=r.curves.length;e<t;e++){var i=r.curves[e];this.curves.push(i.clone())}return this.autoClose=r.autoClose,this}toJSON(){var r=super.toJSON();r.autoClose=this.autoClose,r.curves=[];for(let e=0,t=this.curves.length;e<t;e++){var i=this.curves[e];r.curves.push(i.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.autoClose=r.autoClose,this.curves=[];for(let e=0,t=r.curves.length;e<t;e++){var i=r.curves[e];this.curves.push((new pu[i.type]).fromJSON(i))}return this}}class gu extends mu{constructor(e){super(),this.type="Path",this.currentPoint=new z,e&&this.setFromPoints(e)}setFromPoints(r){this.moveTo(r[0].x,r[0].y);for(let e=1,t=r.length;e<t;e++)this.lineTo(r[e].x,r[e].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){var r=new hu(this.currentPoint.clone(),new z(e,t));return this.curves.push(r),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,r,i){e=new cu(this.currentPoint.clone(),new z(e,t),new z(r,i));return this.curves.push(e),this.currentPoint.set(r,i),this}bezierCurveTo(e,t,r,i,n,s){e=new ou(this.currentPoint.clone(),new z(e,t),new z(r,i),new z(n,s));return this.curves.push(e),this.currentPoint.set(n,s),this}splineThru(e){var t=[this.currentPoint.clone()].concat(e),t=new fu(t);return this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,r,i,n,s){var a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,r,i,n,s),this}absarc(e,t,r,i,n,s){return this.absellipse(e,t,r,r,i,n,s),this}ellipse(e,t,r,i,n,s,a,o){var l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,r,i,n,s,a,o),this}absellipse(e,t,r,i,n,s,a,o){t=new Xh(e,t,r,i,n,s,a,o);if(0<this.curves.length){const e=t.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(t);e=t.getPoint(1);return this.currentPoint.copy(e),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){var e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class vu extends gu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(r){var i=[];for(let e=0,t=this.holes.length;e<t;e++)i[e]=this.holes[e].getPoints(r);return i}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(r){super.copy(r),this.holes=[];for(let e=0,t=r.holes.length;e<t;e++){var i=r.holes[e];this.holes.push(i.clone())}return this}toJSON(){var r=super.toJSON();r.uuid=this.uuid,r.holes=[];for(let e=0,t=this.holes.length;e<t;e++){var i=this.holes[e];r.holes.push(i.toJSON())}return r}fromJSON(r){super.fromJSON(r),this.uuid=r.uuid,this.holes=[];for(let e=0,t=r.holes.length;e<t;e++){var i=r.holes[e];this.holes.push((new gu).fromJSON(i))}return this}}function yu(o,l,h=2){var u=l&&l.length,c=u?l[0]*h:o.length;let d=xu(o,0,c,h,!0);var f=[];if(d&&d.next!==d.prev){let t,r,i,n,s,a,e;if(u&&(d=function(e,t,r,i){var n,s,a=[];let o,l,h,u,c;for(o=0,l=t.length;o<l;o++)h=t[o]*i,u=o<l-1?t[o+1]*i:e.length,(c=xu(e,h,u,i,!1))===c.next&&(c.steiner=!0),a.push(function(e){let t=e,r=e;for(;(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next,t!==e;);return r}(c));for(a.sort(Tu),o=0;o<a.length;o++)n=a[o],(s=function(r,e){let i=e;var n=r.x,s=r.y;let a,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const r=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(r<=n&&r>o){if((o=r)===n){if(s===i.y)return i;if(s===i.next.y)return i.next}a=i.x<i.next.x?i:i.next}}}while((i=i.next)!==e);if(!a)return null;if(n!==o){var l,h,u=a,c=a.x,d=a.y;let e,t=1/0;for(i=a;n>=i.x&&i.x>=c&&n!==i.x&&Eu(s<d?n:o,s,c,d,s<d?o:n,s,i.x,i.y)&&(e=Math.abs(s-i.y)/(n-i.x),Ru(i,r))&&(e<t||e===t&&(i.x>a.x||i.x===a.x&&(l=a,h=i,m(l.prev,l,h.prev)<0)&&m(h.next,l,l.next)<0))&&(a=i,t=e),(i=i.next)!==u;);}return a}(n,s=r))&&(n=Cu(s,n),_u(s,s.next),_u(n,n.next)),r=_u(r,r.next);return r}(o,l,d,h)),o.length>80*h){t=i=o[0],r=n=o[1];for(let e=h;e<c;e+=h)s=o[e],a=o[e+1],s<t&&(t=s),a<r&&(r=a),s>i&&(i=s),a>n&&(n=a);e=0!==(e=Math.max(i-t,n-r))?1/e:0}bu(d,f,h,t,r,e)}return f}function xu(e,a,t,r,i){let n,s;if(i===0<function(r,i,n){let s=0;for(let e=a,t=i-n;e<i;e+=n)s+=(r[t]-r[e])*(r[e+1]+r[t+1]),t=e;return s}(e,t,r))for(n=a;n<t;n+=r)s=Du(n,e[n],e[n+1],s);else for(n=t-r;n>=a;n-=r)s=Du(n,e[n],e[n+1],s);return s&&wu(s,s.next)&&(Iu(s),s=s.next),s}function _u(e,t){if(!e)return e;t=t||e;let r,i=e;do{if(r=!1,i.steiner||!wu(i,i.next)&&0!==m(i.prev,i,i.next))i=i.next;else{if(Iu(i),(i=t=i.prev)===i.next)break;r=!0}}while(r||i!==t);return t}function bu(i,n,s,a,o,l,h){if(i){if(!h&&l){var u=i;var c=a;var d=o;var f=l;let h=u;for(;null===h.z&&(h.z=Su(h.x,h.y,c,d,f)),h.prevZ=h.prev,h.nextZ=h.next,(h=h.next)!==u;);h.prevZ.nextZ=null,h.prevZ=null;{var p=h;let e,t,r,i,n,s,a,o,l=1;do{for(t=p,p=null,n=null,s=0;t;){for(s++,r=t,a=0,e=0;e<l&&(a++,r=r.nextZ);e++);for(o=l;0<a||0<o&&r;)0!==a&&(0===o||!r||t.z<=r.z)?(t=(i=t).nextZ,a--):(r=(i=r).nextZ,o--),n?n.nextZ=i:p=i,i.prevZ=n,n=i;t=r}}while(n.nextZ=null,l*=2,1<s)}}let e,t,r=i;for(;i.prev!==i.next;)if(e=i.prev,t=i.next,l?function(e,t,r,i){var n=e.prev,s=e,a=e.next;if(0<=m(n,s,a))return;var o=(n.x<s.x?n.x<a.x?n:a:s.x<a.x?s:a).x,l=(n.y<s.y?n.y<a.y?n:a:s.y<a.y?s:a).y,h=(n.x>s.x?n.x>a.x?n:a:s.x>a.x?s:a).x,u=(n.y>s.y?n.y>a.y?n:a:s.y>a.y?s:a).y,c=Su(o,l,t,r,i),d=Su(h,u,t,r,i);let f=e.prevZ,p=e.nextZ;for(;f&&f.z>=c&&p&&p.z<=d;){if(f!==e.prev&&f!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&0<=m(f.prev,f,f.next))return;if(f=f.prevZ,p!==e.prev&&p!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&0<=m(p.prev,p,p.next))return;p=p.nextZ}for(;f&&f.z>=c;){if(f!==e.prev&&f!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,f.x,f.y)&&0<=m(f.prev,f,f.next))return;f=f.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Eu(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&0<=m(p.prev,p,p.next))return;p=p.nextZ}return 1}(i,a,o,l):function(e){var t=e.prev,r=e,i=e.next;if(0<=m(t,r,i))return;let n=e.next.next;for(;n!==e.prev;){if(Eu(t.x,t.y,r.x,r.y,i.x,i.y,n.x,n.y)&&0<=m(n.prev,n,n.next))return;n=n.next}return 1}(i))n.push(e.i/s),n.push(i.i/s),n.push(t.i/s),Iu(i),i=t.next,r=t.next;else if((i=t)===r){h?1===h?bu(i=function(e,t,r){let i=e;do{var n=i.prev,s=i.next.next;!wu(n,s)&&Mu(n,i,i.next,s)&&Ru(n,s)&&Ru(s,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(s.i/r),Iu(i),Iu(i.next),i=e=s),i=i.next}while(i!==e);return _u(i)}(_u(i),n,s),n,s,a,o,l,2):2===h&&function(e,t,r,i,n,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){var o;if(a.i!==e.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Mu(r,r.next,e,t))return 1}while((r=r.next)!==e)}(e,t)&&(Ru(e,t)&&Ru(t,e)&&function(e,t){let r=e,i=!1;for(var n=(e.x+t.x)/2,s=(e.y+t.y)/2;r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),(r=r.next)!==e;);return i}(e,t)&&(m(e.prev,e,t.prev)||m(e,t.prev,t))||wu(e,t)&&0<m(e.prev,e,e.next)&&0<m(t.prev,t,t.next))}(a,e))return o=Cu(a,e),a=_u(a,a.next),o=_u(o,o.next),bu(a,t,r,i,n,s),bu(o,t,r,i,n,s);e=e.next}}while(a=a.next,a!==e)}(i,n,s,a,o,l):bu(_u(i),n,s,a,o,l,1);break}}}function Tu(e,t){return e.x-t.x}function Su(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Eu(e,t,r,i,n,s,a,o){return 0<=(n-a)*(t-o)-(e-a)*(s-o)&&0<=(e-a)*(i-o)-(r-a)*(t-o)&&0<=(r-a)*(s-o)-(n-a)*(i-o)}function m(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function wu(e,t){return e.x===t.x&&e.y===t.y}function Mu(e,t,r,i){var n=Lu(m(e,t,r)),s=Lu(m(e,t,i)),a=Lu(m(r,i,e)),o=Lu(m(r,i,t));return n!==s&&a!==o||0===n&&Au(e,r,t)||0===s&&Au(e,i,t)||0===a&&Au(r,e,i)||0===o&&Au(r,t,i)}function Au(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Lu(e){return 0<e?1:e<0?-1:0}function Ru(e,t){return m(e.prev,e,e.next)<0?0<=m(e,t,e.next)&&0<=m(e,e.prev,t):m(e,t,e.prev)<0||m(e,e.next,t)<0}function Cu(e,t){var r=new Pu(e.i,e.x,e.y),i=new Pu(t.i,t.x,t.y),n=e.next,s=t.prev;return(e.next=t).prev=e,(r.next=n).prev=r,(i.next=r).prev=i,(s.next=i).prev=s,i}function Du(e,t,r,i){e=new Pu(e,t,r);return i?(e.next=i.next,(e.prev=i).next.prev=e,i.next=e):(e.prev=e).next=e,e}function Iu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Pu(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ku{static area(r){var i=r.length;let n=0;for(let e=i-1,t=0;t<i;e=t++)n+=r[e].x*r[t].y-r[t].x*r[e].y;return.5*n}static isClockWise(e){return ku.area(e)<0}static triangulateShape(e,t){var r=[],i=[],n=[];Ou(e),Fu(r,e);let s=e.length;t.forEach(Ou);for(let e=0;e<t.length;e++)i.push(s),s+=t[e].length,Fu(r,t[e]);var a=yu(r,i);for(let e=0;e<a.length;e+=3)n.push(a.slice(e,e+3));return n}}function Ou(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function Fu(t,r){for(let e=0;e<r.length;e++)t.push(r[e].x),t.push(r[e].y)}class Nu extends S{constructor(r=new vu([new z(.5,.5),new z(-.5,.5),new z(-.5,-.5),new z(.5,-.5)]),U={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:r,options:U},r=Array.isArray(r)?r:[r];const B=this,G=[],H=[];for(let e=0,t=r.length;e<t;e++)!function(e){const i=[],F=void 0!==U.curveSegments?U.curveSegments:12,c=void 0!==U.steps?U.steps:1;let r=void 0!==U.depth?U.depth:1,n=void 0===U.bevelEnabled||U.bevelEnabled,t=void 0!==U.bevelThickness?U.bevelThickness:.2,s=void 0!==U.bevelSize?U.bevelSize:t-.1,a=void 0!==U.bevelOffset?U.bevelOffset:0,d=void 0!==U.bevelSegments?U.bevelSegments:3;const o=U.extrudePath,f=void 0!==U.UVGenerator?U.UVGenerator:Uu;void 0!==U.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),r=U.amount);let l,h,u,p,m,g=!1;o&&(l=o.getSpacedPoints(c),g=!0,n=!1,h=o.computeFrenetFrames(c,!1),u=new Pe,p=new Pe,m=new Pe),n||(d=0,t=0,s=0,a=0);e=e.extractPoints(F);let v=e.shape;const y=e.holes;if(!ku.isClockWise(v)){v=v.reverse();for(let e=0,t=y.length;e<t;e++){const U=y[e];ku.isClockWise(U)&&(y[e]=U.reverse())}}const x=ku.triangulateShape(v,y),_=v;for(let e=0,t=y.length;e<t;e++){const U=y[e];v=v.concat(U)}function b(e,t,r){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(r).add(e)}const T=v.length,S=x.length;function E(e,t,r){let i,n,s;const a=e.x-t.x,o=e.y-t.y,l=r.x-e.x,h=r.y-e.y,u=a*a+o*o,c=a*h-o*l;if(Math.abs(c)>Number.EPSILON){const c=Math.sqrt(u),d=Math.sqrt(l*l+h*h),f=t.x-o/c,p=t.y+a/c,m=((r.x-h/d-f)*h-(r.y+l/d-p)*l)/(a*h-o*l);i=f+a*m-e.x,n=p+o*m-e.y;t=i*i+n*n;if(t<=2)return new z(i,n);s=Math.sqrt(t/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),s=e?(i=-o,n=a,Math.sqrt(u)):(i=a,n=o,Math.sqrt(u/2))}return new z(i/s,n/s)}var w=[];for(let e=0,t=_.length,r=t-1,i=e+1;e<t;e++,r++,i++)r===t&&(r=0),i===t&&(i=0),w[e]=E(_[e],_[r],_[i]);var M=[];let A,L=w.concat();for(let e=0,t=y.length;e<t;e++){const U=y[e];A=[];for(let e=0,t=U.length,r=t-1,i=e+1;e<t;e++,r++,i++)r===t&&(r=0),i===t&&(i=0),A[e]=E(U[e],U[r],U[i]);M.push(A),L=L.concat(A)}for(let e=0;e<d;e++){const U=e/d,B=t*Math.cos(U*Math.PI/2),G=s*Math.sin(U*Math.PI/2)+a;for(let e=0,t=_.length;e<t;e++){const U=b(_[e],w[e],G);C(U.x,U.y,-B)}for(let e=0,t=y.length;e<t;e++){const U=y[e];A=M[e];for(let e=0,t=U.length;e<t;e++){const H=b(U[e],A[e],G);C(H.x,H.y,-B)}}}var R=s+a;for(let e=0;e<T;e++){const U=n?b(v[e],L[e],R):v[e];g?(p.copy(h.normals[0]).multiplyScalar(U.x),u.copy(h.binormals[0]).multiplyScalar(U.y),m.copy(l[0]).add(p).add(u),C(m.x,m.y,m.z)):C(U.x,U.y,0)}for(let t=1;t<=c;t++)for(let e=0;e<T;e++){const B=n?b(v[e],L[e],R):v[e];g?(p.copy(h.normals[t]).multiplyScalar(B.x),u.copy(h.binormals[t]).multiplyScalar(B.y),m.copy(l[t]).add(p).add(u),C(m.x,m.y,m.z)):C(B.x,B.y,r/c*t)}for(let e=d-1;0<=e;e--){const U=e/d,B=t*Math.cos(U*Math.PI/2),G=s*Math.sin(U*Math.PI/2)+a;for(let e=0,t=_.length;e<t;e++){const U=b(_[e],w[e],G);C(U.x,U.y,r+B)}for(let e=0,t=y.length;e<t;e++){const U=y[e];A=M[e];for(let e=0,t=U.length;e<t;e++){const H=b(U[e],A[e],G);g?C(H.x,H.y+l[c-1].y,l[c-1].x+B):C(H.x,H.y,r+B)}}}function N(e,i){let n=e.length;for(;0<=--n;){var s=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,t=c+2*d;e<t;e++){const n=T*e,u=T*(e+1);h=l=o=a=void 0;var a=i+s+n,o=i+r+n,l=i+r+u,h=i+s+u;I(a),I(o),I(h),I(o),I(l),I(h),a=G.length/3,P((o=f.generateSideWallUV(B,G,a-6,a-3,a-2,a-1))[0]),P(o[1]),P(o[3]),P(o[1]),P(o[2]),P(o[3])}}}function C(e,t,r){i.push(e),i.push(t),i.push(r)}function D(e,t,r){I(e),I(t),I(r);e=G.length/3,t=f.generateTopUV(B,G,e-3,e-2,e-1);P(t[0]),P(t[1]),P(t[2])}function I(e){G.push(i[3*e+0]),G.push(i[3*e+1]),G.push(i[3*e+2])}function P(e){H.push(e.x),H.push(e.y)}{e=G.length/3;if(n){let e=0,t=0*T;for(let e=0;e<S;e++){const B=x[e];D(B[2]+t,B[1]+t,B[0]+t)}e=c+2*d,t=T*e;for(let e=0;e<S;e++){const B=x[e];D(B[0]+t,B[1]+t,B[2]+t)}}else{for(let e=0;e<S;e++){var k=x[e];D(k[2],k[1],k[0])}for(let e=0;e<S;e++){var O=x[e];D(O[0]+T*c,O[1]+T*c,O[2]+T*c)}}B.addGroup(e,G.length/3-e,0)}{e=G.length/3;let r=0;N(_,r),r+=_.length;for(let e=0,t=y.length;e<t;e++){const B=y[e];N(B,r),r+=B.length}B.addGroup(e,G.length/3-e,1)}}(r[e]);this.setAttribute("position",new V(G,3)),this.setAttribute("uv",new V(H,2)),this.computeVertexNormals()}toJSON(){var e=super.toJSON(),r=this.parameters.shapes,t=this.parameters.options,i=e;if(i.shapes=[],Array.isArray(r))for(let e=0,t=r.length;e<t;e++){var n=r[e];i.shapes.push(n.uuid)}else i.shapes.push(r.uuid);return void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}static fromJSON(r,i){var n=[];for(let e=0,t=r.shapes.length;e<t;e++){var s=i[r.shapes[e]];n.push(s)}var e=r.options.extrudePath;return void 0!==e&&(r.options.extrudePath=(new pu[e.type]).fromJSON(e)),new Nu(n,r.options)}}const Uu={generateTopUV:function(e,t,r,i,n){var s=t[3*r],r=t[3*r+1],a=t[3*i],i=t[3*i+1],o=t[3*n],t=t[3*n+1];return[new z(s,r),new z(a,i),new z(o,t)]},generateSideWallUV:function(e,t,r,i,n,s){var a=t[3*r],o=t[3*r+1],r=t[3*r+2],l=t[3*i],h=t[3*i+1],i=t[3*i+2],u=t[3*n],c=t[3*n+1],n=t[3*n+2],d=t[3*s],f=t[3*s+1],t=t[3*s+2];return Math.abs(o-h)<Math.abs(a-l)?[new z(a,1-r),new z(l,1-i),new z(u,1-n),new z(d,1-t)]:[new z(o,1-r),new z(h,1-i),new z(c,1-n),new z(f,1-t)]}};class Bu extends zh{constructor(e=1,t=0){var r=(1+Math.sqrt(5))/2;super([-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[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],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Bu(e.radius,e.detail)}}class Gu extends S{constructor(r=[new z(0,.5),new z(.5,0),new z(0,-.5)],i=12,n=0,s=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:r,segments:i,phiStart:n,phiLength:s},i=Math.floor(i),s=mi(s,0,2*Math.PI);const a=[],o=[],l=[],h=1/i,u=new Pe,c=new z;for(let t=0;t<=i;t++){var e=n+t*h*s,d=Math.sin(e),f=Math.cos(e);for(let e=0;e<=r.length-1;e++)u.x=r[e].x*d,u.y=r[e].y,u.z=r[e].x*f,o.push(u.x,u.y,u.z),c.x=t/i,c.y=e/(r.length-1),l.push(c.x,c.y)}for(let t=0;t<i;t++)for(let e=0;e<r.length-1;e++){const s=e+t*r.length,o=s,l=s+r.length,h=s+r.length+1,u=s+1;a.push(o,l,u),a.push(l,h,u)}if(this.setIndex(a),this.setAttribute("position",new V(o,3)),this.setAttribute("uv",new V(l,2)),this.computeVertexNormals(),s===2*Math.PI){const n=this.attributes.normal.array,s=new Pe,a=new Pe,o=new Pe,l=i*r.length*3;for(let e=0,t=0;e<r.length;e++,t+=3)s.x=n[t+0],s.y=n[t+1],s.z=n[t+2],a.x=n[l+t+0],a.y=n[l+t+1],a.z=n[l+t+2],o.addVectors(s,a).normalize(),n[t+0]=n[l+t+0]=o.x,n[t+1]=n[l+t+1]=o.y,n[t+2]=n[l+t+2]=o.z}}static fromJSON(e){return new Gu(e.points,e.segments,e.phiStart,e.phiLength)}}class Hu extends zh{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Hu(e.radius,e.detail)}}class zu extends S{constructor(e=.5,t=1,r=8,i=1,n=0,s=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:i,thetaStart:n,thetaLength:s},r=Math.max(3,r);const a=[],o=[],l=[],h=[];let u=e;var c=(t-e)/(i=Math.max(1,i)),d=new Pe,f=new z;for(let e=0;e<=i;e++){for(let e=0;e<=r;e++){const i=n+e/r*s;d.x=u*Math.cos(i),d.y=u*Math.sin(i),o.push(d.x,d.y,d.z),l.push(0,0,1),f.x=(d.x/t+1)/2,f.y=(d.y/t+1)/2,h.push(f.x,f.y)}u+=c}for(let e=0;e<i;e++){const t=e*(r+1);for(let e=0;e<r;e++){const i=e+t,n=i,s=i+r+1,o=i+r+2,l=i+1;a.push(n,s,l),a.push(s,o,l)}}this.setIndex(a),this.setAttribute("position",new V(o,3)),this.setAttribute("normal",new V(l,3)),this.setAttribute("uv",new V(h,2))}static fromJSON(e){return new zu(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Vu extends S{constructor(t=new vu([new z(0,.5),new z(-.5,-.5),new z(.5,-.5)]),a=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:a};const o=[],l=[],h=[],u=[];let r=0,c=0;if(!1===Array.isArray(t))i(t);else for(let e=0;e<t.length;e++)i(t[e]),this.addGroup(r,c,e),r+=c,c=0;function i(e){var r=l.length/3,e=e.extractPoints(a);let i=e.shape;var n=e.holes;!1===ku.isClockWise(i)&&(i=i.reverse());for(let e=0,t=n.length;e<t;e++){const a=n[e];!0===ku.isClockWise(a)&&(n[e]=a.reverse())}var s=ku.triangulateShape(i,n);for(let e=0,t=n.length;e<t;e++){const a=n[e];i=i.concat(a)}for(let e=0,t=i.length;e<t;e++){const a=i[e];l.push(a.x,a.y,0),h.push(0,0,1),u.push(a.x,a.y)}for(let e=0,t=s.length;e<t;e++){const a=s[e],l=a[0]+r,h=a[1]+r,u=a[2]+r;o.push(l,h,u),c+=3}}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}toJSON(){var e=super.toJSON(),r=this.parameters.shapes,i=e;if(i.shapes=[],Array.isArray(r))for(let e=0,t=r.length;e<t;e++){var n=r[e];i.shapes.push(n.uuid)}else i.shapes.push(r.uuid);return i}static fromJSON(r,i){var n=[];for(let e=0,t=r.shapes.length;e<t;e++){var s=i[r.shapes[e]];n.push(s)}return new Vu(n,r.curveSegments)}}class Wu extends S{constructor(r=1,i=32,n=16,s=0,a=2*Math.PI,o=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:r,widthSegments:i,heightSegments:n,phiStart:s,phiLength:a,thetaStart:o,thetaLength:l},i=Math.max(3,Math.floor(i)),n=Math.max(2,Math.floor(n));const h=Math.min(o+l,Math.PI);let u=0;var c=[],d=new Pe,f=new Pe,p=[],m=[],g=[],v=[];for(let e=0;e<=n;e++){var y=[],x=e/n;let t=0;0==e&&0==o?t=.5/i:e==n&&h==Math.PI&&(t=-.5/i);for(let e=0;e<=i;e++){const h=e/i;d.x=-r*Math.cos(s+h*a)*Math.sin(o+x*l),d.y=r*Math.cos(o+x*l),d.z=r*Math.sin(s+h*a)*Math.sin(o+x*l),m.push(d.x,d.y,d.z),f.copy(d).normalize(),g.push(f.x,f.y,f.z),v.push(h+t,1-x),y.push(u++)}c.push(y)}for(let t=0;t<n;t++)for(let e=0;e<i;e++){const i=c[t][e+1],a=c[t][e],l=c[t+1][e],u=c[t+1][e+1];(0!==t||0<o)&&p.push(i,a,u),(t!==n-1||h<Math.PI)&&p.push(a,l,u)}this.setIndex(p),this.setAttribute("position",new V(m,3)),this.setAttribute("normal",new V(g,3)),this.setAttribute("uv",new V(v,2))}static fromJSON(e){return new Wu(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ju extends zh{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ju(e.radius,e.detail)}}class Yu extends S{constructor(r=1,i=.4,n=8,s=6,a=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:r,tube:i,radialSegments:n,tubularSegments:s,arc:a},n=Math.floor(n),s=Math.floor(s);const o=[],l=[],h=[],u=[],c=new Pe,d=new Pe,f=new Pe;for(let t=0;t<=n;t++)for(let e=0;e<=s;e++){var p=e/s*a,m=t/n*Math.PI*2;d.x=(r+i*Math.cos(m))*Math.cos(p),d.y=(r+i*Math.cos(m))*Math.sin(p),d.z=i*Math.sin(m),l.push(d.x,d.y,d.z),c.x=r*Math.cos(p),c.y=r*Math.sin(p),f.subVectors(d,c).normalize(),h.push(f.x,f.y,f.z),u.push(e/s),u.push(t/n)}for(let t=1;t<=n;t++)for(let e=1;e<=s;e++){const n=(s+1)*t+e-1,a=(s+1)*(t-1)+e-1,l=(s+1)*(t-1)+e,h=(s+1)*t+e;o.push(n,a,h),o.push(a,l,h)}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}static fromJSON(e){return new Yu(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class $u extends S{constructor(e=1,r=.4,i=64,n=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:r,tubularSegments:i,radialSegments:n,p:s,q:a},i=Math.floor(i),n=Math.floor(n);const o=[],l=[],h=[],u=[],c=new Pe,d=new Pe,f=new Pe,p=new Pe,m=new Pe,g=new Pe,v=new Pe;for(let t=0;t<=i;++t){var y=t/i*s*Math.PI*2;x(y,s,a,e,f),x(.01+y,s,a,e,p),g.subVectors(p,f),v.addVectors(p,f),m.crossVectors(g,v),v.crossVectors(m,g),m.normalize(),v.normalize();for(let e=0;e<=n;++e){const s=e/n*Math.PI*2,a=-r*Math.cos(s),p=r*Math.sin(s);c.x=f.x+(a*v.x+p*m.x),c.y=f.y+(a*v.y+p*m.y),c.z=f.z+(a*v.z+p*m.z),l.push(c.x,c.y,c.z),d.subVectors(c,f).normalize(),h.push(d.x,d.y,d.z),u.push(t/i),u.push(e/n)}}for(let t=1;t<=i;t++)for(let e=1;e<=n;e++){const i=(n+1)*(t-1)+(e-1),s=(n+1)*t+(e-1),a=(n+1)*t+e,l=(n+1)*(t-1)+e;o.push(i,s,l),o.push(s,a,l)}function x(e,t,r,i,n){var s=Math.cos(e),a=Math.sin(e),r=r/t*e,t=Math.cos(r);n.x=i*(2+t)*.5*s,n.y=i*(2+t)*a*.5,n.z=i*Math.sin(r)*.5}this.setIndex(o),this.setAttribute("position",new V(l,3)),this.setAttribute("normal",new V(h,3)),this.setAttribute("uv",new V(u,2))}static fromJSON(e){return new $u(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class qu extends S{constructor(e=new du(new Pe(-1,-1,0),new Pe(-1,1,0),new Pe(1,1,0)),n=64,s=1,a=8,t=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:n,radius:s,radialSegments:a,closed:t};const o=e.computeFrenetFrames(n,t),l=(this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,new Pe),h=new Pe,r=new z;let u=new Pe;const c=[],d=[],i=[],f=[];function p(t){u=e.getPointAt(t/n,u);var r=o.normals[t],i=o.binormals[t];for(let e=0;e<=a;e++){const n=e/a*Math.PI*2,t=Math.sin(n),o=-Math.cos(n);h.x=o*r.x+t*i.x,h.y=o*r.y+t*i.y,h.z=o*r.z+t*i.z,h.normalize(),d.push(h.x,h.y,h.z),l.x=u.x+s*h.x,l.y=u.y+s*h.y,l.z=u.z+s*h.z,c.push(l.x,l.y,l.z)}}for(let e=0;e<n;e++)p(e);p(!1===t?n:0);for(let t=0;t<=n;t++)for(let e=0;e<=a;e++)r.x=t/n,r.y=e/a,i.push(r.x,r.y);for(let t=1;t<=n;t++)for(let e=1;e<=a;e++){var m=(a+1)*(t-1)+(e-1),g=(a+1)*t+(e-1),v=(a+1)*t+e,y=(a+1)*(t-1)+e;f.push(m,g,y),f.push(g,v,y)}this.setIndex(f),this.setAttribute("position",new V(c,3)),this.setAttribute("normal",new V(d,3)),this.setAttribute("uv",new V(i,2))}toJSON(){var e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new qu((new pu[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Ku extends S{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){var i=[],n=new Set,s=new Pe,a=new Pe;if(null!==e.index){var o=e.attributes.position,l=e.index;let r=e.groups;for(let e=0,t=(r=0===r.length?[{start:0,count:l.count,materialIndex:0}]:r).length;e<t;++e){var h=r[e],u=h.start;for(let t=u,e=u+h.count;t<e;t+=3)for(let e=0;e<3;e++){var c=l.getX(t+e),d=l.getX(t+(e+1)%3);s.fromBufferAttribute(o,c),a.fromBufferAttribute(o,d),!0===Xu(s,a,n)&&(i.push(s.x,s.y,s.z),i.push(a.x,a.y,a.z))}}}else{var r=e.attributes.position;for(let t=0,e=r.count/3;t<e;t++)for(let e=0;e<3;e++){var f=3*t+e,p=3*t+(e+1)%3;s.fromBufferAttribute(r,f),a.fromBufferAttribute(r,p),!0===Xu(s,a,n)&&(i.push(s.x,s.y,s.z),i.push(a.x,a.y,a.z))}}this.setAttribute("position",new V(i,3))}}}function Xu(e,t,r){var i=`${e.x},${e.y},${e.z}-${t.x},${t.y},`+t.z,t=`${t.x},${t.y},${t.z}-${e.x},${e.y},`+e.z;return!0!==r.has(i)&&!0!==r.has(t)&&(r.add(i,t),!0)}var Ju=Object.freeze({__proto__:null,BoxGeometry:ks,BoxBufferGeometry:ks,CircleGeometry:Bh,CircleBufferGeometry:Bh,ConeGeometry:Hh,ConeBufferGeometry:Hh,CylinderGeometry:Gh,CylinderBufferGeometry:Gh,DodecahedronGeometry:Vh,DodecahedronBufferGeometry:Vh,EdgesGeometry:qh,ExtrudeGeometry:Nu,ExtrudeBufferGeometry:Nu,IcosahedronGeometry:Bu,IcosahedronBufferGeometry:Bu,LatheGeometry:Gu,LatheBufferGeometry:Gu,OctahedronGeometry:Hu,OctahedronBufferGeometry:Hu,PlaneGeometry:Zs,PlaneBufferGeometry:Zs,PolyhedronGeometry:zh,PolyhedronBufferGeometry:zh,RingGeometry:zu,RingBufferGeometry:zu,ShapeGeometry:Vu,ShapeBufferGeometry:Vu,SphereGeometry:Wu,SphereBufferGeometry:Wu,TetrahedronGeometry:ju,TetrahedronBufferGeometry:ju,TorusGeometry:Yu,TorusBufferGeometry:Yu,TorusKnotGeometry:$u,TorusKnotBufferGeometry:$u,TubeGeometry:qu,TubeBufferGeometry:qu,WireframeGeometry:Ku});class Zu extends r{constructor(e){super(),this.type="ShadowMaterial",this.color=new g(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}Zu.prototype.isShadowMaterial=!0;class Qu extends r{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new g(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 g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.envMapIntensity=e.envMapIntensity,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}}Qu.prototype.isMeshStandardMaterial=!0;class ec extends Qu{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new z(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return mi(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.sheenColor=new g(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new g(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new g(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){0<this._sheen!=0<e&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){0<this._clearcoat!=0<e&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){0<this._transmission!=0<e&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},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.ior=e.ior,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}}ec.prototype.isMeshPhysicalMaterial=!0;class tc extends r{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new g(16777215),this.specular=new g(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.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}}tc.prototype.isMeshPhongMaterial=!0;class rc extends r{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new g(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(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.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}}rc.prototype.isMeshToonMaterial=!0;class ic extends r{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!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}}ic.prototype.isMeshNormalMaterial=!0;class nc extends r{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new g(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new g(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=O,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",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.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,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}}nc.prototype.isMeshLambertMaterial=!0;class sc extends r{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new g(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=kr,this.normalScale=new z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,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}}sc.prototype.isMeshMatcapMaterial=!0;class ac extends y{constructor(e){super(),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}}ac.prototype.isLineDashedMaterial=!0;var oc=Object.freeze({__proto__:null,ShadowMaterial:Zu,SpriteMaterial:Fl,RawShaderMaterial:oa,ShaderMaterial:Us,PointsMaterial:Lh,MeshPhysicalMaterial:ec,MeshStandardMaterial:Qu,MeshPhongMaterial:tc,MeshToonMaterial:rc,MeshNormalMaterial:ic,MeshLambertMaterial:nc,MeshDepthMaterial:yl,MeshDistanceMaterial:xl,MeshBasicMaterial:Qn,MeshMatcapMaterial:sc,LineDashedMaterial:ac,LineBasicMaterial:y,Material:r});const p={arraySlice:function(e,t,r){return p.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==r?r:e.length)):e.slice(t,r)},convertArray:function(e,t,r){return!e||!r&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(r){var t=r.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort(function(e,t){return r[e]-r[t]}),i},sortedArray:function(r,i,n){const s=r.length,a=new r.constructor(s);for(let e=0,t=0;t!==s;++e){const s=n[e]*i;for(let e=0;e!==i;++e)a[t++]=r[s+e]}return a},flattenJSON:function(t,r,i,n){let s=1,a=t[0];for(;void 0!==a&&void 0===a[n];)a=t[s++];if(void 0!==a){let e=a[n];if(void 0!==e)if(Array.isArray(e))for(;void 0!==(e=a[n])&&(r.push(a.time),i.push.apply(i,e)),void 0!==(a=t[s++]););else if(void 0!==e.toArray)for(;void 0!==(e=a[n])&&(r.push(a.time),e.toArray(i,i.length)),void 0!==(a=t[s++]););else for(;void 0!==(e=a[n])&&(r.push(a.time),i.push(e)),void 0!==(a=t[s++]););}},subclip:function(e,r,i,n,s=30){const a=e.clone();a.name=r;var t=[];for(let e=0;e<a.tracks.length;++e){const r=a.tracks[e],o=r.getValueSize(),l=[],h=[];for(let t=0;t<r.times.length;++t){const a=r.times[t]*s;if(!(a<i||a>=n)){l.push(r.times[t]);for(let e=0;e<o;++e)h.push(r.values[t*o+e])}}0!==l.length&&(r.times=p.convertArray(l,r.times.constructor),r.values=p.convertArray(h,r.values.constructor),t.push(r))}a.tracks=t;let o=1/0;for(let e=0;e<a.tracks.length;++e)o>a.tracks[e].times[0]&&(o=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*o);return a.resetDuration(),a},makeClipAdditive:function(i,n=0,s=i,a=30){const o=s.tracks.length,l=n/(a=a<=0?30:a);for(let e=0;e<o;++e){const a=s.tracks[e],o=a.ValueTypeName;if("bool"!==o&&"string"!==o){var h=i.tracks.find(function(e){return e.name===a.name&&e.ValueTypeName===o});if(void 0!==h){let e=0;var u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(e=u/3);let t=0;var c=h.getValueSize(),d=(h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(t=c/3),a.times.length-1);let r;if(l<=a.times[0]){const i=e,n=u-e;r=p.arraySlice(a.values,i,n)}else if(l>=a.times[d]){const i=d*u+e,n=i+u-e;r=p.arraySlice(a.values,i,n)}else{const i=a.createInterpolant(),n=e,s=u-e;i.evaluate(l),r=p.arraySlice(i.resultBuffer,n,s)}"quaternion"===o&&(new ki).fromArray(r).normalize().conjugate().toArray(r);var f=h.times.length;for(let e=0;e<f;++e){const n=e*c+t;if("quaternion"===o)ki.multiplyQuaternionsFlat(h.values,n,r,0,h.values,n);else{const i=c-2*t;for(let e=0;e<i;++e)h.values[n+e]-=r[e]}}}}}return i.blendMode=br,i}};class lc{constructor(e,t,r,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(r),this.sampleValues=t,this.valueSize=r,this.settings=null,this.DefaultSettings_={}}evaluate(t){var r=this.parameterPositions;let i=this._cachedIndex,n=r[i],s=r[i-1];e:{t:{let e;r:{i:if(!(t<n)){for(var a=i+2;;){if(void 0===n){if(t<s)break i;return i=r.length,this._cachedIndex=i,this.afterEnd_(i-1,t,s)}if(i===a)break;if(s=n,t<(n=r[++i]))break t}e=r.length;break r}if(t>=s)break e;var o=r[1];t<o&&(i=2,s=o);for(var l=i-2;;){if(void 0===s)return this._cachedIndex=0,this.beforeStart_(0,t,n);if(i===l)break;if(n=s,t>=(s=r[--i-1]))break t}e=i,i=0}for(;i<e;){const n=i+e>>>1;t<r[n]?e=n:i=1+n}if(n=r[i],void 0===(s=r[i-1]))return this._cachedIndex=0,this.beforeStart_(0,t,n);if(void 0===n)return i=r.length,this._cachedIndex=i,this.afterEnd_(i-1,s,t)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){var t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i;for(let e=0;e!==i;++e)t[e]=r[n+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}lc.prototype.beforeStart_=lc.prototype.copySampleValue_,lc.prototype.afterEnd_=lc.prototype.copySampleValue_;class hc extends lc{constructor(e,t,r,i){super(e,t,r,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vr,endingEnd:vr}}intervalChanged_(e,t,r){var i=this.parameterPositions;let n=e-2,s=e+1,a=i[n],o=i[s];if(void 0===a)switch(this.getSettings_().endingStart){case yr:n=e,a=2*t-r;break;case xr:n=i.length-2,a=t+i[n]-i[n+1];break;default:n=e,a=r}if(void 0===o)switch(this.getSettings_().endingEnd){case yr:s=e,o=2*r-t;break;case xr:s=1,o=r+i[1]-i[0];break;default:s=e-1,o=t}var l=.5*(r-t),h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-r),this._offsetPrev=n*h,this._offsetNext=s*h}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,e=this._weightPrev,c=this._weightNext,r=(r-t)/(i-t),i=r*r,t=i*r,d=-e*t+2*e*i-e*r,f=(1+e)*t+(-1.5-2*e)*i+(-.5+e)*r+1,p=(-1-c)*t+(1.5+c)*i+.5*r,m=c*t-c*i;for(let e=0;e!==a;++e)n[e]=d*s[h+e]+f*s[l+e]+p*s[o+e]+m*s[u+e];return n}}class uc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(r-t)/(i-t),u=1-h;for(let e=0;e!==a;++e)n[e]=s[l+e]*u+s[o+e]*h;return n}}class cc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class dc{constructor(e,t,r,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=p.convertArray(t,this.TimeBufferType),this.values=p.convertArray(r,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let r;if(t.toJSON!==this.toJSON)r=t.toJSON(e);else{r={name:e.name,times:p.convertArray(e.times,Array),values:p.convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(r.interpolation=t)}return r.type=e.ValueTypeName,r}InterpolantFactoryMethodDiscrete(e){return new cc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hc(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case pr:t=this.InterpolantFactoryMethodDiscrete;break;case mr:t=this.InterpolantFactoryMethodLinear;break;case gr:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrack:",t)}else this.createInterpolant=t;return this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return pr;case this.InterpolantFactoryMethodLinear:return mr;case this.InterpolantFactoryMethodSmooth:return gr}}getValueSize(){return this.values.length/this.times.length}shift(r){if(0!==r){var i=this.times;for(let e=0,t=i.length;e!==t;++e)i[e]+=r}return this}scale(r){if(1!==r){var i=this.times;for(let e=0,t=i.length;e!==t;++e)i[e]*=r}return this}trim(e,t){var r=this.times,i=r.length;let n=0,s=i-1;for(;n!==i&&r[n]<e;)++n;for(;-1!==s&&r[s]>t;)--s;if(++s,0!==n||s!==i){n>=s&&(s=Math.max(s,1),n=s-1);const e=this.getValueSize();this.times=p.arraySlice(r,n,s),this.values=p.arraySlice(this.values,n*e,s*e)}return this}validate(){let r=!0;var e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),r=!1);const i=this.times,n=this.values,t=i.length;0===t&&(console.error("THREE.KeyframeTrack: Track is empty.",this),r=!1);let s=null;for(let e=0;e!==t;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),r=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,s),r=!1;break}s=n}if(void 0!==n&&p.isTypedArray(n))for(let e=0,t=n.length;e!==t;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),r=!1;break}}return r}optimize(){const r=p.arraySlice(this.times),i=p.arraySlice(this.values),n=this.getValueSize(),s=this.getInterpolation()===gr,a=r.length-1;let o=1;for(let e=1;e<a;++e){let t=!1;var l=r[e];if(l!==r[e+1]&&(1!==e||l!==r[0]))if(s)t=!0;else{const r=e*n,s=r-n,o=r+n;for(let e=0;e!==n;++e){const n=i[r+e];if(n!==i[s+e]||n!==i[o+e]){t=!0;break}}}if(t){if(e!==o){r[o]=r[e];const s=e*n,a=o*n;for(let e=0;e!==n;++e)i[a+e]=i[s+e]}++o}}if(0<a){r[o]=r[a];for(let e=a*n,t=o*n,r=0;r!==n;++r)i[t+r]=i[e+r];++o}return o!==r.length?(this.times=p.arraySlice(r,0,o),this.values=p.arraySlice(i,0,o*n)):(this.times=r,this.values=i),this}clone(){var e=p.arraySlice(this.times,0),t=p.arraySlice(this.values,0),e=new this.constructor(this.name,e,t);return e.createInterpolant=this.createInterpolant,e}}dc.prototype.TimeBufferType=Float32Array,dc.prototype.ValueBufferType=Float32Array,dc.prototype.DefaultInterpolation=mr;class fc extends dc{}fc.prototype.ValueTypeName="bool",fc.prototype.ValueBufferType=Array,fc.prototype.DefaultInterpolation=pr,fc.prototype.InterpolantFactoryMethodLinear=void 0,fc.prototype.InterpolantFactoryMethodSmooth=void 0;class pc extends dc{}pc.prototype.ValueTypeName="color";class mc extends dc{}mc.prototype.ValueTypeName="number";class gc extends lc{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){var n=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(r-t)/(i-t);let l=e*a;for(var h=l+a;l!==h;l+=4)ki.slerpFlat(n,0,s,l-a,s,l,o);return n}}class vc extends dc{InterpolantFactoryMethodLinear(e){return new gc(this.times,this.values,this.getValueSize(),e)}}vc.prototype.ValueTypeName="quaternion",vc.prototype.DefaultInterpolation=mr,vc.prototype.InterpolantFactoryMethodSmooth=void 0;class yc extends dc{}yc.prototype.ValueTypeName="string",yc.prototype.ValueBufferType=Array,yc.prototype.DefaultInterpolation=pr,yc.prototype.InterpolantFactoryMethodLinear=void 0,yc.prototype.InterpolantFactoryMethodSmooth=void 0;class xc extends dc{}class _c{constructor(e,t=-1,r,i=_r){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=pi(),this.duration<0&&this.resetDuration()}static parse(e){var r=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,t=i.length;e!==t;++e)r.push(function(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return mc;case"vector":case"vector2":case"vector3":case"vector4":return xc;case"color":return pc;case"quaternion":return vc;case"bool":case"boolean":return fc;case"string":return yc}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],r=[];p.flattenJSON(e.keys,t,r,"value"),e.times=t,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}(i[e]).scale(n));var t=new this(e.name,e.duration,r,e.blendMode);return t.uuid=e.uuid,t}static toJSON(e){var r=[],i=e.tracks,e={name:e.name,duration:e.duration,tracks:r,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,t=i.length;e!==t;++e)r.push(dc.toJSON(i[e]));return e}static CreateFromMorphTargetSequence(e,i,n,s){var a=i.length,o=[];for(let r=0;r<a;r++){let e=[],t=[];e.push((r+a-1)%a,r,(r+1)%a),t.push(0,1,0);var l=p.getKeyframeOrder(e);e=p.sortedArray(e,1,l),t=p.sortedArray(t,1,l),s||0!==e[0]||(e.push(a),t.push(t[0])),o.push(new mc(".morphTargetInfluences["+i[r].name+"]",e,t).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let r=e;if(!Array.isArray(e)){const t=e;r=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<r.length;e++)if(r[e].name===t)return r[e];return null}static CreateClipsFromMorphTargetSequences(r,e,i){var n={},s=/^([\w-]*?)([\d]+)$/;for(let e=0,t=r.length;e<t;e++){const i=r[e],a=i.name.match(s);if(a&&1<a.length){const r=a[1];let e=n[r];e||(n[r]=e=[]),e.push(i)}}const a=[];for(const r in n)a.push(this.CreateFromMorphTargetSequence(r,n[r],e,i));return a}static parseAnimation(r,t){if(!r)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(e,t,r,i,n){var s,a;0!==r.length&&(s=[],a=[],p.flattenJSON(r,s,a,i),0!==s.length)&&n.push(new e(t,s,a))},n=[],s=r.name||"default",a=r.fps||30,e=r.blendMode;let o=r.length||-1;var l=r.hierarchy||[];for(let e=0;e<l.length;e++){const s=l[e].keys;if(s&&0!==s.length)if(s[0].morphTargets){const r={};let t;for(t=0;t<s.length;t++)if(s[t].morphTargets)for(let e=0;e<s[t].morphTargets.length;e++)r[s[t].morphTargets[e]]=-1;for(const i in r){const r=[],a=[];for(let e=0;e!==s[t].morphTargets.length;++e){const n=s[t];r.push(n.time),a.push(n.morphTarget===i?1:0)}n.push(new mc(".morphTargetInfluence["+i+"]",r,a))}o=r.length*(a||1)}else{const a=".bones["+t[e].name+"]";i(xc,a+".position",s,"pos",n),i(vc,a+".quaternion",s,"rot",n),i(xc,a+".scale",s,"scl",n)}}return 0===n.length?null:new this(s,o,n,e)}resetDuration(){let r=0;for(let e=0,t=this.tracks.length;e!==t;++e){var i=this.tracks[e];r=Math.max(r,i.times[i.times.length-1])}return this.duration=r,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){var t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}const bc={enabled:!(xc.prototype.ValueTypeName="vector"),files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class Tc{constructor(e,t,r){const i=this;let n=!1,s=0,a=0,o=void 0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){a++,!1===n&&void 0!==i.onStart&&i.onStart(e,s,a),n=!0},this.itemEnd=function(e){s++,void 0!==i.onProgress&&i.onProgress(e,s,a),s===a&&(n=!1,void 0!==i.onLoad)&&i.onLoad()},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){e=l.indexOf(e);return-1!==e&&l.splice(e,2),this},this.getHandler=function(r){for(let e=0,t=l.length;e<t;e+=2){var i=l[e],n=l[e+1];if(i.global&&(i.lastIndex=0),i.test(r))return n}return null}}}const Sc=new Tc;class Ec{constructor(e){this.manager=void 0!==e?e:Sc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(r,i){const n=this;return new Promise(function(e,t){n.load(r,e,i,t)})}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}}const wc={};class Mc extends Ec{constructor(e){super(e)}load(l,e,t,r){void 0===l&&(l=""),void 0!==this.path&&(l=this.path+l),l=this.manager.resolveURL(l);const i=bc.get(l);if(void 0!==i)return this.manager.itemStart(l),setTimeout(()=>{e&&e(i),this.manager.itemEnd(l)},0),i;void 0!==wc[l]?wc[l].push({onLoad:e,onProgress:t,onError:r}):(wc[l]=[],wc[l].push({onLoad:e,onProgress:t,onError:r}),t=new Request(l,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),fetch(t).then(e=>{if(200!==e.status&&0!==e.status)throw Error(`fetch for "${e.url}" responded with ${e.status}: `+e.statusText);{0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");const s=wc[l],r=e.body.getReader(),t=e.headers.get("Content-Length"),a=t?parseInt(t):0,o=0!==a;let n=0;return new ReadableStream({start(t){!function i(){r.read().then(({done:r,value:e})=>{if(r)t.close();else{n+=e.byteLength;const r=new ProgressEvent("progress",{lengthComputable:o,loaded:n,total:a});for(let e=0,t=s.length;e<t;e++){const i=s[e];i.onProgress&&i.onProgress(r)}t.enqueue(e),i()}})}()}})}}).then(e=>{var t=new Response(e);switch(this.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(e=>(new DOMParser).parseFromString(e,this.mimeType));case"json":return t.json();default:return t.text()}}).then(r=>{bc.add(l,r);var i=wc[l];delete wc[l];for(let e=0,t=i.length;e<t;e++){var n=i[e];n.onLoad&&n.onLoad(r)}this.manager.itemEnd(l)}).catch(r=>{var i=wc[l];delete wc[l];for(let e=0,t=i.length;e<t;e++){var n=i[e];n.onError&&n.onError(r)}this.manager.itemError(l),this.manager.itemEnd(l)}),this.manager.itemStart(l))}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ac extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(t){var r=[];for(let e=0;e<t.length;e++){var i=_c.parse(t[e]);r.push(i)}return r}}class Lc extends Ec{constructor(e){super(e)}load(r,i,n,s){const a=this,o=[],l=new Fh,h=new Mc(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setWithCredentials(a.withCredentials);let u=0;if(Array.isArray(r))for(let e=0,t=r.length;e<t;++e)!function(t){h.load(r[t],function(e){e=a.parse(e,!0);o[t]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(u+=1)&&(1===e.mipmapCount&&(l.minFilter=U),l.image=o,l.format=e.format,l.needsUpdate=!0,i)&&i(l)},n,s)}(e);else h.load(r,function(e){var r=a.parse(e,!0);if(r.isCubemap){const e=r.mipmaps.length/r.mipmapCount;for(let t=0;t<e;t++){o[t]={mipmaps:[]};for(let e=0;e<r.mipmapCount;e++)o[t].mipmaps.push(r.mipmaps[t*r.mipmapCount+e]),o[t].format=r.format,o[t].width=r.width,o[t].height=r.height}l.image=o}else l.image.width=r.width,l.image.height=r.height,l.mipmaps=r.mipmaps;1===r.mipmapCount&&(l.minFilter=U),l.format=r.format,l.needsUpdate=!0,i&&i(l)},n,s);return l}}class Rc extends Ec{constructor(e){super(e)}load(t,e,r,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,s=bc.get(t);if(void 0!==s)return n.manager.itemStart(t),setTimeout(function(){e&&e(s),n.manager.itemEnd(t)},0),s;const a=wi("img");function o(){h(),bc.add(t,this),e&&e(this),n.manager.itemEnd(t)}function l(e){h(),i&&i(e),n.manager.itemError(t),n.manager.itemEnd(t)}function h(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),n.manager.itemStart(t),a.src=t,a}}class Cc extends Ec{constructor(e){super(e)}load(r,i,e,n){const s=new Hs,a=new Rc(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let o=0;for(let e=0;e<r.length;++e)!function(t){a.load(r[t],function(e){s.images[t]=e,6===++o&&(s.needsUpdate=!0,i)&&i(s)},void 0,n)}(e);return s}}class Dc extends Ec{constructor(e){super(e)}load(e,t,r,i){const n=this,s=new lh,a=new Mc(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(n.withCredentials),a.load(e,function(e){e=n.parse(e);e&&(void 0!==e.image?s.image=e.image:void 0!==e.data&&(s.image.width=e.width,s.image.height=e.height,s.image.data=e.data),s.wrapS=void 0!==e.wrapS?e.wrapS:Le,s.wrapT=void 0!==e.wrapT?e.wrapT:Le,s.magFilter=void 0!==e.magFilter?e.magFilter:U,s.minFilter=void 0!==e.minFilter?e.minFilter:U,s.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.encoding&&(s.encoding=e.encoding),void 0!==e.flipY&&(s.flipY=e.flipY),void 0!==e.format&&(s.format=e.format),void 0!==e.type&&(s.type=e.type),void 0!==e.mipmaps&&(s.mipmaps=e.mipmaps,s.minFilter=Ze),1===e.mipmapCount&&(s.minFilter=U),void 0!==e.generateMipmaps&&(s.generateMipmaps=e.generateMipmaps),s.needsUpdate=!0,t)&&t(s,e)},r,i),s}}class Ic extends Ec{constructor(e){super(e)}load(e,t,r,i){const n=new u,s=new Rc(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(e){n.image=e,n.needsUpdate=!0,void 0!==t&&t(n)},r,i),n}}class Pc extends c{constructor(e,t=1){super(),this.type="Light",this.color=new g(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){e=super.toJSON(e);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}Pc.prototype.isLight=!0;class kc extends Pc{constructor(e,t,r){super(e,r),this.type="HemisphereLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.groundColor=new g(t)}copy(e){return Pc.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}kc.prototype.isHemisphereLight=!0;const Oc=new ke,Fc=new Pe,Nc=new Pe;class Uc{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new z(512,512),this.map=null,this.mapPass=null,this.matrix=new ke,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ks,this._frameExtents=new z(1,1),this._viewportCount=1,this._viewports=[new Ie(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){var t=this.camera,r=this.matrix;Fc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Fc),Nc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Nc),t.updateMatrixWorld(),Oc.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Oc),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(t.projectionMatrix),r.multiply(t.matrixWorldInverse)}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(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Bc extends Uc{constructor(){super(new N(50,1,.5,500)),this.focus=1}updateMatrices(e){var t=this.camera,r=2*di*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;r===t.fov&&i===t.aspect&&n===t.far||(t.fov=r,t.aspect=i,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Bc.prototype.isSpotLightShadow=!0;class Gc extends Pc{constructor(e,t,r=0,i=Math.PI/3,n=0,s=1){super(e,t),this.type="SpotLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,this.distance=r,this.angle=i,this.penumbra=n,this.decay=s,this.shadow=new Bc}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),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}}Gc.prototype.isSpotLight=!0;const Hc=new ke,zc=new Pe,Vc=new Pe;class Wc extends Uc{constructor(){super(new N(90,1,.5,500)),this._frameExtents=new z(4,2),this._viewportCount=6,this._viewports=[new Ie(2,1,1,1),new Ie(0,1,1,1),new Ie(3,1,1,1),new Ie(1,1,1,1),new Ie(3,0,1,1),new Ie(1,0,1,1)],this._cubeDirections=[new Pe(1,0,0),new Pe(-1,0,0),new Pe(0,0,1),new Pe(0,0,-1),new Pe(0,1,0),new Pe(0,-1,0)],this._cubeUps=[new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,1,0),new Pe(0,0,1),new Pe(0,0,-1)]}updateMatrices(e,t=0){var r=this.camera,i=this.matrix,n=e.distance||r.far;n!==r.far&&(r.far=n,r.updateProjectionMatrix()),zc.setFromMatrixPosition(e.matrixWorld),r.position.copy(zc),Vc.copy(r.position),Vc.add(this._cubeDirections[t]),r.up.copy(this._cubeUps[t]),r.lookAt(Vc),r.updateMatrixWorld(),i.makeTranslation(-zc.x,-zc.y,-zc.z),Hc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Hc)}}Wc.prototype.isPointLightShadow=!0;class jc extends Pc{constructor(e,t,r=0,i=1){super(e,t),this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new Wc}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}jc.prototype.isPointLight=!0;class Yc extends Uc{constructor(){super(new aa(-5,5,5,-5,.5,500))}}Yc.prototype.isDirectionalLightShadow=!0;class $c extends Pc{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(c.DefaultUp),this.updateMatrix(),this.target=new c,this.shadow=new Yc}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}$c.prototype.isDirectionalLight=!0;class qc extends Pc{constructor(e,t){super(e,t),this.type="AmbientLight"}}qc.prototype.isAmbientLight=!0;class Kc extends Pc{constructor(e,t,r=10,i=10){super(e,t),this.type="RectAreaLight",this.width=r,this.height=i}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){e=super.toJSON(e);return e.object.width=this.width,e.object.height=this.height,e}}Kc.prototype.isRectAreaLight=!0;class Xc{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Pe)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){var r=e.x,i=e.y,e=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.282095),t.addScaledVector(n[1],.488603*i),t.addScaledVector(n[2],.488603*e),t.addScaledVector(n[3],.488603*r),t.addScaledVector(n[4],r*i*1.092548),t.addScaledVector(n[5],i*e*1.092548),t.addScaledVector(n[6],.315392*(3*e*e-1)),t.addScaledVector(n[7],r*e*1.092548),t.addScaledVector(n[8],.546274*(r*r-i*i)),t}getIrradianceAt(e,t){var r=e.x,i=e.y,e=e.z,n=this.coefficients;return t.copy(n[0]).multiplyScalar(.886227),t.addScaledVector(n[1],1.023328*i),t.addScaledVector(n[2],1.023328*e),t.addScaledVector(n[3],1.023328*r),t.addScaledVector(n[4],.858086*r*i),t.addScaledVector(n[5],.858086*i*e),t.addScaledVector(n[6],.743125*e*e-.247708),t.addScaledVector(n[7],.858086*r*e),t.addScaledVector(n[8],.429043*(r*r-i*i)),t}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,r){for(let e=0;e<9;e++)this.coefficients[e].addScaledVector(t.coefficients[e],r);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,r){for(let e=0;e<9;e++)this.coefficients[e].lerp(t.coefficients[e],r);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,r=0){var i=this.coefficients;for(let e=0;e<9;e++)i[e].fromArray(t,r+3*e);return this}toArray(t=[],r=0){var i=this.coefficients;for(let e=0;e<9;e++)i[e].toArray(t,r+3*e);return t}static getBasisAt(e,t){var r=e.x,i=e.y,e=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*e,t[3]=.488603*r,t[4]=1.092548*r*i,t[5]=1.092548*i*e,t[6]=.315392*(3*e*e-1),t[7]=1.092548*r*e,t[8]=.546274*(r*r-i*i)}}Xc.prototype.isSphericalHarmonics3=!0;class Jc extends Pc{constructor(e=new Xc,t=1){super(void 0,t),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){e=super.toJSON(e);return e.object.sh=this.sh.toArray(),e}}Jc.prototype.isLightProbe=!0;class Zc extends Ec{constructor(e){super(e),this.textures={}}load(t,r,e,i){const n=this,s=new Mc(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(t){const r=this.textures;function e(e){return void 0===r[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),r[e]}var i=new oc[t.type];if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&void 0!==i.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.sheen&&(i.sheen=t.sheen),void 0!==t.sheenColor&&(i.sheenColor=(new g).setHex(t.sheenColor)),void 0!==t.sheenRoughness&&(i.sheenRoughness=t.sheenRoughness),void 0!==t.emissive&&void 0!==i.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&void 0!==i.specular&&i.specular.setHex(t.specular),void 0!==t.specularIntensity&&(i.specularIntensity=t.specularIntensity),void 0!==t.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(t.specularColor),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearcoat&&(i.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(i.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.transmission&&(i.transmission=t.transmission),void 0!==t.thickness&&(i.thickness=t.thickness),void 0!==t.attenuationDistance&&(i.attenuationDistance=t.attenuationDistance),void 0!==t.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(t.attenuationColor),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.combine&&(i.combine=t.combine),void 0!==t.side&&(i.side=t.side),void 0!==t.shadowSide&&(i.shadowSide=t.shadowSide),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.format&&(i.format=t.format),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(i.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(i.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(i.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(i.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(i.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(i.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(i.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(i.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),1!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.polygonOffset&&(i.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(i.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(i.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.alphaToCoverage&&(i.alphaToCoverage=t.alphaToCoverage),void 0!==t.premultipliedAlpha&&(i.premultipliedAlpha=t.premultipliedAlpha),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.toneMapped&&(i.toneMapped=t.toneMapped),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?i.vertexColors=0<t.vertexColors:i.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const r in t.uniforms){var n=t.uniforms[r];switch(i.uniforms[r]={},n.type){case"t":i.uniforms[r].value=e(n.value);break;case"c":i.uniforms[r].value=(new g).setHex(n.value);break;case"v2":i.uniforms[r].value=(new z).fromArray(n.value);break;case"v3":i.uniforms[r].value=(new Pe).fromArray(n.value);break;case"v4":i.uniforms[r].value=(new Ie).fromArray(n.value);break;case"m3":i.uniforms[r].value=(new v).fromArray(n.value);break;case"m4":i.uniforms[r].value=(new ke).fromArray(n.value);break;default:i.uniforms[r].value=n.value}}if(void 0!==t.defines&&(i.defines=t.defines),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const r in t.extensions)i.extensions[r]=t.extensions[r];if(void 0!==t.shading&&(i.flatShading=1===t.shading),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=e(t.map)),void 0!==t.matcap&&(i.matcap=e(t.matcap)),void 0!==t.alphaMap&&(i.alphaMap=e(t.alphaMap)),void 0!==t.bumpMap&&(i.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=e(t.normalMap)),void 0!==t.normalMapType&&(i.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),i.normalScale=(new z).fromArray(e)}return void 0!==t.displacementMap&&(i.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=e(t.specularMap)),void 0!==t.specularIntensityMap&&(i.specularIntensityMap=e(t.specularIntensityMap)),void 0!==t.specularColorMap&&(i.specularColorMap=e(t.specularColorMap)),void 0!==t.envMap&&(i.envMap=e(t.envMap)),void 0!==t.envMapIntensity&&(i.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(i.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(i.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=e(t.gradientMap)),void 0!==t.clearcoatMap&&(i.clearcoatMap=e(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=e(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(i.clearcoatNormalMap=e(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(i.clearcoatNormalScale=(new z).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(i.transmissionMap=e(t.transmissionMap)),void 0!==t.thicknessMap&&(i.thicknessMap=e(t.thicknessMap)),void 0!==t.sheenColorMap&&(i.sheenColorMap=e(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(i.sheenRoughnessMap=e(t.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}}class Qc{static decodeText(r){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);let i="";for(let e=0,t=r.length;e<t;e++)i+=String.fromCharCode(r[e]);try{return decodeURIComponent(escape(i))}catch(r){return i}}static extractUrlBase(e){var t=e.lastIndexOf("/");return-1===t?"./":e.substr(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===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)}}class ed extends S{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return(new this.constructor).copy(this)}toJSON(){var e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}ed.prototype.isInstancedBufferGeometry=!0;class td extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(n.manager);s.setPath(n.path),s.setRequestHeader(n.requestHeader),s.setWithCredentials(n.withCredentials),s.load(t,function(e){try{r(n.parse(JSON.parse(e)))}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}parse(r){const n={},s={};function i(e,t){var r,i;return void 0!==n[t]?n[t]:(r=e.interleavedBuffers[t],e=e,i=r.buffer,i=void 0!==s[i]?s[i]:(e=e.arrayBuffers[i],e=new Uint32Array(e).buffer,s[i]=e),e=Ei(r.type,i),(i=new kl(e,r.stride)).uuid=r.uuid,n[t]=i)}const a=new(r.isInstancedBufferGeometry?ed:S),o=r.data.index;if(void 0!==o){const r=Ei(o.type,o.array);a.setIndex(new w(r,1))}var t=r.data.attributes;for(const n in t){const s=t[n];let e;if(s.isInterleavedBufferAttribute){const n=i(r.data,s.data);e=new Ol(n,s.itemSize,s.offset,s.normalized)}else{const r=Ei(s.type,s.array);e=new(s.isInstancedBufferAttribute?dh:w)(r,s.itemSize,s.normalized)}void 0!==s.name&&(e.name=s.name),void 0!==s.usage&&e.setUsage(s.usage),void 0!==s.updateRange&&(e.updateRange.offset=s.updateRange.offset,e.updateRange.count=s.updateRange.count),a.setAttribute(n,e)}var e=r.data.morphAttributes;if(e)for(const n in e){const s=e[n],o=[];for(let t=0,e=s.length;t<e;t++){const a=s[t];let e;if(a.isInterleavedBufferAttribute){const n=i(r.data,a.data);e=new Ol(n,a.itemSize,a.offset,a.normalized)}else{const r=Ei(a.type,a.array);e=new w(r,a.itemSize,a.normalized)}void 0!==a.name&&(e.name=a.name),o.push(e)}a.morphAttributes[n]=o}r.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);var l=r.data.groups||r.data.drawcalls||r.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const n=l[e];a.addGroup(n.start,n.count,n.materialIndex)}var h=r.data.boundingSphere;if(void 0!==h){const r=new Pe;void 0!==h.center&&r.fromArray(h.center),a.boundingSphere=new rn(r,h.radius)}return r.name&&(a.name=r.name),r.userData&&(a.userData=r.userData),a}}class rd extends Ec{constructor(e){super(e)}load(r,i,e,n){const s=this,t=""===this.path?Qc.extractUrlBase(r):this.path;this.resourcePath=this.resourcePath||t;var a=new Mc(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(r,function(e){let t=null;try{t=JSON.parse(e)}catch(e){return void 0!==n&&n(e),void console.error("THREE:ObjectLoader: Can't parse "+r+".",e.message)}e=t.metadata;void 0!==e&&void 0!==e.type&&"geometry"!==e.type.toLowerCase()?s.parse(t,i):console.error("THREE.ObjectLoader: Can't load "+r)},e,n)}async loadAsync(e,t){var r=""===this.path?Qc.extractUrlBase(e):this.path,r=(this.resourcePath=this.resourcePath||r,new Mc(this.manager)),r=(r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),await r.loadAsync(e,t)),t=JSON.parse(r),r=t.metadata;if(void 0===r||void 0===r.type||"geometry"===r.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return this.parseAsync(t)}parse(e,t){const r=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),s=this.parseImages(e.images,function(){void 0!==t&&t(l)}),a=this.parseTextures(e.textures,s),o=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,n,o,a,r),h=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,h),void 0!==t){let e=!1;for(const t in s)if(s[t]instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){var t=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,r),i=await this.parseImagesAsync(e.images),i=this.parseTextures(e.textures,i),n=this.parseMaterials(e.materials,i),r=this.parseObject(e.object,r,n,i,t),n=this.parseSkeletons(e.skeletons,r);return this.bindSkeletons(r,n),r}parseShapes(r){var i={};if(void 0!==r)for(let e=0,t=r.length;e<t;e++){var n=(new vu).fromJSON(r[e]);i[n.uuid]=n}return i}parseSkeletons(r,e){const i={},n={};if(e.traverse(function(e){e.isBone&&(n[e.uuid]=e)}),void 0!==r)for(let e=0,t=r.length;e<t;e++){var s=(new ch).fromJSON(r[e],n);i[s.uuid]=s}return i}parseGeometries(r,i){var n={};if(void 0!==r){var s=new td;for(let t=0,e=r.length;t<e;t++){let e;var a=r[t];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":e=s.parse(a);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:a.type in Ju?e=Ju[a.type].fromJSON(a,i):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${a.type}"`)}e.uuid=a.uuid,void 0!==a.name&&(e.name=a.name),!0===e.isBufferGeometry&&void 0!==a.userData&&(e.userData=a.userData),n[a.uuid]=e}}return n}parseMaterials(r,e){const i={},n={};if(void 0!==r){var s=new Zc;s.setTextures(e);for(let e=0,t=r.length;e<t;e++){var a=r[e];if("MultiMaterial"===a.type){const r=[];for(let e=0;e<a.materials.length;e++){const n=a.materials[e];void 0===i[n.uuid]&&(i[n.uuid]=s.parse(n)),r.push(i[n.uuid])}n[a.uuid]=r}else void 0===i[a.uuid]&&(i[a.uuid]=s.parse(a)),n[a.uuid]=i[a.uuid]}}return n}parseAnimations(t){var r={};if(void 0!==t)for(let e=0;e<t.length;e++){var i=t[e],i=_c.parse(i);r[i.uuid]=i}return r}parseImages(r,i){const n=this,s={};let a;function o(e){var t,r;return"string"==typeof e?(r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:n.resourcePath+t,n.manager.itemStart(r),a.load(r,function(){n.manager.itemEnd(r)},void 0,function(){n.manager.itemError(r),n.manager.itemEnd(r)})):e.data?{data:Ei(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==r&&0<r.length){const n=new Tc(i);(a=new Rc(n)).setCrossOrigin(this.crossOrigin);for(let e=0,t=r.length;e<t;e++){const n=r[e],a=n.url;if(Array.isArray(a)){s[n.uuid]=[];for(let e=0,t=a.length;e<t;e++){const i=o(a[e]);null!==i&&(i instanceof HTMLImageElement?s[n.uuid].push(i):s[n.uuid].push(new lh(i.data,i.width,i.height)))}}else{const r=o(n.url);null!==r&&(s[n.uuid]=r)}}}return s}async parseImagesAsync(r){const i=this,n={};let s;async function a(e){var t;return"string"==typeof e?(t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:i.resourcePath+t,s.loadAsync(t)):e.data?{data:Ei(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==r&&0<r.length){(s=new Rc(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,t=r.length;e<t;e++){const s=r[e],o=s.url;if(Array.isArray(o)){n[s.uuid]=[];for(let e=0,t=o.length;e<t;e++){const i=o[e],l=await a(i);null!==l&&(l instanceof HTMLImageElement?n[s.uuid].push(l):n[s.uuid].push(new lh(l.data,l.width,l.height)))}}else{const r=await a(s.url);null!==r&&(n[s.uuid]=r)}}}return n}parseTextures(r,i){function n(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var s={};if(void 0!==r)for(let t=0,e=r.length;t<e;t++){var a=r[t];let e;void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===i[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);var o=i[a.image];Array.isArray(o)?(e=new Hs(o),6===o.length&&(e.needsUpdate=!0)):(e=o&&o.data?new lh(o.data,o.width,o.height):new u(o),o&&(e.needsUpdate=!0)),e.uuid=a.uuid,void 0!==a.name&&(e.name=a.name),void 0!==a.mapping&&(e.mapping=n(a.mapping,id)),void 0!==a.offset&&e.offset.fromArray(a.offset),void 0!==a.repeat&&e.repeat.fromArray(a.repeat),void 0!==a.center&&e.center.fromArray(a.center),void 0!==a.rotation&&(e.rotation=a.rotation),void 0!==a.wrap&&(e.wrapS=n(a.wrap[0],nd),e.wrapT=n(a.wrap[1],nd)),void 0!==a.format&&(e.format=a.format),void 0!==a.type&&(e.type=a.type),void 0!==a.encoding&&(e.encoding=a.encoding),void 0!==a.minFilter&&(e.minFilter=n(a.minFilter,sd)),void 0!==a.magFilter&&(e.magFilter=n(a.magFilter,sd)),void 0!==a.anisotropy&&(e.anisotropy=a.anisotropy),void 0!==a.flipY&&(e.flipY=a.flipY),void 0!==a.premultiplyAlpha&&(e.premultiplyAlpha=a.premultiplyAlpha),void 0!==a.unpackAlignment&&(e.unpackAlignment=a.unpackAlignment),void 0!==a.userData&&(e.userData=a.userData),s[a.uuid]=e}return s}parseObject(e,t,s,r,i){let n,a,o;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function h(r){if(void 0!==r){if(Array.isArray(r)){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e];void 0===s[n]&&console.warn("THREE.ObjectLoader: Undefined material",n),i.push(s[n])}return i}return void 0===s[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),s[r]}}function u(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":n=new Pl,void 0!==e.background&&(Number.isInteger(e.background)?n.background=new g(e.background):n.background=u(e.background)),void 0!==e.environment&&(n.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?n.fog=new Il(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(n.fog=new Dl(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":n=new N(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(n.focus=e.focus),void 0!==e.zoom&&(n.zoom=e.zoom),void 0!==e.filmGauge&&(n.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(n.filmOffset=e.filmOffset),void 0!==e.view&&(n.view=Object.assign({},e.view));break;case"OrthographicCamera":n=new aa(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(n.zoom=e.zoom),void 0!==e.view&&(n.view=Object.assign({},e.view));break;case"AmbientLight":n=new qc(e.color,e.intensity);break;case"DirectionalLight":n=new $c(e.color,e.intensity);break;case"PointLight":n=new jc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":n=new Kc(e.color,e.intensity,e.width,e.height);break;case"SpotLight":n=new Gc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":n=new kc(e.color,e.groundColor,e.intensity);break;case"LightProbe":n=(new Jc).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),o=h(e.material),n=new ah(a,o),void 0!==e.bindMode&&(n.bindMode=e.bindMode),void 0!==e.bindMatrix&&n.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(n.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),o=h(e.material),n=new E(a,o);break;case"InstancedMesh":a=l(e.geometry),o=h(e.material);const t=e.count,s=e.instanceMatrix,r=e.instanceColor;(n=new vh(a,o,t)).instanceMatrix=new dh(new Float32Array(s.array),16),void 0!==r&&(n.instanceColor=new dh(new Float32Array(r.array),r.itemSize));break;case"LOD":n=new eh;break;case"Line":n=new Sh(l(e.geometry),h(e.material));break;case"LineLoop":n=new Ah(l(e.geometry),h(e.material));break;case"LineSegments":n=new Mh(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":n=new Ph(l(e.geometry),h(e.material));break;case"Sprite":n=new Xl(h(e.material));break;case"Group":n=new wl;break;case"Bone":n=new oh;break;default:n=new c}if(n.uuid=e.uuid,void 0!==e.name&&(n.name=e.name),void 0!==e.matrix?(n.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==e.position&&n.position.fromArray(e.position),void 0!==e.rotation&&n.rotation.fromArray(e.rotation),void 0!==e.quaternion&&n.quaternion.fromArray(e.quaternion),void 0!==e.scale&&n.scale.fromArray(e.scale)),void 0!==e.castShadow&&(n.castShadow=e.castShadow),void 0!==e.receiveShadow&&(n.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(n.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(n.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(n.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&n.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera)&&(n.shadow.camera=this.parseObject(e.shadow.camera)),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.frustumCulled&&(n.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(n.renderOrder=e.renderOrder),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.layers&&(n.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)n.add(this.parseObject(a[e],t,s,r,i))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const s=t[e];n.animations.push(i[s])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(n.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const s=t[e],r=n.getObjectByProperty("uuid",s.object);void 0!==r&&n.addLevel(r,s.distance)}}return n}bindSkeletons(e,r){0!==Object.keys(r).length&&e.traverse(function(e){var t;!0===e.isSkinnedMesh&&void 0!==e.skeleton&&(void 0===(t=r[e.skeleton])?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(t,e.bindMatrix))})}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}const id={UVMapping:Me,CubeReflectionMapping:Ue,CubeRefractionMapping:Be,EquirectangularReflectionMapping:Ge,EquirectangularRefractionMapping:He,CubeUVReflectionMapping:ze,CubeUVRefractionMapping:Ve},nd={RepeatWrapping:We,ClampToEdgeWrapping:Le,MirroredRepeatWrapping:je},sd={NearestFilter:Re,NearestMipmapNearestFilter:Ye,NearestMipmapLinearFilter:qe,LinearFilter:U,LinearMipmapNearestFilter:Xe,LinearMipmapLinearFilter:Ze};class ad extends Ec{constructor(e){super(e),"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(t,r,e,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const n=this,s=bc.get(t);if(void 0!==s)return n.manager.itemStart(t),setTimeout(function(){r&&r(s),n.manager.itemEnd(t)},0),s;var a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(t,a).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(e){bc.add(t,e),r&&r(e),n.manager.itemEnd(t)}).catch(function(e){i&&i(e),n.manager.itemError(t),n.manager.itemEnd(t)}),n.manager.itemStart(t)}}let od;ad.prototype.isImageBitmapLoader=!0;const ld={getContext:function(){return od=void 0===od?new(window.AudioContext||window.webkitAudioContext):od},setContext:function(e){od=e}};class hd extends Ec{constructor(e){super(e)}load(t,r,e,i){const n=this,s=new Mc(this.manager);s.setResponseType("arraybuffer"),s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(t,function(e){try{const t=e.slice(0);ld.getContext().decodeAudioData(t,function(e){r(e)})}catch(e){i?i(e):console.error(e),n.manager.itemError(t)}},e,i)}}class ud extends Jc{constructor(e,t,r=1){super(void 0,r);var r=(new g).set(e),e=(new g).set(t),t=new Pe(r.r,r.g,r.b),r=new Pe(e.r,e.g,e.b),e=Math.sqrt(Math.PI),i=e*Math.sqrt(.75);this.sh.coefficients[0].copy(t).add(r).multiplyScalar(e),this.sh.coefficients[1].copy(t).sub(r).multiplyScalar(i)}}ud.prototype.isHemisphereLightProbe=!0;class cd extends Jc{constructor(e,t=1){super(void 0,t);t=(new g).set(e);this.sh.coefficients[0].set(t.r,t.g,t.b).multiplyScalar(2*Math.sqrt(Math.PI))}}cd.prototype.isAmbientLightProbe=!0;const dd=new ke,fd=new ke;class pd{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new N,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new N,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){var t,r,i,n,s,a=this._cache;a.focus===e.focus&&a.fov===e.fov&&a.aspect===e.aspect*this.aspect&&a.near===e.near&&a.far===e.far&&a.zoom===e.zoom&&a.eyeSep===this.eyeSep||(a.focus=e.focus,a.fov=e.fov,a.aspect=e.aspect*this.aspect,a.near=e.near,a.far=e.far,a.zoom=e.zoom,a.eyeSep=this.eyeSep,t=e.projectionMatrix.clone(),r=(n=a.eyeSep/2)*a.near/a.focus,i=a.near*Math.tan(ci*a.fov*.5)/a.zoom,fd.elements[12]=-n,dd.elements[12]=n,n=-i*a.aspect+r,s=i*a.aspect+r,t.elements[0]=2*a.near/(s-n),t.elements[8]=(s+n)/(s-n),this.cameraL.projectionMatrix.copy(t),n=-i*a.aspect-r,s=i*a.aspect-r,t.elements[0]=2*a.near/(s-n),t.elements[8]=(s+n)/(s-n),this.cameraR.projectionMatrix.copy(t)),this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fd),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(dd)}}class md{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gd(),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;var t;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(t=gd(),e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e),e)}}function gd(){return("undefined"==typeof performance?Date:performance).now()}const vd=new Pe,yd=new ki,xd=new Pe,_d=new Pe;class bd extends c{constructor(){super(),this.type="AudioListener",this.context=ld.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new md}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(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(null!==this.filter?(this.gain.disconnect(this.filter),this.filter):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);var t=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(vd,yd,xd),_d.set(0,0,-1).applyQuaternion(yd),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(vd.x,e),t.positionY.linearRampToValueAtTime(vd.y,e),t.positionZ.linearRampToValueAtTime(vd.z,e),t.forwardX.linearRampToValueAtTime(_d.x,e),t.forwardY.linearRampToValueAtTime(_d.y,e),t.forwardZ.linearRampToValueAtTime(_d.z,e),t.upX.linearRampToValueAtTime(r.x,e),t.upY.linearRampToValueAtTime(r.y,e),t.upZ.linearRampToValueAtTime(r.z,e)}else t.setPosition(vd.x,vd.y,vd.z),t.setOrientation(_d.x,_d.y,_d.z,r.x,r.y,r.z)}}class Td extends c{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(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else{if(!1!==this.hasPlaybackControl)return this._startedAt=this.context.currentTime+e,(e=this.context.createBufferSource()).buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect();console.warn("THREE.Audio: this Audio has no playback control.")}}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(0<this.filters.length){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(0<this.filters.length){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||[],!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&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(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}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}}const Sd=new Pe,Ed=new ki,wd=new Pe,Md=new Pe;class Ad extends Td{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(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,r){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=r,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0!==this.hasPlaybackControl||!1!==this.isPlaying){this.matrixWorld.decompose(Sd,Ed,wd),Md.set(0,0,1).applyQuaternion(Ed);var t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Sd.x,e),t.positionY.linearRampToValueAtTime(Sd.y,e),t.positionZ.linearRampToValueAtTime(Sd.z,e),t.orientationX.linearRampToValueAtTime(Md.x,e),t.orientationY.linearRampToValueAtTime(Md.y,e),t.orientationZ.linearRampToValueAtTime(Md.z,e)}else t.setPosition(Sd.x,Sd.y,Sd.z),t.setOrientation(Md.x,Md.y,Md.z)}}}class Ld{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 t=0;var r=this.getFrequencyData();for(let e=0;e<r.length;e++)t+=r[e];return t/r.length}}class Rd{constructor(e,t,r){let i,n,s;switch(this.binding=e,this.valueSize=r,t){case"quaternion":i=this._slerp,n=this._slerpAdditive,s=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*r),this._workIndex=5;break;case"string":case"bool":i=this._select,n=this._select,s=this._setAdditiveIdentityOther,this.buffer=new Array(5*r);break;default:i=this._lerp,n=this._lerpAdditive,s=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*r)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=n,this._setIdentity=s,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){var r=this.buffer,i=this.valueSize,n=e*i+i;let s=this.cumulativeWeight;if(0===s){for(let e=0;e!==i;++e)r[n+e]=r[e];s=t}else{const e=t/(s+=t);this._mixBufferRegion(r,n,0,e,i)}this.cumulativeWeight=s}accumulateAdditive(e){var t=this.buffer,r=this.valueSize,i=r*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,r),this.cumulativeWeightAdditive+=e}apply(e){var r=this.valueSize,i=this.buffer,n=e*r+r,t=this.cumulativeWeight,e=this.cumulativeWeightAdditive,s=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,t<1){const e=r*this._origIndex;this._mixBufferRegion(i,n,e,1-t,r)}0<e&&this._mixBufferRegionAdditive(i,n,this._addIndex*r,1,r);for(let e=r,t=r+r;e!==t;++e)if(i[e]!==i[e+r]){s.setValue(i,n);break}}saveOriginalState(){var e=this.binding,r=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(r,n);for(let e=i,t=n;e!==t;++e)r[e]=r[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){var t=this._addIndex*this.valueSize,r=t+this.valueSize;for(let e=t;e<r;e++)this.buffer[e]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){var t=this._origIndex*this.valueSize,r=this._addIndex*this.valueSize;for(let e=0;e<this.valueSize;e++)this.buffer[r+e]=this.buffer[t+e]}_select(t,r,i,e,n){if(.5<=e)for(let e=0;e!==n;++e)t[r+e]=t[i+e]}_slerp(e,t,r,i){ki.slerpFlat(e,t,e,t,e,r,i)}_slerpAdditive(e,t,r,i,n){n=this._workIndex*n;ki.multiplyQuaternionsFlat(e,n,e,t,e,r),ki.slerpFlat(e,t,e,t,e,n,i)}_lerp(t,r,i,n,s){var a=1-n;for(let e=0;e!==s;++e){const s=r+e;t[s]=t[s]*a+t[i+e]*n}}_lerpAdditive(t,r,i,n,s){for(let e=0;e!==s;++e){const s=r+e;t[s]=t[s]+t[i+e]*n}}}const Cd=new RegExp("[\\[\\]\\.:\\/]","g"),Dd="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Id=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Pd=/(WCOD+)?/.source.replace("WCOD",Dd),kd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Od=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Fd=new RegExp("^"+Id+Pd+kd+Od+"$"),Nd=["material","materials","bones"];class x{constructor(e,t,r){this.path=t,this.parsedPath=r||x.parseTrackName(t),this.node=x.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return new(e&&e.isAnimationObjectGroup?x.Composite:x)(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Cd,"")}static parseTrackName(e){var t=Fd.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var t={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=t.nodeName&&t.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const e=t.nodeName.substring(r+1);-1!==Nd.indexOf(e)&&(t.nodeName=t.nodeName.substring(0,r),t.objectName=e)}if(null===t.propertyName||0===t.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return t}static findNode(e,i){if(!i||""===i||"."===i||-1===i||i===e.name||i===e.uuid)return e;if(e.skeleton){var t=e.skeleton.getBoneByName(i);if(void 0!==t)return t}if(e.children){const n=function(t){for(let e=0;e<t.length;e++){var r=t[e];if(r.name===i||r.uuid===i)return r;r=n(r.children);if(r)return r}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)r[i++]=n[e]}_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(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++]}_setValue_array_setNeedsUpdate(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(r,i){var n=this.resolvedProperty;for(let e=0,t=n.length;e!==t;++e)n[e]=r[i++];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 r=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(r||(r=x.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=r),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,r){if(i){let t=e.objectIndex;switch(i){case"materials":if(!r.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!r.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);r=r.material.materials;break;case"bones":if(!r.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);r=r.skeleton.bones;for(let e=0;e<r.length;e++)if(r[e].name===t){t=e;break}break;default:if(void 0===r[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);r=r[i]}if(void 0!==t){if(void 0===r[t])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,r);r=r[t]}}var a=r[n];if(void 0===a){const i=e.nodeName;void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",r)}else{let e=this.Versioning.None,t=(void 0!==(this.targetObject=r).needsUpdate?e=this.Versioning.NeedsUpdate:void 0!==r.matrixWorldNeedsUpdate&&(e=this.Versioning.MatrixWorldNeedsUpdate),this.BindingType.Direct);if(void 0!==s){if("morphTargetInfluences"===n){if(!r.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!r.geometry.isBufferGeometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);if(!r.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==r.morphTargetDictionary[s]&&(s=r.morphTargetDictionary[s])}t=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else void 0!==a.fromArray&&void 0!==a.toArray?(t=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(t=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[t],this.setValue=this.SetterByBindingTypeAndVersioning[t][e]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}x.Composite=class{constructor(e,t,r){r=r||x.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();var r=this._targetGroup.nCachedObjects_,r=this._bindings[r];void 0!==r&&r.getValue(e,t)}setValue(r,i){var n=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=n.length;e!==t;++e)n[e].setValue(r,i)}bind(){var r=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=r.length;e!==t;++e)r[e].bind()}unbind(){var r=this._bindings;for(let e=this._targetGroup.nCachedObjects_,t=r.length;e!==t;++e)r[e].unbind()}},x.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},x.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},x.prototype.GetterByBindingType=[x.prototype._getValue_direct,x.prototype._getValue_array,x.prototype._getValue_arrayElement,x.prototype._getValue_toArray],x.prototype.SetterByBindingTypeAndVersioning=[[x.prototype._setValue_direct,x.prototype._setValue_direct_setNeedsUpdate,x.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[x.prototype._setValue_array,x.prototype._setValue_array_setNeedsUpdate,x.prototype._setValue_array_setMatrixWorldNeedsUpdate],[x.prototype._setValue_arrayElement,x.prototype._setValue_arrayElement_setNeedsUpdate,x.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[x.prototype._setValue_fromArray,x.prototype._setValue_fromArray_setNeedsUpdate,x.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Ud{constructor(){this.uuid=pi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var r={};this._indicesByUUID=r;for(let e=0,t=arguments.length;e!==t;++e)r[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){const i=this._objects,n=this._indicesByUUID,s=this._paths,a=this._parsedPaths,o=this._bindings,l=o.length;let h=void 0,u=i.length,c=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var d=arguments[e],f=d.uuid;let r=n[f];if(void 0===r){r=u++,n[f]=r,i.push(d);for(let e=0,t=l;e!==t;++e)o[e].push(new x(d,s[e],a[e]))}else if(r<c){h=i[r];const u=--c,p=i[u];n[p.uuid]=r,i[r]=p,n[f]=u,i[u]=d;for(let t=0,e=l;t!==e;++t){const n=o[t],l=n[u];let e=n[r];n[r]=l,void 0===e&&(e=new x(d,s[t],a[t])),n[u]=e}}else i[r]!==h&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const r=this._objects,i=this._indicesByUUID,n=this._bindings,s=n.length;let a=this.nCachedObjects_;for(let e=0,t=arguments.length;e!==t;++e){var o=arguments[e],l=o.uuid,h=i[l];if(void 0!==h&&h>=a){var u=a++,c=r[u];i[c.uuid]=h,r[h]=c,i[l]=u,r[u]=o;for(let e=0,t=s;e!==t;++e){const i=n[e],s=i[u],a=i[h];i[h]=s,i[u]=a}}}this.nCachedObjects_=a}uncache(){const r=this._objects,i=this._indicesByUUID,n=this._bindings,s=n.length;let a=this.nCachedObjects_,o=r.length;for(let e=0,t=arguments.length;e!==t;++e){var l=arguments[e].uuid,h=i[l];if(void 0!==h)if(delete i[l],h<a){var u=--a,l=r[u],c=--o,d=r[c];i[l.uuid]=h,r[h]=l,i[d.uuid]=u,r[u]=d,r.pop();for(let e=0,t=s;e!==t;++e){const i=n[e],s=i[u],a=i[c];i[h]=s,i[u]=a,i.pop()}}else{const a=--o,f=r[a];0<a&&(i[f.uuid]=h),r[h]=f,r.pop();for(let e=0,t=s;e!==t;++e){const i=n[e];i[h]=i[a],i.pop()}}}this.nCachedObjects_=a}subscribe_(r,i){var e=this._bindingsIndicesByPath;let n=e[r];var t=this._bindings;if(void 0!==n)return t[n];var s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,u=new Array(l);n=t.length,e[r]=n,s.push(r),a.push(i),t.push(u);for(let e=h,t=o.length;e!==t;++e){const n=o[e];u[e]=new x(n,r,i)}return u}unsubscribe_(e){var t,r,i,n,s,a=this._bindingsIndicesByPath,o=a[e];void 0!==o&&(t=this._paths,r=this._parsedPaths,s=(i=this._bindings)[n=i.length-1],i[a[e[n]]=o]=s,i.pop(),r[o]=r[n],r.pop(),t[o]=t[n],t.pop())}}Ud.prototype.isAnimationObjectGroup=!0;class Bd{constructor(e,t,r=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=i;var n=t.tracks,s=n.length,a=new Array(s),o={endingStart:vr,endingEnd:vr};for(let e=0;e!==s;++e){const t=n[e].createInterpolant(null);(a[e]=t).settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(s),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=dr,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&&0!==this.timeScale&&null===this._startTime&&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,r){if(e.fadeOut(t),this.fadeIn(t),r){const r=this._clip.duration,i=e._clip.duration,n=i/r,s=r/i;e.warp(1,n,t),this.warp(s,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}stopFading(){var e=this._weightInterpolant;return null!==e&&(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,r){var i=this._mixer,n=i.time,s=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);var i=a.parameterPositions,o=a.sampleValues;return i[0]=n,i[1]=n+r,o[0]=e/s,o[1]=t/s,this}stopWarping(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(r,i,e,n){if(this.enabled){var t=this._startTime;if(null!==t){const n=(r-t)*e;if(n<0||0===e)return;this._startTime=null,i=e*n}i*=this._updateTimeScale(r);var s=this._updateTime(i),a=this._updateWeight(r);if(0<a){const r=this._interpolants,i=this._propertyBindings;if(this.blendMode===br)for(let e=0,t=r.length;e!==t;++e)r[e].evaluate(s),i[e].accumulateAdditive(a);else{_r;for(let e=0,t=r.length;e!==t;++e)r[e].evaluate(s),i[e].accumulate(n,a)}}}else this._updateWeight(r)}_updateWeight(e){let t=0;var r,i;return this.enabled&&(t=this.weight,null!==(r=this._weightInterpolant))&&(i=r.evaluate(e)[0],t*=i,e>r.parameterPositions[1])&&(this.stopFading(),0===i)&&(this.enabled=!1),this._effectiveWeight=t}_updateTimeScale(e){let t=0;var r;return this.paused||(t=this.timeScale,null!==(r=this._timeScaleInterpolant)&&(t*=r.evaluate(e)[0],e>r.parameterPositions[1])&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)),this._effectiveTimeScale=t}_updateTime(e){const t=this._clip.duration,r=this.loop;let i=this.time+e,n=this._loopCount;var s=r===fr;if(0===e)return-1!==n&&s&&1==(1&n)?t-i:i;if(r===cr){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===n&&(0<=e?(n=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const r=Math.floor(i/t);i-=t*r,n+=Math.abs(r);var a=this.repetitions-n;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=0<e?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<e?1:-1});else{if(1==a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=n,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:r})}}else this.time=i;if(s&&1==(1&n))return t-i}return i}_setEndings(e,t,r){var i=this._interpolantSettings;r?(i.endingStart=yr,i.endingEnd=yr):(i.endingStart=e?this.zeroSlopeAtStart?yr:vr:xr,i.endingEnd=t?this.zeroSlopeAtEnd?yr:vr:xr)}_scheduleFading(e,t,r){var i=this._mixer,n=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);var i=s.parameterPositions,a=s.sampleValues;return i[0]=n,a[0]=t,i[1]=n+e,a[1]=r,this}}class Gd extends hi{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,r){const i=e._localRoot||this._root,n=e._clip.tracks,s=n.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,h=this._bindingsByRootAndName;let u=h[l];void 0===u&&(u={},h[l]=u);for(let t=0;t!==s;++t){const s=n[t],h=s.name;let e=u[h];if(void 0===e){if(void 0!==(e=a[t])){null===e._cacheIndex&&(++e.referenceCount,this._addInactiveBinding(e,l,h));continue}const n=r&&r._propertyBindings[t].binding.parsedPath;++(e=new Rd(x.create(i,h,n),s.ValueTypeName,s.getValueSize())).referenceCount,this._addInactiveBinding(e,l,h)}a[t]=e,o[t].resultBuffer=e.buffer}}_activateAction(e){if(!this._isActiveAction(e)){null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,r=e._clip.uuid,i=this._actionsByClip[r],this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,r,t));var t,r,i,n=e._propertyBindings;for(let e=0,t=n.length;e!==t;++e){var s=n[e];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){var r=e._propertyBindings;for(let e=0,t=r.length;e!==t;++e){var i=r[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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){e=e._cacheIndex;return null!==e&&e<this._nActiveActions}_addInactiveAction(e,t,r){var i=this._actions,n=this._actionsByClip;let s=n[t];if(void 0===s)s={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=s;else{const t=s.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),s.actionByRoot[r]=e}_removeInactiveAction(e){var t=this._actions,r=t[t.length-1],i=e._cacheIndex,i=(t[r._cacheIndex=i]=r,t.pop(),e._cacheIndex=null,e._clip.uuid),r=this._actionsByClip,t=r[i],n=t.knownActions,s=n[n.length-1],a=e._byClipCacheIndex;n[s._byClipCacheIndex=a]=s,n.pop(),e._byClipCacheIndex=null,delete t.actionByRoot[(e._localRoot||this._root).uuid],0===n.length&&delete r[i],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){var r=e._propertyBindings;for(let e=0,t=r.length;e!==t;++e){var i=r[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){var t=this._actions,r=e._cacheIndex,i=this._nActiveActions++,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_takeBackAction(e){var t=this._actions,r=e._cacheIndex,i=--this._nActiveActions,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_addInactiveBinding(e,t,r){var i=this._bindingsByRootAndName,n=this._bindings;let s=i[t];void 0===s&&(s={},i[t]=s),(s[r]=e)._cacheIndex=n.length,n.push(e)}_removeInactiveBinding(e){var t=this._bindings,r=e.binding,i=r.rootNode.uuid,r=r.path,n=this._bindingsByRootAndName,s=n[i],a=t[t.length-1],e=e._cacheIndex;t[a._cacheIndex=e]=a,t.pop(),delete s[r],0===Object.keys(s).length&&delete n[i]}_lendBinding(e){var t=this._bindings,r=e._cacheIndex,i=this._nActiveBindings++,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_takeBackBinding(e){var t=this._bindings,r=e._cacheIndex,i=--this._nActiveBindings,n=t[i];t[e._cacheIndex=i]=e,t[n._cacheIndex=r]=n}_lendControlInterpolant(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let r=e[t];return void 0===r&&(e[(r=new uc(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=t]=r),r}_takeBackControlInterpolant(e){var t=this._controlInterpolants,r=e.__cacheIndex,i=--this._nActiveControlInterpolants,n=t[i];t[e.__cacheIndex=i]=e,t[n.__cacheIndex=r]=n}clipAction(e,t,r){var i=t||this._root,n=i.uuid;let s="string"==typeof e?_c.findByName(i,e):e;var i=null!==s?s.uuid:e,a=this._actionsByClip[i];let o=null;if(void 0===r&&(r=null!==s?s.blendMode:_r),void 0!==a){const e=a.actionByRoot[n];if(void 0!==e&&e.blendMode===r)return e;o=a.knownActions[0],null===s&&(s=o._clip)}return null===s?null:(e=new Bd(this,s,t,r),this._bindAction(e,o),this._addInactiveAction(e,i,n),e)}existingAction(e,t){var t=t||this._root,r=t.uuid,t="string"==typeof e?_c.findByName(t,e):e,t=t?t.uuid:e,e=this._actionsByClip[t];return void 0!==e&&e.actionByRoot[r]||null}stopAllAction(){var t=this._actions;for(let e=this._nActiveActions-1;0<=e;--e)t[e].stop();return this}update(t){t*=this.timeScale;var r=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let e=0;e!==i;++e)r[e]._update(n,t,s,a);var o=this._bindings,l=this._nActiveBindings;for(let e=0;e!==l;++e)o[e].apply(a);return this}setTime(e){for(let e=this.time=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(r){const i=this._actions,e=r.uuid,n=this._actionsByClip,s=n[e];if(void 0!==s){const r=s.knownActions;for(let e=0,t=r.length;e!==t;++e){const n=r[e],s=(this._deactivateAction(n),n._cacheIndex),a=i[i.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,a._cacheIndex=s,i[s]=a,i.pop(),this._removeInactiveBindingsForAction(n)}delete n[e]}}uncacheRoot(e){const t=e.uuid,r=this._actionsByClip;for(const e in r){const i=r[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){e=this.existingAction(e,t);null!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}}Gd.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Hd{constructor(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Hd(void 0===this.value.clone?this.value:this.value.clone())}}class zd extends kl{constructor(e,t,r=1){super(e,t),this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){e=super.clone(e);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(e){e=super.toJSON(e);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}zd.prototype.isInstancedInterleavedBuffer=!0;class Vd{constructor(e,t,r,i,n){this.buffer=e,this.type=t,this.itemSize=r,this.elementSize=i,this.count=n,this.version=0}set needsUpdate(e){!0===e&&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}}Vd.prototype.isGLBufferAttribute=!0;class Wd{constructor(e,t,r=0,i=1/0){this.ray=new cn(e,t),this.near=r,this.far=i,this.camera=null,this.layers=new Tn,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){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&&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)}intersectObject(e,t=!0,r=[]){return Yd(e,this,r,t),r.sort(jd),r}intersectObjects(r,i=!0,n=[]){for(let e=0,t=r.length;e<t;e++)Yd(r[e],this,n,i);return n.sort(jd),n}}function jd(e,t){return e.distance-t.distance}function Yd(e,r,i,n){if(e.layers.test(r.layers)&&e.raycast(r,i),!0===n){const n=e.children;for(let e=0,t=n.length;e<t;e++)Yd(n[e],r,i,!0)}}class $d{constructor(e=1,t=0,r=0){return this.radius=e,this.phi=t,this.theta=r,this}set(e,t,r){return this.radius=e,this.phi=t,this.theta=r,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,r){return this.radius=Math.sqrt(e*e+t*t+r*r),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(mi(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class qd{constructor(e=1,t=0,r=0){return this.radius=e,this.theta=t,this.y=r,this}set(e,t,r){return this.radius=e,this.theta=t,this.y=r,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,r){return this.radius=Math.sqrt(e*e+r*r),this.theta=Math.atan2(e,r),this.y=t,this}clone(){return(new this.constructor).copy(this)}}const Kd=new z;class Xd{constructor(e=new z(1/0,1/0),t=new z(-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(r){this.makeEmpty();for(let e=0,t=r.length;e<t;e++)this.expandByPoint(r[e]);return this}setFromCenterAndSize(e,t){t=Kd.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(t),this.max.copy(e).add(t),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 Kd.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),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)}}Xd.prototype.isBox2=!0;const Jd=new Pe,Zd=new Pe;class Qd{constructor(e=new Pe,t=new Pe){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){Jd.subVectors(e,this.start),Zd.subVectors(this.end,this.start);e=Zd.dot(Zd);let r=Zd.dot(Jd)/e;return r=t?mi(r,0,1):r}closestPointToPoint(e,t,r){e=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(e).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)}}const ef=new Pe;class tf extends c{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;var e=new S,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 e=0,t=1;e<32;e++,t++){const i=e/32*Math.PI*2,n=t/32*Math.PI*2;r.push(Math.cos(i),Math.sin(i),1,Math.cos(n),Math.sin(n),1)}e.setAttribute("position",new V(r,3));const i=new y({fog:!1,toneMapped:!1});this.cone=new Mh(e,i),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();var e=this.light.distance||1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ef.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ef),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const rf=new Pe,nf=new ke,sf=new ke;class af extends Mh{constructor(e){const t=function t(r){var i=[];r&&r.isBone&&i.push(r);for(let e=0;e<r.children.length;e++)i.push.apply(i,t(r.children[e]));return i}(e),r=new S,i=[],n=[],s=new g(0,0,1),a=new g(0,1,0);for(let e=0;e<t.length;e++){const r=t[e];r.parent&&r.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),n.push(s.r,s.g,s.b),n.push(a.r,a.g,a.b))}r.setAttribute("position",new V(i,3)),r.setAttribute("color",new V(n,3)),super(r,new y({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){var r=this.bones,t=this.geometry,i=t.getAttribute("position");sf.copy(this.root.matrixWorld).invert();for(let e=0,t=0;e<r.length;e++){var n=r[e];n.parent&&n.parent.isBone&&(nf.multiplyMatrices(sf,n.matrixWorld),rf.setFromMatrixPosition(nf),i.setXYZ(t,rf.x,rf.y,rf.z),nf.multiplyMatrices(sf,n.parent.matrixWorld),rf.setFromMatrixPosition(nf),i.setXYZ(t+1,rf.x,rf.y,rf.z),t+=2)}t.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}class of extends E{constructor(e,t,r){super(new Wu(t,4,2),new Qn({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=r,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const lf=new Pe,hf=new g,uf=new g;class cf extends c{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r;e=new Hu(t),e.rotateY(.5*Math.PI),this.material=new Qn({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0),r=e.getAttribute("position"),t=new Float32Array(3*r.count);e.setAttribute("color",new w(t,3)),this.add(new E(e,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var r=e.geometry.getAttribute("color");hf.copy(this.light.color),uf.copy(this.light.groundColor);for(let e=0,t=r.count;e<t;e++){var i=e<t/2?hf:uf;r.setXYZ(e,i.r,i.g,i.b)}r.needsUpdate=!0}e.lookAt(lf.setFromMatrixPosition(this.light.matrixWorld).negate())}}class df extends Mh{constructor(e=10,i=10,n=4473924,s=8947848){n=new g(n),s=new g(s);var a=i/2,o=e/i,l=e/2,h=[],u=[];for(let e=0,t=0,r=-l;e<=i;e++,r+=o){h.push(-l,0,r,l,0,r),h.push(r,0,-l,r,0,l);const i=e===a?n:s;i.toArray(u,t),t+=3,i.toArray(u,t),t+=3,i.toArray(u,t),t+=3,i.toArray(u,t),t+=3}e=new S;e.setAttribute("position",new V(h,3)),e.setAttribute("color",new V(u,3)),super(e,new y({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}}class ff extends Mh{constructor(t=10,r=16,i=8,n=64,s=4473924,a=8947848){s=new g(s),a=new g(a);var o=[],l=[];for(let e=0;e<=r;e++){const n=e/r*(2*Math.PI),f=Math.sin(n)*t,p=Math.cos(n)*t;o.push(0,0,0),o.push(f,0,p);var h=1&e?s:a;l.push(h.r,h.g,h.b),l.push(h.r,h.g,h.b)}for(let e=0;e<=i;e++){const f=1&e?s:a,m=t-t/i*e;for(let e=0;e<n;e++){var u=e/n*(2*Math.PI),c=Math.sin(u)*m,d=Math.cos(u)*m;o.push(c,0,d),l.push(f.r,f.g,f.b),u=(e+1)/n*(2*Math.PI),c=Math.sin(u)*m,d=Math.cos(u)*m,o.push(c,0,d),l.push(f.r,f.g,f.b)}}const f=new S;f.setAttribute("position",new V(o,3)),f.setAttribute("color",new V(l,3)),super(f,new y({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}}const pf=new Pe,mf=new Pe,gf=new Pe;class vf extends c{constructor(e,t,r){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=r,void 0===t&&(t=1);let i=new S;i.setAttribute("position",new V([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));e=new y({fog:!1,toneMapped:!1});this.lightPlane=new Sh(i,e),this.add(this.lightPlane),(i=new S).setAttribute("position",new V([0,0,0,0,0,1],3)),this.targetLine=new Sh(i,e),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){pf.setFromMatrixPosition(this.light.matrixWorld),mf.setFromMatrixPosition(this.light.target.matrixWorld),gf.subVectors(mf,pf),this.lightPlane.lookAt(mf),void 0!==this.color?(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(mf),this.targetLine.scale.z=gf.length()}}const yf=new Pe,o=new Bs;class xf extends Mh{constructor(e){const t=new S,r=new y({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],n=[],s={},a=new g(16755200),o=new g(16711680),l=new g(43775),h=new g(16777215),u=new g(3355443);function c(e,t,r){d(e,r),d(t,r)}function d(e,t){i.push(0,0,0),n.push(t.r,t.g,t.b),void 0===s[e]&&(s[e]=[]),s[e].push(i.length/3-1)}c("n1","n2",a),c("n2","n4",a),c("n4","n3",a),c("n3","n1",a),c("f1","f2",a),c("f2","f4",a),c("f4","f3",a),c("f3","f1",a),c("n1","f1",a),c("n2","f2",a),c("n3","f3",a),c("n4","f4",a),c("p","n1",o),c("p","n2",o),c("p","n3",o),c("p","n4",o),c("u1","u2",l),c("u2","u3",l),c("u3","u1",l),c("c","t",h),c("p","c",u),c("cn1","cn2",u),c("cn3","cn4",u),c("cf1","cf2",u),c("cf3","cf4",u),t.setAttribute("position",new V(i,3)),t.setAttribute("color",new V(n,3)),super(t,r),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){var e=this.geometry,t=this.pointMap;o.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),l("c",t,e,o,0,0,-1),l("t",t,e,o,0,0,1),l("n1",t,e,o,-1,-1,-1),l("n2",t,e,o,1,-1,-1),l("n3",t,e,o,-1,1,-1),l("n4",t,e,o,1,1,-1),l("f1",t,e,o,-1,-1,1),l("f2",t,e,o,1,-1,1),l("f3",t,e,o,-1,1,1),l("f4",t,e,o,1,1,1),l("u1",t,e,o,.7,1.1,-1),l("u2",t,e,o,-.7,1.1,-1),l("u3",t,e,o,0,2,-1),l("cf1",t,e,o,-1,0,1),l("cf2",t,e,o,1,0,1),l("cf3",t,e,o,0,-1,1),l("cf4",t,e,o,0,1,1),l("cn1",t,e,o,-1,0,-1),l("cn2",t,e,o,1,0,-1),l("cn3",t,e,o,0,-1,-1),l("cn4",t,e,o,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function l(r,e,t,i,n,s,a){yf.set(n,s,a).unproject(i);var o=e[r];if(void 0!==o){const r=t.getAttribute("position");for(let e=0,t=o.length;e<t;e++)r.setXYZ(o[e],yf.x,yf.y,yf.z)}}const _f=new Ni;class bf extends Mh{constructor(e,t=16776960){var r=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]),i=new Float32Array(24),n=new S;n.setIndex(new w(r,1)),n.setAttribute("position",new w(i,3)),super(n,new y({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){var t,r,i;void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&_f.setFromObject(this.object),_f.isEmpty()||(e=_f.min,t=_f.max,(i=(r=this.geometry.attributes.position).array)[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere())}setFromObject(e){return this.object=e,this.update(),this}copy(e){return Mh.prototype.copy.call(this,e),this.object=e.object,this}}class Tf extends Mh{constructor(e,t=16776960){var r=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]),i=new S;i.setIndex(new w(r,1)),i.setAttribute("position",new V([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new y({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class Sf extends Sh{constructor(e,t=1,r=16776960){var i=new S,i=(i.setAttribute("position",new V([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,0,1,0,0,0],3)),i.computeBoundingSphere(),super(i,new y({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t,new S);i.setAttribute("position",new V([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),i.computeBoundingSphere(),this.add(new E(i,new Qn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?Ae:Oe,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}}const Ef=new Pe;let wf,Mf;class Af extends c{constructor(e=new Pe(0,0,1),t=new Pe(0,0,0),r=1,i=16776960,n=.2*r,s=.2*n){super(),this.type="ArrowHelper",void 0===wf&&((wf=new S).setAttribute("position",new V([0,0,0,0,1,0],3)),(Mf=new Gh(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Sh(wf,new y({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new E(Mf,new Qn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(r,n,s)}setDirection(e){.99999<e.y?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(Ef.set(e.z,0,-e.x).normalize(),e=Math.acos(e.y),this.quaternion.setFromAxisAngle(Ef,e))}setLength(e,t=.2*e,r=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),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}}class Lf extends Mh{constructor(e=1){var e=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],t=new S;t.setAttribute("position",new V(e,3)),t.setAttribute("color",new V([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,new y({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,r){var i=new g,n=this.geometry.attributes.color.array;return i.set(e),i.toArray(n,0),i.toArray(n,3),i.set(t),i.toArray(n,6),i.toArray(n,9),i.set(r),i.toArray(n,12),i.toArray(n,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rf{constructor(){this.type="ShapePath",this.color=new g,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new gu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,n,s){return this.currentPath.bezierCurveTo(e,t,r,i,n,s),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(a,o){function e(r){var i=[];for(let e=0,t=r.length;e<t;e++){var n=r[e],s=new vu;s.curves=n.curves,i.push(s)}return i}const l=ku.isClockWise,h=this.subPaths;if(0===h.length)return[];if(!0===o)return e(h);let u,c,d;var t=[];if(1===h.length)c=h[0],(d=new vu).curves=c.curves,t.push(d);else{var f=!l(h[0].getPoints()),f=a?!f:f,p=[],m=[];let r,i,s=[],n=0;m[n]=void 0,s[n]=[];for(let e=0,t=h.length;e<t;e++)r=(c=h[e]).getPoints(),u=l(r),(u=a?!u:u)?(!f&&m[n]&&n++,m[n]={s:new vu,p:r},m[n].s.curves=c.curves,f&&n++,s[n]=[]):s[n].push({h:c,p:r[0]});if(!m[0])return e(h);if(1<m.length){let n=!1;const o=[];for(let e=0,t=m.length;e<t;e++)p[e]=[];for(let i=0,e=m.length;i<e;i++){const l=s[i];for(let r=0;r<l.length;r++){const u=l[r];let t=!0;for(let e=0;e<m.length;e++)!function(a,o){var e=o.length;let l=!1;for(let n=e-1,s=0;s<e;n=s++){let e=o[n],t=o[s],r=t.x-e.x,i=t.y-e.y;if(Math.abs(i)>Number.EPSILON){if(i<0&&(e=o[s],r=-r,t=o[n],i=-i),!(a.y<e.y||a.y>t.y))if(a.y===e.y){if(a.x===e.x)return 1}else{const o=i*(a.x-e.x)-r*(a.y-e.y);if(0==o)return 1;o<0||(l=!l)}}else if(a.y===e.y&&(t.x<=a.x&&a.x<=e.x||e.x<=a.x&&a.x<=t.x))return 1}return l}(u.p,m[e].p)||(i!==e&&o.push({froms:i,tos:e,hole:r}),t?(t=!1,p[e].push(u)):n=!0);t&&p[i].push(u)}}0<o.length&&(n||(s=p))}for(let r=0,e=m.length;r<e;r++){d=m[r].s,t.push(d);for(let e=0,t=(i=s[r]).length;e<t;e++)d.holes.push(i[e].h)}}return t}}const Cf=new Float32Array(1),Df=new Int32Array(Cf.buffer);class If{static toHalfFloat(e){65504<e&&(console.warn("THREE.DataUtils.toHalfFloat(): value exceeds 65504."),e=65504),Cf[0]=e;e=Df[0];let t=e>>16&32768,r=e>>12&2047;var i=e>>23&255;return i<103||(142<i?t=t|31744|((255==i?0:1)&&8388607&e):i<113?(r|=2048,t|=(r>>114-i)+(r>>113-i&1)):t=(t|=i-112<<10|r>>1)+(1&r)),t}}const Pf=0,kf=1,Of=0,Ff=1,Nf=2;function Uf(e){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),e}function Bf(e=[]){return console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,(e.materials=e).clone=function(){return e.slice()},e}function Gf(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new Ph(e,t)}function Hf(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Xl(e)}function zf(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new Ph(e,t)}function Vf(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function Wf(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function jf(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new Lh(e)}function Yf(e,t,r){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Pe(e,t,r)}function $f(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new w(e,t).setUsage(Qr)}function qf(e,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ts(e,t)}function Kf(e,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new rs(e,t)}function Xf(e,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new is(e,t)}function Jf(e,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new ns(e,t)}function Zf(e,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ss(e,t)}function Qf(e,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new as(e,t)}function ep(e,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new os(e,t)}function tp(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new V(e,t)}function rp(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new hs(e,t)}function ip(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Lf(e)}function np(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new bf(e,t)}function sp(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Mh(new qh(e.geometry),new y({color:void 0!==t?t:16777215}))}function ap(e,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new Mh(new Ku(e.geometry),new y({color:void 0!==t?t:16777215}))}function op(e){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Mc(e)}function lp(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Dc(e)}function hp(e,t,r){return console.warn("THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options )."),new zs(e,r)}function up(){console.error("THREE.CanvasRenderer has been removed")}function cp(){console.error("THREE.JSONLoader has been removed.")}Kh.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Kh.prototype),(e.prototype.constructor=e).prototype.getPoint=t,e},gu.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},df.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},af.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Ec.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Qc.extractUrlBase(e)},Ec.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Xd.prototype.center=function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Xd.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Xd.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Xd.prototype.size=function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},Ni.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},Ni.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ni.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Ni.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Ni.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},rn.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Ks.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Qd.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},v.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},v.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},v.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},v.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},v.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},v.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},ke.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},ke.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},ke.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new Pe).setFromMatrixColumn(this,3)},ke.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},ke.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},ke.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},ke.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},ke.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},ke.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},ke.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},ke.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},ke.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},ke.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},ke.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},ke.prototype.makeFrustum=function(e,t,r,i,n,s){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,i,r,n,s)},ke.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Ys.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},ki.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},ki.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},cn.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},cn.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},cn.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},f.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},f.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},f.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},f.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},f.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},f.barycoordFromPoint=function(e,t,r,i,n){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),f.getBarycoord(e,t,r,i,n)},f.normal=function(e,t,r,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),f.getNormal(e,t,r,i)},vu.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},vu.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new Nu(this,e)},vu.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new Vu(this,e)},z.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},z.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},z.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Pe.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},Pe.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},Pe.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},Pe.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},Pe.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},Pe.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},Pe.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},Pe.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},Pe.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},Ie.prototype.fromAttribute=function(e,t,r){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,r)},Ie.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},c.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},c.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},c.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},c.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},c.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(c.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),E.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(E.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),Tr},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),ah.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},N.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Pc.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(w.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Qr},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Qr)}}}),w.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Qr:Zr),this},w.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},w.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},S.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},S.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new w(t,arguments[2])))},S.prototype.addDrawCall=function(e,t,r){void 0!==r&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},S.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},S.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},S.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},S.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(S.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),kl.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?Qr:Zr),this},kl.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},Nu.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},Nu.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},Nu.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},Pl.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Hd.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(r.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new g}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=e===P}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}}),Object.defineProperties(Us.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),s.prototype.clearTarget=function(e,t,r,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,r,i)},s.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},s.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},s.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},s.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},s.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},s.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},s.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},s.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},s.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},s.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},s.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},s.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},s.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},s.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},s.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},s.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},s.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},s.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},s.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},s.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},s.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},s.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},s.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},s.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(s.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?wr:De}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(_l.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(Di.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),Td.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new hd).load(e,function(e){t.setBuffer(e)}),this},Ld.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},Gs.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},Gs.prototype.clear=function(e,t,r,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,r,i)},Li.crossOrigin=void 0,Li.loadTexture=function(e,t,r,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var n=new Ic,n=(n.setCrossOrigin(this.crossOrigin),n.load(e,r,void 0,i));return t&&(n.mapping=t),n},Li.loadTextureCube=function(e,t,r,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var n=new Cc,n=(n.setCrossOrigin(this.crossOrigin),n.load(e,r,void 0,i));return t&&(n.mapping=t),n},Li.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},Li.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const dp={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};function fp(){console.error("THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js")}function pp(){return console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),new S}function mp(){return console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),new S}function gp(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function vp(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function yp(){console.error("THREE.ImmediateRenderObject has been removed.")}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_)},555:function(e,C,D){"use strict";!function(e){var E=D(764),s=D(765),l=D(766);function r(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function h(e,t){if(r()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(e=null===e?new c(t):e).length=t,e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"!=typeof e)return i(this,e,t,r);if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return a(this,e)}function i(e,t,r,i){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer){var n=e,s=t,a=r;if(s.byteLength,a<0||s.byteLength<a)throw new RangeError("'offset' is out of bounds");if(s.byteLength<a+(i||0))throw new RangeError("'length' is out of bounds");return s=void 0===a&&void 0===i?new Uint8Array(s):void 0===i?new Uint8Array(s,a):new Uint8Array(s,a,i),c.TYPED_ARRAY_SUPPORT?(n=s).__proto__=c.prototype:n=u(n,s),n}if("string"==typeof t){a=e,i=t,s=r;if(c.isEncoding(s="string"==typeof s&&""!==s?s:"utf8"))return(i=(a=h(a,n=0|f(i,s))).write(i,s))!==n?a.slice(0,i):a;throw new TypeError('"encoding" must be a valid string encoding')}var o,r=e,i=t;if(c.isBuffer(i))return 0!==(r=h(r,o=0|d(i.length))).length&&i.copy(r,0,0,o),r;if(i){if("undefined"!=typeof ArrayBuffer&&i.buffer instanceof ArrayBuffer||"length"in i)return"number"!=typeof i.length||(o=i.length)!=o?h(r,0):u(r,i);if("Buffer"===i.type&&l(i.data))return u(r,i.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function n(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function a(e,t){if(n(t),e=h(e,t<0?0:0|d(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function u(e,t){var r=t.length<0?0:0|d(t.length);e=h(e,r);for(var i=0;i<r;i+=1)e[i]=255&t[i];return e}function d(e){if(e>=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function f(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;var r=(e="string"!=typeof e?""+e:e).length;if(0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return A(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return L(e).length;default:if(i)return A(e).length;t=(""+t).toLowerCase(),i=!0}}function t(e,t,r){var i,n=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((r=void 0===r||r>this.length?this.length:r)<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var s=this,a=t,o=r,l=s.length;(!o||o<0||l<o)&&(o=l);for(var h="",u=a=!a||a<0?0:a;u<o;++u)h+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(s[u]);return h;case"utf8":case"utf-8":return w(this,t,r);case"ascii":var c=this,l=t,d=r,f="";d=Math.min(c.length,d);for(var p=l;p<d;++p)f+=String.fromCharCode(127&c[p]);return f;case"latin1":case"binary":var m=this,a=t,g=r,v="";g=Math.min(m.length,g);for(var y=a;y<g;++y)v+=String.fromCharCode(m[y]);return v;case"base64":return x=this,i=r,0===(_=t)&&i===x.length?E.fromByteArray(x):E.fromByteArray(x.slice(_,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var x=t,_=r,b=this.slice(x,_),T="",S=0;S<b.length;S+=2)T+=String.fromCharCode(b[S]+256*b[S+1]);return T;default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function o(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function p(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,(r=(r=isNaN(r)?n?0:e.length-1:r)<0?e.length+r:r)>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,i,n);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(n?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,r):m(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,i,n){var s=1,a=e.length,o=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;a/=s=2,o/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n)for(var h=-1,u=r;u<a;u++)if(l(e,u)===l(t,-1===h?0:u-h)){if(u-(h=-1===h?u:h)+1===o)return h*s}else-1!==h&&(u-=u-h),h=-1;else for(u=r=a<r+o?a-o:r;0<=u;u--){for(var c=!0,d=0;d<o;d++)if(l(e,u+d)!==l(t,d)){c=!1;break}if(c)return u}return-1}function y(e,t,r,i){return R(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function w(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var s,a,o,l,h=e[n],u=null,c=239<h?4:223<h?3:191<h?2:1;if(n+c<=r)switch(c){case 1:h<128&&(u=h);break;case 2:128==(192&(s=e[n+1]))&&127<(l=(31&h)<<6|63&s)&&(u=l);break;case 3:s=e[n+1],a=e[n+2],128==(192&s)&&128==(192&a)&&2047<(l=(15&h)<<12|(63&s)<<6|63&a)&&(l<55296||57343<l)&&(u=l);break;case 4:s=e[n+1],a=e[n+2],o=e[n+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&65535<(l=(15&h)<<18|(63&s)<<12|(63&a)<<6|63&o)&&l<1114112&&(u=l)}null===u?(u=65533,c=1):65535<u&&(i.push((u-=65536)>>>10&1023|55296),u=56320|1023&u),i.push(u),n+=c}var d=i,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",m=0;m<f;)p+=String.fromCharCode.apply(String,d.slice(m,m+=4096));return p}function g(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(r<e+t)throw new RangeError("Trying to access beyond buffer length")}function v(e,t,r,i,n,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(n<t||t<s)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function x(e,t,r,i){t<0&&(t=65535+t+1);for(var n=0,s=Math.min(e.length-r,2);n<s;++n)e[r+n]=(t&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function _(e,t,r,i){t<0&&(t=4294967295+t+1);for(var n=0,s=Math.min(e.length-r,4);n<s;++n)e[r+n]=t>>>8*(i?n:3-n)&255}function b(e,t,r,i){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function T(e,t,r,i,n){return n||b(e,0,r,4),s.write(e,t,r,i,23,4),r+4}function S(e,t,r,i,n){return n||b(e,0,r,8),s.write(e,t,r,i,52,8),r+8}C.Buffer=c,C.SlowBuffer=function(e){return c.alloc(+(e=+e!=e?0:e))},C.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),C.kMaxLength=r(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return i(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol)&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0}),c.alloc=function(e,t,r){return t=t,r=r,n(e=e),!(e<=0)&&void 0!==t?"string"==typeof r?h(null,e).fill(t,r):h(null,e).fill(t):h(null,e)},c.allocUnsafe=function(e){return a(null,e)},c.allocUnsafeSlow=function(e){return a(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,n=0,s=Math.min(r,i);n<s;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!l(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);if(void 0===t)for(n=t=0;n<e.length;++n)t+=e[n].length;for(var r=c.allocUnsafe(t),i=0,n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},c.byteLength=f,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)o(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)o(this,t,t+3),o(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)o(this,t,t+7),o(this,t+1,t+6),o(this,t+2,t+5),o(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0==e?"":0===arguments.length?w(this,0,e):t.apply(this,arguments)},c.prototype.equals=function(e){if(c.isBuffer(e))return this===e||0===c.compare(this,e);throw new TypeError("Argument must be a Buffer")},c.prototype.inspect=function(){var e="",t=C.INSPECT_MAX_BYTES;return 0<this.length&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t)&&(e+=" ... "),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,i,n){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),(t=void 0===t?0:t)<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(n<=i&&r<=t)return 0;if(n<=i)return-1;if(r<=t)return 1;if(this===e)return 0;for(var s=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),o=Math.min(s,a),l=this.slice(i,n),h=e.slice(t,r),u=0;u<o;++u)if(l[u]!==h[u]){s=l[u],a=h[u];break}return s<a?-1:a<s?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return p(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return p(this,e,t,r,!1)},c.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||n<r)&&(r=n),0<e.length&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i=i||"utf8";for(var s,a,o,l,h,u=!1;;)switch(i){case"hex":var c=this,d=e,f=t,p=r,m=(f=Number(f)||0,c.length-f);if((!p||(p=Number(p))>m)&&(p=m),(m=d.length)%2!=0)throw new TypeError("Invalid hex string");m/2<p&&(p=m/2);for(var g=0;g<p;++g){var v=parseInt(d.substr(2*g,2),16);if(isNaN(v))return g;c[f+g]=v}return g;case"utf8":case"utf-8":return m=t,h=r,R(A(e,(l=this).length-m),l,m,h);case"ascii":return y(this,e,t,r);case"latin1":case"binary":return y(this,e,t,r);case"base64":return l=this,h=t,o=r,R(L(e),l,h,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o=t,a=r,R(function(e,t){for(var r,i,n=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n.push(r%256),n.push(i);return n}(e,(s=this).length-o),s,o,a);default:if(u)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),u=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(e,t){var r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else for(var i=t-e,n=new c(i,void 0),s=0;s<i;++s)n[s]=this[s+e];return n},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e+--t],n=1;0<t&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUInt8=function(e,t){return t||g(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||g(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||g(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||g(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||g(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=this[e],n=1,s=0;++s<t&&(n*=256);)i+=this[e+s]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||g(e,t,this.length);for(var i=t,n=1,s=this[e+--i];0<i&&(n*=256);)s+=this[e+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||g(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||g(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt16BE=function(e,t){t||g(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},c.prototype.readInt32LE=function(e,t){return t||g(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||g(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||g(e,4,this.length),s.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||g(e,4,this.length),s.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||g(e,8,this.length),s.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||g(e,8,this.length),s.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,i){e=+e,t|=0,r|=0,i||v(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[t]=255&e;++s<r&&(n*=256);)this[t+s]=e/n&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,i){e=+e,t|=0,r|=0,i||v(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,s=1;for(this[t+n]=255&e;0<=--n&&(s*=256);)this[t+n]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):_(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,i){e=+e,t|=0,i||v(this,e,t,r,(i=Math.pow(2,8*r-1))-1,-i);var n=0,s=1,a=0;for(this[t]=255&e;++n<r&&(s*=256);)e<0&&0===a&&0!==this[t+n-1]&&(a=1),this[t+n]=(e/s>>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){e=+e,t|=0,i||v(this,e,t,r,(i=Math.pow(2,8*r-1))-1,-i);var n=r-1,s=1,a=0;for(this[t+n]=255&e;0<=--n&&(s*=256);)e<0&&0===a&&0!==this[t+n+1]&&(a=1),this[t+n]=(e/s>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&(e=e<0?255+e+1:e),t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):x(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):x(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):_(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||v(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):_(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return T(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return T(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return S(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return S(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(r=r||0,i||0===i||(i=this.length),t>=e.length&&(t=e.length),(i=0<i&&i<r?r:i)===r)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length);var n,s=(i=e.length-t<i-r?e.length-t+r:i)-r;if(this===e&&r<t&&t<i)for(n=s-1;0<=n;--n)e[n+t]=this[n+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(n=0;n<s;++n)e[n+t]=this[n+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},c.prototype.fill=function(e,t,r,i){if("string"==typeof e){var n;if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===e.length&&(n=e.charCodeAt(0))<256&&(e=n),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(!(r<=t))if(t>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(e=e||0))for(o=t;o<r;++o)this[o]=e;else for(var s=c.isBuffer(e)?e:A(new c(e,i).toString()),a=s.length,o=0;o<r-t;++o)this[o+t]=s[o%a];return this};var M=/[^+\/0-9A-Za-z-_]/g;function A(e,t){var r;t=t||1/0;for(var i=e.length,n=null,s=[],a=0;a<i;++a){if(55295<(r=e.charCodeAt(a))&&r<57344){if(!n){if(56319<r){-1<(t-=3)&&s.push(239,191,189);continue}if(a+1===i){-1<(t-=3)&&s.push(239,191,189);continue}n=r;continue}if(r<56320){-1<(t-=3)&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&-1<(t-=3)&&s.push(239,191,189);if(n=null,r<128){if(--t<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function L(e){return E.toByteArray(function(e){if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(M,"")).length<2)return"";for(var t;e.length%4!=0;)e+="=";return e}(e))}function R(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}}.call(this,D(32))},560:function(e,t){function r(){return e.exports=r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,r.apply(this,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},566:function(e,t,r){var i=r(699);e.exports=function(e){return null==e?"":i(e)}},567:function(e,t,r){"use strict";var{default:r,DraggableCore:i}=r(721);e.exports=r,e.exports.default=r,e.exports.DraggableCore=i},569:function(e,n,s){!function(e){var t=void 0!==e&&e||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}n.setTimeout=function(){return new i(r.call(setTimeout,t,arguments),clearTimeout)},n.setInterval=function(){return new i(r.call(setInterval,t,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(t,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},s(761),n.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,n.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}.call(this,s(32))},575:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},t.findInArray=function(r,i){for(let e=0,t=r.length;e<t;e++)if(i.apply(i,[r[e],e,r]))return r[e]},t.int=function(e){return parseInt(e,10)},t.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},t.isNum=function(e){return"number"==typeof e&&!isNaN(e)}},580:function(e,t,r){"use strict";e.exports=r(664)},583:function(e,t){e.exports=function(e,t){if(null==e)return{};var r,i={};for(r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(0<=t.indexOf(r))continue;i[r]=e[r]}return i},e.exports.__esModule=!0,e.exports.default=e.exports},587:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addClassName=h,t.addEvent=function(e,t,r,i){e&&(i={capture:!0,...i},e.addEventListener?e.addEventListener(t,r,i):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r)},t.addUserSelectStyles=function(e){var t;e&&((t=e.getElementById("react-draggable-style-el"))||((t=e.createElement("style")).type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t)),e.body)&&h(e.body,"react-draggable-transparent-selection")},t.createCSSTransform=function(e,t){e=l(e,t,"px");return{[(0,n.browserPrefixToKey)("transform",n.default)]:e}},t.createSVGTransform=function(e,t){return l(e,t,"")},t.getTouch=function(e,t){return e.targetTouches&&(0,i.findInArray)(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&(0,i.findInArray)(e.changedTouches,e=>t===e.identifier)},t.getTouchIdentifier=function(e){return e.targetTouches&&e.targetTouches[0]?e.targetTouches[0].identifier:e.changedTouches&&e.changedTouches[0]?e.changedTouches[0].identifier:void 0},t.getTranslation=l,t.innerHeight=function(e){var t=e.clientHeight,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t-=(0,i.int)(e.paddingTop))-(0,i.int)(e.paddingBottom)},t.innerWidth=function(e){var t=e.clientWidth,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t-=(0,i.int)(e.paddingLeft))-(0,i.int)(e.paddingRight)},t.matchesSelector=o,t.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(o(i,t))return!0;if(i===r)return!1}while(i=i.parentNode);return!1},t.offsetXYFromParent=function(e,t,r){var i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-i.left)/r,y:(e.clientY+t.scrollTop-i.top)/r}},t.outerHeight=function(e){var t=e.clientHeight,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t+=(0,i.int)(e.borderTopWidth))+(0,i.int)(e.borderBottomWidth)},t.outerWidth=function(e){var t=e.clientWidth,e=e.ownerDocument.defaultView.getComputedStyle(e);return(t+=(0,i.int)(e.borderLeftWidth))+(0,i.int)(e.borderRightWidth)},t.removeClassName=u,t.removeEvent=function(e,t,r,i){e&&(i={capture:!0,...i},e.removeEventListener?e.removeEventListener(t,r,i):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null)},t.removeUserSelectStyles=function(e){if(e)try{var t;e.body&&u(e.body,"react-draggable-transparent-selection"),e.selection?e.selection.empty():(t=(e.defaultView||window).getSelection())&&"Caret"!==t.type&&t.removeAllRanges()}catch(e){}};var i=r(575),n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=a(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(722));function a(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(a=function(e){return e?r:t})(e))}let s="";function o(t,e){return s=s||(0,i.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(e){return(0,i.isFunction)(t[e])}),!!(0,i.isFunction)(t[s])&&t[s](e)}function l(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);s="translate(".concat(e,", ").concat(i,")")+s}return s}function h(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function u(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}},602:function(e,t,r){"use strict";t.a={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},603:function(e,t,r){"use strict";r.r(t),t.default=function(t){var r={};return function(e){return void 0===r[e]&&(r[e]=t(e)),r[e]}}},606:function(e,t){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}},614:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},t.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},t.createCoreData=function(e,t,r){var i=!(0,l.isNum)(e.lastX),n=u(e);return i?{node:n,deltaX:0,deltaY:0,lastX:t,lastY:r,x:t,y:r}:{node:n,deltaX:t-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:r}},t.createDraggableData=function(e,t){var r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},t.getBoundPosition=function(t,r,i){if(t.props.bounds){let e=t.props["bounds"];e="string"==typeof e?e:{left:(n=e).left,top:n.top,right:n.right,bottom:n.bottom};var n=u(t);if("string"==typeof e){const t=n["ownerDocument"],r=t.defaultView;var s="parent"===e?n.parentNode:t.querySelector(e);if(!(s instanceof r.HTMLElement))throw new Error('Bounds selector "'+e+'" could not find an element.');const u=s,a=r.getComputedStyle(n),o=r.getComputedStyle(u);e={left:-n.offsetLeft+(0,l.int)(o.paddingLeft)+(0,l.int)(a.marginLeft),top:-n.offsetTop+(0,l.int)(o.paddingTop)+(0,l.int)(a.marginTop),right:(0,h.innerWidth)(u)-(0,h.outerWidth)(n)-n.offsetLeft+(0,l.int)(o.paddingRight)-(0,l.int)(a.marginRight),bottom:(0,h.innerHeight)(u)-(0,h.outerHeight)(n)-n.offsetTop+(0,l.int)(o.paddingBottom)-(0,l.int)(a.marginBottom)}}(0,l.isNum)(e.right)&&(r=Math.min(r,e.right)),(0,l.isNum)(e.bottom)&&(i=Math.min(i,e.bottom)),(0,l.isNum)(e.left)&&(r=Math.max(r,e.left)),(0,l.isNum)(e.top)&&(i=Math.max(i,e.top))}return[r,i]},t.getControlPosition=function(e,t,r){var i="number"==typeof t?(0,h.getTouch)(e,t):null;return"number"!=typeof t||i?(t=u(r),t=r.props.offsetParent||t.offsetParent||t.ownerDocument.body,(0,h.offsetXYFromParent)(i||e,t,r.props.scale)):null},t.snapToGrid=function(e,t,r){return[Math.round(t/e[0])*e[0],Math.round(r/e[1])*e[1]]};var l=r(575),h=r(587);function u(e){e=e.findDOMNode();if(e)return e;throw new Error("<DraggableCore>: Unmounted during event!")}},615:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){}},620:function(e,t,r){"use strict";r.d(t,"a",function(){return n});var i=r(621);function n(r){return function e(t){return 0===arguments.length||Object(i.a)(t)?e:r.apply(this,arguments)}}},621:function(e,t,r){"use strict";function i(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}r.d(t,"a",function(){return i})},648:function(i,e,t){"use strict";t.d(e,"a",function(){return In});n=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,o=/^(?=([^\/?#]*))\1([^]*)$/,l=/(?:\/|^)\.(?=\/)/g,h=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=s.parseURL(e);if(i)return i.path=s.normalizePath(i.path),s.buildURLFromParts(i);throw new Error("Error trying to parse base URL.")}i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):t;t=s.parseURL(e);if(!t)throw new Error("Error trying to parse base URL.");!t.netLoc&&t.path&&"/"!==t.path[0]&&(e=o.exec(t.path),t.netLoc=e[1],t.path=e[2]),t.netLoc&&!t.path&&(t.path="/");var n,e={scheme:t.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};return i.netLoc||(e.netLoc=t.netLoc,"/"===i.path[0])||(i.path?(n=(n=t.path).substring(0,n.lastIndexOf("/")+1)+i.path,e.path=s.normalizePath(n)):(e.path=t.path,i.params||(e.params=t.params,i.query)||(e.query=t.query))),null===e.path&&(e.path=r.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(e)},parseURL:function(e){e=n.exec(e);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(l,"");e.length!==(e=e.replace(h,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var n,o,l,h,s,H=s;function z(t,e){var r,i=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,r)),i}function m(i){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?z(Object(n),!0).forEach(function(e){var t,r;t=i,e=n[r=e],(r=function(){var e=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r);return"symbol"==typeof e?e:String(e)}())in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(n,e))})}return i}function L(){return(L=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}const M=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};(t={}).MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached";let R=t,C=((e={}).NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e),D=((t={}).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t);function V(){}const W={trace:V,debug:V,log:V,warn:V,info:V,error:V};let j=W;function Y(r,...e){e.forEach(function(e){var t;j[e]=r[e]?r[e].bind(r):(t=self.console[e])?t.bind(self.console,`[${e}] >`):V})}const I=j,$=/^(\d+)x(\d+)$/,q=/(.+?)=(".*?"|.*?)(?:,|$)/g;class A{constructor(e){for(const t in e="string"==typeof e?A.parseAttrList(e):e)e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){e=parseInt(this[e],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(e){if(this[e]){var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){e=parseInt(this[e],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){e=this[e];return e?parseFloat(e):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){e=$.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(e){var t,r={};for(q.lastIndex=0;null!==(t=q.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),r[t[1].trim()]=e}return r}}class K{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){I.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=L(new A({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);M(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var e;return this._endDate||(null!==(e=this.duration)?new Date(this._startDate.getTime()+1e3*e):null)}get duration(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(M(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&M(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class X{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var b="audio",S="video",J="audiovideo";class Z{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={audio:null,video:null,audiovideo:null},this.baseurl=e}setByteRange(e,t){var e=e.split("@",2),r=[];1===e.length?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(e[1]),r[1]=parseInt(e[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=H.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Q extends Z{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new X,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const e=this["levelkeys"];if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var e;return null!==this.programDateTime&&M(this.programDateTime)?(e=M(this.duration)?this.duration:0,this.programDateTime+1e3*e):null}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(1<t||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){this.levelkeys&&(e=this.levelkeys[e])&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}abortRequests(){var e;null!=(e=this.loader)&&e.abort(),null!=(e=this.keyLoader)&&e.abort()}setElementaryStreamInfo(e,t,r,i,n,s=!1){var a=this["elementaryStreams"],o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}clearElementaryStreamInfo(){var e=this["elementaryStreams"];e[b]=null,e[S]=null,e[J]=null}}class ee extends Z{constructor(e,t,r,i,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new X,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;r=e.enumeratedString("BYTERANGE");r&&this.setByteRange(r,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){var e=this["elementaryStreams"];return!!(e.audio||e.video||e.audiovideo)}}class te{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){var t,r;e?(t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex,this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||0<t||0==t&&0<r,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay):(this.advanced=!0,this.updated=!0)}get hasProgramDateTime(){return!!this.fragments.length&&M(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){var e=this.driftEndTime-this.driftStartTime;return 0<e?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function re(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function ie(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}var c={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ne="org.w3.clearkey",se="com.apple.streamingkeydelivery",ae="com.microsoft.playready",oe="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function le(e){switch(e){case se:return c.FAIRPLAY;case ae:return c.PLAYREADY;case oe:return c.WIDEVINE;case ne:return c.CLEARKEY}}var he="edef8ba979d64acea3c827dcd51d21ed";function ue(e){switch(e){case c.FAIRPLAY:return se;case c.PLAYREADY:return ae;case c.WIDEVINE:return oe;case c.CLEARKEY:return ne}}function ce(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[c.FAIRPLAY,c.WIDEVINE,c.PLAYREADY,c.CLEARKEY].filter(e=>!!t[e]):[];return!i[c.WIDEVINE]&&r&&i.push(c.WIDEVINE),i}const de="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function fe(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}const pe=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,me=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,ge=(e,t)=>{var r=t;let i=0;for(;pe(e,t);)i=(i+=10)+ve(e,t+6),me(e,t+10)&&(i+=10),t+=i;if(0<i)return e.subarray(r,r+i)},ve=(e,t)=>{var r=(127&e[t])<<21;return(r|=(127&e[t+1])<<14)|(127&e[t+2])<<7|127&e[t+3]},ye=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,xe=e=>{let t=0;for(var r,i=[];pe(e,t);){for(var n=ve(e,t+6),s=(t+=10)+n;t+8<s;){r=e.subarray(t),o=a=void 0,a=String.fromCharCode(r[0],r[1],r[2],r[3]),o=ve(r,4);var a={type:a,size:o,data:r.subarray(10,10+o)},o=("PRIV"===(r=a).type?_e:"W"===r.type[0]?Te:be)(r);o&&i.push(o),t+=a.size+10}me(e,t)&&(t+=10)}return i},_e=e=>{var t,r;if(!(e.size<2))return t=E(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:r.buffer}},be=e=>{var t,r;if(!(e.size<2))return"TXXX"===e.type?(t=1,t+=(r=E(e.data.subarray(1),!0)).length+1,t=E(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=E(e.data.subarray(1)),{key:e.type,data:r})},Te=e=>{var t,r;return"WXXX"===e.type?e.size<2?void 0:(t=1,t+=(r=E(e.data.subarray(1),!0)).length+1,t=E(e.data.subarray(t)),{key:e.type,info:r,data:t}):(r=E(e.data),{key:e.type,data:r})},E=(e,t=!1)=>{var r=Se=Se||void 0===self.TextDecoder?Se:new self.TextDecoder("utf-8");if(r){const i=r.decode(e);if(t){const e=i.indexOf("\0");return-1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}const i=e.length;let n,s,a,o="",l=0;for(;l<i;){if(0===(n=e[l++])&&t)return o;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(n);break;case 12:case 13:s=e[l++],o+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[l++],a=e[l++],o+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&a)<<0)}}return o};let Se;function d(r){let i="";for(let t=0;t<r.length;t++){let e=r[t].toString(16);e.length<2&&(e="0"+e),i+=e}return i}const Ee=Math.pow(2,32)-1,we=[].push,Me={video:1,audio:2,id3:3,text:4};function f(e){return String.fromCharCode.apply(null,e)}function Ae(e,t){e=e[t]<<8|e[t+1];return e<0?65536+e:e}function w(e,t){e=Le(e,t);return e<0?4294967296+e:e}function Le(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Re(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function P(t,r){var i=[];if(r.length){const s=t.byteLength;for(let e=0;e<s;){var n=w(t,e),n=1<n?e+n:s;if(f(t.subarray(e+4,e+8))===r[0])if(1===r.length)i.push(t.subarray(e+8,n));else{const s=P(t.subarray(e+8,n),r.slice(1));s.length&&we.apply(i,s)}e=n}}return i}function Ce(t){const r=[],i=P(t,["moov","trak"]);for(let e=0;e<i.length;e++){var n=i[e],s=P(n,["tkhd"])[0];if(s){var s=w(s,0===s[0]?12:20),a=P(n,["mdia","mdhd"])[0];if(a){var a=w(a,0===a[0]?12:20),o=P(n,["mdia","hdlr"])[0];if(o){const t=f(o.subarray(8,12)),i={soun:b,vide:S}[t];if(i){const t=P(n,["mdia","minf","stbl","stsd"])[0];let e;t&&(e=f(t.subarray(12,16))),r[s]={timescale:a,type:i},r[i]={timescale:a,id:s,codec:e}}}}}}return P(t,["moov","mvex","trex"]).forEach(e=>{var t=w(e,4),t=r[t];t&&(t.default={duration:w(e,12),flags:w(e,20)})}),r}function De(e){var t=P(e,["schm"])[0];if(t){t=f(t.subarray(4,8));if("cbcs"===t||"cenc"===t)return P(e,["schi","tenc"])[0]}return I.error("[eme] missing 'schm' box"),null}function Ie(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Pe(v,y){const x=[],_=y.samples,b=y.timescale,o=y.id;let T=!1;return P(_,["moof"]).map(e=>{const g=e.byteOffset-8;P(e,["traf"]).map(a=>{var e=P(a,["tfdt"]).map(e=>{var t=e[0];let r=w(e,4);return(r=1===t?(r*=Math.pow(2,32))+w(e,8):r)/b})[0];return void 0!==e&&(v=e),P(a,["tfhd"]).map(e=>{var t=w(e,4),r=16777215&w(e,0);let p=0;var i=0!=(16&r);let m=0;var n=0!=(32&r);let s=8;t===o&&(0!=(1&r)&&(s+=8),0!=(2&r)&&(s+=4),0!=(8&r)&&(p=w(e,s),s+=4),i&&(m=w(e,s),s+=4),n&&(s+=4),"video"===y.type&&(T=!!(t=y.codec)&&("hvc1"===(t=(r=t.indexOf("."))<0?t:t.substring(0,r))||"hev1"===t||"dvh1"===t||"dvhe"===t)),P(a,["trun"]).map(t=>{var r=t[0],e=16777215&w(t,0);let i=0;var n=0!=(256&e);let s=0;var a=0!=(512&e);let o=0;var l=0!=(1024&e),h=0!=(2048&e);let u=0;var c=w(t,4);let d=8,f=(0!=(1&e)&&(i=w(t,d),d+=4),0!=(4&e)&&(d+=4),i+g);for(let e=0;e<c;e++){if(n?(s=w(t,d),d+=4):s=p,a?(o=w(t,d),d+=4):o=m,l&&(d+=4),h&&(u=(0===r?w:Le)(t,d),d+=4),y.type===S){let e=0;for(;e<o;){const t=w(_,f);f+=4,function(e,t){if(e){const e=t>>1&63;return 39==e||40==e}return 6==(31&t)}(T,_[f])&&ke(_.subarray(f,f+t),T?2:1,v+u/b,x),f+=t,e+=t+4}}v+=s/b}}))})})}),x}function ke(t,r,i,e){var n=Oe(t);let s=0,a=(s+=r,0),o=0,l=!1,h=0;for(;s<n.length;){for(a=0;!(s>=n.length)&&(h=n[s++],a+=h,255===h););for(o=0;!(s>=n.length)&&(h=n[s++],o+=h,255===h););const t=n.length-s;if(!l&&4===a&&s<n.length){if(l=!0,181===n[s++]){const t=Ae(n,s);if(s+=2,49===t){const t=w(n,s);if(s+=4,1195456820===t){const t=n[s++];if(3===t){const r=n[s++],o=31&r,l=64&r,h=l?2+3*o:0,u=new Uint8Array(h);if(l){u[0]=r;for(let e=1;e<h;e++)u[e]=n[s++]}e.push({type:t,payloadType:a,pts:i,bytes:u})}}}}}else if(5===a&&o<t){if(l=!0,16<o){const t=[];for(let e=0;e<16;e++){const i=n[s++].toString(16);t.push(1==i.length?"0"+i:i),3!==e&&5!==e&&7!==e&&9!==e||t.push("-")}const r=o-16,l=new Uint8Array(r);for(let e=0;e<r;e++)l[e]=n[s++];e.push({payloadType:a,pts:i,uuid:t.join(""),userData:E(l),userDataBytes:l})}}else if(o<t)s+=o;else if(o>t)break}}function Oe(e){var t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}let Fe={};class Ne{static clearKeyUriToKeyIdMap(){Fe={}}constructor(e,t,r,i=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case se:case oe:case ae:case ne:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(t){var r=new Uint8Array(16);for(let e=12;e<16;e++)r[e]=t>>8*(15-e)&255;return r}(e);return new Ne(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=function(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),s=e[e.length-1].split(",");if(2===s.length){const t="base64"===s[0],a=s[1];r=t?(e.splice(-1,1),re(a)):(i=ie(a).subarray(0,16),(n=new Uint8Array(16)).set(i,16-i.length),n)}}var i,n;return r}(this.uri);if(t)switch(this.keyFormat){case oe:22<=(this.pssh=t).length&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case ae:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(r,t,i){if(16!==r.byteLength)throw new RangeError("Invalid system id");let n,s,a;if(t){n=1,s=new Uint8Array(16*t.length);for(let e=0;e<t.length;e++){const i=t[e];if(16!==i.byteLength)throw new RangeError("Invalid key");s.set(i,16*e)}}else n=0,s=new Uint8Array;0<n?(a=new Uint8Array(4),0<t.length&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var o=new Uint8Array(4);i&&0<i.byteLength&&new DataView(o.buffer).setUint32(0,i.byteLength,!1);{var l=[new Uint8Array([n,0,0,0]),r,a,s,o,i||new Uint8Array],h=l.length;let e=8,t=h;for(;t--;)e+=l[t].byteLength;var u=new Uint8Array(e);for(u[0]=e>>24&255,u[1]=e>>16&255,u[2]=e>>8&255,u[3]=255&e,u.set([112,115,115,104],4),t=0,e=8;t<h;t++)u.set(l[t],e),e+=l[t].byteLength;return u}}(e,null,t);var r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),r=String.fromCharCode.apply(null,Array.from(r)),r=r.substring(r.indexOf("<"),r.length),r=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(r){const e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){const t=re(e).subarray(0,16);r=t,i(r,0,3),i(r,1,2),i(r,4,5),i(r,6,7),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}function i(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}if(!this.keyId||16!==this.keyId.byteLength){let e=Fe[this.uri];if(!e){const t=Object.keys(Fe).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16),new DataView(e.buffer,12,4).setUint32(0,t),Fe[this.uri]=e}this.keyId=e}return this}}const Ue=/\{\$([a-zA-Z0-9-_]+)\}/g;function Be(e){return Ue.test(e)}function k(t,r,i){if(null!==t.variableList||t.hasVariableRefs)for(let e=i.length;e--;){var n=i[e],s=r[n];s&&(r[n]=Ge(t,s))}}function Ge(i,e){if(null!==i.variableList||i.hasVariableRefs){const n=i.variableList;return e.replace(Ue,e=>{var t=e.substring(2,e.length-1),r=null==n?void 0:n[t];return void 0===r?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${t}"`)),e):r})}return e}function He(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function ze(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Ve={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},We=ze();function je(e,t){return null!=(t=null==We?void 0:We.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&t}const Ye=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,$e=/#EXT-X-MEDIA:(.*)/g,qe=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ke=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Xe=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class p{static findGroup(t,r){for(let e=0;e<t.length;e++){var i=t[e];if(i.id===r)return i}}static convertAVC1ToAVCOTI(e){var t,r=e.split(".");return 2<r.length?(t=r.shift()+".",(t+=parseInt(r.shift()).toString(16))+("000"+parseInt(r.shift()).toString(16)).slice(-4)):e}static resolve(e,t){return H.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return qe.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Be(e)},i=[];var n,s;for(Ye.lastIndex=0;null!=(n=Ye.exec(e));)if(n[1]){const e=new A(n[1]),a=(k(r,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]),Ge(r,n[2])),o={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:p.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),function(i,n){["video","audio","text"].forEach(r=>{const t=i.filter(e=>{var t=r;return!!(t=Ve[t])&&!0===t[e.slice(0,4)]});var e;t.length&&(e=t.filter(e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)),n[r+"Codec"]=(0<e.length?e:t)[0],i=i.filter(e=>-1===t.indexOf(e)))}),n.unknownCodecs=i}((e.CODECS||"").split(/[ ,]+/).filter(e=>e),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=p.convertAVC1ToAVCOTI(o.videoCodec)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new A(i),t=(k(r,e,["DATA-ID","LANGUAGE","VALUE","URI"]),e["DATA-ID"]);t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Je(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const e=new A(i);k(r,e,["NAME","VALUE","QUERYPARAM"]),He(r,e,t)}break;case"CONTENT-STEERING":{const e=new A(i);k(r,e,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:p.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Ze(i)}}const a=0<i.length&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for($e.lastIndex=0;null!==(i=$e.exec(e));){const e=new A(i[1]),s=e.TYPE;if(s){const i=a[s],h=n[s]||[];n[s]=h,k(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var l={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?p.resolve(e.URI,t):""};if(null!=i&&i.length){const e=p.findGroup(i,l.groupId)||i[0];Qe(l,e,"audioCodec"),Qe(l,e,"textCodec")}h.push(l)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){const a=new te(t),o=a.fragments;let l,h,u,c=null,d=0,f=0,p=0,m=0,g=null,v=new Q(i,t),y=-1,x=!1;for(Ke.lastIndex=0,a.m3u8=e,a.hasVariableRefs=Be(e);null!==(l=Ke.exec(e));){x&&(x=!1,(v=new Q(i,t)).start=p,v.sn=d,v.cc=m,v.level=r,c)&&(v.initSegment=c,v.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null);const e=l[1];if(e){v.duration=parseFloat(e);const t=(" "+l[2]).slice(1);v.title=t||null,v.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(M(v.duration)){v.start=p,u&&rt(v,u,a),v.sn=d,v.level=r,v.cc=m,v.urlId=n,o.push(v);const e=(" "+l[3]).slice(1);v.relurl=Ge(a,e),et(v,g),g=v,p+=v.duration,d++,f=0,x=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);g?v.setByteRange(e,g):v.setByteRange(e)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else if(l=l[0].match(Xe)){for(h=1;h<l.length&&void 0===l[h];h++);const e=(" "+l[h]).slice(1),n=(" "+l[h+1]).slice(1),p=l[h+2]?(" "+l[h+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":a.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(n);break;case"SKIP":{const e=new A(n),t=(k(a,e,["RECENTLY-REMOVED-DATERANGES"]),e.decimalInteger("SKIPPED-SEGMENTS"));if(M(t)){for(let e=a.skippedSegments=t;e--;)o.unshift(null);d+=t}const r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(a.recentlyRemovedDateranges=r.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(n),1);break;case"VERSION":a.version=parseInt(n);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(n||p)&&v.tagList.push(p?[n,p]:[n]);break;case"DISCONTINUITY":m++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([e]);break;case"BITRATE":v.tagList.push([e,n]);break;case"DATERANGE":{const e=new A(n),t=(k(a,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),k(a,e,e.clientAttrs),new K(e,a.dateRanges[e.ID]));t.isValid||a.skippedSegments?a.dateRanges[t.id]=t:I.warn(`Ignoring invalid DATERANGE tag: "${n}"`),v.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new A(n);if(k(a,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e){_=void 0;b=void 0;T=void 0;var _=a;var b=e;var T=s;if(b=b.IMPORT,T&&b in T){let e=_.variableList;e||(_.variableList=e={}),e[b]=T[b]}else _.playlistParsingError||(_.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${b}"`))}else He(a,e,t)}break;case"DISCONTINUITY-SEQUENCE":m=parseInt(n);break;case"KEY":{const e=Je(n,t,a);if(e.isSupported()){if("NONE"===e.method){u=void 0;break}(u=(u=u||{})[e.keyFormat]?L({},u):u)[e.keyFormat]=e}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${n}"`);break}case"START":a.startTimeOffset=Ze(n);break;case"MAP":{const e=new A(n);if(k(a,e,["BYTERANGE","URI"]),v.duration){const n=new Q(i,t);tt(n,e,r,u),c=n,(v.initSegment=c).rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=c.rawProgramDateTime)}else tt(v,e,r,u),c=v,x=!0;break}case"SERVER-CONTROL":{const e=new A(n);a.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=0<a.canSkipUntil&&e.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),a.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new A(n);a.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=a.partList;e=e||(a.partList=[]);const r=0<f?e[e.length-1]:void 0,i=f++,s=new A(n),o=(k(a,s,["BYTERANGE","URI"]),new ee(s,v,t,i,r));e.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const e=new A(n);k(a,e,["URI"]),a.preloadHint=e;break}case"RENDITION-REPORT":{const e=new A(n);k(a,e,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(e);break}default:I.warn("line parsed but not handled: "+l)}}else I.warn("No matches on slow regex match for level playlist!")}g&&!g.relurl?(o.pop(),p-=g.duration,a.partList&&(a.fragmentHint=g)):a.partList&&(et(v,g),v.cc=m,a.fragmentHint=v,u)&&rt(v,u,a);var S=o.length,E=o[0],w=o[S-1];if(0<(p+=a.skippedSegments*a.targetduration)&&S&&w){a.averagetargetduration=p/S;const e=w.sn;a.endSN="initSegment"!==e?e:0,a.live||(w.endList=!0),E&&(a.startCC=E.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(p+=a.fragmentHint.duration),a.totalduration=p,a.endCC=m,0<y&&function(t,r){let i=t[r];for(let e=r;e--;){const r=t[e];if(!r)return;r.programDateTime=i.programDateTime-1e3*r.duration,i=r}}(o,y),a}}function Je(e,t,r){var e=new A(e),r=(k(r,e,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]),null!=(r=e.METHOD)?r:""),i=e.URI,n=e.hexadecimalInteger("IV"),s=e.KEYFORMATVERSIONS,a=null!=(a=e.KEYFORMAT)?a:"identity",e=(i&&e.IV&&!n&&I.error("Invalid IV: "+e.IV),i?p.resolve(i,t):""),i=(s||"1").split("/").map(Number).filter(Number.isFinite);return new Ne(r,e,a,i,n)}function Ze(e){e=new A(e).decimalFloatingPoint("TIME-OFFSET");return M(e)?e:null}function Qe(e,t,r){t=t[r];t&&(e[r]=t)}function et(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),M(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function tt(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function rt(e,t,r){e.levelkeys=t;r=r.encryptedFragments;r.length&&r[r.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||r.push(e)}var it="manifest",nt="level",g="audioTrack",v="subtitleTrack",y="main",T="audio",st="subtitle";function at(e){e=e.type;switch(e){case g:return T;case v:return st;default:return y}}function ot(e,t){let r=e.url;return r=void 0!==r&&0!==r.indexOf("data:")?r:t.url}class lt{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){var t=this.hls.config,r=t.pLoader,i=t.loader,r=new(r||i)(t);return this.loaders[e.type]=r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){t=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:it,url:t,deliveryDirectives:null})}onLevelLoading(e,t){var{id:t,level:r,url:i,deliveryDirectives:n}=t;this.load({id:t,level:r,responseType:"text",type:nt,url:i,deliveryDirectives:n})}onAudioTrackLoading(e,t){var{id:t,groupId:r,url:i,deliveryDirectives:n}=t;this.load({id:t,groupId:r,level:null,responseType:"text",type:g,url:i,deliveryDirectives:n})}onSubtitleTrackLoading(e,t){var{id:t,groupId:r,url:i,deliveryDirectives:n}=t;this.load({id:t,groupId:r,level:null,responseType:"text",type:v,url:i,deliveryDirectives:n})}load(t){const r=this.hls.config;let i,e=this.getInternalLoader(t);if(e){const n=e.context;if(n&&n.url===t.url)return void I.trace("[playlist-loader]: playlist request ongoing");I.log("[playlist-loader]: aborting previous loader for type: "+t.type),e.abort()}if(i=t.type===it?r.manifestLoadPolicy.default:L({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),e=this.createInternalLoader(t),null!=(n=t.deliveryDirectives)&&n.part){let e;if(t.type===nt&&null!==t.level?e=this.hls.levels[t.level].details:t.type===g&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===v&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,r=e.targetduration;if(t&&r){const n=1e3*Math.max(3*t,.8*r);i=L({},i,{maxTimeToFirstByteMs:Math.min(n,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(n,i.maxTimeToFirstByteMs)})}}}var n=i.errorRetry||i.timeoutRetry||{},n={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};e.load(t,n,{onSuccess:(e,t,r,i)=>{var n=this.getInternalLoader(r),s=(this.resetInternalLoader(r.type),e.data);0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),p.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}})}handleMasterPlaylist(e,t,r,i){var n,s,a,o,l,h=this.hls,u=e.data,c=ot(e,r),d=p.parseMasterPlaylist(u,c);d.playlistParsingError?this.handleManifestParsingError(e,r,d.playlistParsingError,i,t):({contentSteering:e,levels:r,sessionData:n,sessionKeys:s,startTimeOffset:a,variableList:o}=d,{AUDIO:u=[],SUBTITLES:d,"CLOSED-CAPTIONS":l}=(this.variableList=o,p.parseMasterPlaylistMedia(u,c,d)),u.length&&!u.some(e=>!e.url)&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),u.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new A({}),bitrate:0,url:""})),h.trigger(R.MANIFEST_LOADED,{levels:r,audioTracks:u,subtitles:d,captions:l,contentSteering:e,url:c,stats:t,networkDetails:i,sessionData:n,sessionKeys:s,startTimeOffset:a,variableList:o}))}handleTrackOrLevelPlaylist(e,t,r,i,n){var s=this.hls,{id:a,level:o,type:l}=r,h=ot(e,r),a=M(a)?a:0,o=M(o)?o:a,u=at(r),o=p.parseLevelPlaylist(e.data,h,o,u,a,this.variableList);if(l===it){const e={attrs:new A({}),bitrate:0,details:o,name:"",url:h};s.trigger(R.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:h,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=o,this.handlePlaylistLoaded(o,e,t,r,i,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===it,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading `+e.type;e.type===nt?s+=`: ${e.level} id: `+e.id:e.type!==g&&e.type!==v||(s+=` id: ${e.id} group-id: "${e.groupId}"`);var a=new Error(s);I.warn("[playlist-loader]: "+s);let o=D.UNKNOWN,l=!1;var h=this.getInternalLoader(e);switch(e.type){case it:o=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,l=!0;break;case nt:o=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,l=!1;break;case g:o=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case v:o=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,l=!1}h&&this.resetInternalLoader(e.type);h={type:C.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:h,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;h.response=m({url:r,data:void 0},i)}this.hls.trigger(R.ERROR,h)}handlePlaylistLoaded(e,t,r,i,n,s){var a=this.hls,{type:o,level:l,id:h,groupId:u,deliveryDirectives:c}=i,d=ot(t,i),f=at(i),p="number"==typeof i.level&&f===y?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));l=e.playlistParsingError;if(l)a.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:l,reason:l.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r});else switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case it:case nt:a.trigger(R.LEVEL_LOADED,{details:e,level:p||0,id:h||0,stats:r,networkDetails:n,deliveryDirectives:c});break;case g:a.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:h||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:c});break;case v:a.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:h||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:c})}}else{const e=new Error("No Segments found in Playlist");void a.trigger(R.ERROR,{type:C.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:e,reason:e.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r})}}}function ht(e,t){let r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ut(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){I.debug("[texttrack-utils]: "+r);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){I.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===r&&(e.mode=r)}function ct(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function dt(t,e,r,i){const n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&0<t.cues.length){const n=function(r,i,n){const s=[],a=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;let i=0,n=r;for(;i<=n;){var s=Math.floor((n+i)/2);if(t<e[s].startTime)n=s-1;else{if(!(t>e[s].startTime&&i<r))return s;i=s+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(r,i);if(-1<a)for(let e=a,t=r.length;e<t;e++){const a=r[e];if(a.startTime>=i&&a.endTime<=n)s.push(a);else if(a.startTime>n)return s}return s}(t.cues,e,r);for(let e=0;e<n.length;e++)i&&!i(n[e])||t.removeCue(n[e])}"disabled"===n&&(t.mode=n)}var ft="org.id3",pt="https://aomedia.org/emsg/ID3";function mt(){if("undefined"!=typeof self)return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const gt=(()=>{var e=mt();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function vt(e,t){return e.getTime()/1e3-t}class yt{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(ct(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){e=this.getID3Track(e.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){var r=t[e];if("metadata"===r.kind&&"id3"===r.label)return ht(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(r,i){if(this.media){const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:t}}=this["hls"];if(a||t){const o=i["samples"];this.id3Track||(this.id3Track=this.createTrack(this.media));var n=mt();for(let e=0;e<o.length;e++){const i=o[e].type;if((i!==pt||a)&&t){var s=xe(o[e].data);if(s){const a=o[e].pts;let t=a+o[e].duration;(t=t>gt?gt:t)-a<=0&&(t=a+.25);for(let e=0;e<s.length;e++){const o=s[e];if(!ye(o)){this.updateId3CueEnds(a,i);const r=new n(a,t,"");r.value=o,i&&(r.type=i),this.id3Track.addCue(r)}}}}}}}}updateId3CueEnds(t,r){var e,i=null==(e=this.id3Track)?void 0:e.cues;if(i)for(let e=i.length;e--;){var n=i[e];n.type===r&&n.startTime<t&&n.endTime===gt&&(n.endTime=t)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){var{id3Track:n,hls:s}=this;if(s){const{enableEmsgMetadataCues:a,enableID3MetadataCues:o}=s["config"];n&&(a||o)&&dt(n,t,r,"audio"===i?e=>e.type===ft&&o:"video"===i?e=>e.type===pt&&a:e=>e.type===ft&&o||e.type===pt&&a)}}onLevelUpdated(t,{details:n}){if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:c,id3Track:d}=this,f=n["dateRanges"],p=Object.keys(f);if(d){const t=Object.keys(c).filter(e=>!p.includes(e));for(let e=t.length;e--;){const f=t[e];Object.keys(c[f].cues).forEach(e=>{d.removeCue(c[f].cues[e])}),delete c[f]}}const m=n.fragments[n.fragments.length-1];if(0!==p.length&&M(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var s,a=m.programDateTime/1e3-m.start,o=mt();for(let e=0;e<p.length;e++){const n=p[e],d=f[n],m=c[n],M=(null==m?void 0:m.cues)||{};let r=(null==m?void 0:m.durationKnown)||!1;var l=vt(d.startDate,a);let i=gt;var h=d.endDate;if(h)i=vt(h,a),r=!0;else if(d.endOnNext&&!r){const t=p.reduce((e,t)=>{var r=f[t];return r.class===d.class&&r.id!==t&&r.startDate>d.startDate&&e.push(r),e},[]).sort((e,t)=>e.startDate.getTime()-t.startDate.getTime())[0];t&&(i=vt(t.startDate,a),r=!0)}var u=Object.keys(d.attr);for(let e=0;e<u.length;e++){const c=u[e];if("ID"!==(s=c)&&"CLASS"!==s&&"START-DATE"!==s&&"DURATION"!==s&&"END-DATE"!==s&&"END-ON-NEXT"!==s){let t=M[c];if(t)r&&!m.durationKnown&&(t.endTime=i);else{let e=d.attr[c];t=new o(l,i,""),"SCTE35-OUT"!==(s=c)&&"SCTE35-IN"!==s||(s=e,e=Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),t.value={key:c,data:e},t.type="com.apple.quicktime.HLS",t.id=n,this.id3Track.addCue(t),M[c]=t}}}c[n]={cues:M,dateRange:d,durationKnown:r}}}}}}class xt{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){var e=this["levelDetails"];if(null===e)return null;var{holdBack:e,partHoldBack:t,targetduration:r}=e,{liveSyncDuration:i,liveSyncDurationCount:n,lowLatencyMode:s}=this.config,a=this.hls.userConfig;let o=s&&t||e;return(o=a.liveSyncDuration||a.liveSyncDurationCount||0===o?void 0!==i?i:n*r:o)+Math.min(+this.stallCount,r)}get liveSyncPosition(){var e,t=this.estimateLiveEdge(),r=this.targetLatency,i=this.levelDetails;return null===t||null===r||null===i?null:(e=i.edge,t=t-r-this.edgeStalled,r=e-i.totalduration,e=e-(this.config.lowLatencyMode&&i.partTarget||i.targetduration),Math.min(Math.max(r,t),e))}get drift(){var e=this["levelDetails"];return null===e?1:e.drift}get edgeStalled(){var e,t=this["levelDetails"];return null===t?0:(e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),Math.max(t.age-e,0))}get forwardBufferLength(){var e,{media:t,levelDetails:r}=this;return t&&r?((e=t.buffered.length)?t.buffered.end(e-1):r.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){(this.levelDetails=t).advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(t=this.levelDetails))&&t.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){const{media:e,levelDetails:t}=this;if(e&&t){this.currentTime=e.currentTime;const s=this.computeLatency();if(null!==s){this._latency=s;var{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(r&&1!==i){r=this.targetLatency;if(null!==r){var n=s-r,r=n<Math.min(this.maxLatency,r+t.targetduration);if(t.live&&r&&.05<n&&1<this.forwardBufferLength){const t=Math.min(2,Math.max(1,i)),s=Math.round(2/(1+Math.exp(-.75*n-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,s))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}}estimateLiveEdge(){var e=this["levelDetails"];return null===e?null:e.edge+e.age}computeLatency(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const _t=["NONE","TYPE-0","TYPE-1",null];class bt{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){e=new self.URL(e);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Tt{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){e%=this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function St(r,i){var n=i.startPTS;if(M(n)){let e,t=0;(e=i.sn>r.sn?(t=n-r.start,r):(t=r.start-n,i)).duration!==t&&(e.duration=t)}else i.sn>r.sn?r.cc===i.cc&&r.minEndPTS?i.start=r.start+(r.minEndPTS-r.start):i.start=r.start+r.duration:i.start=Math.max(r.start-i.duration,0)}function Et(e,t,r,i,n,s){i-r<=0&&(I.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let a=r,o=i;var l=t.startPTS,h=t.endPTS;if(M(l)){const e=Math.abs(l-r);M(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,a=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),o=Math.min(i,h),i=Math.max(i,h),s=Math.max(s,t.endDTS)}l=r-t.start,0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=a,t.startDTS=n,t.endPTS=i,t.minEndPTS=o,t.endDTS=s,h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let u;var r=h-e.startSN,c=e.fragments;for(c[r]=t,u=r;0<u;u--)St(c[u],c[u-1]);for(u=r;u<c.length-1;u++)St(c[u],c[u+1]);return e.fragmentHint&&St(c[c.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,l}function wt(e,r){let i=null;var t=e.fragments;for(let e=t.length-1;0<=e;e--){const r=t[e].initSegment;if(r){i=r;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let n,s=0;{var a,o,l=e,h=r;const m=h.skippedSegments,g=Math.max(l.startSN,h.startSN)-h.startSN,v=(l.fragmentHint?1:0)+(m?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,y=h.startSN-l.startSN,x=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,_=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;for(let t=g;t<=v;t++){const g=_[y+t];let e=x[t];m&&!e&&t<m&&(e=h.fragments[t]=g),g&&e&&(a=g,o=e,a.relurl&&(s=a.cc-o.cc),M(a.startPTS)&&M(a.endPTS)&&(o.start=o.startPTS=a.startPTS,o.startDTS=a.startDTS,o.maxStartPTS=a.maxStartPTS,o.endPTS=a.endPTS,o.endDTS=a.endDTS,o.minEndPTS=a.minEndPTS,o.duration=a.endPTS-a.startPTS,o.duration&&(n=o),r.PTSKnown=r.alignedSliding=!0),o.elementaryStreams=a.elementaryStreams,o.loader=a.loader,o.stats=a.stats,o.urlId=a.urlId,a.initSegment)&&(o.initSegment=a.initSegment,i=a.initSegment)}}if(i&&(r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments).forEach(e=>{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(e=>!e),r.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=r.skippedSegments;e--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(e,r,t){const i=L({},e);return t&&t.forEach(e=>{delete i[e]}),Object.keys(r).forEach(e=>{var t=new K(r[e].attr,i[e]);t.isValid?i[e]=t:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(r[e].attr)}"`)}),i}(e.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var u=r.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<u.length;e++)u[e].cc+=s}r.skippedSegments&&(r.startCC=r.fragments[0].cc);var c=e.partList,d=r.partList;if(c&&d){let r=0;for(let e=0,t=c.length;e<=t;e++){var f=c[e],p=d[e+r];f&&p&&f.index===p.index&&f.fragment.sn===p.fragment.sn?(f=f,(p=p).elementaryStreams=f.elementaryStreams,p.stats=f.stats):r--}}n?Et(r,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Mt(e,r),u.length&&(r.totalduration=r.edge-u[0].start),r.driftStartTime=e.driftStartTime,r.driftStart=e.driftStart;l=r.advancedDateTime;if(r.advanced&&l){const e=r.edge;r.driftStart||(r.driftStartTime=l,r.driftStart=e),r.driftEndTime=l,r.driftEnd=e}else r.driftEndTime=e.driftEndTime,r.driftEnd=e.driftEnd,r.advancedDateTime=e.advancedDateTime}function Mt(e,t){var r=t.startSN+t.skippedSegments-e.startSN,e=e.fragments;r<0||r>=e.length||At(t,e[r].start)}function At(t,r){if(r){var i=t.fragments;for(let e=t.skippedSegments;e<i.length;e++)i[e].start+=r;t.fragmentHint&&(t.fragmentHint.start+=r)}}function Lt(e,t,r){return null!=e&&e.details?Rt(null==(e=e.details)?void 0:e.partList,t,r):null}function Rt(t,r,i){if(t)for(let e=t.length;e--;){var n=t[e];if(n.index===i&&n.fragment.sn===r)return n}return null}function Ct(e){switch(e.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Dt(e,t){t=Ct(t);return e.default[(t?"timeout":"error")+"Retry"]}function It(e,t){t="linear"===e.backoff?1:Math.pow(2,t);return Math.min(t*e.retryDelayMs,e.maxRetryDelayMs)}function Pt(e){return m(m({},e),{errorRetry:null,timeoutRetry:null})}function kt(e,t,r,i){return e&&t<e.maxNumRetry&&(0===i&&!1===navigator.onLine||i&&(i<400||499<i)||r)}function Ot(e,t){let r=0,i=e.length-1,n,s;for(;r<=i;){var a=t(s=e[n=(r+i)/2|0]);if(0<a)r=1+n;else{if(!(a<0))return s;i=n-1}}return null}function Ft(e,t,r=0,i=0){let n=null;return e?n=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(n=t[0]),n&&0===Nt(r,i,n)||!(t=Ot(t,Nt.bind(null,r,i)))||t===e&&n?n:t}function Nt(e=0,t=0,r){return r.start<=e&&r.start+r.duration>e?0:(t=Math.min(t,r.duration+(r.deltaPTS||0)),r.start+r.duration-t<=e?1:r.start-t>e&&r.start?-1:0)}class Ut{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,t+":"),this.warn=I.warn.bind(I,t+":"),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(i,n){var s=null==n?void 0:n.renditionReports;if(s){let r=-1;for(let t=0;t<s.length;t++){var a=s[t];let e;try{e=new self.URL(a.URI,n.url).href}catch(i){I.warn("Could not construct new URL for Rendition Report: "+i),e=a.URI||""}if(e===i){r=t;break}e===i.substring(0,e.length)&&(r=t)}if(-1!==r){const i=s[r],t=parseInt(i["LAST-MSN"])||(null==n?void 0:n.lastPartSn);let e=parseInt(i["LAST-PART"])||(null==n?void 0:n.lastPartIndex);if(this.hls.config.lowLatencyMode){const i=Math.min(n.age-n.partTarget,n.targetduration);0<=e&&i>n.partTarget&&(e+=1)}return new bt(t,0<=e?e:void 0,"")}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(n,s,a){const{details:o,stats:l}=s,h=self.performance.now(),e=l.loading.first?Math.max(0,h-l.loading.first):0;if(o.advancedDateTime=Date.now()-e,o.live||null!=a&&a.live){if(o.reloaded(a),a&&this.log(`live playlist ${n} `+(o.advanced?"REFRESHED "+o.lastPartSn+"-"+o.lastPartIndex:o.updated?"UPDATED":"MISSED")),a&&0<o.fragments.length&&wt(a,o),this.canLoad&&o.live){let t,r=void 0,i=void 0;if(o.canBlockReload&&o.endSN&&o.advanced){const n=this.hls.config.lowLatencyMode,l=o.lastPartSn,h=o.endSN,d=o.lastPartIndex,f=l===h,p=n?0:d;-1!==d?(r=f?h+1:l,i=f?p:d+1):r=h+1;var u=o.age,c=u+o.ageHeader;let e=Math.min(c-o.partTarget,1.5*o.targetduration);if(0<e){if(a&&e>a.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${a.tuneInGoal} to: ${e} with playlist age: `+o.age),e=0;else{const n=Math.floor(e/o.targetduration);r+=n,void 0!==i&&(i+=Math.round(e%o.targetduration/o.partTarget)),this.log(`CDN Tune-in age: ${o.ageHeader}s last advanced ${u.toFixed(2)}s goal: ${e} skip sn ${n} to part `+i)}o.tuneInGoal=e}if(t=this.getDeliveryDirectives(o,s.deliveryDirectives,r,i),n||!f)return void this.loadPlaylist(t)}else(o.canBlockReload||o.canSkipUntil)&&(t=this.getDeliveryDirectives(o,s.deliveryDirectives,r,i));c=this.hls.mainForwardBufferInfo,a=c?c.end-c.len:0,u=function(e,t){let r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}(o,1e3*(o.edge-a)),s=(o.updated&&h>this.requestScheduled+u&&(this.requestScheduled=l.loading.start),void 0!==r&&o.canBlockReload?this.requestScheduled=l.loading.first+u-(1e3*o.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<h?this.requestScheduled=h:this.requestScheduled-h<=0&&(this.requestScheduled+=u),this.requestScheduled-h),s=Math.max(0,s);this.log(`reload live playlist ${n} in ${Math.round(s)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(t),s)}}else this.clearTimer()}getDeliveryDirectives(i,e,n,t){let r=function(){var{canSkipUntil:e,canSkipDateRanges:t,endSN:r}=i;return e&&(void 0!==n?n-r:0)<e?t?"v2":"YES":""}();return null!=e&&e.skip&&i.deltaUpdateFailed&&(n=e.msn,t=e.part,r=""),new bt(n,t,r)}checkRetry(e){var t=e.details,r=Ct(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},n=!!i&&!!a&&(5===n||!i.resolved&&2===n);if(n){if(this.requestScheduled=-1,s>=a.maxNumRetry)return!1;if(r&&null!=(r=e.context)&&r.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=It(a,s);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return n}}let Bt;class Gt extends Ut{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.ERROR,this.onError,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const o=[],l={};let h;t.levels.forEach(e=>{var t=e.attrs,{AUDIO:r,CODECS:t,"FRAME-RATE":i,"PATHWAY-ID":n,RESOLUTION:s,SUBTITLES:a}=(-1!==(null==(r=e.audioCodec)?void 0:r.indexOf("mp4a.40.34"))&&(Bt=Bt||/chrome|firefox/i.test(navigator.userAgent))&&(e.audioCodec=void 0),t),n=(n||".")+"-"+e.bitrate+`-${s}-${i}-`+t;(h=l[n])?h.addFallback(e):(h=new Tt(e),l[n]=h,o.push(h)),Ht(h,"audio",r),Ht(h,"text",a)}),this.filterAndSortMediaOptions(o,t)}filterAndSortMediaOptions(e,r){let i=[],n=[],s=!1,a=!1,o=!1,l=e.filter(({audioCodec:e,videoCodec:t,width:r,height:i,unknownCodecs:n})=>(s=s||!(!r||!i),a=a||!!t,o=o||!!e,!(null!=n&&n.length)&&(!e||je(e,"audio"))&&(!t||je(t,"video"))));if(0===(l=(s||a)&&o?l.filter(({videoCodec:e,width:t,height:r})=>!!e||!(!t||!r)):l).length)Promise.resolve().then(()=>{var e;this.hls&&(e=new Error("no level with compatible codecs found in manifest"),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:e,reason:e.message}))});else{r.audioTracks&&zt(i=r.audioTracks.filter(e=>!e.audioCodec||je(e.audioCodec,"audio"))),r.subtitles&&zt(n=r.subtitles);var h=l.slice(0);l.sort((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):s&&e.height!==t.height?e.height-t.height:0);let t=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(let e=0;e<h.length;e++)if(h[e].pathwayId===l[0].pathwayId){t=h[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===t){this._firstLevel=e,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: `+t.bitrate);break}e=o&&!a,e={levels:l,audioTracks:i,subtitleTracks:n,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:o,video:a,altAudio:!e&&i.some(e=>!!e.url)};this.hls.trigger(R.MANIFEST_PARSED,e),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r!==e||!s.details||!i||n!==a){this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level `+r+(n?" with Pathway "+n:""));t=L({},s,{level:e,maxBitrate:s.maxBitrate,attrs:s.attrs,uri:s.uri,urlId:s.urlId}),e=(delete t._attrs,delete t._urlId,this.hls.trigger(R.LEVEL_SWITCHING,t),s.details);if(!e||e.live){const e=this.switchParams(s.uri,null==i?void 0:i.details);this.loadPlaylist(e)}}}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===nt&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(void 0!==t&&t.type===y){const e=this._levels[t.level];void 0!==e&&(e.loadError=0)}}onLevelLoaded(e,t){var{level:r,details:i}=t,n=this._levels[r];n?r===this.currentLevelIndex?(0===n.fragmentError&&(n.loadError=0),this.playlistLoaded(r,t,n.details)):null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0):(this.warn("Invalid level index "+r),null!=(n=t.deliveryDirectives)&&n.skip&&(i.deltaUpdateFailed=!0))}onAudioTrackSwitched(e,t){var r=this.currentLevel;if(r){var i=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let t=-1;for(let e=0;e<r.audioGroupIds.length;e++)if(r.audioGroupIds[e]===i){t=e;break}-1!==t&&t!==r.urlId&&(r.urlId=t,this.canLoad)&&this.startLoad()}}}loadPlaylist(t){super.loadPlaylist();var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.urlId;let e=i.uri;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}var s=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${r}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""} with${s?" Pathway "+s:""} URI ${n+1}/${i.url.length} `+e),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:e,level:r,id:n,deliveryDirectives:t||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(r,i){const n=(e,t)=>t!==i,e=this._levels.filter((e,t)=>t!==r||(1<e.url.length&&void 0!==i?(e.url=e.url.filter(n),e.audioGroupIds&&(e.audioGroupIds=e.audioGroupIds.filter(n)),e.textGroupIds&&(e.textGroupIds=e.textGroupIds.filter(n)),!(e.urlId=0)):(this.steering&&this.steering.removeLevel(e),!1)));this.hls.trigger(R.LEVELS_UPDATED,{levels:e})}onLevelsUpdated(e,{levels:t}){t.forEach((e,t)=>{e=e.details;null!=e&&e.fragments&&e.fragments.forEach(e=>{e.level=t})}),this._levels=t}}function Ht(e,t,r){r&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=r):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=r))}function zt(e){const r={};e.forEach(e=>{var t=e.groupId||"";e.id=r[t]=r[t]||0,r[t]++})}var Vt="NOT_LOADED",Wt="PARTIAL";class jt{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var e=this["hls"];e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){var r=this.activePartLists[e];if(r)for(let e=r.length;e--;){var i=r[e];if(!i)break;var n=i.end;if(i.start<=t&&null!==n&&t<=n)return i}return this.getBufferedFrag(t,e)}getBufferedFrag(t,r){var i=this["fragments"],n=Object.keys(i);for(let e=n.length;e--;){var s=i[n[e]];if((null==s?void 0:s.body.type)===r&&s.buffered){const r=s.body;if(r.start<=t&&t<=r.end)return r}}return null}detectEvictedFragments(r,i,n,e){this.timeRanges&&(this.timeRanges[r]=i);const s=(null==e?void 0:e.fragment.sn)||-1;Object.keys(this.fragments).forEach(e=>{const t=this.fragments[e];!t||s>=t.body.sn||(t.buffered||t.loaded?(e=t.range[r])&&e.time.some(e=>{e=!this.isTimeBuffered(e.startPTS,e.endPTS,i);return e&&this.removeFragment(t.body),e}):t.body.type===n&&this.removeFragment(t.body))})}detectPartialFragments(e){const i=this.timeRanges,{frag:n,part:s}=e;if(i&&"initSegment"!==n.sn){const t=$t(n),a=this.fragments[t];if(!(!a||a.buffered&&n.gap)){const o=!n.relurl;Object.keys(i).forEach(e=>{var t,r=n.elementaryStreams[e];r&&(t=i[e],r=o||!0===r.partial,a.range[e]=this.getBufferedTimes(n,s,r,t))}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=n.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Yt(a)||this.removeParts(n.sn-1,n.type)):this.removeFragment(a.body)}}}removeParts(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter(e=>e.fragment.sn>=t))}fragBuffered(e,t){var r=$t(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap)&&(this.hasGaps=!0),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,r,i){var n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t)n.partial=!0,n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});else if(a<=t)break}return n}getPartialFragment(t){let r,i,n,s=null,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(e=>{e=l[e];e&&Yt(e)&&(i=e.body.start-o,n=e.body.end+o,t>=i)&&t<=n&&(r=Math.min(t-i,n-t),a<=r)&&(s=e.body,a=r)}),s}isEndListAppended(e){e=this.endListFragments[e];return void 0!==e&&(e.buffered||Yt(e))}getState(e){e=$t(e),e=this.fragments[e];return e?e.buffered?Yt(e)?Wt:"OK":"APPENDING":Vt}isTimeBuffered(t,r,i){var n,s;for(let e=0;e<i.length;e++){if(n=i.start(e)-this.bufferPadding,s=i.end(e)+this.bufferPadding,n<=t&&r<=s)return!0;if(r<=n)return!1}return!1}onFragLoaded(e,t){var r,{frag:i,part:n}=t;"initSegment"===i.sn||i.bitrateTest||(r=$t(i),this.fragments[r]={body:i,appendedPTS:null,loaded:n?null:t,buffered:!1,range:Object.create(null)})}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n}=t;if("initSegment"!==r.sn){const s=r.type;if(i){let e=this.activePartLists[s];e||(this.activePartLists[s]=e=[]),e.push(i)}this.timeRanges=n,Object.keys(n).forEach(e=>{var t=n[e];this.detectEvictedFragments(e,t,s,i)})}}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){e=$t(e);return!!this.fragments[e]}hasParts(e){return!(null==(e=this.activePartLists[e])||!e.length)}removeFragmentsInRange(r,i,n,s,a){s&&!this.hasGaps||Object.keys(this.fragments).forEach(e=>{var t,e=this.fragments[e];!e||(t=e.body).type!==n||s&&!t.gap||t.start<i&&t.end>r&&(e.buffered||a)&&this.removeFragment(t)})}removeFragment(e){const t=$t(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=r.filter(e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Yt(e){var t;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(t=e.range.audio)?void 0:t.partial)||(null==(t=e.range.audiovideo)?void 0:t.partial))}function $t(e){return`${e.type}_${e.level}_${e.urlId}_`+e.sn}const qt=Math.pow(2,17);class Kt{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const h=o.url;if(!h)return Promise.reject(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(h?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,u=r.fLoader,c=r.loader;return new Promise((s,n)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(e=>"GAP"===e[0]))return void n(Jt(o));o.gap=!1}const a=this.loader=o.loader=new(u||c)(r),e=Xt(o),t=Pt(r.fragLoadPolicy.default),i={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:qt};o.stats=a.stats,a.load(e,i,{onSuccess:(e,t,r,i)=>{this.resetLoader(o,a);let n=e.data;r.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),s({frag:o,part:null,payload:n,networkDetails:i})},onError:(e,t,r,i)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:m({url:h,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:r,stats:i}))},onAbort:(e,t,r)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,t,r)=>{this.resetLoader(o,a),n(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:e}))},onProgress:(e,t,r,i)=>{l&&l({frag:o,part:null,payload:r,networkDetails:i})}})})}loadPart(l,h,u){this.abort();const t=this.config,r=t.fLoader,c=t.loader;return new Promise((n,s)=>{if(this.loader&&this.loader.destroy(),l.gap||h.gap)s(Jt(l,h));else{const a=this.loader=l.loader=new(r||c)(t),o=Xt(l,h),e=Pt(t.fragLoadPolicy.default),i={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qt};h.stats=a.stats,a.load(o,i,{onSuccess:(e,t,r,i)=>{this.resetLoader(l,a),this.updateStatsFromPart(l,h);e={frag:l,part:h,payload:e.data,networkDetails:i};u(e),n(e)},onError:(e,t,r,i)=>{this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:h,response:m({url:o.url,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:r,stats:i}))},onAbort:(e,t,r)=>{l.stats.aborted=h.stats.aborted,this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:l,part:h,error:new Error("Aborted"),networkDetails:r,stats:e}))},onTimeout:(e,t,r)=>{this.resetLoader(l,a),s(new x({type:C.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:h,error:new Error(`Timeout after ${i.timeout}ms`),networkDetails:r,stats:e}))}})}})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Xt(r,i=null){var n=i||r,i={frag:r,part:i,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,n=n.byteRangeEndOffset;if(M(s)&&M(n)){let e=s,t=n;if("initSegment"===r.sn&&"AES-128"===(null==(r=r.decryptdata)?void 0:r.method)){const r=n-s;r%16&&(t=n+(16-r%16)),0!==s&&(i.resetIV=!0,e=s-16)}i.rangeStart=e,i.rangeEnd=t}return i}function Jt(e,t){var r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),r={type:C.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(r.part=t),(t||e).stats.aborted=!0,new x(r)}class x extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Zt{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[r].loader;if(t){if(e&&e!==t.context.frag.type)return;t.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,i,n){return new x({type:C.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){var{sn:r,cc:i}=e;for(let e=0;e<t.length;e++){const n=t[e];if(i<=n.cc&&("initSegment"===r||"initSegment"===n.sn||r<n.sn)){this.emeController.selectKeySystemFormat(n).then(e=>{n.setKeyFormat(e)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const i=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,i))}var i,e=r.uri;if(!e)return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${e}"`)));let n=this.keyUriToKeyInfo[e];if(null!=(i=n)&&i.decryptdata.key)return r.key=n.decryptdata.key,Promise.resolve({frag:t,keyInfo:n});if(null!=(i=n)&&i.keyLoadPromise)switch(null==(i=n.mediaKeySessionContext)?void 0:i.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return n.keyLoadPromise.then(e=>(r.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:n}))}switch(n=this.keyUriToKeyInfo[e]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(n,t):this.loadKeyEME(n,t);case"AES-128":return this.loadKeyHTTP(n,t);default:return Promise.reject(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(t,e){const r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(r);if(e)return(t.keyLoadPromise=e.then(e=>(t.mediaKeySessionContext=e,r))).catch(e=>{throw t.keyLoadPromise=null,e})}return Promise.resolve(r)}loadKeyHTTP(i,s){const l=this.config,h=new l.loader(l);return s.keyLoader=i.loader=h,i.keyLoadPromise=new Promise((a,o)=>{const n={keyInfo:i,frag:s,responseType:"arraybuffer",url:i.decryptdata.uri},e=l.keyLoadPolicy.default,t={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},r={onSuccess:(e,t,r,i)=>{var{frag:r,keyInfo:n,url:s}=r;if(!r.decryptdata||n!==this.keyUriToKeyInfo[s])return o(this.createKeyLoadError(r,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));n.decryptdata.key=r.decryptdata.key=new Uint8Array(e.data),r.keyLoader=null,n.loader=null,a({frag:r,keyInfo:n})},onError:(e,t,r,i)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key `+e.text),r,m({url:n.url,data:void 0},e)))},onTimeout:(e,t,r)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(e,t,r)=>{this.resetLoader(t),o(this.createKeyLoadError(s,D.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};h.load(n,t,r)})}resetLoader(e){var{frag:e,keyInfo:t,url:r}=e,i=t.loader;e.keyLoader===i&&(e.keyLoader=null,t.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}const Qt={length:0,start:()=>0,end:()=>0};class _{static isBuffered(e,t){try{if(e){var r=_.getBuffered(e);for(let e=0;e<r.length;e++)if(t>=r.start(e)&&t<=r.end(e))return!0}}catch(e){}return!1}static bufferInfo(t,r,i){try{if(t){var n=_.getBuffered(t),s=[];let e;for(e=0;e<n.length;e++)s.push({start:n.start(e),end:n.end(e)});return this.bufferedInfo(s,r,i)}}catch(t){}return{len:0,start:r,end:r,nextStart:void 0}}static bufferedInfo(t,r,i){r=Math.max(0,r),t.sort(function(e,t){return e.start-t.start||t.end-e.end});let n=[];if(i)for(let e=0;e<t.length;e++){const s=n.length;if(s){const a=n[s-1].end;t[e].start-a<i?t[e].end>a&&(n[s-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;let s,a=0,o=r,l=r;for(let e=0;e<n.length;e++){var h=n[e].start,u=n[e].end;if(h<=r+i&&r<u)o=h,l=u,a=l-r;else if(r+i<h){s=h;break}}return{len:a,start:o||0,end:l||0,nextStart:s}}static getBuffered(e){try{return e.buffered}catch(e){return I.log("failed to get media.buffered",e),Qt}}}class er{constructor(e,t,r,i=0,n=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=s}}function tr(r,i){let n=null;for(let e=0,t=r.length;e<t;e++){var s=r[e];if(s&&s.cc===i){n=s;break}}return n}function rr(e,t){e&&(t=e.start+t,e.start=e.startPTS=t,e.endPTS=t+e.duration)}function ir(r,e){var i=e.fragments;for(let e=0,t=i.length;e<t;e++)rr(i[e],r);e.fragmentHint&&rr(e.fragmentHint,r),e.alignedSliding=!0}function nr(e,t){var r,i,n;e.hasProgramDateTime&&t.hasProgramDateTime&&(r=e.fragments,t=t.fragments,r.length)&&t.length&&(r=tr(r,(t=t[Math.round(t.length/2)-1]).cc)||r[Math.round(r.length/2)-1],i=t.programDateTime,n=r.programDateTime,null!==i)&&null!==n&&ir((n-i)/1e3-(r.start-t.start),e)}class sr{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class ar{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class or{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){var t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],h=o[1],u=o[2],c=o[3],d=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)d[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var g=(g=p^p<<1^p<<2^p<<3^p<<4)>>>8^255&g^99;e[f]=g,t[g]=f;const o=d[f],m=d[o],y=d[m];var v=257*d[g]^16843008*g;i[f]=v<<24|v>>>8,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*y^65537*m^257*o^16843008*f,l[g]=v<<24|v>>>8,h[g]=v<<16|v>>>16,u[g]=v<<8|v>>>24,c[g]=v,f?(f=o^d[d[d[y^o]]],p^=d[d[p]]):f=p=1}}expandKey(n){var s=this.uint8ArrayToUint32Array_(n);let e=!0,t=0;for(;t<s.length&&e;)e=s[t]===this.key[t],t++;if(!e){this.key=s;var a=this.keySize=s.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var o=this.ksRows=4*(a+6+1);let e,t;var l=this.keySchedule=new Uint32Array(o),h=this.invKeySchedule=new Uint32Array(o),u=this.sBox,c=this.rcon,n=this.invSubMix,d=n[0],f=n[1],p=n[2],m=n[3];let r,i;for(e=0;e<o;e++)e<a?r=l[e]=s[e]:(i=r,e%a==0?(i=u[(i=i<<8|i>>>24)>>>24]<<24|u[i>>>16&255]<<16|u[i>>>8&255]<<8|u[255&i],i^=c[e/a|0]<<24):6<a&&e%a==4&&(i=u[i>>>24]<<24|u[i>>>16&255]<<16|u[i>>>8&255]<<8|u[255&i]),l[e]=r=(l[e-a]^i)>>>0);for(t=0;t<o;t++)e=o-t,i=3&t?l[e]:l[e-4],h[t]=t<4||e<=4?i:d[u[i>>>24]]^f[u[i>>>16&255]]^p[u[i>>>8&255]]^m[u[255&i]],h[t]=h[t]>>>0}}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){var i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],h=a[2],u=a[3],a=this.uint8ArrayToUint32Array_(r);let c=a[0],d=a[1],f=a[2],p=a[3];var m=new Int32Array(e),g=new Int32Array(m.length);let v,y,x,_,b,T,S,E,w,M,A,L,R,C;for(var D=this.networkToHostOrderSwap;t<m.length;){for(w=D(m[t]),M=D(m[t+1]),A=D(m[t+2]),L=D(m[t+3]),b=w^n[0],T=L^n[1],S=A^n[2],E=M^n[3],R=4,C=1;C<i;C++)v=o[b>>>24]^l[T>>16&255]^h[S>>8&255]^u[255&E]^n[R],y=o[T>>>24]^l[S>>16&255]^h[E>>8&255]^u[255&b]^n[R+1],x=o[S>>>24]^l[E>>16&255]^h[b>>8&255]^u[255&T]^n[R+2],_=o[E>>>24]^l[b>>16&255]^h[T>>8&255]^u[255&S]^n[R+3],b=v,T=y,S=x,E=_,R+=4;v=s[b>>>24]<<24^s[T>>16&255]<<16^s[S>>8&255]<<8^s[255&E]^n[R],y=s[T>>>24]<<24^s[S>>16&255]<<16^s[E>>8&255]<<8^s[255&b]^n[R+1],x=s[S>>>24]<<24^s[E>>16&255]<<16^s[b>>8&255]<<8^s[255&T]^n[R+2],_=s[E>>>24]<<24^s[b>>16&255]<<16^s[T>>8&255]<<8^s[255&S]^n[R+3],g[t]=D(v^c),g[t+1]=D(_^d),g[t+2]=D(x^f),g[t+3]=D(y^p),c=w,d=M,f=A,p=L,t+=4}return g.buffer}}class lr{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}null===this.subtle&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){var e,t,{currentResult:r,remainderData:i}=this;return!r||i?(this.reset(),null):(i=new Uint8Array(r),this.reset(),this.removePKCS7Padding?(e=(r=i).byteLength,(t=e&&new DataView(r.buffer).getUint8(e-1))?fe(r,0,e-t):r):i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(i,n,s){return this.useSoftware?new Promise((e,t)=>{this.softwareDecrypt(new Uint8Array(i),n,s);var r=this.flush();r?e(r.buffer):t(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(i),n,s)}softwareDecrypt(e,t,r){var{currentIV:i,currentResult:n,remainderData:s}=this,s=(this.logOnce("JS AES decrypt"),s&&(e=Ie(s,e),this.remainderData=null),this.getValidChunk(e));if(!s.length)return null;i&&(r=i);let a=this.softwareDecrypter;(a=a||(this.softwareDecrypter=new or)).expandKey(t);e=n;return this.currentResult=a.decrypt(s.buffer,0,r),this.currentIV=fe(s,-16).buffer,e||null}webCryptoDecrypt(t,r,i){const n=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new ar(n,r)),this.fastAesKey.expandKey().then(e=>n?(this.logOnce("WebCrypto AES decrypt"),new sr(n,new Uint8Array(i)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))).catch(e=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${e.name}: `+e.message),this.onWebCryptoError(t,r,i)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);e=this.flush();if(e)return e.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;var r=e.length-e.length%16;return r!==e.length&&(t=fe(e,0,r),this.remainderData=fe(e,r)),t}logOnce(e){this.logEnabled&&(I.log("[decrypter]: "+e),this.logEnabled=!1)}}const a="STOPPED",u="IDLE",hr="KEY_LOADING",ur="FRAG_LOADING",cr="FRAG_LOADING_WAITING_RETRY",dr="WAITING_TRACK",O="PARSING",fr="PARSED",pr="ENDED",mr="ERROR",gr="WAITING_INIT_PTS",vr="WAITING_LEVEL";class yr extends class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),!(this._tickInterval=null))}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),!(this._tickTimer=null))}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),1<this._tickCallCount&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}{constructor(e,t,r,i,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=a,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=i,this.log=I.log.bind(I,i+":"),this.warn=I.warn.bind(I,i+":"),this.hls=e,this.fragmentLoader=new Kt(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new lr(e.config),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=a}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;var r=t.partList;if(null!=r&&r.length){const e=r[r.length-1];return _.isBuffered(this.media,e.start+e.duration/2)}e=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(e)}getLevelDetails(){var e;return!this.levels||null===this.levelLastLoaded||null==(e=this.levels[this.levelLastLoaded])?void 0:e.details}onMediaAttached(e,t){t=this.media=this.mediaBuffer=t.media,this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended),t=this.config;this.levels&&t.autoStartLoad&&this.state===a&&this.startLoad(t.startPosition)}onMediaDetaching(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:n}=this,s=r?r.currentTime:0,a=_.bufferInfo(i||r,s,e.maxBufferHole);if(this.log(`media seeking to ${M(s)?s.toFixed(3):s}, state: `+n),this.state===pr)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(!a.len||n<a.start||i>a.end){const e=s>n;(s<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),this.lastCurrentTime=s),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=a,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(r,e,t){this._doFragLoad(r,e,t,e=>{this.fragContextChanged(r)?(this.warn(`Fragment ${r.sn}${e.part?" p: "+e.part.index:""} of level ${r.level} was dropped during download.`),this.fragmentTracker.removeFragment(r)):(r.stats.chunkCount++,this._handleFragmentLoadProgress(e))}).then(e=>{var t;e&&(t=this.state,this.fragContextChanged(r)?t!==ur&&(this.fragCurrent||t!==O)||(this.fragmentTracker.removeFragment(r),this.state=u):("payload"in e&&(this.log(`Loaded fragment ${r.sn} of level `+r.level),this.hls.trigger(R.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)))}).catch(e=>{this.state!==a&&this.state!==mr&&(this.warn(e),this.resetFragmentLoading(r))})}clearTrackerIfNeeded(e){var t,r=this["fragmentTracker"];if("APPENDING"===r.getState(e)){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(n)&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Wt)&&r.removeFragment(e)}checkLiveUpdate(e){var t;e.updated&&!e.live&&(t=e.fragments[e.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})),e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){e-t&&(e={startOffset:e,endOffset:t,type:r},this.hls.trigger(R.BUFFER_FLUSHING,e))}_loadInitSegment(s,n){this._doFragLoad(s,n).then(e=>{if(e&&!this.fragContextChanged(s)&&this.levels)return e;throw new Error("init load aborted")}).then(r=>{const i=this["hls"],e=r["payload"],t=s.decryptdata;if(e&&0<e.byteLength&&t&&t.key&&t.iv&&"AES-128"===t.method){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(e),t.key.buffer,t.iv.buffer).catch(e=>{throw i.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:s}),e}).then(e=>{var t=self.performance.now();return i.trigger(R.FRAG_DECRYPTED,{frag:s,payload:e,stats:{tstart:n,tdecrypt:t}}),r.payload=e,r})}return r}).then(e=>{var{fragCurrent:t,hls:r,levels:i}=this;if(!i)throw new Error("init load aborted, missing levels");i=s.stats;this.state=u,n.fragmentError=0,s.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),e.frag===t&&r.trigger(R.FRAG_BUFFERED,{stats:i,frag:t,part:null,id:s.type}),this.tick()}).catch(e=>{this.state!==a&&this.state!==mr&&(this.warn(e),this.resetFragmentLoading(s))})}fragContextChanged(e){var t=this["fragCurrent"];return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r=this.mediaBuffer||this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===y?"level":"track"} ${e.level} (frag:[${(null!=(t=e.startPTS)?t:NaN).toFixed(3)}-${(null!=(t=e.endPTS)?t:NaN).toFixed(3)}] > buffer:${r?function(t){let r="";var i=t.length;for(let e=0;e<i;e++)r+=`[${t.start(e).toFixed(3)}-${t.end(e).toFixed(3)}]`;return r}(_.getBuffered(r)):"(detached)"})`),this.state=u,r&&(!this.loadedmetadata&&e.type==y&&r.buffered.length&&(null==(t=this.fragCurrent)?void 0:t.sn)===(null==(e=this.fragPrevious)?void 0:e.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){var t,r,i=this["transmuxer"];i&&({frag:e,part:t,partsLoaded:r}=e,r=!r||0===r.length||r.some(e=>!e),e=new er(e.level,e.sn,e.stats.chunkCount+1,0,t?t.index:-1,!r),i.flush(e))}_handleFragmentLoadProgress(e){}_doFragLoad(t,r,e=null,i){var n,s,a=null==r?void 0:r.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key?!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+t.level),this.state=hr,this.fragCurrent=t,o=this.keyLoader.load(t).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(R.KEY_LOADED,e),this.state===hr&&(this.state=u),e}),this.hls.trigger(R.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),e=Math.max(t.start,e||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const n=a.partList;if(n&&i){e>t.end&&a.fragmentHint&&(t=a.fragmentHint);const l=this.getNextPart(n,t,e);if(-1<l){const h=n[l];return this.log(`Loading part sn: ${t.sn} p: ${h.index} cc: ${t.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${l}-${n.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: `+parseFloat(e.toFixed(3))),this.nextLoadPosition=h.start+h.duration,this.state=ur,s=o?o.then(e=>!e||this.fragContextChanged(e.frag)?null:this.doFragPartsLoad(t,h,r,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(t,h,r,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:h,targetBufferTime:e}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):s}if(!t.url||this.loadedEndOfParts(n,e))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: `+parseFloat(e.toFixed(3))),M(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ur;const l=this.config.progressive;let h;return h=l&&o?o.then(e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(t,l?i:void 0),o]).then(([e])=>(!l&&e&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:e}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(o,r,l,h){return new Promise((i,e)=>{var t;const n=[],s=null==(t=l.details)?void 0:t.partList,a=r=>{this.fragmentLoader.loadPart(o,r,h).then(e=>{var t=(n[r.index]=e).part,e=(this.hls.trigger(R.FRAG_LOADED,e),Lt(l,o.sn,r.index+1)||Rt(s,o.sn,r.index+1));if(!e)return i({frag:o,part:t,partsLoaded:n});a(e)}).catch(e)};a(r)})}handleFragLoadError(e){var t;return"data"in e?(t=e.data,e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(R.ERROR,t)):this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0}),null}_handleTransmuxerFlush(e){var t,r,i,n=this.getCurrentContext(e);n&&this.state===O?({frag:n,part:t,level:r}=n,i=self.performance.now(),n.stats.parsing.end=i,t&&(t.stats.parsing.end=i),this.updateLevelTiming(n,t,r,e.partial)):this.fragCurrent||this.state===a||this.state===mr||(this.state=u)}getCurrentContext(e){var{levels:t,fragCurrent:r}=this,{level:e,sn:i,part:n}=e;if(null==t||!t[e])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${e}. The current chunk will not be buffered.`),null;const s=t[e],a=-1<n?Lt(s,i,n):null,o=a?a.fragment:null!=s&&s.details?(t=s.details).fragments[i-t.startSN]||((e=t.fragmentHint)&&e.sn===i?e:i<t.startSN&&r&&r.sn===i?r:null):null;return o?(r&&r!==o&&(o.stats=r.stats),{frag:o,part:a,level:s}):null}bufferFragmentData(t,r,i,n,s){if(t&&this.state===O){var{data1:a,data2:o}=t;let e=a;null!=(a=e=a&&o?Ie(a,o):e)&&a.length&&(o={type:t.type,frag:r,part:i,chunkMeta:n,parent:r.type,data:e},this.hls.trigger(R.BUFFER_APPENDING,o),t.dropped)&&t.independent&&!i&&!s&&this.flushBufferGap(r)}}flushBufferGap(e){var t,r,i=this.media;i&&(_.isBuffered(i,i.currentTime)?(t=i.currentTime,i=_.bufferInfo(i,t,0),r=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),i=Math.max(Math.min(e.start-r,i.end-r),t+r),e.start-i>r&&this.flushMainBuffer(i,e.start)):this.flushMainBuffer(0,e.start))}getFwdBufferInfo(e,t){var r=this.getLoadPosition();return M(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){var i=this["config"]["maxBufferHole"],n=_.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){r=this.fragmentTracker.getBufferedFrag(t,r);if(r&&n.nextStart<r.end)return _.bufferInfo(e,t,Math.max(n.nextStart,i))}return n}getMaxBufferLength(e){var t=this["config"],e=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength;return Math.min(e,t.maxMaxBufferLength)}reduceMaxBufferLength(e){var t=this.config,e=e||t.maxBufferLength;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=0){e=this.fragmentTracker.getAppendedFrag(e,y);return e&&"fragment"in e?e.fragment:e}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const n=this["config"],s=r[0].start;let a;if(t.live){const s=n.initialLiveManifestSize;if(i<s)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${s})`),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(t,r),this.startPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=s&&(a=r[0]);if(!a){const r=n.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,r,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){var r=this.fragmentTracker.getState(e);return("OK"===r||r===Wt&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){var s=e.gap,t=this.getNextFragment(this.nextLoadPosition,t);if(null===t)return t;if(e=t,s&&e&&!e.gap&&r.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,r.nextStart,i);if(null!==t&&r.len+t.len>=n)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: `+e.sn),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(r,i,n){let s=-1,a=!1,o=!0;for(let e=0,t=r.length;e<t;e++){var l=r[e];if(o=o&&!l.independent,-1<s&&n<l.start)break;var h=l.loaded;h?s=-1:(a||l.independent||o)&&l.fragment===i&&(s=e),a=h}return s}loadedEndOfParts(e,t){e=e[e.length-1];return e&&t>e.start&&e.loaded}getInitialLiveFragment(e,t){var r,i,n=this.fragPrevious;let s=null;if(n)e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),s=function(t,r,i){if(null!==r&&Array.isArray(t)&&t.length&&M(r)&&!(r<(t[0].programDateTime||0)||r>=(t[t.length-1].endProgramDateTime||0))){i=i||0;for(let e=0;e<t.length;++e){var n=t[e];if(s=r,a=i,o=n,a=1e3*Math.min(i,o.duration+(o.deltaPTS||0)),(o.endProgramDateTime||0)-a>s)return n}var s,a,o}return null}(t,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),s||((r=n.sn+1)>=e.startSN&&r<=e.endSN&&(r=t[r-e.startSN],n.cc===r.cc)&&(s=r,this.log("Live playlist, switching playlist, load frag with next SN: "+s.sn)),s)||(s=(r=t,i=n.cc,Ot(r,e=>e.cc<i?1:e.cc>i?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+s.sn);else{const t=this.hls.liveSyncPosition;null!==t&&(s=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){var i=this["config"];let n=this["fragPrevious"],{fragments:s,endSN:a}=r;var o=r["fragmentHint"],l=i.maxFragLookUpTolerance,h=r.partList,i=!!(i.lowLatencyMode&&null!=h&&h.length&&o);let u;if(i&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),u=e<t?Ft(n,s,e,t-l<e?0:l):s[s.length-1]){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((n="OK"===t||t===Wt&&u.gap?u:n)&&u.sn===n.sn&&(!i||h[0].fragment.sn>u.sn)&&n&&u.level===n.level){const t=s[1+e];u=u.sn<a&&"OK"!==this.fragmentTracker.getState(t)?t:null}}return u}synchronizeToLiveEdge(e){var{config:t,media:r}=this;if(r){const i=this.hls.liveSyncPosition,n=r.currentTime,s=e.fragments[0].start,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<a-s)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState)&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : `+i.toFixed(3)),r.currentTime=i)}}}alignPlaylists(e,t){const{levels:r,levelLastLoaded:i,fragPrevious:n}=this,s=null!==i?r[i]:null,a=e.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=e.fragments[0].start,l=!t,h=e.alignedSliding&&M(o);if(l||!h&&!o){var u,l=n,h=s,c=e;if(h){var d=l,f=(l=c,h);if(f.details&&(l.endCC>l.startCC||d&&d.cc<l.startCC)){f=f.details.fragments;const d=(u=l.fragments).length&&f.length?(f=tr(f,u[0].cc))&&f.startPTS?f:void I.log("No frag in previous level to align on"):void I.log("No fragments to align");d&&M(d.start)&&(I.log("Adjusting PTS using last level due to CC increase within current level "+l.url),ir(d.start,l))}!c.alignedSliding&&h.details&&(d=c,(u=h.details).fragments.length)&&d.hasProgramDateTime&&u.hasProgramDateTime&&(f=u.fragments[0].programDateTime,u=((l=d.fragments[0].programDateTime)-f)/1e3+u.fragments[0].start)&&M(u)&&(I.log(`Adjusting PTS using programDateTime delta ${l-f}ms, sliding:${u.toFixed(3)} ${d.url} `),ir(u,d)),c.alignedSliding||!h.details||c.skippedSegments||Mt(h.details,c)}const r=e.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: `+a),r}return o}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;var i,n;-1!==(r=r<t?-1:r)&&-1!==this.lastCurrentTime||(null!==(n=((i=null!==this.startTimeOffset)?this:e).startTimeOffset)&&M(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${i?"multivariant":"media"} playlist, adjust startPosition to `+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r),this.nextLoadPosition=r}getLoadPosition(){var e=this["media"];let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===cr)||(this.state=u)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}var r=t.frag;if(r&&r.type===e&&this.levels)if(this.fragContextChanged(r))this.warn(`Frag load error must match current frag to retry ${r.url} > `+(null==(i=this.fragCurrent)?void 0:i.url));else{var i=t.details===D.FRAG_GAP,n=(i&&this.fragmentTracker.fragBuffered(r,!0),t.errorAction),{action:s,retryCount:a=0,retryConfig:o}=n||{};if(n&&5===s&&o){this.resetStartWhenNotLoaded(null!=(s=this.levelLastLoaded)?s:r.level);const i=It(o,a);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${a+1}/${o.maxNumRetry} in ${i}ms`),n.resolved=!0,this.retryDate=self.performance.now()+i,this.state=cr}else o&&n?(this.resetFragmentErrors(e),a<o.maxNumRetry?i||(n.resolved=!0):I.warn(t.details+` reached or exceeded max retry (${a})`)):2===(null==n?void 0:n.action)?this.state=vr:this.state=mr;this.tickImmediate()}}reduceLengthAndFlushBuffer(e){var t,r,i;return(this.state===O||this.state===fr)&&(t=e.parent,(r=(i=this.getFwdBufferInfo(this.mediaBuffer,t))&&.5<i.len)&&this.reduceMaxBufferLength(i.len),(i=!r)&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),i)}resetFragmentErrors(e){e===T&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==a&&(this.state=u)}afterBufferFlushed(e,t,r){e&&(e=_.getBuffered(e),this.fragmentTracker.detectEvictedFragments(t,e,r),this.state===pr)&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=u}resetStartWhenNotLoaded(e){this.loadedmetadata||(this.startFragRequested=!1,null!=(e=this.levels?this.levels[e].details:null)&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition)}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(n,e,s,a){var t;const o=s.details;if(o){if(Object.keys(n.elementaryStreams).reduce((e,t)=>{var r,i=n.elementaryStreams[t];return i?(r=i.endPTS-i.startPTS)<=0?(this.warn(`Could not parse fragment ${n.sn} ${t} duration reliably (${r})`),e||!1):(r=a?0:Et(o,n,i.startPTS,i.endPTS,i.startDTS,i.endDTS),this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:o,level:s,drift:r,type:t,frag:n,start:i.startPTS,end:i.endPTS}),!0):e},!1))s.fragmentError=0;else if(null===(null==(t=this.transmuxer)?void 0:t.error)){const e=new Error(`Found no media in fragment ${n.sn} of level ${n.level} resetting transmuxer to fallback to playlist timing`);if(0===s.fragmentError&&(s.fragmentError++,n.gap=!0,this.fragmentTracker.removeFragment(n),this.fragmentTracker.fragBuffered(n,!0)),this.warn(e.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:n,reason:`Found no media in msn ${n.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=fr,this.hls.trigger(R.FRAG_PARSED,{frag:n,part:e})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(e=this.levelLastLoaded)?e:null==(e=this.fragCurrent)?void 0:e.level)?e:0),this.resetLoadingState())}set state(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}get state(){return this._state}}function xr(){return self.SourceBuffer||self.WebKitSourceBuffer}function F(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class _r{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Ie(this.cachedData,e),this.cachedData=null);let r,i=ge(e,0),n=i?i.length:0;var s,a,o=this._audioTrack,l=this._id3Track,h=i?(e=>{var t=xe(e);for(let e=0;e<t.length;e++){var r=t[e];if(ye(r)){if(8===r.data.byteLength){var r=new Uint8Array(r.data),i=1&r[3];let e=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];return e/=45,i&&(e+=47721858.84),Math.round(e)}return}}})(i):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&M(h))&&(this.basePTS=br(h,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&0<i.length&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY});n<u;){if(this.canParse(e,n)){const t=this.appendFrame(o,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=u}else s=e,a=n,pe(s,a)&&ve(s,a+6)+10<=s.length-a?(i=ge(e,n),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:ft,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===u&&r!==u){const t=fe(e,r);this.cachedData?this.cachedData=Ie(this.cachedData,t):this.cachedData=t}}return{audioTrack:o,videoTrack:F(),id3Track:l,textTrack:F()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:F(),id3Track:this._id3Track,textTrack:F()}}destroy(){}}const br=(e,t,r)=>M(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0);function Tr(e,t){return 255===e[t]&&240==(246&e[t+1])}function Sr(e,t){return 1&e[t+1]?7:9}function Er(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function wr(e,t){return t+1<e.length&&Tr(e,t)}function Mr(e,t,r,i,n){e.samplerate||(t=function(e,t,r,i){let n,s,a,o;var l=navigator.userAgent.toLowerCase(),h=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],c=(n=1+((192&t[r+2])>>>6),(60&t[r+2])>>>2);if(!(u.length-1<c))return a=(1&t[r+2])<<2,a|=(192&t[r+3])>>>6,I.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:`+c),s=/firefox/i.test(l)?6<=c?(n=5,o=new Array(4),c-3):(n=2,o=new Array(2),c):-1!==l.indexOf("android")?(n=2,o=new Array(2),c):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&6<=c?c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(6<=c&&1==a||/vivaldi/i.test(l))||!i&&1==a)&&(n=2,o=new Array(2)),c)),o[0]=n<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=a<<3,5===n&&(o[1]|=(14&s)>>1,o[2]=(1&s)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+n,manifestCodec:h};e.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(t,r,i,n))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,I.log(`parsed codec:${e.codec}, rate:${t.samplerate}, channels:`+t.channelCount))}function Ar(e){return 9216e4/e}function Lr(e,r,i,t,n){var s=t+n*Ar(e.samplerate),a=function(){var e=Sr(r,i);if(i+e<=r.length){var t=Er(r,i)-e;if(0<t)return{headerLength:e,frameLength:t}}}();let o;if(a){const{frameLength:t,headerLength:n}=a,l=n+t,h=Math.max(0,i+l-r.length);h?(o=new Uint8Array(l-n)).set(r.subarray(i+n,r.length),0):o=r.subarray(i+n,i+l);a={unit:o,pts:s};return h||e.samples.push(a),{sample:a,length:l,missing:h}}const l=r.length-i;return(o=new Uint8Array(l)).set(r.subarray(i,r.length),0),{sample:{unit:o,pts:s},length:l,missing:-1}}const Rr=/\/emsg[-/]ID3/i;let Cr=null;const Dr=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Ir=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Pr=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],kr=[0,1,1,4];function Or(e,t,r,i,n){var s;return!(r+24>t.length)&&(s=Fr(t,r))&&r+s.frameLength<=t.length?(i=i+n*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:t.subarray(r,r+s.frameLength),pts:i,dts:i},e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(n),{sample:n,length:s.frameLength,missing:0}):void 0}function Fr(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!=r&&0!=n&&15!=n&&3!=s){var a=e[t+2]>>1&1,o=e[t+3]>>6,n=1e3*Dr[14*(3==r?3-i:3==i?3:4)+n-1],s=Ir[3*(3==r?0:2==r?1:2)+s],l=3==o?1:2,r=Pr[r][i],h=kr[i],u=8*r*h,r=Math.floor(r*n/s+a)*h;if(null===Cr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cr=e?parseInt(e[1]):0}return Cr&&Cr<=87&&2==i&&224e3<=n&&0==o&&(e[t+3]=128|e[t+3]),{sampleRate:s,channelCount:l,frameLength:r,samplesPerFrame:u}}}function Nr(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Ur(e,t){return t+1<e.length&&Nr(e,t)}class Br{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),t=Math.min(4,t);if(0===t)throw new Error("no bytes available");i.set(e.subarray(r,r+t)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*t,this.bytesAvailable-=t}skipBits(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e||(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(32<e&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,0<this.bitsAvailable)this.word<<=t;else{if(!(0<this.bytesAvailable))throw new Error("no bits available");this.loadWord()}return 0<(t=e-t)&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var e=this.skipLZ();return this.readBits(e+1)-1}readEG(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let r,i=8,n=8;for(let e=0;e<t;e++)0!==n&&(r=this.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(){let e,t,r,i=0,n=0,s=0,a=0;var o=this.readUByte.bind(this),l=this.readBits.bind(this),h=this.readUEG.bind(this),u=this.readBoolean.bind(this),c=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this),m=(o(),o());if(l(5),c(3),o(),f(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){const e=h();if(3===e&&c(1),f(),f(),c(1),u())for(t=3!==e?8:12,r=0;r<t;r++)u()&&p(r<6?16:64)}f();m=h();if(0===m)h();else if(1===m)for(c(1),d(),d(),e=h(),r=0;r<e;r++)d();f(),c(1);m=h(),f=h(),l=l(1);0===l&&c(1),c(1),u()&&(i=h(),n=h(),s=h(),a=h());let g=[1,1];if(u()&&u())switch(o()){case 1:g=[1,1];break;case 2:g=[12,11];break;case 3:g=[10,11];break;case 4:g=[16,11];break;case 5:g=[40,33];break;case 6:g=[24,11];break;case 7:g=[20,11];break;case 8:g=[32,11];break;case 9:g=[80,33];break;case 10:g=[18,11];break;case 11:g=[15,11];break;case 12:g=[64,33];break;case 13:g=[160,99];break;case 14:g=[4,3];break;case 15:g=[3,2];break;case 16:g=[2,1];break;case 255:g=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(m+1)-2*i-2*n),height:(2-l)*(f+1)*16-(l?2:4)*(s+a),pixelRatio:g}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Gr{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new lr(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,r,i){const n=t[r].unit;var e;n.length<=16||(e=(e=n.subarray(16,n.length-n.length%16)).buffer.slice(e.byteOffset,e.byteOffset+e.length),this.decryptBuffer(e).then(e=>{e=new Uint8Array(e);n.set(e,16),this.decrypter.isSync()||this.decryptAacSamples(t,r+1,i)}))}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}}getAvcEncryptedData(t){var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)r.set(t.subarray(e,e+16),i);return r}getAvcDecryptedUnit(t,e){var r=new Uint8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)t.set(r.subarray(i,i+16),e);return t}decryptAvcSample(t,r,i,n,s){const a=Oe(s.data),e=this.getAvcEncryptedData(a);this.decryptBuffer(e.buffer).then(e=>{s.data=this.getAvcDecryptedUnit(a,e),this.decrypter.isSync()||this.decryptAvcSamples(t,r,i+1,n)})}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class Hr{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}static probe(e){e=Hr.syncOffset(e);return 0<e&&I.warn("MPEG2-TS detected but first sync word found @ offset "+e),-1!==e}static syncOffset(n){var s=n.length;let a=Math.min(940,n.length-188)+1,o=0;for(;o<a;){let t=!1,r=-1,i=0;for(let e=o;e<s;e+=188){if(71!==n[e]){if(i)return-1;break}if(i++,-1===r&&0!==(r=e)&&(a=Math.min(r+18612,n.length-188)+1),(t=t||0===Vr(n,e))&&1<i&&(0===r&&2<i||e+188>a))return r}o++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Me[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Hr.createTrack("video"),this._audioTrack=Hr.createTrack("audio",i),this._id3Track=Hr.createTrack("id3"),this._txtTrack=Hr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){var{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(r,e,i=!1,n=!1){let s;i||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,l=this._id3Track,h=this._txtTrack;let u=a.pid,c=a.pesData,d=o.pid,f=l.pid,p=o.pesData,m=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,x=r.length;if(this.remainderData&&(x=(r=Ie(this.remainderData,r)).length,this.remainderData=null),x<188&&!n)return this.remainderData=r,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};var _,b,T=Math.max(0,Hr.syncOffset(r));(x-=(x-T)%188)<r.byteLength&&!n&&(this.remainderData=new Uint8Array(r.buffer,x,r.buffer.byteLength-x));let S=0;for(let t=T;t<x;t+=188)if(71===r[t]){const n=!!(64&r[t+1]),R=Vr(r,t);let e;if(1<(48&r[t+3])>>4){if((e=t+5+r[t+4])===t+188)continue}else e=t+4;switch(R){case u:n&&(c&&(s=Wr(c))&&this.parseAVCPES(a,h,s,!1),c={data:[],size:0}),c&&(c.data.push(r.subarray(e,t+188)),c.size+=t+188-e);break;case d:if(n){if(p&&(s=Wr(p)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,s);break;case"mp3":this.parseMPEGPES(o,s)}p={data:[],size:0}}p&&(p.data.push(r.subarray(e,t+188)),p.size+=t+188-e);break;case f:n&&(m&&(s=Wr(m))&&this.parseID3PES(l,s),m={data:[],size:0}),m&&(m.data.push(r.subarray(e,t+188)),m.size+=t+188-e);break;case 0:n&&(e+=r[e]+1),y=this._pmtId=(_=r,b=e,(31&_[b+10])<<8|_[b+11]);break;case y:{n&&(e+=r[e]+1);const s=function(e,t,r,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){const s=Vr(e,t);switch(e[t]){case 207:if(!i){I.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){I.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?I.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=s,n.segmentCodec="mp3");break;case 36:I.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return n}(r,e,this.typeSupported,i);0<(u=s.avc)&&(a.pid=u),0<(d=s.audio)&&(o.pid=d,o.segmentCodec=s.segmentCodec),0<(f=s.id3)&&(l.pid=f),null===g||v||(I.warn(`MPEG-TS PMT found at ${t} after unknown PID '${g}'. Backtracking to sync byte @${T} to parse all TS packets.`),g=null,t=T-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=R}}else S++;if(0<S){const r=new Error(`Found ${S} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:r,reason:r.message})}a.pesData=c,o.pesData=p,l.pesData=m;var t={audioTrack:o,videoTrack:a,id3Track:l,textTrack:h};return n&&this.extractRemainingSamples(t),t}flush(){var e=this["remainderData"];return this.remainderData=null,e=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(e){var{audioTrack:t,videoTrack:e,id3Track:r,textTrack:i}=e,n=e.pesData,s=t.pesData,a=r.pesData;let o;if(n&&(o=Wr(n))?(this.parseAVCPES(e,i,o,!0),e.pesData=null):e.pesData=n,s&&(o=Wr(s))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,o);break;case"mp3":this.parseMPEGPES(t,o)}t.pesData=null}else null!=s&&s.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=s;a&&(o=Wr(a))?(this.parseID3PES(r,o),r.pesData=null):r.pesData=a}demuxSampleAes(e,t,r){e=this.demux(e,r,!0,!this.config.progressive),r=this.sampleAes=new Gr(this.observer,this.config,t);return this.decrypt(e,r)}decrypt(i,n){return new Promise(e=>{const{audioTrack:t,videoTrack:r}=i;t.samples&&"aac"===t.segmentCodec?n.decryptAacSamples(t.samples,0,()=>{r.samples?n.decryptAvcSamples(r.samples,0,0,()=>{e(i)}):e(i)}):r.samples&&n.decryptAvcSamples(r.samples,0,0,()=>{e(i)})})}destroy(){this._duration=0}parseAVCPES(n,e,s,t){var r=this.parseAVCNALu(n,s.data);let a,o=this.avcSample,l=!1;s.data=null,o&&r.length&&!n.audFound&&(jr(o,n),o=this.avcSample=zr(!1,s.pts,s.dts,"")),r.forEach(t=>{var i,r;switch(t.type){case 1:{let e=!1;a=!0;const i=t.data;if(l&&4<i.length){const n=new Br(i).readSliceType();2!==n&&4!==n&&7!==n&&9!==n||(e=!0)}e&&null!=(r=o)&&r.frame&&!o.key&&(jr(o,n),o=this.avcSample=null),(o=o||(this.avcSample=zr(!0,s.pts,s.dts,""))).frame=!0,o.key=e;break}case 5:a=!0,null!=(i=o)&&i.frame&&!o.key&&(jr(o,n),o=this.avcSample=null),(o=o||(this.avcSample=zr(!0,s.pts,s.dts,""))).key=!0,o.frame=!0;break;case 6:a=!0,ke(t.data,1,s.pts,e.samples);break;case 7:if(a=!0,l=!0,!n.sps){const e=t.data,s=new Br(e).readSPS(),i=(n.width=s.width,n.height=s.height,n.pixelRatio=s.pixelRatio,n.sps=[e],n.duration=this._duration,e.subarray(1,4));let r="avc1.";for(let t=0;t<3;t++){let e=i[t].toString(16);e.length<2&&(e="0"+e),r+=e}n.codec=r}break;case 8:a=!0,n.pps||(n.pps=[t.data]);break;case 9:a=!1,n.audFound=!0,o&&jr(o,n),o=this.avcSample=zr(!1,s.pts,s.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+t.type+" ")}o&&a&&o.units.push(t)}),t&&o&&(jr(o,n),this.avcSample=null)}getLastNalUnit(e){let t,r=this.avcSample;if(null!=(e=r=r&&0!==r.units.length?r:e[e.length-1])&&e.units){const e=r.units;t=e[e.length-1]}return t}parseAVCNALu(e,t){const r=t.byteLength;let i=e.naluState||0;var n=i,s=[];let a,o,l,h=0,u=-1,c=0;for(-1===i&&(u=0,c=31&t[0],i=0,h=1);h<r;)if(a=t[h++],i)if(1!==i)if(a)if(1===a){if(0<=u){const e={data:t.subarray(u,h-i-1),type:c};s.push(e)}else{const r=this.getLastNalUnit(e.samples);if(r&&(n&&h<=4-n&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-n)),0<(o=h-i-1))){const e=new Uint8Array(r.data.byteLength+o);e.set(r.data,0),e.set(t.subarray(0,o),r.data.byteLength),r.data=e,r.state=0}}i=h<r?(l=31&t[h],u=h,c=l,0):-1}else i=0;else i=3;else i=a?0:2;else i=a?0:1;if(0<=u&&0<=i){const e={data:t.subarray(u,r),type:c,state:i};s.push(e)}if(0===s.length){const r=this.getLastNalUnit(e.samples);if(r){const e=new Uint8Array(r.data.byteLength+t.byteLength);e.set(r.data,0),e.set(t,r.data.byteLength),r.data=e}}return e.naluState=i,s}parseAACPES(e,t){let r=0;var i,n=this.aacOverFlow;let s,a,o,l=t.data;if(n){this.aacOverFlow=null;const t=n.missing,s=n.sample.unit.byteLength;if(-1===t){const e=new Uint8Array(s+l.byteLength);e.set(n.sample.unit,0),e.set(l,s),l=e}else{const a=s-t;n.sample.unit.set(l.subarray(0,t),a),e.samples.push(n.sample),r=n.missing}}for(s=r,a=l.length;s<a-1&&!wr(l,s);s++);if(s!==r){const t=s<a-1,r=(i=t?"AAC PES did not start with ADTS header,offset:"+s:"No ADTS header found in AAC PES",new Error(i));if(I.warn("parsing error: "+i),this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:r,reason:i}),!t)return}if(Mr(e,this.observer,l,s,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!n)return void I.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=Ar(e.samplerate);o=n.sample.pts+t}}let h,u=0;for(;s<a;){if(h=Lr(e,l,s,o,u),s+=h.length,h.missing){this.aacOverFlow=h;break}for(u++;s<a-1&&!wr(l,s);s++);}}parseMPEGPES(e,t){var r=t.data,i=r.length;let n=0,s=0;var a=t.pts;if(void 0!==a)for(;s<i;)if(Ur(r,s)){const t=Or(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;else I.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseID3PES(e,t){void 0===t.pts?I.warn("[tsdemuxer]: ID3 PES unknown PTS"):(t=L({},t,{type:this._avcTrack?pt:ft,duration:Number.POSITIVE_INFINITY}),e.samples.push(t))}}function zr(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function Vr(e,t){return((31&e[t+1])<<8)+e[t+2]}function Wr(e){let i,t,n,s,a,o=0;var l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&1<l.length;){const e=new Uint8Array(l[0].length+l[1].length);e.set(l[0]),e.set(l[1],l[0].length),l[0]=e,l.splice(1,1)}if(1!==((i=l[0])[0]<<16)+(i[1]<<8)+i[2])return null;{if((t=(i[4]<<8)+i[5])&&t>e.size-6)return null;var h=i[7];192&h&&(s=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&h?(a=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,54e5<s-a&&(I.warn(Math.round((s-a)/9e4)+"s delta between PTS and DTS, align them"),s=a)):a=s);let r=(n=i[8])+9;if(e.size<=r)return null;e.size-=r;var u=new Uint8Array(e.size);for(let t=0,e=l.length;t<e;t++){let e=(i=l[t]).byteLength;if(r){if(r>e){r-=e;continue}i=i.subarray(r),e-=r,r=0}u.set(i,o),o+=e}return t&&(t-=n+3),{data:u,pts:s,dts:a,len:t}}}function jr(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}class Yr{static getSilentFrame(e,t){return"mp4a.40.2"===e?1===t?new Uint8Array([0,200,0,128,35,128]):2===t?new Uint8Array([33,0,73,144,2,25,0,35,128]):3===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]):4===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]):5===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]):6===t?new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]):void 0:1===t?new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]):2===t||3===t?new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]):void 0}}const $r=Math.pow(2,32)-1;class N{static init(){let e;for(e in N.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},N.types)N.types.hasOwnProperty(e)&&(N.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),t=(N.HDLR_TYPES={video:t,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(N.STTS=N.STSC=N.STCO=r,N.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),N.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),N.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),N.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),i=new Uint8Array([97,118,99,49]),n=new Uint8Array([0,0,0,1]);N.FTYP=N.box(N.types.ftyp,r,n,r,i),N.DINF=N.box(N.types.dinf,N.box(N.types.dref,t))}static box(e,...t){let r=8,i=t.length;for(var n=i;i--;)r+=t[i].byteLength;var s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return N.box(N.types.hdlr,N.HDLR_TYPES[e])}static mdat(e){return N.box(N.types.mdat,e)}static mdhd(e,t){t*=e;var r=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r));return N.box(N.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))}static mdia(e){return N.box(N.types.mdia,N.mdhd(e.timescale,e.duration),N.hdlr(e.type),N.minf(e))}static mfhd(e){return N.box(N.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?N.box(N.types.minf,N.box(N.types.smhd,N.SMHD),N.DINF,N.stbl(e)):N.box(N.types.minf,N.box(N.types.vmhd,N.VMHD),N.DINF,N.stbl(e))}static moof(e,t,r){return N.box(N.types.moof,N.mfhd(e),N.traf(r,t))}static moov(e){let t=e.length;for(var r=[];t--;)r[t]=N.trak(e[t]);return N.box.apply(null,[N.types.moov,N.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(N.mvex(e)))}static mvex(e){let t=e.length;for(var r=[];t--;)r[t]=N.trex(e[t]);return N.box.apply(null,[N.types.mvex,...r])}static mvhd(e,t){t*=e;var r=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return N.box(N.types.mvhd,e)}static sdtp(e){var t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return N.box(N.types.sdtp,r)}static stbl(e){return N.box(N.types.stbl,N.stsd(e),N.box(N.types.stts,N.STTS),N.box(N.types.stsc,N.STSC),N.box(N.types.stsz,N.STSZ),N.box(N.types.stco,N.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));var a=N.box(N.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,h=e.pixelRatio[0],u=e.pixelRatio[1];return N.box(N.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,N.box(N.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),N.box(N.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){var t=e.samplerate;return N.box(N.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),N.box(N.types.esds,N.esds(e)))}static mp3(e){var t=e.samplerate;return N.box(N.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?N.box(N.types.stsd,N.STSD,N.mp3(e)):N.box(N.types.stsd,N.STSD,N.mp4a(e)):N.box(N.types.stsd,N.STSD,N.avc1(e))}static tkhd(e){var t=e.id,r=e.duration*e.timescale,i=e.width,e=e.height,n=Math.floor(r/(1+$r)),r=Math.floor(r%(1+$r));return N.box(N.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,e>>8&255,255&e,0,0]))}static traf(e,t){var r=N.sdtp(e),i=e.id,n=Math.floor(t/(1+$r)),t=Math.floor(t%(1+$r));return N.box(N.types.traf,N.box(N.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),N.box(N.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t])),N.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,N.box(N.types.trak,N.tkhd(e),N.mdia(e))}static trex(e){e=e.id;return N.box(N.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){var r=e.samples||[],i=r.length,n=12+16*i,s=new Uint8Array(n);let a,o,l,h,u,c;for(s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,(t+=8+n)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)l=(o=r[a]).duration,h=o.size,u=o.flags,c=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*a);return N.box(N.types.trun,s)}static initSegment(e){N.types||N.init();var e=N.moov(e),t=new Uint8Array(N.FTYP.byteLength+e.byteLength);return t.set(N.FTYP),t.set(e,N.FTYP.byteLength),t}}function qr(e,t,r=1,i=!1){e=e*t*r;return i?Math.round(e):e}function Kr(e,t=!1){return qr(e,1e3,1/9e4,t)}N.types=void 0,N.HDLR_TYPES=void 0,N.STTS=void 0,N.STSC=void 0,N.STCO=void 0,N.STSZ=void 0,N.VMHD=void 0,N.SMHD=void 0,N.STSD=void 0,N.FTYP=void 0,N.DINF=void 0;let Xr,Jr=null,Zr=null;class Qr{constructor(e,t,r,i=0){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Jr){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Jr=e?parseInt(e[1]):0}if(null===Zr){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Zr=e?parseInt(e[1]):0}}destroy(){}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let i=!1;e=e.reduce((e,t)=>{var r=t.pts-e;return r<-4294967296?(i=!0,U(e,t.pts)):0<r?e:t.pts},e[0].pts);return i&&I.debug("PTS rollover detected"),e}remux(r,i,n,s,a,o,e,l){let h,u,c,t,d,f,p=a,m=a;var g=-1<r.pid,v=-1<i.pid,y=i.samples.length,x=0<r.samples.length,_=e&&0<y||1<y;if((!g||x)&&(!v||_)||this.ISGenerated||e){this.ISGenerated||(c=this.generateIS(r,i,a,o));const n=this.isVideoContiguous;let e,t=-1;if(_&&(t=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(i.samples),!n)&&this.config.forceKeyFrameOnDiscontinuity)if(f=!0,0<t){I.warn(`[mp4-remuxer]: Dropped ${t} out of ${y} video samples due to a missing keyframe`);const r=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(t),i.dropped+=t,m+=(i.samples[0].pts-r)/i.inputTimeScale,e=m}else-1===t&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(x&&_){const n=this.getVideoStartPts(i.samples),s=(U(r.samples[0].pts,n)-n)/i.inputTimeScale;p+=Math.max(0,s),m+=Math.max(0,-s)}if(x){if(r.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(r,i,a,o)),u=this.remuxAudio(r,p,this.isAudioContiguous,o,v||_||l===T?m:void 0),_){const s=u?u.endPTS-u.startPTS:0;i.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(r,i,a,o)),h=this.remuxVideo(i,m,n,s)}}else _&&(h=this.remuxVideo(i,m,n,0));h&&(h.firstKeyFrame=t,h.independent=-1!==t,h.firstKeyFramePTS=e)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(d=ei(n,a,this._initPTS,this._initDTS)),s.samples.length)&&(t=ti(s,a,this._initPTS)),{audio:u,video:h,initSegment:c,independent:f,text:t,id3:d}}generateIS(e,t,r,i){var n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let h,u,c,d=!l||i,f="audio/mp4";if(d&&(h=u=1/0),e.config&&n.length&&("mp3"===(e.timescale=e.samplerate,e.segmentCodec)&&(a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3")),o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):N.initSegment([e]),metadata:{channelCount:e.channelCount}},d)&&(c=e.inputTimeScale,l&&c===l.timescale?d=!1:h=u=n[0].pts-Math.round(c*r)),t.sps&&t.pps&&s.length&&(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:N.initSegment([t]),metadata:{width:t.width,height:t.height}},d))if(c=t.inputTimeScale,l&&c===l.timescale)d=!1;else{const e=this.getVideoStartPts(s),t=Math.round(c*r);u=Math.min(u,U(s[0].dts,e)-t),h=Math.min(h,e-t)}if(Object.keys(o).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:h,timescale:c},this._initDTS={baseTime:u,timescale:c}):h=c=void 0,{tracks:o,initPTS:h,timescale:c}}remuxVideo(i,n,s,a){const o=i.inputTimeScale,l=i.samples,h=[],u=l.length,e=this._initPTS;let c,t,r=this.nextAvcDts,d=8,f=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,g=!1;s&&null!==r||(r=n*o-(l[0].pts-U(l[0].dts,l[0].pts)));var v=e.baseTime*o/e.timescale;for(let e=0;e<u;e++){const n=l[e];n.pts=U(n.pts-v,r),n.dts=U(n.dts-v,r),n.dts<l[0<e?e-1:e].dts&&(g=!0)}g&&l.sort(function(e,t){var r=e.dts-t.dts,e=e.pts-t.pts;return r||e}),c=l[0].dts;var n=l[l.length-1].dts-c,y=n?Math.round(n/(u-1)):f||i.inputTimeScale/30;if(s){const i=c-r,n=i>y,s=i<-1;if((n||s)&&(n?I.warn(`AVC: ${Kr(i,!0)} ms (${i}dts) hole between fragments detected, filling it`):I.warn(`AVC: ${Kr(-i,!0)} ms (${i}dts) overlapping between fragments detected`),!s||r>=l[0].pts)){c=r;const n=l[0].pts-i;l[0].dts=c,l[0].pts=n,I.log(`Video: First PTS/DTS adjusted: ${Kr(n,!0)}/${Kr(c,!0)}, delta: ${Kr(i,!0)} ms`)}}c=Math.max(0,c);let x=0,_=0;for(let e=0;e<u;e++){const n=l[e],s=n.units,a=s.length;let t=0;for(let e=0;e<a;e++)t+=s[e].data.length;_+=t,x+=a,n.length=t,n.dts=Math.max(n.dts,c),p=Math.min(n.pts,p),m=Math.max(n.pts,m)}t=l[u-1].dts;n=_+4*x+8;let b;try{b=new Uint8Array(n)}catch(i){return void this.observer.emit(R.ERROR,R.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:i,bytes:n,reason:"fail allocating video mdat "+n})}var T=new DataView(b.buffer);T.setUint32(0,n),b.set(N.types.mdat,4);let S=!1,E=Number.POSITIVE_INFINITY,w=Number.POSITIVE_INFINITY,M=Number.NEGATIVE_INFINITY,A=Number.NEGATIVE_INFINITY;for(let t=0;t<u;t++){const n=l[t],s=n.units;let e,r=0;for(let e=0,t=s.length;e<t;e++){const n=s[e],a=n.data,o=n.data.byteLength;T.setUint32(d,o),d+=4,b.set(a,d),d+=o,r+=4+o}if(t<u-1)f=l[t+1].dts-n.dts,e=l[t+1].pts-n.pts;else{const s=this.config,h=0<t?n.dts-l[t-1].dts:y;if(e=0<t?n.pts-l[t-1].pts:y,s.stretchShortVideoTrack&&null!==this.nextAudioPts){const i=Math.floor(s.maxBufferHole*o),l=(a?p+a*o:this.nextAudioPts)-n.pts;l>i?((f=l-h)<0?f=h:S=!0,I.log(`[mp4-remuxer]: It is approximately ${l/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=h}else f=h}const c=Math.round(n.pts-n.dts);E=Math.min(E,f),M=Math.max(M,f),w=Math.min(w,e),A=Math.max(A,e),h.push(new ri(n.key,f,r,c))}if(h.length)if(Jr){if(Jr<70){const i=h[0].flags;i.dependsOn=2,i.isNonSync=0}}else if(Zr&&A-w<M-E&&y/M<.025&&0===h[0].cts){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let r=c;for(let e=0,t=h.length;e<t;e++){const a=r+h[e].duration,o=r+h[e].cts;if(e<t-1){const i=a+h[e+1].cts;h[e].duration=i-o}else h[e].duration=e?h[e-1].duration:y;h[e].cts=0,r=a}}f=S||!f?y:f,this.nextAvcDts=r=t+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;s={data1:N.moof(i.sequenceNumber++,c,L({},i,{samples:h})),data2:b,startPTS:p/o,endPTS:(m+f)/o,startDTS:c/o,endDTS:r/o,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:i.dropped};return i.samples=[],i.dropped=0,s}remuxAudio(n,s,r,i,a){const e=n.inputTimeScale,o=e/(n.samplerate||e),l="aac"===n.segmentCodec?1024:1152,h=l*o,t=this._initPTS,u="mp3"===n.segmentCodec&&this.typeSupported.mpeg,c=[],d=void 0!==a;let f=n.samples,p=u?0:8,m=this.nextAudioPts||-1;const g=s*e,v=t.baseTime*e/t.timescale;if(this.isAudioContiguous=r=r||f.length&&0<m&&(i&&Math.abs(g-m)<9e3||Math.abs(U(f[0].pts-v,g)-m)<20*h),f.forEach(function(e){e.pts=U(e.pts-v,g)}),!r||m<0){if(!(f=f.filter(e=>0<=e.pts)).length)return;m=0===a?0:i&&!d?Math.max(0,g):f[0].pts}if("aac"===n.segmentCodec){const s=this.config.maxAudioFramesDrift;for(let r=0,i=m;r<f.length;r++){const a=f[r],o=a.pts,l=o-i,L=Math.abs(1e3*l/e);if(l<=-s*h&&d)0===r&&(I.warn(`Audio frame @ ${(o/e).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*l/e)} ms.`),this.nextAudioPts=m=i=o);else if(l>=s*h&&L<1e4&&d){let t=Math.round(l/h);(i=o-t*h)<0&&(t--,i+=h),0===r&&(this.nextAudioPts=m=i),I.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/e).toFixed(3)}s due to ${Math.round(1e3*l/e)} ms gap.`);for(let e=0;e<t;e++){const s=Math.max(i,0);let e=Yr.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);e||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),e=a.unit.subarray()),f.splice(r,0,{unit:e,pts:s}),i+=h,r++}}a.pts=i,i+=h}}let y,x=null,_=null,b=0,T=f.length;for(;T--;)b+=f[T].unit.byteLength;for(let t=0,e=f.length;t<e;t++){const i=f[t],a=i.unit;let e=i.pts;if(null!==_)c[t-1].duration=Math.round((e-_)/o);else{if(r&&"aac"===n.segmentCodec&&(e=m),x=e,!(0<b))return;b+=p;try{y=new Uint8Array(b)}catch(n){return void this.observer.emit(R.ERROR,R.ERROR,{type:C.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:n,bytes:b,reason:"fail allocating audio mdat "+b})}u||(new DataView(y.buffer).setUint32(0,b),y.set(N.types.mdat,4))}y.set(a,p);const h=a.byteLength;p+=h,c.push(new ri(!0,l,h,0)),_=e}var S,s=c.length;if(s)return this.nextAudioPts=m=_+o*c[c.length-1].duration,a=u?new Uint8Array(0):N.moof(n.sequenceNumber++,x/o,L({},n,{samples:c})),n.samples=[],i=x/e,S=m/e,a={data1:a,data2:y,startPTS:i,endPTS:S,startDTS:i,endDTS:S,type:"audio",hasAudio:!0,hasVideo:!1,nb:s},this.isAudioContiguous=!0,a}remuxEmptyAudio(e,t,r,i){var n=e.inputTimeScale,s=n/(e.samplerate||n),a=this.nextAudioPts,o=this._initDTS,o=9e4*o.baseTime/o.timescale,l=(null!==a?a:i.startDTS*n)+o,a=i.endDTS*n+o,h=1024*s,u=Math.ceil((a-l)/h),c=Yr.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),c){var d=[];for(let e=0;e<u;e++){const t=l+e*h;d.push({unit:c,pts:t,dts:t})}return e.samples=d,this.remuxAudio(e,t,r,!1)}I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")}}function U(e,t){var r;if(null!==t)for(r=t<e?-8589934592:8589934592;4294967296<Math.abs(e-t);)e+=r;return e}function ei(t,r,i,n){const s=t.samples.length;if(s){var a=t.inputTimeScale;for(let e=0;e<s;e++){const s=t.samples[e];s.pts=U(s.pts-i.baseTime*a/i.timescale,r*a)/a,s.dts=U(s.dts-n.baseTime*a/n.timescale,r*a)/a}var e=t.samples;return t.samples=[],{samples:e}}}function ti(t,r,i){const n=t.samples.length;if(n){var s=t.inputTimeScale;for(let e=0;e<n;e++){const n=t.samples[e];n.pts=U(n.pts-i.baseTime*s/i.timescale,r*s)/s}t.samples.sort((e,t)=>e.pts-t.pts);var e=t.samples;return t.samples=[],{samples:e}}}class ri{constructor(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new ii(e)}}class ii{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}function ni(e,t){e=null==e?void 0:e.codec;return e&&4<e.length?e:"hvc1"===e||"hev1"===e?"hvc1.1.6.L120.90":"av01"===e?"av01.0.04M.08":"avc1"===e||t===S?"avc1.42e01e":"mp4a.40.5"}try{Xr=self.performance.now.bind(self.performance)}catch(i){I.debug("Unable to use Performance API on this environment"),Xr="undefined"!=typeof self&&self.Date.now}const si=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){var n=this.videoTrack=F("video",1),s=this.audioTrack=F("audio",1),a=this.txtTrack=F("text",1);if(this.id3Track=F("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=Ce(e);if(o.video){const{id:e,timescale:t,codec:r}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=Me.text,n.sampleDuration=0,n.duration=s.duration=i}}resetContiguity(){this.remainderData=null}static probe(e){return 0<P(e=16384<e.length?e.subarray(0,16384):e,["moof"]).length}demux(e,t){this.timeOffset=t;let r=e;var i,n,s=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ie(this.remainderData,e));e=r,i={valid:null,remainder:null},(n=P(e,["moof"]))&&(n.length<2?i.remainder=e:(n=n[n.length-1],i.valid=fe(e,0,n.byteOffset-8),i.remainder=fe(e,n.byteOffset-8)));const t=i;this.remainderData=t.remainder,s.samples=t.valid||new Uint8Array}else s.samples=r;e=this.extractID3Track(s,t);return a.samples=Pe(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:e,textTrack:this.txtTrack}}flush(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack,i=(t.samples=this.remainderData||new Uint8Array,this.remainderData=null,this.extractID3Track(t,this.timeOffset));return r.samples=Pe(e,t),{videoTrack:t,audioTrack:F(),id3Track:i,textTrack:F()}}extractID3Track(e,i){const n=this.id3Track;return e.samples.length&&(e=P(e.samples,["emsg"]))&&e.forEach(t=>{var r=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,h=0;if(0===t){for(;"\0"!==f(e.subarray(h,h+1));)r+=f(e.subarray(h,h+1)),h+=1;for(r+=f(e.subarray(h,h+1)),h+=1;"\0"!==f(e.subarray(h,h+1));)i+=f(e.subarray(h,h+1)),h+=1;i+=f(e.subarray(h,h+1)),h+=1,n=w(e,12),s=w(e,16),o=w(e,20),l=w(e,24),h=28}else if(1===t){h+=4,n=w(e,h);const t=w(e,h+=4),s=w(e,h+=4);for(h+=4,a=2**32*t+s,Number.isSafeInteger(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=w(e,h),h+=4,l=w(e,h),h+=4;"\0"!==f(e.subarray(h,h+1));)r+=f(e.subarray(h,h+1)),h+=1;for(r+=f(e.subarray(h,h+1)),h+=1;"\0"!==f(e.subarray(h,h+1));)i+=f(e.subarray(h,h+1)),h+=1;i+=f(e.subarray(h,h+1)),h+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(h,e.byteLength)}}(t);if(Rr.test(r.schemeIdUri)){const t=M(r.presentationTime)?r.presentationTime/r.timeScale:i+r.presentationTimeDelta/r.timeScale;let e=4294967295===r.eventDuration?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;e<=.001&&(e=Number.POSITIVE_INFINITY);r=r.payload;n.samples.push({data:r,len:r.byteLength,dts:t,pts:t,type:pt,duration:e})}}),n}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(e&&t){const i=t.keyId;i&&t.isCommonEncryption&&P(e,["moov","trak"]).forEach(e=>{e=P(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let t=P(e,["enca"]);const r=0<t.length;(t=r?t:P(e,["encv"])).forEach(e=>{P(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var t=De(e);if(t){const e=t.subarray(8,24);e.some(e=>0!==e)||(I.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${d(e)} -> `+d(i)),t.set(i,8))}})})})}return e}(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;var i,n;null!=e&&e.byteLength?(i=this.initData=Ce(e),t=t||ni(i.audio,b),r=r||ni(i.video,S),n={},i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n):(this.initTracks=void 0,this.initData=void 0)}remux(r,i,n,s,a,o){let{initPTS:l,lastEndTime:h}=this;var u={audio:void 0,video:void 0,text:s,id3:n,initSegment:void 0},i=(M(h)||(h=this.lastEndTime=a||0),i.samples);if(null!=i&&i.length){var c={initPTS:void 0,timescale:1};let t=this.initData;if(null!=(m=t)&&m.length||(this.generateInitSegment(i),t=this.initData),null!=(m=t)&&m.length){this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var d,f,p,m=function(e,t){let r=0,i=0,n=0;var s=P(e,["moof","traf"]);for(let e=0;e<s.length;e++){var a=s[e],o=P(a,["tfhd"])[0],l=t[w(o,4)];if(l){var h=l.default,u=w(o,0)|(null==h?void 0:h.flags);let t=null==h?void 0:h.duration;8&u&&(t=w(o,2&u?12:8));var c=l.timescale||9e4,d=P(a,["trun"]);for(let e=0;e<d.length;e++)!(r=function(t){var r=w(t,0);let i=8,n=(1&r&&(i+=4),4&r&&(i+=4),0);var s=w(t,4);for(let e=0;e<s;e++)256&r&&(n+=w(t,i),i+=4),512&r&&(i+=4),1024&r&&(i+=4),2048&r&&(i+=4);return n}(d[e]))&&t&&(r=t*w(d[e],4)),l.type===S?i+=r/c:l.type===b&&(n+=r/c)}}if(0!==i||0!==n)return i||n;{let t=0;const r=P(e,["sidx"]);for(let e=0;e<r.length;e++){const i=function(t){var r=[],e=t[0];let i=8;var n=w(t,i);i=(i+=4)+(0===e?8:16)+2;let s=t.length+0;const a=Ae(t,i);i+=2;for(let e=0;e<a;e++){var o=i;const a=w(t,o);o+=4;var l=2147483647&a;if(1==(2147483648&a)>>>31)return I.warn("SIDX has hierarchical references (not supported)"),null;var h=w(t,o);o+=4,r.push({referenceSize:l,subsegmentDuration:h,info:{duration:h/n,start:s,end:s+l-1}}),s+=l,o+=4,i=o}return{earliestPresentationTime:0,timescale:n,version:e,referencesCount:a,references:r}}(r[e]);null!=i&&i.references&&(t+=i.references.reduce((e,t)=>e+t.info.duration||0,0))}return t}}(i,t),g=(d=t,P(i,["moof","traf"]).reduce((e,t)=>{const n=P(t,["tfdt"])[0],s=n[0],r=P(t,["tfhd"]).reduce((t,r)=>{var r=w(r,4),i=d[r];if(i){let e=w(n,4);if(1===s){if(e===Ee)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e=(e*=1+Ee)+w(n,8)}const r=e/(i.timescale||9e4);if(isFinite(r)&&(null===t||r<t))return r}return t},null);return null!==r&&isFinite(r)&&(null===e||r<e)?r:e},null)),g=null===g?a:g,v=(v=l,y=g,x=a,(null===v||(_=Math.max(m,1),y=y-v.baseTime/v.timescale,Math.abs(y-x)>_)||c.timescale!==l.timescale&&o)&&(c.initPTS=g-a,l&&1===l.timescale&&I.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1}),r?g-l.baseTime/l.timescale:h),y=v+m,x=(f=t,p=l.baseTime/l.timescale,P(i,["moof","traf"]).forEach(t=>{P(t,["tfhd"]).forEach(e=>{e=w(e,4),e=f[e];if(e){const n=e.timescale||9e4;P(t,["tfdt"]).forEach(e=>{const t=e[0];let r=w(e,4);if(0===t)r-=p*n,Re(e,4,r=Math.max(r,0));else{r=(r=(r*=Math.pow(2,32))+w(e,8))-p*n,r=Math.max(r,0);const t=Math.floor(r/(1+Ee)),i=Math.floor(r%(1+Ee));Re(e,4,t),Re(e,8,i)}})}})}),0<m?this.lastEndTime=y:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp()),!!t.audio),_=!!t.video;let e="";x&&(e+="audio"),_&&(e+="video");o={data1:i,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:e,hasAudio:x,hasVideo:_,nb:1,dropped:0};u.audio="audio"===o.type?o:void 0,u.video="audio"!==o.type?o:void 0,u.initSegment=c,u.id3=ei(n,a,l,l),s.samples.length&&(u.text=ti(s,a,l))}else I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment.")}return u}}},{demux:Hr,remux:Qr},{demux:class extends _r{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(t){let e=(ge(t,0)||[]).length;for(var r,i,n,s,a=t.length;e<a;e++)if(r=t,i=e,s=n=void 0,!wr(r,i)||i+(s=Sr(r,i))>=r.length?void 0:!((n=Er(r,i))<=s)&&((s=i+n)===r.length||wr(r,s)))return I.log("ADTS sync word found !"),!0}return!1}canParse(e,t){return(t=t)+5<(e=e).length&&Tr(e,t)&&Er(e,t)<=e.length-t}appendFrame(e,t,r){Mr(e,this.observer,t,r,e.manifestCodec);e=Lr(e,t,r,this.basePTS,this.frameIndex);if(e&&0===e.missing)return e}},remux:Qr},{demux:class extends _r{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(t){let e=(ge(t,0)||[]).length;for(var r=t.length;e<r;e++)if(function(t,r){if(r+1<t.length&&Nr(t,r)){var i=Fr(t,r);let e=4;r=r+(e=null!=i&&i.frameLength?i.frameLength:e);return r===t.length||Ur(t,r)}}(t,e))return I.log("MPEG Audio sync word found !"),!0}return!1}canParse(e,t){return Nr(e,t)&&4<=e.length-t}appendFrame(e,t,r){if(null!==this.basePTS)return Or(e,t,r,this.basePTS,this.frameIndex)}},remux:Qr}];class ai{constructor(e,t,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(t,r,i,e){var n=i.transmuxing;n.executeStart=Xr();let s=new Uint8Array(t);var{currentTransmuxState:t,transmuxConfig:a}=this,{contiguous:e,discontinuity:t,trackSwitch:o,accurateTimeOffset:l,timeOffset:h,initSegmentChange:u}=(e&&(this.currentTransmuxState=e),e||t),{audioCodec:a,videoCodec:c,defaultInitPts:d,duration:f,initSegmentData:p}=a,m=function(e){let t=null;return t=0<e.byteLength&&null!=r&&null!=r.key&&null!==r.iv&&null!=r.method?r:t}(s);if(m&&"AES-128"===m.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(s,m.key.buffer,m.iv.buffer).then(e=>{e=this.push(e,null,i);return this.decryptionPromise=null,e}),this.decryptionPromise;{let e=t.softwareDecrypt(s,m.key.buffer,m.iv.buffer);if(!(e=-1<i.part?t.flush():e))return n.executeEnd=Xr(),oi(i);s=new Uint8Array(e)}}var g=this.needsProbing(t,o);if(g){const t=this.configureTransmuxer(s);if(t)return I.warn("[transmuxer] "+t.message),this.observer.emit(R.ERROR,R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),n.executeEnd=Xr(),oi(i)}(t||o||u||g)&&this.resetInitSegment(p,a,c,f,r),(t||u||g)&&this.resetInitialTimestamp(d),e||this.resetContiguity();o=this.transmux(s,m,h,l,i),p=this.currentTransmuxState;return p.contiguous=!0,p.discontinuity=!1,p.trackSwitch=!1,n.executeEnd=Xr(),o}flush(t){const e=t.transmuxing;e.executeStart=Xr();var{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(t));const s=[],a=i["timeOffset"];if(r){const e=r.flush();e&&s.push(this.push(e,null,t))}var{demuxer:n,remuxer:i}=this;return n&&i?li(r=n.flush(a))?r.then(e=>(this.flushRemux(s,e,t),s)):(this.flushRemux(s,r,t),s):(e.executeEnd=Xr(),[oi(t)])}flushRemux(e,t,r){var{audioTrack:t,videoTrack:i,id3Track:n,textTrack:s}=t,{accurateTimeOffset:a,timeOffset:o}=this.currentTransmuxState,t=(I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${-1<r.part?" p: "+r.part:""} of level `+r.level),this.remuxer.remux(t,i,n,s,o,a,!0,this.id));e.push({remuxResult:t,chunkMeta:r}),r.transmuxing.executeEnd=Xr()}resetInitialTimestamp(e){var{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){var{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,n){var{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)}transmuxUnencrypted(e,t,r,i){var{audioTrack:e,videoTrack:n,id3Track:s,textTrack:a}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(e,n,s,a,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:n}))}configureTransmuxer(r){var{config:e,observer:t,typeSupported:i,vendor:n}=this;let s;for(let e=0,t=si.length;e<t;e++)if(si[e].demux.probe(r)){s=si[e];break}if(!s)return new Error("Failed to find demuxer by probing fragment data");var a=this.demuxer,o=this.remuxer,l=s.remux,h=s.demux;o&&o instanceof l||(this.remuxer=new l(t,e,i,n)),a&&a instanceof h||(this.demuxer=new h(t,e,i),this.probe=h.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e=e||(this.decrypter=new lr(this.config))}}const oi=e=>({remuxResult:{},chunkMeta:e});function li(e){return"then"in e&&e.then instanceof Function}class hi{constructor(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null}}class ui{constructor(e,t,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}}var ci,B,e={exports:{}};function di(){}function fi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function pi(e,t,r,i,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new fi(r,i||e,n),i=B?B+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],r]:e._events[i].push(r):(e._events[i]=r,e._eventsCount++),e}function mi(e,t){0==--e._eventsCount?e._events=new di:delete e._events[t]}function r(){this._events=new di,this._eventsCount=0}t=e,ci=Object.prototype.hasOwnProperty,B="~",Object.create&&(di.prototype=Object.create(null),(new di).__proto__||(B=!1)),r.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)ci.call(e,t)&&r.push(B?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},r.prototype.listeners=function(e){var e=B?B+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var r=0,i=t.length,n=new Array(i);r<i;r++)n[r]=t[r].fn;return n},r.prototype.listenerCount=function(e){e=B?B+e:e,e=this._events[e];return e?e.fn?1:e.length:0},r.prototype.emit=function(e,t,r,i,n,s){var a=B?B+e:e;if(!this._events[a])return!1;var o,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,n),!0;case 6:return l.fn.call(l.context,t,r,i,n,s),!0}for(d=1,o=new Array(h-1);d<h;d++)o[d-1]=arguments[d];l.fn.apply(l.context,o)}else for(var u,c=l.length,d=0;d<c;d++)switch(l[d].once&&this.removeListener(e,l[d].fn,void 0,!0),h){case 1:l[d].fn.call(l[d].context);break;case 2:l[d].fn.call(l[d].context,t);break;case 3:l[d].fn.call(l[d].context,t,r);break;case 4:l[d].fn.call(l[d].context,t,r,i);break;default:if(!o)for(u=1,o=new Array(h-1);u<h;u++)o[u-1]=arguments[u];l[d].fn.apply(l[d].context,o)}return!0},r.prototype.on=function(e,t,r){return pi(this,e,t,r,!1)},r.prototype.once=function(e,t,r){return pi(this,e,t,r,!0)},r.prototype.removeListener=function(e,t,r,i){e=B?B+e:e;if(this._events[e])if(t){var n=this._events[e];if(n.fn)n.fn!==t||i&&!n.once||r&&n.context!==r||mi(this,e);else{for(var s=0,a=[],o=n.length;s<o;s++)(n[s].fn!==t||i&&!n[s].once||r&&n[s].context!==r)&&a.push(n[s]);a.length?this._events[e]=1===a.length?a[0]:a:mi(this,e)}}else mi(this,e);return this},r.prototype.removeAllListeners=function(e){return e?(e=B?B+e:e,this._events[e]&&mi(this,e)):(this._events=new di,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=B,t.exports=r.EventEmitter=r;var gi=(t=e.exports)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;const vi=ze()||{isTypeSupported:()=>!1};class yi{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var s,r=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===R.ERROR&&(this.error=t.error),this.hls.trigger(e,t)},i=(this.observer=new gi,this.observer.on(R.FRAG_DECRYPTED,r),this.observer.on(R.ERROR,r),{mp4:vi.isTypeSupported("video/mp4"),mpeg:vi.isTypeSupported("audio/mpeg"),mp3:vi.isTypeSupported('audio/mp4; codecs="mp3"')}),r=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__))try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){e=new self.URL(e,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=(s=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),s=self.URL.createObjectURL(s),{worker:new self.Worker(s),objectURL:s})),this.onwmsg=e=>this.onWorkerMessage(e);const e=this.workerContext["worker"];e.addEventListener("message",this.onwmsg),e.onerror=e=>{e=new Error(`${e.message} (${e.filename}:${e.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})},e.postMessage({cmd:"init",typeSupported:i,vendor:r,id:t,config:JSON.stringify(n)})}catch(e){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new ai(this.observer,i,n,r,t)}else this.transmuxer=new ai(this.observer,i,n,r,t)}resetWorker(){var e,t;this.workerContext&&({worker:e,objectURL:t}=this.workerContext,t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null)}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,i,n,s,a,o,l,h){var u=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],c=(s||n).start,d=n.decryptdata,f=this.frag,p=!(f&&n.cc===f.cc),m=!(f&&l.level===f.level),g=f?l.sn-f.sn:-1,v=this.part?l.part-this.part.index:-1,y=0==g&&1<l.id&&l.id===(null==f?void 0:f.stats.chunkCount),y=!m&&(1==g||0==g&&(1==v||y&&v<=0)),x=self.performance.now(),x=((m||g||0===n.stats.parsing.start)&&(n.stats.parsing.start=x),!s||!v&&y||(s.stats.parsing.start=x),!(f&&(null==(g=n.initSegment)?void 0:g.url)===(null==(v=f.initSegment)?void 0:v.url))),g=new ui(p,y,o,m,c,x);if(!y||p||x){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}
|
|
122
122
|
discontinuity: ${p}
|
|
123
123
|
trackSwitch: ${m}
|
|
124
124
|
contiguous: ${y}
|
|
@@ -132,4 +132,4 @@
|
|
|
132
132
|
TTFB estimate: ${l}
|
|
133
133
|
Current BW estimate: ${M(d)?(d/1024).toFixed(3):"Unknown"} Kb/s
|
|
134
134
|
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
|
135
|
-
Aborting and switching to level `+e),r.loader&&(this.fragCurrent=this.partCurrent=null,r.abortRequests()),n.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:a}))}}}}}}}onFragLoaded(e,{frag:t,part:r}){var i=(r||t).stats;if(t.type===y&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const e=(r||t).duration,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(R.FRAG_BUFFERED,e),t.bitrateTest=!1}}}onFragBuffered(e,t){var r,{frag:t,part:i}=t,i=(null!=i&&i.stats.loaded?i:t).stats;i.aborted||this.ignoreFragment(t)||(r=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(r,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0)}ignoreFragment(e){return e.type!==y||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,r)&&t[e].loadError<=t[r].loadError)return e}return r=-1!==e?Math.min(e,r):r}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:n,minAutoLevel:s,media:a}=r,o=t?t.duration:e?e.duration:0,l=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,c=(u?u.len:0)/l;var d=this.findBestLevel(h,s,i,c,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(0<=d)return d;I.trace(`[abr] ${c?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,p=n.abrBandWidthFactor,m=n.abrBandWidthUpFactor;if(!c){const e=this.bitrateTestDelay;e&&(f=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-e,I.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),p=m=1)}return d=this.findBestLevel(h,s,i,c+f,p,m),Math.max(d,0)}findBestLevel(t,r,i,n,s,a){var e;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:h}=this,u=this.hls["levels"],c=u[h],d=!(null==c||null==(e=c.details)||!e.live),f=null==c?void 0:c.codecSet,p=l?l.duration:o?o.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let g=r,v=-1;for(let e=i;e>=r;e--){const r=u[e];if(!r||f&&r.codecSet!==f)r&&(g=Math.min(e,g),v=Math.max(e,v));else{-1!==v&&I.trace(`[abr] Skipped level(s) ${g}-${v} with CODECS:"${u[v].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);const i=r.details,o=(l?null==i?void 0:i.partTarget:null==i?void 0:i.averagetargetduration)||p;var y=e<=h?s*t:a*t,x=u[e].maxBitrate,_=this.getTimeToLoadFrag(m,y,x*o,void 0===i);if(I.trace(`[abr] level:${e} adjustedbw-bitrate:${Math.round(y-x)} avgDuration:${o.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:`+_.toFixed(1)),x<y&&(0===_||!M(_)||d&&!this.bitrateTestDelay||_<n))return e}}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},bufferController:class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{var{media:e,mediaSource:t}=this;I.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{I.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{I.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:e,_objectUrl:t}=this;e&&e.src!==t&&I.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ai(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(!t.audio||t.video)&&t.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,I.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(e,t){t=this.media=t.media;if(t&&Ri){const e=this.mediaSource=new Ri;e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(e),this._objectUrl=t.src,t.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){var{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(I.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){I.warn(`[buffer-controller]: onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):I.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{var t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(t){I.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,t)}}),this._initSourceBuffer()}onBufferCodecs(e,l){const h=this.getSourceBufferTypes().length;Object.keys(l).forEach(e=>{if(h){const h=this.tracks[e];if(h&&"function"==typeof h.buffer.changeType){var{id:t,codec:r,levelCodec:i,container:n,metadata:s}=l[e],a=(h.levelCodec||h.codec).replace(Ci,"$1"),o=(i||r).replace(Ci,"$1");if(a!==o){const l=n+";codecs="+(i||r);this.appendChangeType(e,l),I.log(`[buffer-controller]: switching codec ${a} to `+o),this.tracks[e]={buffer:h.buffer,codec:r,container:n,levelCodec:i,metadata:s,id:t}}}}else this.pendingTracks[e]=l[e]}),h||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,r){const i=this["operationQueue"],e={execute:()=>{var e=this.sourceBuffer[t];e&&(I.log(`[buffer-controller]: changing ${t} sourceBuffer type to `+r),e.changeType(r)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{I.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,e)}};i.append(e,t)}onBufferAppending(e,t){const{hls:r,operationQueue:i,tracks:n}=this,{data:s,type:a,frag:o,part:l,chunkMeta:h}=t,u=h.buffering[a],c=self.performance.now(),d=(u.start=c,o.stats.buffering),f=l?l.stats.buffering:null;0===d.start&&(d.start=c),f&&0===f.start&&(f.start=c);t=n.audio;let p=!1;"audio"===a&&"audio/mpeg"===(null==t?void 0:t.container)&&(p=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const m=o.start,g={execute:()=>{var e,t;u.executeStart=self.performance.now(),p&&(e=this.sourceBuffer[a])&&(t=m-e.timestampOffset,.1<=Math.abs(t))&&(I.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${m} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=m),this.appendExecutor(s,a)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();u.executeEnd=u.end=e,0===d.first&&(d.first=e),f&&0===f.first&&(f.first=e);var t=this["sourceBuffer"],r={};for(const e in t)r[e]=_.getBuffered(t[e]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:h,parent:o.type,timeRanges:r})},onError:e=>{I.error(`[buffer-controller]: Error encountered while trying to append to the ${a} SourceBuffer`,e);var t={type:C.MEDIA_ERROR,parent:o.type,details:D.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:h,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=D.BUFFER_FULL_ERROR:(this.appendError++,t.details=D.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(I.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),r.trigger(R.ERROR,t)}};i.append(g,a)}onBufferFlushing(e,r){const t=this["operationQueue"],i=t=>({execute:this.removeExecutor.bind(this,t,r.startOffset,r.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:t})},onError:e=>{I.warn(`[buffer-controller]: Failed to remove from ${t} SourceBuffer`,e)}});r.type?t.append(i(r.type),r.type):this.getSourceBufferTypes().forEach(e=>{t.append(i(e),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=(i||r).elementaryStreams;s[J]?n.push("audiovideo"):(s[b]&&n.push("audio"),s[S]&&n.push("video")),0===n.length&&I.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: `+r.sn),this.blockBuffers(()=>{var e=self.performance.now(),e=(r.stats.buffering.end=e,i&&(i.stats.buffering.end=e),(i||r).stats);this.hls.trigger(R.FRAG_BUFFERED,{frag:r,part:i,stats:e,id:r.type})},n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,i){this.getSourceBufferTypes().reduce((e,t)=>{var r=this.sourceBuffer[t];return!r||i.type&&i.type!==t||(r.ending=!0,r.ended)||(r.ended=!0,I.log(`[buffer-controller]: ${t} sourceBuffer now EOS`)),e&&!(r&&!r.ended)},!0)&&(I.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{e=this.sourceBuffer[e];e&&(e.ending=!1)});var e=this["mediaSource"];e&&"open"===e.readyState?(I.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&I.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:r,details:i,media:e,sourceBuffer:n}=this;if(e&&null!==i){var t=this.getSourceBufferTypes();if(t.length){var s=i.live&&null!==r.config.liveBackBufferLength?r.config.liveBackBufferLength:r.config.backBufferLength;if(M(s)&&!(s<0)){const a=e.currentTime,o=i.levelTargetDuration,l=Math.max(s,o),h=Math.floor(a/o)*o-l;t.forEach(e=>{var t=n[e];if(t){const n=_.getBuffered(t);if(0<n.length&&h>n.start(0)){if(r.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:h}),i.live)r.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(t.ended&&n.end(n.length-1)-a<2*o)return void I.info(`[buffer-controller]: Cannot flush ${e} back buffer while SourceBuffer is in ended state`);r.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:e})}}})}}}}updateMediaElementDuration(){var e,t,r,i,n,s;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:e,hls:t,media:n,mediaSource:r}=this,i=e.fragments[0].start+e.totalduration,n=n.duration,s=M(r.duration)?r.duration:0,e.live&&t.config.liveDurationInfinity?(I.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(s<i&&n<i||!M(n))&&(I.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),r.duration=i))}updateSeekableRange(e){var t=this.mediaSource,r=e.fragments;r.length&&e.live&&null!=t&&t.setLiveSeekableRange&&(r=Math.max(0,r[0].start),e=Math.max(r,r+e.totalduration),t.setLiveSeekableRange(r,e))}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),e.forEach(e=>{t.executeNext(e)});else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){var{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const a in e)if(!t[a]){var i=e[a];if(!i)throw Error(`source buffer exists for track ${a}, however track does not`);var n=i.levelCodec||i.codec,s=i.container+";codecs="+n;I.log(`[buffer-controller]: creating sourceBuffer(${s})`);try{const e=t[a]=r.addSourceBuffer(s),o=a;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[a]={buffer:e,codec:n,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(e){I.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:s})}}}_onSBUpdateStart(e){var t=this["operationQueue"];t.current(e).onStart()}_onSBUpdateEnd(e){var t=this["operationQueue"];t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r=new Error(e+" SourceBuffer error"),r=(I.error("[buffer-controller]: "+r,t),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,error:r,fatal:!1}),this.operationQueue.current(e));r&&r.onError(t)}removeExecutor(e,t,r){var{media:i,mediaSource:n,operationQueue:s,sourceBuffer:a}=this,a=a[e];i&&n&&a?(i=M(i.duration)?i.duration:1/0,n=M(n.duration)?n.duration:1/0,(t=Math.max(0,t))<(r=Math.min(r,i,n))&&!a.ending?(a.ended=!1,I.log(`[buffer-controller]: Removing [${t},${r}] from the ${e} SourceBuffer`),a.remove(t,r)):s.shiftAndExecuteNext(e)):(I.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),s.shiftAndExecuteNext(e))}appendExecutor(e,t){var{operationQueue:r,sourceBuffer:i}=this,i=i[t];i?(i.ended=!1,i.appendBuffer(e)):(I.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t))}blockBuffers(e,t=this.getSourceBufferTypes()){if(t.length){const r=this["operationQueue"],i=t.map(e=>r.appendBlocker(e));Promise.all(i).then(()=>{e(),t.forEach(e=>{var t=this.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})}else I.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){var i=this.sourceBuffer[e];i&&(r=r.bind(this,e),this.listeners[e].push({event:t,listener:r}),i.addEventListener(t,r))}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}},capLevelController:vn,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===y?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){if(!t.fatal){var r,i=this.hls,n=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case D.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:0,flags:0});case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=2);case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{const e=t.parent===y?t.level:i.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.levels[i.loadLevel];if(e&&(n.type===g&&n.groupId===e.audioGroupId||n.type===v&&n.groupId===e.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=2,void(t.errorAction.flags=1)}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=i.levels[i.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r&&(t.errorAction={action:2,flags:2,hdcpLevel:r})}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(r=t.level)?r:i.loadLevel));case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:0,flags:0})}if(t.type===C.KEY_SYSTEM_ERROR){const e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)}}}getPlaylistRetryOrSwitchAction(e,t){var r=Dt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++,n=null==(n=e.response)?void 0:n.code;return kt(r,i,Ct(e),n)?{action:5,flags:0,retryConfig:r,retryCount:i}:(n=this.getLevelSwitchAction(e,t),r&&(n.retryConfig=r,n.retryCount=i),n)}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=Dt(e.details.startsWith("key")?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i){e.details!==D.FRAG_GAP&&i.fragmentError++;const t=null==(l=e.response)?void 0:l.code;if(kt(a,o,Ct(e),t))return{action:5,flags:0,retryConfig:a,retryCount:o}}var l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(r,i){const n=this.hls;null==i&&(i=n.loadLevel);var s,a=this.hls.levels[i];if(a&&(a.loadError++,n.autoLevelEnabled)){let t=-1;var{levels:o,loadLevel:l,minAutoLevel:h,maxAutoLevel:u}=n,c=null==(s=r.frag)?void 0:s.type,{type:d,groupId:f}=null!=(i=r.context)?i:{};for(let e=o.length;e--;){const s=(e+l)%o.length;if(s!==l&&s>=h&&s<=u&&0===o[s].loadError){const n=o[s];if(r.details===D.FRAG_GAP&&r.frag){const i=o[s].details;if(i){const n=Ft(r.frag,i.fragments,r.frag.start);if(null!=n&&n.gap)continue}}else{if(d===g&&f===n.audioGroupId||d===v&&f===n.textGroupId)continue;if(c===T&&a.audioGroupId===n.audioGroupId||c===st&&a.textGroupId===n.textGroupId)continue}t=s;break}}if(-1<t&&n.loadLevel!==t)return r.levelRetry=!0,{action:2,flags:this.playlistError=0,nextAutoLevel:t}}return{action:2,flags:1}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===D.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){var t=this.hls,r=e.errorAction;if(r){var{flags:i,hdcpLevel:n,nextAutoLevel:s}=r;switch(i){case 0:this.switchLevel(e,s);break;case 1:r.resolved||(r.resolved=this.redundantFailover(e));break;case 2:n&&(t.maxHdcpLevel=_t[_t.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(e,s)}}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after `+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){var{hls:r,penalizedRenditions:i}=this,n=t.parent===y?t.level:r.loadLevel,s=r.levels[n],a=s.url.length,o=(t.frag||s).urlId;s.urlId!==o||t.frag&&!s.details||this.penalizeRendition(s,t);for(let e=1;e<a;e++){const l=(o+e)%a,h=i[l];if(!h||function(e,t,r){if(3e5<performance.now()-e.lastErrorPerfMs)return 1;var i=e.details;if(t.details===D.FRAG_GAP&&i&&t.frag){const e=t.frag.start,r=Ft(null,i.fragments,e);if(r&&!r.gap)return 1}if(r&&e.errors.length<r.errors.length){const r=e.errors[e.errors.length-1];if(i&&r.frag&&t.frag&&Math.abs(r.frag.start-t.frag.start)>3*i.targetduration)return 1}}(h,t,i[o]))return this.warn(`Switching to Redundant Stream ${1+l}/${a}: "${s.url[l]}" after `+t.details),this.playlistError=0,r.levels.forEach(e=>{e.urlId=l}),r.nextLoadLevel=n,!0}return!1}penalizeRendition(e,t){var r=this["penalizedRenditions"],i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;(this.media=e)&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){var i,n=performance.now();if(t){if(this.lastTime){const e=n-this.lastTime,s=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,o=1e3*s/e,l=this.hls;l.trigger(R.FPS_DROP,{currentDropped:s,currentDecoded:a,totalDroppedFrames:r}),0<o&&s>l.config.fpsDroppedMonitoringThreshold*a&&(i=l.currentLevel,I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),0<i)&&(-1===l.autoLevelCapping||l.autoLevelCapping>=i)&&(--i,l.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:l.currentLevel}),l.autoLevelCapping=i,this.streamController.nextLevelSwitch())}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:de,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Rn,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends yr{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",st),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.ERROR,this.onError,this),e.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.ERROR,this.onError,this),e.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=u,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,r){var{frag:r,success:i}=r;if(this.fragPrevious=r,this.state=u,i){var n=this.tracksBuffered[this.currentTrackId];if(n){let t;var s=r.start;for(let e=0;e<n.length;e++)if(s>=n[e].start&&s<=n[e].end){t=n[e];break}i=r.start+r.duration;t?t.end=i:(t={start:s,end:i},n.push(t)),this.fragmentTracker.fragBuffered(r)}}}onBufferFlushing(r,e){var{startOffset:t,endOffset:i}=e;if(0===t&&i!==Number.POSITIVE_INFINITY){const r=i-1;r<=0||(e.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(t=>{for(let e=0;e<t.length;)if(t[e].end<=r)t.shift();else{if(!(t[e].start<r))break;t[e].start=r,e++}}),this.fragmentTracker.removeFragmentsInRange(t,r,st))}}onFragBuffered(e,t){this.loadedmetadata||t.frag.type!==y||null!=(t=this.media)&&t.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){t=t.frag;(null==t?void 0:t.type)===st&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==a)&&(this.state=u)}onSubtitleTracksUpdated(e,{subtitleTracks:t}){Ei(this.levels,t)?this.levels=t.map(e=>new Tt(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{e=new Tt(e);return this.tracksBuffered[e.id]=[],e}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,st),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId?(null!=(t=this.levels[this.currentTrackId])&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(t,r){var{details:i,id:r}=r,{currentTrackId:e,levels:n}=this;if(n.length){var s=n[e];if(!(r>=n.length||r!==e)&&s){this.mediaBuffer=this.mediaBufferTimeRanges;let e=0;if(i.live||null!=(n=s.details)&&n.live){const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;const r=t.fragments[0];s.details?0===(e=this.alignPlaylists(i,s.details))&&r&&At(i,e=r.start):i.hasProgramDateTime&&t.hasProgramDateTime?(nr(i,t),e=i.fragments[0].start):r&&At(i,e=r.start)}s.details=i,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(s.details,e),this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==u||Ft(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}}_handleFragmentLoadComplete(r){const{frag:i,payload:e}=r,t=i.decryptdata,n=this.hls;if(!this.fragContextChanged(i)&&e&&0<e.byteLength&&t&&t.key&&t.iv&&"AES-128"===t.method){const r=performance.now();this.decrypter.decrypt(new Uint8Array(e),t.key.buffer,t.iv.buffer).catch(e=>{throw n.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(e=>{var t=performance.now();n.trigger(R.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:r,tdecrypt:t}})}).catch(e=>{this.warn(e.name+": "+e.message),this.state=u})}}doTick(){if(this.media){if(this.state===u){var{currentTrackId:t,levels:r}=this,t=r[t];if(r.length&&t&&t.details){var r=this["config"],i=this.getLoadPosition(),{end:i,len:n}=_.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),s=this.getFwdBufferInfo(this.media,y),a=t.details;if(!(n>this.getMaxBufferLength(null==s?void 0:s.len)+a.levelTargetDuration)){var n=a.fragments,s=n.length,o=a.edge;let e=null;var l=this.fragPrevious;i<o?(r=o-(o=r.maxFragLookUpTolerance)<i?0:o,!(e=Ft(l,n,Math.max(n[0].start,i),r))&&l&&l.start<n[0].start&&(e=n[0])):e=n[s-1],e&&("initSegment"!==(e=this.mapToInitFragWhenRequired(e)).sn&&(o=n[e.sn-a.startSN-1])&&o.cc===e.cc&&this.fragmentTracker.getState(o)===Vt&&(e=o),this.fragmentTracker.getState(e)===Vt)&&this.loadFragment(e,t,i)}}}}else this.state=u}getMaxBufferLength(e){var t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){"initSegment"===(this.fragCurrent=e).sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new wi(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Ut{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,-1<this.trackId&&this.toggleTrackModes(this.trackId)}registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(-1<this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId),Mi(this.media.textTracks).forEach(e=>{ct(e)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){var r,{id:i,details:n}=t,s=this["trackId"],s=this.tracksInGroup[s];s?(r=s.details,s.details=t.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,r)):this.warn("Invalid subtitle track id "+i)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null!=t&&t.textGroupIds){const i=t.textGroupIds[t.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const e=this.tracks.filter(e=>!i||e.groupId===i),t=(this.tracksInGroup=e,this.findTrackId(null==n?void 0:n.name)||this.findTrackId());this.groupId=i||null;var r={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${i}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,r),-1!==t&&this.setSubtitleTrack(t,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}}findTrackId(t){var r=this.tracksInGroup;for(let e=0;e<r.length;e++){var i=r[e];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1}onError(e,t){!t.fatal&&t.context&&t.context.type===v&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(t){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,n=r.groupId;let e=r.url;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:e,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(e){var{media:t,trackId:r}=this;if(t){var t=Mi(t.textTracks),i=t.filter(e=>e.groupId===this.groupId);if(-1===e)[].slice.call(t).forEach(e=>{e.mode="disabled"});else{const e=i[r];e&&(e.mode="disabled")}t=i[e];t&&(t.mode=this.subtitleDisplay?"showing":"hidden")}}setSubtitleTrack(e,t){var r;const i=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!=(r=i[e])&&r.details)||e<-1||e>=i.length)){this.clearTimer();var n=i[e];if(this.log("Switching to subtitle-track "+e+(n?` "${n.name}" lang:${n.lang} group:`+n.groupId:"")),this.trackId=e,n){const{id:e,groupId:r="",name:i,type:s,url:a}=n;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:e,groupId:r,name:i,type:s,url:a});n=this.switchParams(n.url,null==t?void 0:t.details);this.loadPlaylist(n)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let t=-1;var r=Mi(this.media.textTracks);for(let e=0;e<r.length;e++)if("hidden"===r[e].mode)t=e;else if("showing"===r[e].mode){t=e;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}},timelineController:class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new $i(this,"textTrack1"),t=new $i(this,"textTrack2"),r=new $i(this,"textTrack3"),i=new $i(this,"textTrack4");this.cea608Parser1=new Wi(1,e,t),this.cea608Parser2=new Wi(3,r,i)}e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){var e=this["hls"];e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],h=(a=i[0],o=i[1],l=t,Math.min(o,r)-Math.max(a,l));if(0<=h&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,.5<h/(r-t)))return}var a,o,l;if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n}){var s=this["unparsedVttFrags"];"main"===r&&(this.initPTS[t.cc]={baseTime:i,timescale:n}),s.length&&(this.unparsedVttFrags=[],s.forEach(e=>{this.onFragLoaded(R.FRAG_LOADED,e)}))}getExistingTrack(t){var r=this["media"];if(r)for(let e=0;e<r.textTracks.length;e++){var i=r.textTracks[e];if(i[t])return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(!this.captionsTracks[e]){const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:n,languageCode:s}=t[e],a=this.getExistingTrack(e);if(a)r[e]=a,ct(r[e]),ht(r[e],i);else{const t=this.createTextTrack("captions",n,s);t&&(t[e]=!0,r[e]=t)}}}createNonNativeTrack(e){var t;this.nonNativeCaptionsTracks[e]||(t=this.captionsProperties[e])&&(t={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media},this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]}))}createTextTrack(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const t=this["captionsTracks"];Object.keys(t).forEach(e=>{ct(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var e=this["media"];if(e){var t=e.textTracks;if(t)for(let e=0;e<t.length;e++)ct(t[e])}}onSubtitleTracksUpdated(a,e){var e=e.subtitleTracks||[],t=e.some(e=>"stpp.ttml.im1t"===e.textCodec);if(this.config.enableWebVTT||t&&this.config.enableIMSC1)if(Ei(this.tracks,e))this.tracks=e;else if(this.textTracks=[],this.tracks=e,this.config.renderTextTracksNatively){const a=this.media?this.media.textTracks:null;this.tracks.forEach((r,e)=>{let i;if(a&&e<a.length){let t=null;for(let e=0;e<a.length;e++)if(n=a[e],s=r,n&&n.label===s.name&&!n.textTrack1&&!n.textTrack2){t=a[e];break}t&&(i=t)}var n,s;if(i)ct(i);else{const a=this._captionsOrSubtitlesFromCharacteristics(r);(i=this.createTextTrack(a,r.name,r.lang))&&(i.mode="disabled")}i&&(i.groupId=r.groupId,this.textTracks.push(i))})}else if(this.tracks.length){const a=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),e=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&e)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);t&&(t="textTrack"+t[1],t=this.captionsProperties[t])&&(t.label=e.name,e.lang&&(t.languageCode=e.lang),t.media=e)})}closedCaptionsForLevel(e){e=this.hls.levels[e.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){var{cea608Parser1:r,cea608Parser2:i,lastSn:n,lastPartIndex:s}=this;if(this.enabled&&r&&i&&t.frag.type===y){const e=t.frag.sn,a=null!=(t=null==t||null==(t=t.part)?void 0:t.index)?t:-1;e===n+1||e===n&&a===s+1||(r.reset(),i.reset()),this.lastSn=e,this.lastPartIndex=a}}onFragLoaded(e,t){var{frag:r,payload:i}=t;if(r.type===st)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&"stpp.ttml.im1t"===e.textCodec?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const r=this.hls;cn(e,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},e=>{I.log("Failed to parse IMSC1: "+e),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})})}_parseVTTs(i){var e;const{frag:o,payload:l}=i,{initPTS:t,unparsedVttFrags:h}=this,u=t.length-1;if(t[o.cc]||-1!=u){const y=this.hls;{var c=null!=(c=o.initSegment)&&c.data?Ie(o.initSegment.data,new Uint8Array(l)):l;var d=this.initPTS[o.cc];var f=this.vttCCs;var p=o.cc;var m=o.start;var g=e=>{this._appendCues(e,o.level),y.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})};var v=e=>{var t="Missing initPTS for VTT MPEGTS"===e.message;t?h.push(i):this._fallbackToIMSC1(o,l),I.log("Failed to parse VTT cue: "+e),t&&u>o.cc||y.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:e})};const x=new rn,_=E(new Uint8Array(c)).trim().replace(an,"\n").split("\n"),b=[],T=d?([c,e=1]=[d.baseTime,d.timescale],qr(c,9e4,1/e)):0;let n,t="00:00.000",s=0,a=0,r=!0;x.oncue=function(e){var t=f[p];let r=f.ccOffset;var i=(s-T)/9e4;if(null!=t&&t.new&&(void 0!==a?r=f.ccOffset=t.start:function(e,t){let r=e[p],i=e[r.prevCC];if(!i||!i.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,r.new=!1;for(;null!=(n=i)&&n.new;){var n;e.ccOffset+=r.start-i.start,r.new=!1,i=e[(r=i).prevCC]}e.presentationOffset=t}(f,i)),i){if(!d)return void(n=new Error("Missing initPTS for VTT MPEGTS"));r=i-f.presentationOffset}t=e.endTime-e.startTime,i=U(9e4*(e.startTime+r-a),9e4*m)/9e4,e.startTime=Math.max(i,0),e.endTime=Math.max(i+t,0),i=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(i)),e.id||(e.id=on(e.startTime,e.endTime,i)),0<e.endTime&&b.push(e)},x.onparsingerror=function(e){n=e},x.onflush=function(){n?v(n):g(b)},_.forEach(e=>{if(r){if(nn(e,"X-TIMESTAMP-MAP=")){r=!1,e.slice(16).split(",").forEach(e=>{nn(e,"LOCAL:")?t=e.slice(6):nn(e,"MPEGTS:")&&(s=parseInt(e.slice(7)))});try{a=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),n=9<e.length?parseInt(e.substring(0,e.indexOf(":"))):0;if(M(t)&&M(r)&&M(i)&&M(n))return(t+=1e3*r)+6e4*i+36e5*n;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e)}(t)/1e3}catch(e){n=e}return}""===e&&(r=!1)}x.parse(e+"\n")}),x.flush()}}else h.push(i)}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||cn(t,this.initPTS[e.cc],()=>{r.textCodec="stpp.ttml.im1t",this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];r&&"disabled"!==r.mode&&e.forEach(e=>ut(r,e))}else{var i=this.tracks[t];i&&(i=i.default?"default":"subtitles"+t,r.trigger(R.CUES_PARSED,{type:"subtitles",cues:e,track:i}))}}onFragDecrypted(e,t){var r=t["frag"];r.type===st&&this.onFragLoaded(R.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){var{cea608Parser1:r,cea608Parser2:i}=this;if(this.enabled&&r&&i){const{frag:n,samples:s}=t;if(n.type!==y||"NONE"!==this.closedCaptionsForLevel(n))for(let e=0;e<s.length;e++){const t=s[e].bytes;if(t){const n=this.extractCea608Data(t);r.addData(s[e].pts,n[0]),i.addData(s[e].pts,n[1])}}}}onBufferFlushing(t,{startOffset:r,endOffset:i,endOffsetSubtitles:n,type:e}){var s=this["media"];if(s&&!(s.currentTime<i)){if(!e||"video"===e){const t=this["captionsTracks"];Object.keys(t).forEach(e=>dt(t[e],r,i))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){const t=this["textTracks"];Object.keys(t).forEach(e=>dt(t[e],r,n))}}}extractCea608Data(t){const r=[[],[]],i=31&t[0];let n=2;for(let e=0;e<i;e++){const i=t[n++],s=127&t[n++],a=127&t[n++];if((0!=s||0!=a)&&0!=(4&i)){const t=3&i;0!=t&&1!=t||(r[t].push(s),r[t].push(a))}}return r}},audioStreamController:class extends yr{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",T),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(R.ERROR,this.onError,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_CREATED,this.onBufferCreated,this),e.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(R.ERROR,this.onError,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_CREATED,this.onBufferCreated,this),e.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n}){if("main"===r){const e=t.cc;this.initPTS[t.cc]={baseTime:i,timescale:n},this.log(`InitPTS for cc: ${e} found from main: `+i),this.videoTrackCC=e,this.state===gr&&this.tick()}}startLoad(e){var t;this.levels?(t=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),0<t&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=u):(this.loadedmetadata=!1,this.state=dr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()):(this.startPosition=e,this.state=a)}doTick(){switch(this.state){case u:this.doTickIdle();break;case dr:{var e;const{levels:t,trackId:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=gr}break}case cr:{var t;const e=performance.now(),n=this.retryDate;(!n||e>=n||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=u);break}case gr:{const e=this.waitingData;if(e){const{frag:t,part:s,cache:a,complete:o}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=ur;const e={frag:t,part:s,payload:a.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),o&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc `+this.videoTrackCC),this.clearWaitingFragment();else{const e=this.getLoadPosition(),l=_.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);Nt(l.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${l.end} is needed`),this.clearWaitingFragment())}}else this.state=u}}this.onTickEnd()}clearWaitingFragment(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=u)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){var e=this["media"];null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:i,levels:e,media:n,trackId:t}=this,r=i.config;if(null!=e&&e[t]&&(n||!this.startFragRequested&&r.startFragPrefetch)){var s=e[t],a=s.details;if(!a||a.live&&this.levelLastLoaded!==t||this.waitForCdnTuneIn(a))this.state=dr;else{var o=this.mediaBuffer||this.media,o=(this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,b,T)),this.getFwdBufferInfo(o,T));if(null!==o){var{bufferedTrack:l,switchingTrack:h}=this;if(!h&&this._streamEnded(o,a))i.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=pr;else{var u=this.getFwdBufferInfo(this.videoBuffer||this.media,y),c=o.len,d=this.getMaxBufferLength(null==u?void 0:u.len);if(!(d<=c)||h){c=a.fragments[0].start;let e=o.end;if(h&&n){const i=this.getLoadPosition();l&&h.attrs!==l.attrs&&(e=i),a.PTSKnown&&i<c&&(o.end>c||o.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=c+.05)}let t=this.getNextFragment(e,a),r=!1;if(t&&this.isLoopLoading(t,e)&&(r=!!t.gap,t=this.getNextFragmentLoopLoading(t,a,o,y,d)),t){h=u&&t.start>u.end+a.targetduration;if(h||(null==u||!u.len)&&o.len){const i=this.getAppendedFrag(t.start,y);if(null===i)return;if(r=r||!!i.gap||!!h&&0===u.len,h&&!r||r&&o.nextStart&&o.nextStart<i.end)return}this.loadFragment(t,s,e)}else this.bufferFlushed=!0}}}}}}getMaxBufferLength(e){var t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Tt(e))}onAudioTrackSwitching(e,t){var r=!!t.url,i=(this.trackId=t.id,this)["fragCurrent"];i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=u):(this.switchingTrack=null,this.bufferedTrack=t,this.state=a),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(R.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,r){var i;if(null==this.mainDetails)this.cachedTrackLoadedData=r;else{var n=this["levels"],{details:r,id:s}=r;if(n){this.log(`Track ${s} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:`+r.totalduration);n=n[s];let e=0;if(r.live||null!=(i=n.details)&&i.live){this.checkLiveUpdate(r);const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;e=!n.details&&r.hasProgramDateTime&&t.hasProgramDateTime?(nr(r,t),r.fragments[0].start):this.alignPlaylists(r,n.details)}n.details=r,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(n.details,e),this.state!==dr||this.waitForCdnTuneIn(r)||(this.state=u),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)}}_handleFragmentLoadProgress(t){var r;const{frag:i,part:n,payload:s}=t,{config:a,trackId:o,levels:e}=this;if(e){t=e[o];if(t){var l=t.details;if(l){var h=a.defaultAudioCodec||t.audioCodec||"mp4a.40.2";let e=this.transmuxer;e=e||(this.transmuxer=new yi(this.hls,T,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var u=this.initPTS[i.cc],c=null==(r=i.initSegment)?void 0:r.data;if(void 0!==u){const t=!1,r=n?n.index:-1,a=-1!==r,o=new er(i.level,i.sn,i.stats.chunkCount,s.byteLength,r,a);e.push(s,c,h,"",i,n,l.totalduration,!1,o,u)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track `+o);const t=(this.waitingData=this.waitingData||{frag:i,part:n,cache:new Si,complete:!1})["cache"];t.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=gr}}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){var{frag:t,part:r}=t;if(t.type===T)if(this.fragContextChanged(t))this.warn(`Fragment ${t.sn}${r?" p: "+r.index:""} of level ${t.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==t.sn){this.fragPrevious=t;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,m({},e)))}this.fragBufferedComplete(t,r)}else if(!this.loadedmetadata&&t.type===y){const e=this.videoBuffer||this.media;e&&_.getBuffered(e).length&&(this.loadedmetadata=!0)}}onError(e,t){var r;if(t.fatal)this.state=mr;else switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(T,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==dr||(null==(r=t.context)?void 0:r.type)!==g||(this.state=u);break;case D.BUFFER_FULL_ERROR:t.parent&&"audio"===t.parent&&this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushed(e,{type:t}){t===b&&(this.bufferFlushed=!0,this.state===pr)&&(this.state=u)}_handleTransmuxComplete(e){var t;const r="audio",i=this["hls"],{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(a){var{frag:o,part:l,level:e}=a,h=e["details"],{audio:u,text:c,id3:d,initSegment:f}=n;if(!this.fragContextChanged(o)&&h){if(this.state=O,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const e=o.initSegment||o;this._bufferInitSegment(f.tracks,e,s),i.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:f.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[b]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(b,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=d&&null!=(t=d.samples)&&t.length){const e=L({id:r,frag:o,details:h},d);i.trigger(R.FRAG_PARSING_METADATA,e)}if(c){const e=L({id:r,frag:o,details:h},c);i.trigger(R.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(s)}_bufferInitSegment(e,t,r){if(this.state===O){e.video&&delete e.video;var i=e.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e);i=i.initSegment;if(null!=i&&i.byteLength){const e={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:i};this.hls.trigger(R.BUFFER_APPENDING,e)}this.tick()}}}loadFragment(e,t,r){var i=this.fragmentTracker.getState(e);this.fragCurrent=e,this.switchingTrack||i===Vt||i===Wt?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(i=t.details)&&i.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level `+this.trackId),this.state=gr):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){var{hls:t,media:r,bufferedTrack:i}=this,i=null==i?void 0:i.attrs,n=e.attrs;r&&i&&(i.CHANNELS!==n.CHANNELS||i.NAME!==n.NAME||i.LANGUAGE!==n.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(R.AUDIO_TRACK_SWITCHED,m({},e))}},audioTrackController:class extends Ut{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(R.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){var r,{id:i,groupId:n,details:s}=t,a=this.tracksInGroup[i];a&&a.groupId===n?(r=a.details,a.details=t.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,r)):this.warn(`Track with id:${i} and group:${n} not found in active group `+a.groupId)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){const r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;const e=this.tracks.filter(e=>!r||e.groupId===r),t=(this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),{audioTracks:this.tracksInGroup=e});this.log(`Updating audio tracks, ${e.length} track(s) found in group:`+r),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(e,t){!t.fatal&&t.context&&t.context.type===g&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){var t,r,i,n=this.tracksInGroup;e<0||e>=n.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=this.currentTrack,n[this.trackId],{groupId:r,name:i}=n=n[e],this.log(`Switching to audio-track ${e} "${i}" lang:${n.lang} group:`+r),this.trackId=e,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,m({},n)),n.details&&!n.details.live||(i=this.switchParams(n.url,null==t?void 0:t.details),this.loadPlaylist(i)))}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{const t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+e.length);this.warn(t.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}findTrackId(t){var r=this.tracksInGroup;for(let e=0;e<r.length;e++){var i=r[e];if(!this.selectDefaultTrack||i.default){if(!t||void 0!==t.attrs["STABLE-RENDITION-ID"]&&t.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(t.name===i.name&&t.lang===i.lang)return i.id}}return-1}loadPlaylist(t){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,n=r.groupId;let e=r.url;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log(`loading audio-track playlist ${i} "${r.name}" lang:${r.lang} group:`+n),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:e,id:i,groupId:n,deliveryDirectives:t||null})}}},emeController:yn,cmcdController:xn,contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.ERROR,this.onError,this))}startLoad(){var e;this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri&&(this.updated?(e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0),this.scheduleRefresh(this.uri,e)):this.loadSteeringManifest(this.uri))}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){var e=this.levels;e&&(this.levels=e.filter(e=>e!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){t=t.contentSteering;null!==t&&(this.pathwayId=t.pathwayId,this.uri=t.uri,this.started)&&this.startLoad()}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){var r=t["errorAction"];if(2===(null==r?void 0:r.action)&&1===r.flags){let e=this.pathwayPriority;const t=this.pathwayId;this.penalizedPathways[t]||(this.penalizedPathways[t]=performance.now()),(e=!e&&this.levels?this.levels.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[]):e)&&1<e.length&&(this.updatePathwayPriority(e),r.resolved=this.pathwayId!==t)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);var r;return 0===t.length&&(r=e[0].pathwayId,this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r),t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{3e5<i-r[e]&&delete r[e]});for(let e=0;e<t.length;e++){var n=t[e];if(!r[n]){if(n===this.pathwayId)return;var s,a=this.hls.nextLoadLevel,o=this.hls.levels[a];if(0<(s=this.getLevelsForPathway(n)).length){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,this.hls.trigger(R.LEVELS_UPDATED,{levels:s});const t=this.hls.levels[a];o&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to `+t.bitrate),this.hls.nextLoadLevel=a);break}}}}clonePathways(e){const r=this.levels;if(r){const a={},o={};e.forEach(e=>{const{ID:n,"BASE-ID":t,"URI-REPLACEMENT":s}=e;r.some(e=>e.pathwayId===n)||(e=this.getLevelsForPathway(t).map(e=>{var t=L({},e),e=(t.details=void 0,t.url=bn(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s),new A(e.attrs)),r=(e["PATHWAY-ID"]=n,e.AUDIO&&e.AUDIO+"_clone_"+n),i=e.SUBTITLES&&e.SUBTITLES+"_clone_"+n,e=(r&&(a[e.AUDIO]=r,e.AUDIO=r),i&&(o[e.SUBTITLES]=i,e.SUBTITLES=i),t.attrs=e,new Tt(t));return Ht(e,"audio",r),Ht(e,"text",i),e}),r.push(...e),_n(this.audioTracks,a,s,n),_n(this.subtitleTracks,o,s,n))})}}loadSteeringManifest(e){var t=this.hls.config,r=t.loader;let o;this.loader&&this.loader.destroy(),this.loader=new r(t);try{o=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==o.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+e)}var r={responseType:"json",url:o.href},e=t.steeringManifestLoadPolicy.default,i=e.errorRetry||e.timeoutRetry||{},e={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},i={onSuccess:(e,t,r,i)=>{this.log(`Loaded steering manifest: "${o}"`);var n=e.data;if(1!==n.VERSION)this.log(`Steering VERSION ${n.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=n.TTL;var{"RELOAD-URI":n,"PATHWAY-CLONES":s,"PATHWAY-PRIORITY":a}=n;if(n)try{this.uri=new self.URL(n,o).href}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+n)}this.scheduleRefresh(this.uri||r.url),s&&this.clonePathways(s),a&&this.updatePathwayPriority(a)}},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);else{var n=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,n);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&parseFloat(t)}this.log(`Steering manifest ${t.url} rate limited`)}}},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(r,e,i)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}});function Dn(r){return r&&"object"==typeof r?Array.isArray(r)?r.map(Dn):Object.keys(r).reduce((e,t)=>(e[t]=Dn(r[t]),e),{}):r}class In{static get version(){return"1.4.12"}static isSupported(){return!!(t=ze())&&(e=xr(),t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove,!!t)&&!!e;var e,t}static get Events(){return R}static get ErrorTypes(){return C}static get ErrorDetails(){return D}static get DefaultConfig(){return In.defaultConfig||Cn}static set DefaultConfig(e){In.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new gi,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=e.debug||!1;if(self.console&&!0===t||"object"==typeof t){Y(t,"debug","log","info","warn","error");try{j.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(t){j=W}}else j=W;var r=this.config=function(e,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==o.liveMaxLatencyDurationCount&&(void 0===o.liveSyncDurationCount||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==o.liveMaxLatencyDuration&&(void 0===o.liveSyncDuration||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const l=Dn(e),t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(i=>{const n=("level"===i?"playlist":i)+"LoadPolicy",s=void 0===o[n],a=[];t.forEach(e=>{var t=i+"Loading"+e,r=o[t];if(void 0!==r&&s){a.push(t);const i=l[n].default;switch(o[n]={default:i},e){case"TimeOut":i.maxLoadTimeMs=r,i.maxTimeToFirstByteMs=r;break;case"MaxRetry":i.errorRetry.maxNumRetry=r,i.timeoutRetry.maxNumRetry=r;break;case"RetryDelay":i.errorRetry.retryDelayMs=r,i.timeoutRetry.retryDelayMs=r;break;case"MaxRetryTimeout":i.errorRetry.maxRetryDelayMs=r,i.timeoutRetry.maxRetryDelayMs=r}}}),a.length&&I.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${n}": `+JSON.stringify(o[n]))}),m(m({},l),o)}(In.DefaultConfig,e),{abrController:i,bufferController:e,capLevelController:n,errorController:s,fpsController:a}=(this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&((i=(e=r).loader)!==wn&&i!==Sn?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),1}catch(e){}}()&&(e.loader=wn,e.progressive=!0,e.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))),r),s=new s(this),o=this.abrController=new i(this),e=this.bufferController=new e(this),n=this.capLevelController=new n(this),a=new a(this),l=new lt(this),h=new yt(this),u=r.contentSteeringController,u=u?new u(this):null,c=this.levelController=new Gt(this,u),d=new jt(this),f=new Zt(this.config),p=this.streamController=new _i(this,d,f),l=(n.setStreamController(p),a.setStreamController(p),[l,c,p]),c=(u&&l.splice(1,0,u),this.networkControllers=l,[o,e,n,a,h,d]),p=(this.audioTrackController=this.createController(r.audioTrackController,l),r.audioStreamController),u=(p&&l.push(new p(this,d,f)),this.subtitleTrackController=this.createController(r.subtitleTrackController,l),r.subtitleStreamController),o=(u&&l.push(new u(this,d,f)),this.createController(r.timelineController,c),f.emeController=this.emeController=this.createController(r.emeController,c),this.cmcdController=this.createController(r.cmcdController,c),this.latencyController=this.createController(xt,c),this.coreComponents=c,l.push(s),s.onErrorOut);"function"==typeof o&&this.on(R.ERROR,o,s)}createController(e,t){return e?(e=new e(this),t&&t.push(e),e):null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){I.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=H.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});I.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})}startLoad(t=-1){I.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){I.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log("set loadLevel:"+e),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log("set firstLevel:"+e),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){I.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){e=!!e;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimate():NaN}get ttfbEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){-1<_t.indexOf(e)&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){var{levels:t,config:{minAutoBitrate:r}}=this;if(t){var i=t.length;for(let e=0;e<i;e++)if(t[e].maxBitrate>=r)return e}return 0}get maxAutoLevel(){var{levels:t,autoLevelCapping:e,maxHdcpLevel:r}=this;let i;if(i=-1===e&&t&&t.length?t.length-1:e,r)for(let e=i;e--;){const i=t[e].attrs["HDCP-LEVEL"];if(i&&i<=r)return e}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){var e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}In.defaultConfig=void 0},659:function(e,t,r){"use strict";var i="function"==typeof Symbol&&Symbol.for,n=i?Symbol.for("react.element"):60103,s=i?Symbol.for("react.portal"):60106,a=i?Symbol.for("react.fragment"):60107,o=i?Symbol.for("react.strict_mode"):60108,l=i?Symbol.for("react.profiler"):60114,h=i?Symbol.for("react.provider"):60109,u=i?Symbol.for("react.context"):60110,c=i?Symbol.for("react.async_mode"):60111,d=i?Symbol.for("react.concurrent_mode"):60111,f=i?Symbol.for("react.forward_ref"):60112,p=i?Symbol.for("react.suspense"):60113,m=i?Symbol.for("react.suspense_list"):60120,g=i?Symbol.for("react.memo"):60115,v=i?Symbol.for("react.lazy"):60116,y=i?Symbol.for("react.block"):60121,x=i?Symbol.for("react.fundamental"):60117,_=i?Symbol.for("react.responder"):60118,b=i?Symbol.for("react.scope"):60119;function T(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case c:case d:case a:case l:case o:case p:return e;default:switch(e=e&&e.$$typeof){case u:case f:case v:case g:case h:return e;default:return t}}case s:return t}}}function S(e){return T(e)===d}t.AsyncMode=c,t.ConcurrentMode=d,t.ContextConsumer=u,t.ContextProvider=h,t.Element=n,t.ForwardRef=f,t.Fragment=a,t.Lazy=v,t.Memo=g,t.Portal=s,t.Profiler=l,t.StrictMode=o,t.Suspense=p,t.isAsyncMode=function(e){return S(e)||T(e)===c},t.isConcurrentMode=S,t.isContextConsumer=function(e){return T(e)===u},t.isContextProvider=function(e){return T(e)===h},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return T(e)===f},t.isFragment=function(e){return T(e)===a},t.isLazy=function(e){return T(e)===v},t.isMemo=function(e){return T(e)===g},t.isPortal=function(e){return T(e)===s},t.isProfiler=function(e){return T(e)===l},t.isStrictMode=function(e){return T(e)===o},t.isSuspense=function(e){return T(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===d||e===l||e===o||e===p||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===g||e.$$typeof===h||e.$$typeof===u||e.$$typeof===f||e.$$typeof===x||e.$$typeof===_||e.$$typeof===b||e.$$typeof===y)},t.typeOf=T},694:function(e,t,r){var i=r(127),n=r(601),s=r(126),a=r(314),r=i?i.prototype:void 0,o=r?r.toString:void 0;e.exports=function e(t){var r;return"string"==typeof t?t:s(t)?n(t,e)+"":a(t)?o?o.call(t):"":"0"==(r=t+"")&&1/t==-1/0?"-0":r}},716:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"DraggableCore",{enumerable:!0,get:function(){return x.default}}),t.default=void 0;var m=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=l(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(1)),i=o(r(0)),n=o(r(26)),g=o(r(44)),v=r(582),y=r(609),s=r(570),x=o(r(718)),a=o(r(610));function o(e){return e&&e.__esModule?e:{default:e}}function l(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(l=function(e){return e?r:t})(e))}function _(){return(_=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function h(e,t,r){var i;i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t),(t="symbol"==typeof i?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}class u extends m.Component{static getDerivedStateFromProps(e,t){e=e.position,t=t.prevPropsPosition;return!e||t&&e.x===t.x&&e.y===t.y?null:((0,a.default)("Draggable: getDerivedStateFromProps %j",{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}})}constructor(e){super(e),h(this,"onDragStart",(e,t)=>{if((0,a.default)("Draggable: onDragStart: %j",t),!1===this.props.onStart(e,(0,y.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,a.default)("Draggable: onDrag: %j",t);var r=(0,y.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;var[n,s]=(0,y.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),h(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,y.createDraggableData)(this,t)))return!1;(0,a.default)("Draggable: onDragStop: %j",t);var r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:(e.position||e.defaultPosition).x,y:(e.position||e.defaultPosition).y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e;return null!=(e=null==(e=this.props)||null==(e=e.nodeRef)?void 0:e.current)?e:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:r,defaultPosition:i,defaultClassName:n,defaultClassNameDragging:s,defaultClassNameDragged:a,position:o,positionOffset:l,scale:h,...u}=this.props;let c={},d=null;var f=!Boolean(o)||this.state.dragging,p=o||i,f={x:((0,y.canDragX)(this)&&f?this.state:p).x,y:((0,y.canDragY)(this)&&f?this.state:p).y},p=(this.state.isElementSVG?d=(0,v.createSVGTransform)(f,l):c=(0,v.createCSSTransform)(f,l),(0,g.default)(r.props.className||"",n,{[s]:this.state.dragging,[a]:this.state.dragged}));return m.createElement(x.default,_({},u,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),m.cloneElement(m.Children.only(r),{className:p,style:{...r.props.style,...c},transform:d}))}}h(t.default=u,"displayName","Draggable"),h(u,"propTypes",{...x.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:s.dontSetMe,style:s.dontSetMe,transform:s.dontSetMe}),h(u,"defaultProps",{...x.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},717:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browserPrefixToKey=s,t.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},t.default=void 0,t.getPrefix=n;const i=["Moz","Webkit","O","ms"];function n(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"!=typeof window){var r=null==(e=window.document)||null==(e=e.documentElement)?void 0:e.style;if(r&&!(t in r))for(let e=0;e<i.length;e++)if(s(t,i[e])in r)return i[e]}return""}function s(e,t){return t?"".concat(t).concat(function(t){let r="",i=!0;for(let e=0;e<t.length;e++)i?(r+=t[e].toUpperCase(),i=!1):"-"===t[e]?i=!0:r+=t[e];return r}(e)):e}t.default=n()},718:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(1)),n=u(r(0)),s=u(r(26)),a=r(582),o=r(609),l=r(570),h=u(r(610));function u(e){return e&&e.__esModule?e:{default:e}}function c(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(c=function(e){return e?r:t})(e))}function d(e,t,r){var i;i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t),(t="symbol"==typeof i?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}const f={start:"touchstart",move:"touchmove",stop:"touchend"},p={start:"mousedown",move:"mousemove",stop:"mouseup"};let m=p;class g extends i.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;var t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");var r,i,n=t["ownerDocument"];this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,a.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,a.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t)||("touchstart"===e.type&&e.preventDefault(),t=(0,a.getTouchIdentifier)(e),this.touchIdentifier=t,null!=(t=(0,o.getControlPosition)(e,t,this))&&({x:t,y:r}=t,i=(0,o.createCoreData)(this,t,r),(0,h.default)("DraggableCore: handleDragStart: %j",i),(0,h.default)("calling",this.props.onStart),!1!==this.props.onStart(e,i))&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,a.addUserSelectStyles)(n),this.dragging=!0,this.lastX=t,this.lastY=r,(0,a.addEvent)(n,m.move,this.handleDrag),(0,a.addEvent)(n,m.stop,this.handleDragStop)))}),d(this,"handleDrag",r=>{const i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:e,y:t}=i;if(Array.isArray(this.props.grid)){var n=e-this.lastX,s=t-this.lastY;if([n,s]=(0,o.snapToGrid)(this.props.grid,n,s),!n&&!s)return;e=this.lastX+n,t=this.lastY+s}n=(0,o.createCoreData)(this,e,t);if((0,h.default)("DraggableCore: handleDrag: %j",n),!1!==this.props.onDrag(r,n)&&!1!==this.mounted)this.lastX=e,this.lastY=t;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(r){const i=document.createEvent("MouseEvents");i.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(i)}}}),d(this,"handleDragStop",r=>{if(this.dragging){var i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:e,y:t}=i;Array.isArray(this.props.grid)&&(i=e-this.lastX||0,n=t-this.lastY||0,[i,n]=(0,o.snapToGrid)(this.props.grid,i,n),e=this.lastX+i,t=this.lastY+n);i=(0,o.createCoreData)(this,e,t);if(!1===this.props.onStop(r,i)||!1===this.mounted)return!1;var n=this.findDOMNode();n&&this.props.enableUserSelectHack&&(0,a.removeUserSelectStyles)(n.ownerDocument),(0,h.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,n&&((0,h.default)("DraggableCore: Removing handlers"),(0,a.removeEvent)(n.ownerDocument,m.move,this.handleDrag),(0,a.removeEvent)(n.ownerDocument,m.stop,this.handleDragStop))}}}),d(this,"onMouseDown",e=>(m=p,this.handleDragStart(e))),d(this,"onMouseUp",e=>(m=p,this.handleDragStop(e))),d(this,"onTouchStart",e=>(m=f,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(m=f,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;var e=this.findDOMNode();e&&(0,a.addEvent)(e,f.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;var e,t=this.findDOMNode();t&&(e=t["ownerDocument"],(0,a.removeEvent)(e,p.move,this.handleDrag),(0,a.removeEvent)(e,f.move,this.handleDrag),(0,a.removeEvent)(e,p.stop,this.handleDragStop),(0,a.removeEvent)(e,f.stop,this.handleDragStop),(0,a.removeEvent)(t,f.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack)&&(0,a.removeUserSelectStyles)(e)}findDOMNode(){var e;return null!=(e=this.props)&&e.nodeRef?null==(e=this.props)||null==(e=e.nodeRef)?void 0:e.current:s.default.findDOMNode(this)}render(){return i.cloneElement(i.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}d(t.default=g,"displayName","DraggableCore"),d(g,"propTypes",{allowAnyClick:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),d(g,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},756:function(e,t,r){!function(e,f){!function(r){"use strict";var i,t,n,e,s,a,o,l,h,u;function c(e){delete a[e]}function d(e){if(o)setTimeout(d,0,e);else{var t=a[e];if(t){o=!0;try{var r=t.callback,i=t.args;switch(i.length){case 0:r();break;case 1:r(i[0]);break;case 2:r(i[0],i[1]);break;case 3:r(i[0],i[1],i[2]);break;default:r.apply(void 0,i)}}finally{c(e),o=!1}}}}r.setImmediate||(s=1,o=!(a={}),l=r.document,h=(h=Object.getPrototypeOf&&Object.getPrototypeOf(r))&&h.setTimeout?h:r,u="[object process]"==={}.toString.call(r.process)?function(e){f.nextTick(function(){d(e)})}:function(){var e,t;if(r.postMessage&&!r.importScripts)return e=!0,t=r.onmessage,r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}()?(n="setImmediate$"+Math.random()+"$",e=function(e){e.source===r&&"string"==typeof e.data&&0===e.data.indexOf(n)&&d(+e.data.slice(n.length))},r.addEventListener?r.addEventListener("message",e,!1):r.attachEvent("onmessage",e),function(e){r.postMessage(n+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):function(e){setTimeout(d,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];return a[s]={callback:e,args:t},u(s),s++},h.clearImmediate=c)}("undefined"==typeof self?void 0===e?this:e:self)}.call(this,r(30),r(313))},759:function(e,t,r){"use strict";t.byteLength=function(e){var e=u(e),t=e[0],e=e[1];return 3*(t+e)/4-e},t.toByteArray=function(e){for(var t,r=u(e),i=r[0],r=r[1],n=new h(3*(i+r)/4-r),s=0,a=0<r?i-4:i,o=0;o<a;o+=4)t=l[e.charCodeAt(o)]<<18|l[e.charCodeAt(o+1)]<<12|l[e.charCodeAt(o+2)]<<6|l[e.charCodeAt(o+3)],n[s++]=t>>16&255,n[s++]=t>>8&255,n[s++]=255&t;return 2===r&&(t=l[e.charCodeAt(o)]<<2|l[e.charCodeAt(o+1)]>>4,n[s++]=255&t),1===r&&(t=l[e.charCodeAt(o)]<<10|l[e.charCodeAt(o+1)]<<4|l[e.charCodeAt(o+2)]>>2,n[s++]=t>>8&255,n[s++]=255&t),n},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n=[],s=0,a=r-i;s<a;s+=16383)n.push(function(e,t,r){for(var i,n=[],s=t;s<r;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),n.push(o[(i=i)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return n.join("")}(e,s,a<s+16383?a:s+16383));return 1==i?(t=e[r-1],n.push(o[t>>2]+o[t<<4&63]+"==")):2==i&&(t=(e[r-2]<<8)+e[r-1],n.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"=")),n.join("")};for(var o=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,s=i.length;n<s;++n)o[n]=i[n],l[i.charCodeAt(n)]=n;function u(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("=");return[e=-1===e?t:e,e===t?0:4-e%4]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},760:function(e,t){t.read=function(e,t,r,i,n){var s,a,o=8*n-i-1,l=(1<<o)-1,h=l>>1,u=-7,c=r?n-1:0,d=r?-1:1,n=e[t+c];for(c+=d,s=n&(1<<-u)-1,n>>=-u,u+=o;0<u;s=256*s+e[t+c],c+=d,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;0<u;a=256*a+e[t+c],c+=d,u-=8);if(0===s)s=1-h;else{if(s===l)return a?NaN:1/0*(n?-1:1);a+=Math.pow(2,i),s-=h}return(n?-1:1)*a*Math.pow(2,s-i)},t.write=function(e,t,r,i,n,s){var a,o,l=8*s-n-1,h=(1<<l)-1,u=h>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,f=i?1:-1,s=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(i=Math.pow(2,-a))<1&&(a--,i*=2),2<=(t+=1<=a+u?c/i:c*Math.pow(2,1-u))*i&&(a++,i/=2),h<=a+u?(o=0,a=h):1<=a+u?(o=(t*i-1)*Math.pow(2,n),a+=u):(o=t*Math.pow(2,u-1)*Math.pow(2,n),a=0));8<=n;e[r+d]=255&o,d+=f,o/=256,n-=8);for(a=a<<n|o,l+=n;0<l;e[r+d]=255&a,d+=f,a/=256,l-=8);e[r+d-f]|=128*s}},761:function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},917:function(e,t,r){"use strict";var i=r(615),n=r(616);function s(t,r){switch(arguments.length){case 0:return s;case 1:return Object(n.a)(t)?s:Object(i.a)(function(e){return a(t,e)});default:return Object(n.a)(t)&&Object(n.a)(r)?s:Object(n.a)(t)?Object(i.a)(function(e){return a(e,r)}):Object(n.a)(r)?Object(i.a)(function(e){return a(t,e)}):a(t,r)}}var a;a=function(e,t){for(var r,i={},n={},s=0,a=e.length;s<a;)s+=n[e[s]]=1;for(r in t)n.hasOwnProperty(r)||(i[r]=t[r]);return i};t.a=s}}]);
|
|
135
|
+
Aborting and switching to level `+e),r.loader&&(this.fragCurrent=this.partCurrent=null,r.abortRequests()),n.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:a}))}}}}}}}onFragLoaded(e,{frag:t,part:r}){var i=(r||t).stats;if(t.type===y&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const e=(r||t).duration,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(R.FRAG_BUFFERED,e),t.bitrateTest=!1}}}onFragBuffered(e,t){var r,{frag:t,part:i}=t,i=(null!=i&&i.stats.loaded?i:t).stats;i.aborted||this.ignoreFragment(t)||(r=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(r,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0)}ignoreFragment(e){return e.type!==y||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,r)&&t[e].loadError<=t[r].loadError)return e}return r=-1!==e?Math.min(e,r):r}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:n,minAutoLevel:s,media:a}=r,o=t?t.duration:e?e.duration:0,l=a&&0!==a.playbackRate?Math.abs(a.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,c=(u?u.len:0)/l;var d=this.findBestLevel(h,s,i,c,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(0<=d)return d;I.trace(`[abr] ${c?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,p=n.abrBandWidthFactor,m=n.abrBandWidthUpFactor;if(!c){const e=this.bitrateTestDelay;e&&(f=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-e,I.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),p=m=1)}return d=this.findBestLevel(h,s,i,c+f,p,m),Math.max(d,0)}findBestLevel(t,r,i,n,s,a){var e;const{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:h}=this,u=this.hls["levels"],c=u[h],d=!(null==c||null==(e=c.details)||!e.live),f=null==c?void 0:c.codecSet,p=l?l.duration:o?o.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3;let g=r,v=-1;for(let e=i;e>=r;e--){const r=u[e];if(!r||f&&r.codecSet!==f)r&&(g=Math.min(e,g),v=Math.max(e,v));else{-1!==v&&I.trace(`[abr] Skipped level(s) ${g}-${v} with CODECS:"${u[v].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);const i=r.details,o=(l?null==i?void 0:i.partTarget:null==i?void 0:i.averagetargetduration)||p;var y=e<=h?s*t:a*t,x=u[e].maxBitrate,_=this.getTimeToLoadFrag(m,y,x*o,void 0===i);if(I.trace(`[abr] level:${e} adjustedbw-bitrate:${Math.round(y-x)} avgDuration:${o.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:`+_.toFixed(1)),x<y&&(0===_||!M(_)||d&&!this.bitrateTestDelay||_<n))return e}}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}},bufferController:class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{var{media:e,mediaSource:t}=this;I.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{I.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{I.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:e,_objectUrl:t}=this;e&&e.src!==t&&I.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0<this.getSourceBufferTypes().length||0<Object.keys(this.pendingTracks).length}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ai(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(!t.audio||t.video)&&t.altAudio||(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,I.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}onMediaAttaching(e,t){t=this.media=t.media;if(t&&Ri){const e=this.mediaSource=new Ri;e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),t.src=self.URL.createObjectURL(e),this._objectUrl=t.src,t.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){var{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(I.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){I.warn(`[buffer-controller]: onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):I.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{var t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(t){I.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,t)}}),this._initSourceBuffer()}onBufferCodecs(e,l){const h=this.getSourceBufferTypes().length;Object.keys(l).forEach(e=>{if(h){const h=this.tracks[e];if(h&&"function"==typeof h.buffer.changeType){var{id:t,codec:r,levelCodec:i,container:n,metadata:s}=l[e],a=(h.levelCodec||h.codec).replace(Ci,"$1"),o=(i||r).replace(Ci,"$1");if(a!==o){const l=n+";codecs="+(i||r);this.appendChangeType(e,l),I.log(`[buffer-controller]: switching codec ${a} to `+o),this.tracks[e]={buffer:h.buffer,codec:r,container:n,levelCodec:i,metadata:s,id:t}}}}else this.pendingTracks[e]=l[e]}),h||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,r){const i=this["operationQueue"],e={execute:()=>{var e=this.sourceBuffer[t];e&&(I.log(`[buffer-controller]: changing ${t} sourceBuffer type to `+r),e.changeType(r)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{I.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,e)}};i.append(e,t)}onBufferAppending(e,t){const{hls:r,operationQueue:i,tracks:n}=this,{data:s,type:a,frag:o,part:l,chunkMeta:h}=t,u=h.buffering[a],c=self.performance.now(),d=(u.start=c,o.stats.buffering),f=l?l.stats.buffering:null;0===d.start&&(d.start=c),f&&0===f.start&&(f.start=c);t=n.audio;let p=!1;"audio"===a&&"audio/mpeg"===(null==t?void 0:t.container)&&(p=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);const m=o.start,g={execute:()=>{var e,t;u.executeStart=self.performance.now(),p&&(e=this.sourceBuffer[a])&&(t=m-e.timestampOffset,.1<=Math.abs(t))&&(I.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${m} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=m),this.appendExecutor(s,a)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();u.executeEnd=u.end=e,0===d.first&&(d.first=e),f&&0===f.first&&(f.first=e);var t=this["sourceBuffer"],r={};for(const e in t)r[e]=_.getBuffered(t[e]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:h,parent:o.type,timeRanges:r})},onError:e=>{I.error(`[buffer-controller]: Error encountered while trying to append to the ${a} SourceBuffer`,e);var t={type:C.MEDIA_ERROR,parent:o.type,details:D.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:h,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=D.BUFFER_FULL_ERROR:(this.appendError++,t.details=D.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(I.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),r.trigger(R.ERROR,t)}};i.append(g,a)}onBufferFlushing(e,r){const t=this["operationQueue"],i=t=>({execute:this.removeExecutor.bind(this,t,r.startOffset,r.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:t})},onError:e=>{I.warn(`[buffer-controller]: Failed to remove from ${t} SourceBuffer`,e)}});r.type?t.append(i(r.type),r.type):this.getSourceBufferTypes().forEach(e=>{t.append(i(e),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=(i||r).elementaryStreams;s[J]?n.push("audiovideo"):(s[b]&&n.push("audio"),s[S]&&n.push("video")),0===n.length&&I.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: `+r.sn),this.blockBuffers(()=>{var e=self.performance.now(),e=(r.stats.buffering.end=e,i&&(i.stats.buffering.end=e),(i||r).stats);this.hls.trigger(R.FRAG_BUFFERED,{frag:r,part:i,stats:e,id:r.type})},n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,i){this.getSourceBufferTypes().reduce((e,t)=>{var r=this.sourceBuffer[t];return!r||i.type&&i.type!==t||(r.ending=!0,r.ended)||(r.ended=!0,I.log(`[buffer-controller]: ${t} sourceBuffer now EOS`)),e&&!(r&&!r.ended)},!0)&&(I.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{e=this.sourceBuffer[e];e&&(e.ending=!1)});var e=this["mediaSource"];e&&"open"===e.readyState?(I.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&I.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:r,details:i,media:e,sourceBuffer:n}=this;if(e&&null!==i){var t=this.getSourceBufferTypes();if(t.length){var s=i.live&&null!==r.config.liveBackBufferLength?r.config.liveBackBufferLength:r.config.backBufferLength;if(M(s)&&!(s<0)){const a=e.currentTime,o=i.levelTargetDuration,l=Math.max(s,o),h=Math.floor(a/o)*o-l;t.forEach(e=>{var t=n[e];if(t){const n=_.getBuffered(t);if(0<n.length&&h>n.start(0)){if(r.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:h}),i.live)r.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h});else if(t.ended&&n.end(n.length-1)-a<2*o)return void I.info(`[buffer-controller]: Cannot flush ${e} back buffer while SourceBuffer is in ended state`);r.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:e})}}})}}}}updateMediaElementDuration(){var e,t,r,i,n,s;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:e,hls:t,media:n,mediaSource:r}=this,i=e.fragments[0].start+e.totalduration,n=n.duration,s=M(r.duration)?r.duration:0,e.live&&t.config.liveDurationInfinity?(I.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(s<i&&n<i||!M(n))&&(I.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),r.duration=i))}updateSeekableRange(e){var t=this.mediaSource,r=e.fragments;r.length&&e.live&&null!=t&&t.setLiveSeekableRange&&(r=Math.max(0,r[0].start),e=Math.max(r,r+e.totalduration),t.setLiveSeekableRange(r,e))}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),e.forEach(e=>{t.executeNext(e)});else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){var{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const a in e)if(!t[a]){var i=e[a];if(!i)throw Error(`source buffer exists for track ${a}, however track does not`);var n=i.levelCodec||i.codec,s=i.container+";codecs="+n;I.log(`[buffer-controller]: creating sourceBuffer(${s})`);try{const e=t[a]=r.addSourceBuffer(s),o=a;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[a]={buffer:e,codec:n,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(e){I.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:s})}}}_onSBUpdateStart(e){var t=this["operationQueue"];t.current(e).onStart()}_onSBUpdateEnd(e){var t=this["operationQueue"];t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r=new Error(e+" SourceBuffer error"),r=(I.error("[buffer-controller]: "+r,t),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,error:r,fatal:!1}),this.operationQueue.current(e));r&&r.onError(t)}removeExecutor(e,t,r){var{media:i,mediaSource:n,operationQueue:s,sourceBuffer:a}=this,a=a[e];i&&n&&a?(i=M(i.duration)?i.duration:1/0,n=M(n.duration)?n.duration:1/0,(t=Math.max(0,t))<(r=Math.min(r,i,n))&&!a.ending?(a.ended=!1,I.log(`[buffer-controller]: Removing [${t},${r}] from the ${e} SourceBuffer`),a.remove(t,r)):s.shiftAndExecuteNext(e)):(I.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),s.shiftAndExecuteNext(e))}appendExecutor(e,t){var{operationQueue:r,sourceBuffer:i}=this,i=i[t];i?(i.ended=!1,i.appendBuffer(e)):(I.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(t))}blockBuffers(e,t=this.getSourceBufferTypes()){if(t.length){const r=this["operationQueue"],i=t.map(e=>r.appendBlocker(e));Promise.all(i).then(()=>{e(),t.forEach(e=>{var t=this.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})}else I.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){var i=this.sourceBuffer[e];i&&(r=r.bind(this,e),this.listeners[e].push({event:t,listener:r}),i.addEventListener(t,r))}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}},capLevelController:vn,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===y?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){if(!t.fatal){var r,i=this.hls,n=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case D.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:0,flags:0});case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=2);case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{const e=t.parent===y?t.level:i.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.levels[i.loadLevel];if(e&&(n.type===g&&n.groupId===e.audioGroupId||n.type===v&&n.groupId===e.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=2,void(t.errorAction.flags=1)}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=i.levels[i.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r&&(t.errorAction={action:2,flags:2,hdcpLevel:r})}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(r=t.level)?r:i.loadLevel));case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:0,flags:0})}if(t.type===C.KEY_SYSTEM_ERROR){const e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)}}}getPlaylistRetryOrSwitchAction(e,t){var r=Dt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++,n=null==(n=e.response)?void 0:n.code;return kt(r,i,Ct(e),n)?{action:5,flags:0,retryConfig:r,retryCount:i}:(n=this.getLevelSwitchAction(e,t),r&&(n.retryConfig=r,n.retryCount=i),n)}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=Dt(e.details.startsWith("key")?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i){e.details!==D.FRAG_GAP&&i.fragmentError++;const t=null==(l=e.response)?void 0:l.code;if(kt(a,o,Ct(e),t))return{action:5,flags:0,retryConfig:a,retryCount:o}}var l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(r,i){const n=this.hls;null==i&&(i=n.loadLevel);var s,a=this.hls.levels[i];if(a&&(a.loadError++,n.autoLevelEnabled)){let t=-1;var{levels:o,loadLevel:l,minAutoLevel:h,maxAutoLevel:u}=n,c=null==(s=r.frag)?void 0:s.type,{type:d,groupId:f}=null!=(i=r.context)?i:{};for(let e=o.length;e--;){const s=(e+l)%o.length;if(s!==l&&s>=h&&s<=u&&0===o[s].loadError){const n=o[s];if(r.details===D.FRAG_GAP&&r.frag){const i=o[s].details;if(i){const n=Ft(r.frag,i.fragments,r.frag.start);if(null!=n&&n.gap)continue}}else{if(d===g&&f===n.audioGroupId||d===v&&f===n.textGroupId)continue;if(c===T&&a.audioGroupId===n.audioGroupId||c===st&&a.textGroupId===n.textGroupId)continue}t=s;break}}if(-1<t&&n.loadLevel!==t)return r.levelRetry=!0,{action:2,flags:this.playlistError=0,nextAutoLevel:t}}return{action:2,flags:1}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===D.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){var t=this.hls,r=e.errorAction;if(r){var{flags:i,hdcpLevel:n,nextAutoLevel:s}=r;switch(i){case 0:this.switchLevel(e,s);break;case 1:r.resolved||(r.resolved=this.redundantFailover(e));break;case 2:n&&(t.maxHdcpLevel=_t[_t.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(e,s)}}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after `+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){var{hls:r,penalizedRenditions:i}=this,n=t.parent===y?t.level:r.loadLevel,s=r.levels[n],a=s.url.length,o=(t.frag||s).urlId;s.urlId!==o||t.frag&&!s.details||this.penalizeRendition(s,t);for(let e=1;e<a;e++){const l=(o+e)%a,h=i[l];if(!h||function(e,t,r){if(3e5<performance.now()-e.lastErrorPerfMs)return 1;var i=e.details;if(t.details===D.FRAG_GAP&&i&&t.frag){const e=t.frag.start,r=Ft(null,i.fragments,e);if(r&&!r.gap)return 1}if(r&&e.errors.length<r.errors.length){const r=e.errors[e.errors.length-1];if(i&&r.frag&&t.frag&&Math.abs(r.frag.start-t.frag.start)>3*i.targetduration)return 1}}(h,t,i[o]))return this.warn(`Switching to Redundant Stream ${1+l}/${a}: "${s.url[l]}" after `+t.details),this.playlistError=0,r.levels.forEach(e=>{e.urlId=l}),r.nextLoadLevel=n,!0}return!1}penalizeRendition(e,t){var r=this["penalizedRenditions"],i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;(this.media=e)&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){var i,n=performance.now();if(t){if(this.lastTime){const e=n-this.lastTime,s=r-this.lastDroppedFrames,a=t-this.lastDecodedFrames,o=1e3*s/e,l=this.hls;l.trigger(R.FPS_DROP,{currentDropped:s,currentDecoded:a,totalDroppedFrames:r}),0<o&&s>l.config.fpsDroppedMonitoringThreshold*a&&(i=l.currentLevel,I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+i),0<i)&&(-1===l.autoLevelCapping||l.autoLevelCapping>=i)&&(--i,l.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:l.currentLevel}),l.autoLevelCapping=i,this.streamController.nextLevelSwitch())}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:de,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Rn,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends yr{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",st),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.ERROR,this.onError,this),e.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.ERROR,this.onError,this),e.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=u,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,r){var{frag:r,success:i}=r;if(this.fragPrevious=r,this.state=u,i){var n=this.tracksBuffered[this.currentTrackId];if(n){let t;var s=r.start;for(let e=0;e<n.length;e++)if(s>=n[e].start&&s<=n[e].end){t=n[e];break}i=r.start+r.duration;t?t.end=i:(t={start:s,end:i},n.push(t)),this.fragmentTracker.fragBuffered(r)}}}onBufferFlushing(r,e){var{startOffset:t,endOffset:i}=e;if(0===t&&i!==Number.POSITIVE_INFINITY){const r=i-1;r<=0||(e.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(t=>{for(let e=0;e<t.length;)if(t[e].end<=r)t.shift();else{if(!(t[e].start<r))break;t[e].start=r,e++}}),this.fragmentTracker.removeFragmentsInRange(t,r,st))}}onFragBuffered(e,t){this.loadedmetadata||t.frag.type!==y||null!=(t=this.media)&&t.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){t=t.frag;(null==t?void 0:t.type)===st&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==a)&&(this.state=u)}onSubtitleTracksUpdated(e,{subtitleTracks:t}){Ei(this.levels,t)?this.levels=t.map(e=>new Tt(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{e=new Tt(e);return this.tracksBuffered[e.id]=[],e}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,st),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId?(null!=(t=this.levels[this.currentTrackId])&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(t,r){var{details:i,id:r}=r,{currentTrackId:e,levels:n}=this;if(n.length){var s=n[e];if(!(r>=n.length||r!==e)&&s){this.mediaBuffer=this.mediaBufferTimeRanges;let e=0;if(i.live||null!=(n=s.details)&&n.live){const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;const r=t.fragments[0];s.details?0===(e=this.alignPlaylists(i,s.details))&&r&&At(i,e=r.start):i.hasProgramDateTime&&t.hasProgramDateTime?(nr(i,t),e=i.fragments[0].start):r&&At(i,e=r.start)}s.details=i,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(s.details,e),this.tick(),!i.live||this.fragCurrent||!this.media||this.state!==u||Ft(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}}_handleFragmentLoadComplete(r){const{frag:i,payload:e}=r,t=i.decryptdata,n=this.hls;if(!this.fragContextChanged(i)&&e&&0<e.byteLength&&t&&t.key&&t.iv&&"AES-128"===t.method){const r=performance.now();this.decrypter.decrypt(new Uint8Array(e),t.key.buffer,t.iv.buffer).catch(e=>{throw n.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(e=>{var t=performance.now();n.trigger(R.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:r,tdecrypt:t}})}).catch(e=>{this.warn(e.name+": "+e.message),this.state=u})}}doTick(){if(this.media){if(this.state===u){var{currentTrackId:t,levels:r}=this,t=r[t];if(r.length&&t&&t.details){var r=this["config"],i=this.getLoadPosition(),{end:i,len:n}=_.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),s=this.getFwdBufferInfo(this.media,y),a=t.details;if(!(n>this.getMaxBufferLength(null==s?void 0:s.len)+a.levelTargetDuration)){var n=a.fragments,s=n.length,o=a.edge;let e=null;var l=this.fragPrevious;i<o?(r=o-(o=r.maxFragLookUpTolerance)<i?0:o,!(e=Ft(l,n,Math.max(n[0].start,i),r))&&l&&l.start<n[0].start&&(e=n[0])):e=n[s-1],e&&("initSegment"!==(e=this.mapToInitFragWhenRequired(e)).sn&&(o=n[e.sn-a.startSN-1])&&o.cc===e.cc&&this.fragmentTracker.getState(o)===Vt&&(e=o),this.fragmentTracker.getState(e)===Vt)&&this.loadFragment(e,t,i)}}}}else this.state=u}getMaxBufferLength(e){var t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){"initSegment"===(this.fragCurrent=e).sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new wi(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Ut{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,-1<this.trackId&&this.toggleTrackModes(this.trackId)}registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(-1<this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),-1<this.trackId&&(this.queuedDefaultTrack=this.trackId),Mi(this.media.textTracks).forEach(e=>{ct(e)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){var r,{id:i,details:n}=t,s=this["trackId"],s=this.tracksInGroup[s];s?(r=s.details,s.details=t.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,r)):this.warn("Invalid subtitle track id "+i)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null!=t&&t.textGroupIds){const i=t.textGroupIds[t.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const e=this.tracks.filter(e=>!i||e.groupId===i),t=(this.tracksInGroup=e,this.findTrackId(null==n?void 0:n.name)||this.findTrackId());this.groupId=i||null;var r={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${i}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,r),-1!==t&&this.setSubtitleTrack(t,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}}findTrackId(t){var r=this.tracksInGroup;for(let e=0;e<r.length;e++){var i=r[e];if((!this.selectDefaultTrack||i.default)&&(!t||t===i.name))return i.id}return-1}onError(e,t){!t.fatal&&t.context&&t.context.type===v&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(t){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,n=r.groupId;let e=r.url;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:e,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(e){var{media:t,trackId:r}=this;if(t){var t=Mi(t.textTracks),i=t.filter(e=>e.groupId===this.groupId);if(-1===e)[].slice.call(t).forEach(e=>{e.mode="disabled"});else{const e=i[r];e&&(e.mode="disabled")}t=i[e];t&&(t.mode=this.subtitleDisplay?"showing":"hidden")}}setSubtitleTrack(e,t){var r;const i=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!=(r=i[e])&&r.details)||e<-1||e>=i.length)){this.clearTimer();var n=i[e];if(this.log("Switching to subtitle-track "+e+(n?` "${n.name}" lang:${n.lang} group:`+n.groupId:"")),this.trackId=e,n){const{id:e,groupId:r="",name:i,type:s,url:a}=n;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:e,groupId:r,name:i,type:s,url:a});n=this.switchParams(n.url,null==t?void 0:t.details);this.loadPlaylist(n)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let t=-1;var r=Mi(this.media.textTracks);for(let e=0;e<r.length;e++)if("hidden"===r[e].mode)t=e;else if("showing"===r[e].mode){t=e;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}},timelineController:class{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new $i(this,"textTrack1"),t=new $i(this,"textTrack2"),r=new $i(this,"textTrack3"),i=new $i(this,"textTrack4");this.cea608Parser1=new Wi(1,e,t),this.cea608Parser2=new Wi(3,r,i)}e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){var e=this["hls"];e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],h=(a=i[0],o=i[1],l=t,Math.min(o,r)-Math.max(a,l));if(0<=h&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,.5<h/(r-t)))return}var a,o,l;if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n}){var s=this["unparsedVttFrags"];"main"===r&&(this.initPTS[t.cc]={baseTime:i,timescale:n}),s.length&&(this.unparsedVttFrags=[],s.forEach(e=>{this.onFragLoaded(R.FRAG_LOADED,e)}))}getExistingTrack(t){var r=this["media"];if(r)for(let e=0;e<r.textTracks.length;e++){var i=r.textTracks[e];if(i[t])return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(!this.captionsTracks[e]){const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:n,languageCode:s}=t[e],a=this.getExistingTrack(e);if(a)r[e]=a,ct(r[e]),ht(r[e],i);else{const t=this.createTextTrack("captions",n,s);t&&(t[e]=!0,r[e]=t)}}}createNonNativeTrack(e){var t;this.nonNativeCaptionsTracks[e]||(t=this.captionsProperties[e])&&(t={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media},this.nonNativeCaptionsTracks[e]=t,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[t]}))}createTextTrack(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const t=this["captionsTracks"];Object.keys(t).forEach(e=>{ct(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var e=this["media"];if(e){var t=e.textTracks;if(t)for(let e=0;e<t.length;e++)ct(t[e])}}onSubtitleTracksUpdated(a,e){var e=e.subtitleTracks||[],t=e.some(e=>"stpp.ttml.im1t"===e.textCodec);if(this.config.enableWebVTT||t&&this.config.enableIMSC1)if(Ei(this.tracks,e))this.tracks=e;else if(this.textTracks=[],this.tracks=e,this.config.renderTextTracksNatively){const a=this.media?this.media.textTracks:null;this.tracks.forEach((r,e)=>{let i;if(a&&e<a.length){let t=null;for(let e=0;e<a.length;e++)if(n=a[e],s=r,n&&n.label===s.name&&!n.textTrack1&&!n.textTrack2){t=a[e];break}t&&(i=t)}var n,s;if(i)ct(i);else{const a=this._captionsOrSubtitlesFromCharacteristics(r);(i=this.createTextTrack(a,r.name,r.lang))&&(i.mode="disabled")}i&&(i.groupId=r.groupId,this.textTracks.push(i))})}else if(this.tracks.length){const a=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),e=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&e)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);t&&(t="textTrack"+t[1],t=this.captionsProperties[t])&&(t.label=e.name,e.lang&&(t.languageCode=e.lang),t.media=e)})}closedCaptionsForLevel(e){e=this.hls.levels[e.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){var{cea608Parser1:r,cea608Parser2:i,lastSn:n,lastPartIndex:s}=this;if(this.enabled&&r&&i&&t.frag.type===y){const e=t.frag.sn,a=null!=(t=null==t||null==(t=t.part)?void 0:t.index)?t:-1;e===n+1||e===n&&a===s+1||(r.reset(),i.reset()),this.lastSn=e,this.lastPartIndex=a}}onFragLoaded(e,t){var{frag:r,payload:i}=t;if(r.type===st)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&"stpp.ttml.im1t"===e.textCodec?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const r=this.hls;cn(e,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},e=>{I.log("Failed to parse IMSC1: "+e),r.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})})}_parseVTTs(i){var e;const{frag:o,payload:l}=i,{initPTS:t,unparsedVttFrags:h}=this,u=t.length-1;if(t[o.cc]||-1!=u){const y=this.hls;{var c=null!=(c=o.initSegment)&&c.data?Ie(o.initSegment.data,new Uint8Array(l)):l;var d=this.initPTS[o.cc];var f=this.vttCCs;var p=o.cc;var m=o.start;var g=e=>{this._appendCues(e,o.level),y.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})};var v=e=>{var t="Missing initPTS for VTT MPEGTS"===e.message;t?h.push(i):this._fallbackToIMSC1(o,l),I.log("Failed to parse VTT cue: "+e),t&&u>o.cc||y.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:e})};const x=new rn,_=E(new Uint8Array(c)).trim().replace(an,"\n").split("\n"),b=[],T=d?([c,e=1]=[d.baseTime,d.timescale],qr(c,9e4,1/e)):0;let n,t="00:00.000",s=0,a=0,r=!0;x.oncue=function(e){var t=f[p];let r=f.ccOffset;var i=(s-T)/9e4;if(null!=t&&t.new&&(void 0!==a?r=f.ccOffset=t.start:function(e,t){let r=e[p],i=e[r.prevCC];if(!i||!i.new&&r.new)return e.ccOffset=e.presentationOffset=r.start,r.new=!1;for(;null!=(n=i)&&n.new;){var n;e.ccOffset+=r.start-i.start,r.new=!1,i=e[(r=i).prevCC]}e.presentationOffset=t}(f,i)),i){if(!d)return void(n=new Error("Missing initPTS for VTT MPEGTS"));r=i-f.presentationOffset}t=e.endTime-e.startTime,i=U(9e4*(e.startTime+r-a),9e4*m)/9e4,e.startTime=Math.max(i,0),e.endTime=Math.max(i+t,0),i=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(i)),e.id||(e.id=on(e.startTime,e.endTime,i)),0<e.endTime&&b.push(e)},x.onparsingerror=function(e){n=e},x.onflush=function(){n?v(n):g(b)},_.forEach(e=>{if(r){if(nn(e,"X-TIMESTAMP-MAP=")){r=!1,e.slice(16).split(",").forEach(e=>{nn(e,"LOCAL:")?t=e.slice(6):nn(e,"MPEGTS:")&&(s=parseInt(e.slice(7)))});try{a=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),n=9<e.length?parseInt(e.substring(0,e.indexOf(":"))):0;if(M(t)&&M(r)&&M(i)&&M(n))return(t+=1e3*r)+6e4*i+36e5*n;throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e)}(t)/1e3}catch(e){n=e}return}""===e&&(r=!1)}x.parse(e+"\n")}),x.flush()}}else h.push(i)}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||cn(t,this.initPTS[e.cc],()=>{r.textCodec="stpp.ttml.im1t",this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];r&&"disabled"!==r.mode&&e.forEach(e=>ut(r,e))}else{var i=this.tracks[t];i&&(i=i.default?"default":"subtitles"+t,r.trigger(R.CUES_PARSED,{type:"subtitles",cues:e,track:i}))}}onFragDecrypted(e,t){var r=t["frag"];r.type===st&&this.onFragLoaded(R.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){var{cea608Parser1:r,cea608Parser2:i}=this;if(this.enabled&&r&&i){const{frag:n,samples:s}=t;if(n.type!==y||"NONE"!==this.closedCaptionsForLevel(n))for(let e=0;e<s.length;e++){const t=s[e].bytes;if(t){const n=this.extractCea608Data(t);r.addData(s[e].pts,n[0]),i.addData(s[e].pts,n[1])}}}}onBufferFlushing(t,{startOffset:r,endOffset:i,endOffsetSubtitles:n,type:e}){var s=this["media"];if(s&&!(s.currentTime<i)){if(!e||"video"===e){const t=this["captionsTracks"];Object.keys(t).forEach(e=>dt(t[e],r,i))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){const t=this["textTracks"];Object.keys(t).forEach(e=>dt(t[e],r,n))}}}extractCea608Data(t){const r=[[],[]],i=31&t[0];let n=2;for(let e=0;e<i;e++){const i=t[n++],s=127&t[n++],a=127&t[n++];if((0!=s||0!=a)&&0!=(4&i)){const t=3&i;0!=t&&1!=t||(r[t].push(s),r[t].push(a))}}return r}},audioStreamController:class extends yr{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",T),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){var e=this["hls"];e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(R.ERROR,this.onError,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_CREATED,this.onBufferCreated,this),e.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var e=this["hls"];e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(R.ERROR,this.onError,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_CREATED,this.onBufferCreated,this),e.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n}){if("main"===r){const e=t.cc;this.initPTS[t.cc]={baseTime:i,timescale:n},this.log(`InitPTS for cc: ${e} found from main: `+i),this.videoTrackCC=e,this.state===gr&&this.tick()}}startLoad(e){var t;this.levels?(t=this.lastCurrentTime,this.stopLoad(),this.setInterval(100),0<t&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=u):(this.loadedmetadata=!1,this.state=dr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()):(this.startPosition=e,this.state=a)}doTick(){switch(this.state){case u:this.doTickIdle();break;case dr:{var e;const{levels:t,trackId:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=gr}break}case cr:{var t;const e=performance.now(),n=this.retryDate;(!n||e>=n||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=u);break}case gr:{const e=this.waitingData;if(e){const{frag:t,part:s,cache:a,complete:o}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=ur;const e={frag:t,part:s,payload:a.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),o&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc `+this.videoTrackCC),this.clearWaitingFragment();else{const e=this.getLoadPosition(),l=_.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);Nt(l.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${l.end} is needed`),this.clearWaitingFragment())}}else this.state=u}}this.onTickEnd()}clearWaitingFragment(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=u)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){var e=this["media"];null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:i,levels:e,media:n,trackId:t}=this,r=i.config;if(null!=e&&e[t]&&(n||!this.startFragRequested&&r.startFragPrefetch)){var s=e[t],a=s.details;if(!a||a.live&&this.levelLastLoaded!==t||this.waitForCdnTuneIn(a))this.state=dr;else{var o=this.mediaBuffer||this.media,o=(this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,b,T)),this.getFwdBufferInfo(o,T));if(null!==o){var{bufferedTrack:l,switchingTrack:h}=this;if(!h&&this._streamEnded(o,a))i.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=pr;else{var u=this.getFwdBufferInfo(this.videoBuffer||this.media,y),c=o.len,d=this.getMaxBufferLength(null==u?void 0:u.len);if(!(d<=c)||h){c=a.fragments[0].start;let e=o.end;if(h&&n){const i=this.getLoadPosition();l&&h.attrs!==l.attrs&&(e=i),a.PTSKnown&&i<c&&(o.end>c||o.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=c+.05)}let t=this.getNextFragment(e,a),r=!1;if(t&&this.isLoopLoading(t,e)&&(r=!!t.gap,t=this.getNextFragmentLoopLoading(t,a,o,y,d)),t){h=u&&t.start>u.end+a.targetduration;if(h||(null==u||!u.len)&&o.len){const i=this.getAppendedFrag(t.start,y);if(null===i)return;if(r=r||!!i.gap||!!h&&0===u.len,h&&!r||r&&o.nextStart&&o.nextStart<i.end)return}this.loadFragment(t,s,e)}else this.bufferFlushed=!0}}}}}}getMaxBufferLength(e){var t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Tt(e))}onAudioTrackSwitching(e,t){var r=!!t.url,i=(this.trackId=t.id,this)["fragCurrent"];i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=u):(this.switchingTrack=null,this.bufferedTrack=t,this.state=a),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(R.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,r){var i;if(null==this.mainDetails)this.cachedTrackLoadedData=r;else{var n=this["levels"],{details:r,id:s}=r;if(n){this.log(`Track ${s} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:`+r.totalduration);n=n[s];let e=0;if(r.live||null!=(i=n.details)&&i.live){this.checkLiveUpdate(r);const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;e=!n.details&&r.hasProgramDateTime&&t.hasProgramDateTime?(nr(r,t),r.fragments[0].start):this.alignPlaylists(r,n.details)}n.details=r,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(n.details,e),this.state!==dr||this.waitForCdnTuneIn(r)||(this.state=u),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)}}_handleFragmentLoadProgress(t){var r;const{frag:i,part:n,payload:s}=t,{config:a,trackId:o,levels:e}=this;if(e){t=e[o];if(t){var l=t.details;if(l){var h=a.defaultAudioCodec||t.audioCodec||"mp4a.40.2";let e=this.transmuxer;e=e||(this.transmuxer=new yi(this.hls,T,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var u=this.initPTS[i.cc],c=null==(r=i.initSegment)?void 0:r.data;if(void 0!==u){const t=!1,r=n?n.index:-1,a=-1!==r,o=new er(i.level,i.sn,i.stats.chunkCount,s.byteLength,r,a);e.push(s,c,h,"",i,n,l.totalduration,!1,o,u)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track `+o);const t=(this.waitingData=this.waitingData||{frag:i,part:n,cache:new Si,complete:!1})["cache"];t.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=gr}}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){var{frag:t,part:r}=t;if(t.type===T)if(this.fragContextChanged(t))this.warn(`Fragment ${t.sn}${r?" p: "+r.index:""} of level ${t.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false"));else{if("initSegment"!==t.sn){this.fragPrevious=t;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,m({},e)))}this.fragBufferedComplete(t,r)}else if(!this.loadedmetadata&&t.type===y){const e=this.videoBuffer||this.media;e&&_.getBuffered(e).length&&(this.loadedmetadata=!0)}}onError(e,t){var r;if(t.fatal)this.state=mr;else switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(T,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==dr||(null==(r=t.context)?void 0:r.type)!==g||(this.state=u);break;case D.BUFFER_FULL_ERROR:t.parent&&"audio"===t.parent&&this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushed(e,{type:t}){t===b&&(this.bufferFlushed=!0,this.state===pr)&&(this.state=u)}_handleTransmuxComplete(e){var t;const r="audio",i=this["hls"],{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(a){var{frag:o,part:l,level:e}=a,h=e["details"],{audio:u,text:c,id3:d,initSegment:f}=n;if(!this.fragContextChanged(o)&&h){if(this.state=O,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const e=o.initSegment||o;this._bufferInitSegment(f.tracks,e,s),i.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:f.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[b]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(b,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=d&&null!=(t=d.samples)&&t.length){const e=L({id:r,frag:o,details:h},d);i.trigger(R.FRAG_PARSING_METADATA,e)}if(c){const e=L({id:r,frag:o,details:h},c);i.trigger(R.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(s)}_bufferInitSegment(e,t,r){if(this.state===O){e.video&&delete e.video;var i=e.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e);i=i.initSegment;if(null!=i&&i.byteLength){const e={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:i};this.hls.trigger(R.BUFFER_APPENDING,e)}this.tick()}}}loadFragment(e,t,r){var i=this.fragmentTracker.getState(e);this.fragCurrent=e,this.switchingTrack||i===Vt||i===Wt?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(i=t.details)&&i.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level `+this.trackId),this.state=gr):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){var{hls:t,media:r,bufferedTrack:i}=this,i=null==i?void 0:i.attrs,n=e.attrs;r&&i&&(i.CHANNELS!==n.CHANNELS||i.NAME!==n.NAME||i.LANGUAGE!==n.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(R.AUDIO_TRACK_SWITCHED,m({},e))}},audioTrackController:class extends Ut{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var e=this["hls"];e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this["hls"];e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(R.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){var r,{id:i,groupId:n,details:s}=t,a=this.tracksInGroup[i];a&&a.groupId===n?(r=a.details,a.details=t.details,this.log(`audio-track ${i} "${a.name}" lang:${a.lang} group:${n} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,r)):this.warn(`Track with id:${i} and group:${n} not found in active group `+a.groupId)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){const r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;const e=this.tracks.filter(e=>!r||e.groupId===r),t=(this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),{audioTracks:this.tracksInGroup=e});this.log(`Updating audio tracks, ${e.length} track(s) found in group:`+r),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(e,t){!t.fatal&&t.context&&t.context.type===g&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){var t,r,i,n=this.tracksInGroup;e<0||e>=n.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=this.currentTrack,n[this.trackId],{groupId:r,name:i}=n=n[e],this.log(`Switching to audio-track ${e} "${i}" lang:${n.lang} group:`+r),this.trackId=e,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,m({},n)),n.details&&!n.details.live||(i=this.switchParams(n.url,null==t?void 0:t.details),this.loadPlaylist(i)))}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{const t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+e.length);this.warn(t.message),this.hls.trigger(R.ERROR,{type:C.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}findTrackId(t){var r=this.tracksInGroup;for(let e=0;e<r.length;e++){var i=r[e];if(!this.selectDefaultTrack||i.default){if(!t||void 0!==t.attrs["STABLE-RENDITION-ID"]&&t.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"])return i.id;if(t.name===i.name&&t.lang===i.lang)return i.id}}return-1}loadPlaylist(t){super.loadPlaylist();var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,n=r.groupId;let e=r.url;if(t)try{e=t.addDirectives(e)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log(`loading audio-track playlist ${i} "${r.name}" lang:${r.lang} group:`+n),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:e,id:i,groupId:n,deliveryDirectives:t||null})}}},emeController:yn,cmcdController:xn,contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.ERROR,this.onError,this)}unregisterListeners(){var e=this.hls;e&&(e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.ERROR,this.onError,this))}startLoad(){var e;this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri&&(this.updated?(e=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0),this.scheduleRefresh(this.uri,e)):this.loadSteeringManifest(this.uri))}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){var e=this.levels;e&&(this.levels=e.filter(e=>e!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){t=t.contentSteering;null!==t&&(this.pathwayId=t.pathwayId,this.uri=t.uri,this.started)&&this.startLoad()}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){var r=t["errorAction"];if(2===(null==r?void 0:r.action)&&1===r.flags){let e=this.pathwayPriority;const t=this.pathwayId;this.penalizedPathways[t]||(this.penalizedPathways[t]=performance.now()),(e=!e&&this.levels?this.levels.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[]):e)&&1<e.length&&(this.updatePathwayPriority(e),r.resolved=this.pathwayId!==t)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);var r;return 0===t.length&&(r=e[0].pathwayId,this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r),t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{3e5<i-r[e]&&delete r[e]});for(let e=0;e<t.length;e++){var n=t[e];if(!r[n]){if(n===this.pathwayId)return;var s,a=this.hls.nextLoadLevel,o=this.hls.levels[a];if(0<(s=this.getLevelsForPathway(n)).length){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,this.hls.trigger(R.LEVELS_UPDATED,{levels:s});const t=this.hls.levels[a];o&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to `+t.bitrate),this.hls.nextLoadLevel=a);break}}}}clonePathways(e){const r=this.levels;if(r){const a={},o={};e.forEach(e=>{const{ID:n,"BASE-ID":t,"URI-REPLACEMENT":s}=e;r.some(e=>e.pathwayId===n)||(e=this.getLevelsForPathway(t).map(e=>{var t=L({},e),e=(t.details=void 0,t.url=bn(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",s),new A(e.attrs)),r=(e["PATHWAY-ID"]=n,e.AUDIO&&e.AUDIO+"_clone_"+n),i=e.SUBTITLES&&e.SUBTITLES+"_clone_"+n,e=(r&&(a[e.AUDIO]=r,e.AUDIO=r),i&&(o[e.SUBTITLES]=i,e.SUBTITLES=i),t.attrs=e,new Tt(t));return Ht(e,"audio",r),Ht(e,"text",i),e}),r.push(...e),_n(this.audioTracks,a,s,n),_n(this.subtitleTracks,o,s,n))})}}loadSteeringManifest(e){var t=this.hls.config,r=t.loader;let o;this.loader&&this.loader.destroy(),this.loader=new r(t);try{o=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==o.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);o.searchParams.set("_HLS_pathway",this.pathwayId),o.searchParams.set("_HLS_throughput",""+e)}var r={responseType:"json",url:o.href},e=t.steeringManifestLoadPolicy.default,i=e.errorRetry||e.timeoutRetry||{},e={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:i.maxNumRetry||0,retryDelay:i.retryDelayMs||0,maxRetryDelay:i.maxRetryDelayMs||0},i={onSuccess:(e,t,r,i)=>{this.log(`Loaded steering manifest: "${o}"`);var n=e.data;if(1!==n.VERSION)this.log(`Steering VERSION ${n.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=n.TTL;var{"RELOAD-URI":n,"PATHWAY-CLONES":s,"PATHWAY-PRIORITY":a}=n;if(n)try{this.uri=new self.URL(n,o).href}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+n)}this.scheduleRefresh(this.uri||r.url),s&&this.clonePathways(s),a&&this.updatePathwayPriority(a)}},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)this.enabled=!1,this.log(`Steering manifest ${t.url} no longer available`);else{var n=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,n);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&parseFloat(t)}this.log(`Steering manifest ${t.url} rate limited`)}}},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log("Requesting steering manifest: "+o),this.loader.load(r,e,i)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}});function Dn(r){return r&&"object"==typeof r?Array.isArray(r)?r.map(Dn):Object.keys(r).reduce((e,t)=>(e[t]=Dn(r[t]),e),{}):r}class In{static get version(){return"1.4.12"}static isSupported(){return!!(t=ze())&&(e=xr(),t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove,!!t)&&!!e;var e,t}static get Events(){return R}static get ErrorTypes(){return C}static get ErrorDetails(){return D}static get DefaultConfig(){return In.defaultConfig||Cn}static set DefaultConfig(e){In.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new gi,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=e.debug||!1;if(self.console&&!0===t||"object"==typeof t){Y(t,"debug","log","info","warn","error");try{j.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.12')}catch(t){j=W}}else j=W;var r=this.config=function(e,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==o.liveMaxLatencyDurationCount&&(void 0===o.liveSyncDurationCount||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==o.liveMaxLatencyDuration&&(void 0===o.liveSyncDuration||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const l=Dn(e),t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(i=>{const n=("level"===i?"playlist":i)+"LoadPolicy",s=void 0===o[n],a=[];t.forEach(e=>{var t=i+"Loading"+e,r=o[t];if(void 0!==r&&s){a.push(t);const i=l[n].default;switch(o[n]={default:i},e){case"TimeOut":i.maxLoadTimeMs=r,i.maxTimeToFirstByteMs=r;break;case"MaxRetry":i.errorRetry.maxNumRetry=r,i.timeoutRetry.maxNumRetry=r;break;case"RetryDelay":i.errorRetry.retryDelayMs=r,i.timeoutRetry.retryDelayMs=r;break;case"MaxRetryTimeout":i.errorRetry.maxRetryDelayMs=r,i.timeoutRetry.maxRetryDelayMs=r}}}),a.length&&I.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${n}": `+JSON.stringify(o[n]))}),m(m({},l),o)}(In.DefaultConfig,e),{abrController:i,bufferController:e,capLevelController:n,errorController:s,fpsController:a}=(this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&((i=(e=r).loader)!==wn&&i!==Sn?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),1}catch(e){}}()&&(e.loader=wn,e.progressive=!0,e.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))),r),s=new s(this),o=this.abrController=new i(this),e=this.bufferController=new e(this),n=this.capLevelController=new n(this),a=new a(this),l=new lt(this),h=new yt(this),u=r.contentSteeringController,u=u?new u(this):null,c=this.levelController=new Gt(this,u),d=new jt(this),f=new Zt(this.config),p=this.streamController=new _i(this,d,f),l=(n.setStreamController(p),a.setStreamController(p),[l,c,p]),c=(u&&l.splice(1,0,u),this.networkControllers=l,[o,e,n,a,h,d]),p=(this.audioTrackController=this.createController(r.audioTrackController,l),r.audioStreamController),u=(p&&l.push(new p(this,d,f)),this.subtitleTrackController=this.createController(r.subtitleTrackController,l),r.subtitleStreamController),o=(u&&l.push(new u(this,d,f)),this.createController(r.timelineController,c),f.emeController=this.emeController=this.createController(r.emeController,c),this.cmcdController=this.createController(r.cmcdController,c),this.latencyController=this.createController(xt,c),this.coreComponents=c,l.push(s),s.onErrorOut);"function"==typeof o&&this.on(R.ERROR,o,s)}createController(e,t){return e?(e=new e(this),t&&t.push(e),e):null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){I.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(R.ERROR,{type:C.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=H.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});I.log("loadSource:"+i),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})}startLoad(t=-1){I.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){I.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log("set loadLevel:"+e),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log("set firstLevel:"+e),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){I.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){e=!!e;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimate():NaN}get ttfbEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){-1<_t.indexOf(e)&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){var{levels:t,config:{minAutoBitrate:r}}=this;if(t){var i=t.length;for(let e=0;e<i;e++)if(t[e].maxBitrate>=r)return e}return 0}get maxAutoLevel(){var{levels:t,autoLevelCapping:e,maxHdcpLevel:r}=this;let i;if(i=-1===e&&t&&t.length?t.length-1:e,r)for(let e=i;e--;){const i=t[e].attrs["HDCP-LEVEL"];if(i&&i<=r)return e}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){var e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}In.defaultConfig=void 0},664:function(e,t,r){"use strict";var i="function"==typeof Symbol&&Symbol.for,n=i?Symbol.for("react.element"):60103,s=i?Symbol.for("react.portal"):60106,a=i?Symbol.for("react.fragment"):60107,o=i?Symbol.for("react.strict_mode"):60108,l=i?Symbol.for("react.profiler"):60114,h=i?Symbol.for("react.provider"):60109,u=i?Symbol.for("react.context"):60110,c=i?Symbol.for("react.async_mode"):60111,d=i?Symbol.for("react.concurrent_mode"):60111,f=i?Symbol.for("react.forward_ref"):60112,p=i?Symbol.for("react.suspense"):60113,m=i?Symbol.for("react.suspense_list"):60120,g=i?Symbol.for("react.memo"):60115,v=i?Symbol.for("react.lazy"):60116,y=i?Symbol.for("react.block"):60121,x=i?Symbol.for("react.fundamental"):60117,_=i?Symbol.for("react.responder"):60118,b=i?Symbol.for("react.scope"):60119;function T(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:switch(e=e.type){case c:case d:case a:case l:case o:case p:return e;default:switch(e=e&&e.$$typeof){case u:case f:case v:case g:case h:return e;default:return t}}case s:return t}}}function S(e){return T(e)===d}t.AsyncMode=c,t.ConcurrentMode=d,t.ContextConsumer=u,t.ContextProvider=h,t.Element=n,t.ForwardRef=f,t.Fragment=a,t.Lazy=v,t.Memo=g,t.Portal=s,t.Profiler=l,t.StrictMode=o,t.Suspense=p,t.isAsyncMode=function(e){return S(e)||T(e)===c},t.isConcurrentMode=S,t.isContextConsumer=function(e){return T(e)===u},t.isContextProvider=function(e){return T(e)===h},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return T(e)===f},t.isFragment=function(e){return T(e)===a},t.isLazy=function(e){return T(e)===v},t.isMemo=function(e){return T(e)===g},t.isPortal=function(e){return T(e)===s},t.isProfiler=function(e){return T(e)===l},t.isStrictMode=function(e){return T(e)===o},t.isSuspense=function(e){return T(e)===p},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===d||e===l||e===o||e===p||e===m||"object"==typeof e&&null!==e&&(e.$$typeof===v||e.$$typeof===g||e.$$typeof===h||e.$$typeof===u||e.$$typeof===f||e.$$typeof===x||e.$$typeof===_||e.$$typeof===b||e.$$typeof===y)},t.typeOf=T},699:function(e,t,r){var i=r(131),n=r(606),s=r(130),a=r(319),r=i?i.prototype:void 0,o=r?r.toString:void 0;e.exports=function e(t){var r;return"string"==typeof t?t:s(t)?n(t,e)+"":a(t)?o?o.call(t):"":"0"==(r=t+"")&&1/t==-1/0?"-0":r}},721:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"DraggableCore",{enumerable:!0,get:function(){return x.default}}),t.default=void 0;var m=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=l(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(1)),i=o(r(0)),n=o(r(27)),g=o(r(47)),v=r(587),y=r(614),s=r(575),x=o(r(723)),a=o(r(615));function o(e){return e&&e.__esModule?e:{default:e}}function l(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(l=function(e){return e?r:t})(e))}function _(){return(_=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r,i=arguments[t];for(r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function h(e,t,r){var i;i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t),(t="symbol"==typeof i?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}class u extends m.Component{static getDerivedStateFromProps(e,t){e=e.position,t=t.prevPropsPosition;return!e||t&&e.x===t.x&&e.y===t.y?null:((0,a.default)("Draggable: getDerivedStateFromProps %j",{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}})}constructor(e){super(e),h(this,"onDragStart",(e,t)=>{if((0,a.default)("Draggable: onDragStart: %j",t),!1===this.props.onStart(e,(0,y.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),h(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,a.default)("Draggable: onDrag: %j",t);var r=(0,y.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;var[n,s]=(0,y.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),h(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,y.createDraggableData)(this,t)))return!1;(0,a.default)("Draggable: onDragStop: %j",t);var r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:(e.position||e.defaultPosition).x,y:(e.position||e.defaultPosition).y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e;return null!=(e=null==(e=this.props)||null==(e=e.nodeRef)?void 0:e.current)?e:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:r,defaultPosition:i,defaultClassName:n,defaultClassNameDragging:s,defaultClassNameDragged:a,position:o,positionOffset:l,scale:h,...u}=this.props;let c={},d=null;var f=!Boolean(o)||this.state.dragging,p=o||i,f={x:((0,y.canDragX)(this)&&f?this.state:p).x,y:((0,y.canDragY)(this)&&f?this.state:p).y},p=(this.state.isElementSVG?d=(0,v.createSVGTransform)(f,l):c=(0,v.createCSSTransform)(f,l),(0,g.default)(r.props.className||"",n,{[s]:this.state.dragging,[a]:this.state.dragged}));return m.createElement(x.default,_({},u,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),m.cloneElement(m.Children.only(r),{className:p,style:{...r.props.style,...c},transform:d}))}}h(t.default=u,"displayName","Draggable"),h(u,"propTypes",{...x.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:s.dontSetMe,style:s.dontSetMe,transform:s.dontSetMe}),h(u,"defaultProps",{...x.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},722:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browserPrefixToKey=s,t.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},t.default=void 0,t.getPrefix=n;const i=["Moz","Webkit","O","ms"];function n(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"!=typeof window){var r=null==(e=window.document)||null==(e=e.documentElement)?void 0:e.style;if(r&&!(t in r))for(let e=0;e<i.length;e++)if(s(t,i[e])in r)return i[e]}return""}function s(e,t){return t?"".concat(t).concat(function(t){let r="",i=!0;for(let e=0;e<t.length;e++)i?(r+=t[e].toUpperCase(),i=!1):"-"===t[e]?i=!0:r+=t[e];return r}(e)):e}t.default=n()},723:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c(void 0);if(t&&t.has(e))return t.get(e);var r,i,n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&((i=s?Object.getOwnPropertyDescriptor(e,r):null)&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]);return n.default=e,t&&t.set(e,n),n}(r(1)),n=u(r(0)),s=u(r(27)),a=r(587),o=r(614),l=r(575),h=u(r(615));function u(e){return e&&e.__esModule?e:{default:e}}function c(e){var t,r;return"function"!=typeof WeakMap?null:(t=new WeakMap,r=new WeakMap,(c=function(e){return e?r:t})(e))}function d(e,t,r){var i;i=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t),(t="symbol"==typeof i?i:String(i))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}const f={start:"touchstart",move:"touchmove",stop:"touchend"},p={start:"mousedown",move:"mousemove",stop:"mouseup"};let m=p;class g extends i.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;var t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");var r,i,n=t["ownerDocument"];this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,a.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,a.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t)||("touchstart"===e.type&&e.preventDefault(),t=(0,a.getTouchIdentifier)(e),this.touchIdentifier=t,null!=(t=(0,o.getControlPosition)(e,t,this))&&({x:t,y:r}=t,i=(0,o.createCoreData)(this,t,r),(0,h.default)("DraggableCore: handleDragStart: %j",i),(0,h.default)("calling",this.props.onStart),!1!==this.props.onStart(e,i))&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,a.addUserSelectStyles)(n),this.dragging=!0,this.lastX=t,this.lastY=r,(0,a.addEvent)(n,m.move,this.handleDrag),(0,a.addEvent)(n,m.stop,this.handleDragStop)))}),d(this,"handleDrag",r=>{const i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:e,y:t}=i;if(Array.isArray(this.props.grid)){var n=e-this.lastX,s=t-this.lastY;if([n,s]=(0,o.snapToGrid)(this.props.grid,n,s),!n&&!s)return;e=this.lastX+n,t=this.lastY+s}n=(0,o.createCoreData)(this,e,t);if((0,h.default)("DraggableCore: handleDrag: %j",n),!1!==this.props.onDrag(r,n)&&!1!==this.mounted)this.lastX=e,this.lastY=t;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(r){const i=document.createEvent("MouseEvents");i.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(i)}}}),d(this,"handleDragStop",r=>{if(this.dragging){var i=(0,o.getControlPosition)(r,this.touchIdentifier,this);if(null!=i){let{x:e,y:t}=i;Array.isArray(this.props.grid)&&(i=e-this.lastX||0,n=t-this.lastY||0,[i,n]=(0,o.snapToGrid)(this.props.grid,i,n),e=this.lastX+i,t=this.lastY+n);i=(0,o.createCoreData)(this,e,t);if(!1===this.props.onStop(r,i)||!1===this.mounted)return!1;var n=this.findDOMNode();n&&this.props.enableUserSelectHack&&(0,a.removeUserSelectStyles)(n.ownerDocument),(0,h.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,n&&((0,h.default)("DraggableCore: Removing handlers"),(0,a.removeEvent)(n.ownerDocument,m.move,this.handleDrag),(0,a.removeEvent)(n.ownerDocument,m.stop,this.handleDragStop))}}}),d(this,"onMouseDown",e=>(m=p,this.handleDragStart(e))),d(this,"onMouseUp",e=>(m=p,this.handleDragStop(e))),d(this,"onTouchStart",e=>(m=f,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(m=f,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;var e=this.findDOMNode();e&&(0,a.addEvent)(e,f.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;var e,t=this.findDOMNode();t&&(e=t["ownerDocument"],(0,a.removeEvent)(e,p.move,this.handleDrag),(0,a.removeEvent)(e,f.move,this.handleDrag),(0,a.removeEvent)(e,p.stop,this.handleDragStop),(0,a.removeEvent)(e,f.stop,this.handleDragStop),(0,a.removeEvent)(t,f.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack)&&(0,a.removeUserSelectStyles)(e)}findDOMNode(){var e;return null!=(e=this.props)&&e.nodeRef?null==(e=this.props)||null==(e=e.nodeRef)?void 0:e.current:s.default.findDOMNode(this)}render(){return i.cloneElement(i.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}d(t.default=g,"displayName","DraggableCore"),d(g,"propTypes",{allowAnyClick:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),d(g,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},761:function(e,t,r){!function(e,f){!function(r){"use strict";var i,t,n,e,s,a,o,l,h,u;function c(e){delete a[e]}function d(e){if(o)setTimeout(d,0,e);else{var t=a[e];if(t){o=!0;try{var r=t.callback,i=t.args;switch(i.length){case 0:r();break;case 1:r(i[0]);break;case 2:r(i[0],i[1]);break;case 3:r(i[0],i[1],i[2]);break;default:r.apply(void 0,i)}}finally{c(e),o=!1}}}}r.setImmediate||(s=1,o=!(a={}),l=r.document,h=(h=Object.getPrototypeOf&&Object.getPrototypeOf(r))&&h.setTimeout?h:r,u="[object process]"==={}.toString.call(r.process)?function(e){f.nextTick(function(){d(e)})}:function(){var e,t;if(r.postMessage&&!r.importScripts)return e=!0,t=r.onmessage,r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}()?(n="setImmediate$"+Math.random()+"$",e=function(e){e.source===r&&"string"==typeof e.data&&0===e.data.indexOf(n)&&d(+e.data.slice(n.length))},r.addEventListener?r.addEventListener("message",e,!1):r.attachEvent("onmessage",e),function(e){r.postMessage(n+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){d(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):function(e){setTimeout(d,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];return a[s]={callback:e,args:t},u(s),s++},h.clearImmediate=c)}("undefined"==typeof self?void 0===e?this:e:self)}.call(this,r(32),r(318))},764:function(e,t,r){"use strict";t.byteLength=function(e){var e=u(e),t=e[0],e=e[1];return 3*(t+e)/4-e},t.toByteArray=function(e){for(var t,r=u(e),i=r[0],r=r[1],n=new h(3*(i+r)/4-r),s=0,a=0<r?i-4:i,o=0;o<a;o+=4)t=l[e.charCodeAt(o)]<<18|l[e.charCodeAt(o+1)]<<12|l[e.charCodeAt(o+2)]<<6|l[e.charCodeAt(o+3)],n[s++]=t>>16&255,n[s++]=t>>8&255,n[s++]=255&t;return 2===r&&(t=l[e.charCodeAt(o)]<<2|l[e.charCodeAt(o+1)]>>4,n[s++]=255&t),1===r&&(t=l[e.charCodeAt(o)]<<10|l[e.charCodeAt(o+1)]<<4|l[e.charCodeAt(o+2)]>>2,n[s++]=t>>8&255,n[s++]=255&t),n},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,n=[],s=0,a=r-i;s<a;s+=16383)n.push(function(e,t,r){for(var i,n=[],s=t;s<r;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),n.push(o[(i=i)>>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return n.join("")}(e,s,a<s+16383?a:s+16383));return 1==i?(t=e[r-1],n.push(o[t>>2]+o[t<<4&63]+"==")):2==i&&(t=(e[r-2]<<8)+e[r-1],n.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"=")),n.join("")};for(var o=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,s=i.length;n<s;++n)o[n]=i[n],l[i.charCodeAt(n)]=n;function u(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("=");return[e=-1===e?t:e,e===t?0:4-e%4]}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},765:function(e,t){t.read=function(e,t,r,i,n){var s,a,o=8*n-i-1,l=(1<<o)-1,h=l>>1,u=-7,c=r?n-1:0,d=r?-1:1,n=e[t+c];for(c+=d,s=n&(1<<-u)-1,n>>=-u,u+=o;0<u;s=256*s+e[t+c],c+=d,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;0<u;a=256*a+e[t+c],c+=d,u-=8);if(0===s)s=1-h;else{if(s===l)return a?NaN:1/0*(n?-1:1);a+=Math.pow(2,i),s-=h}return(n?-1:1)*a*Math.pow(2,s-i)},t.write=function(e,t,r,i,n,s){var a,o,l=8*s-n-1,h=(1<<l)-1,u=h>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,f=i?1:-1,s=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(i=Math.pow(2,-a))<1&&(a--,i*=2),2<=(t+=1<=a+u?c/i:c*Math.pow(2,1-u))*i&&(a++,i/=2),h<=a+u?(o=0,a=h):1<=a+u?(o=(t*i-1)*Math.pow(2,n),a+=u):(o=t*Math.pow(2,u-1)*Math.pow(2,n),a=0));8<=n;e[r+d]=255&o,d+=f,o/=256,n-=8);for(a=a<<n|o,l+=n;0<l;e[r+d]=255&a,d+=f,a/=256,l-=8);e[r+d-f]|=128*s}},766:function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},922:function(e,t,r){"use strict";var i=r(620),n=r(621);function s(t,r){switch(arguments.length){case 0:return s;case 1:return Object(n.a)(t)?s:Object(i.a)(function(e){return a(t,e)});default:return Object(n.a)(t)&&Object(n.a)(r)?s:Object(n.a)(t)?Object(i.a)(function(e){return a(e,r)}):Object(n.a)(r)?Object(i.a)(function(e){return a(t,e)}):a(t,r)}}var a;a=function(e,t){for(var r,i={},n={},s=0,a=e.length;s<a;)s+=n[e[s]]=1;for(r in t)n.hasOwnProperty(r)||(i[r]=t[r]);return i};t.a=s}}]);
|