three-vr-player 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/Player.d.ts +4 -0
- package/dist/{VideoSource-pc2RM7bl.js → VideoSource-CJGIX8gL.js} +72 -64
- package/dist/VideoSource-CJGIX8gL.js.map +1 -0
- package/dist/core/StereoScene.d.ts +3 -0
- package/dist/core/VideoSource.d.ts +2 -0
- package/dist/core.js +1 -1
- package/dist/three-vr-player.js +135 -109
- package/dist/three-vr-player.js.map +1 -1
- package/dist/three-vr-player.standalone.js +1 -1
- package/dist/three-vr-player.standalone.js.map +1 -1
- package/dist/types.d.ts +9 -1
- package/package.json +39 -9
- package/dist/VideoSource-pc2RM7bl.js.map +0 -1
|
@@ -3683,7 +3683,7 @@ void main() {
|
|
|
3683
3683
|
squared_mean = squared_mean / samples;
|
|
3684
3684
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3685
3685
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3686
|
-
}`;function $g(s,e,t){let i=new xl;const n=new it,r=new it,a=new Ft,o=new Bg({depthPacking:3201}),l=new Gg,c={},h=t.maxTextureSize,u={0:1,1:0,2:2},d=new on({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new it},radius:{value:4}},vertexShader:Vg,fragmentShader:Hg}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ji;p.setAttribute("position",new Ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new mi(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let g=this.type;this.render=function(R,A,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||R.length===0)return;const x=s.getRenderTarget(),y=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(0),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const H=g!==3&&this.type===3,w=g===3&&this.type!==3;for(let F=0,O=R.length;F<O;F++){const z=R[F],N=z.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;n.copy(N.mapSize);const k=N.getFrameExtents();if(n.multiply(k),r.copy(N.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/k.x),n.x=r.x*k.x,N.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/k.y),n.y=r.y*k.y,N.mapSize.y=r.y)),N.map===null||H===!0||w===!0){const G=this.type!==3?{minFilter:1003,magFilter:1003}:{};N.map!==null&&N.map.dispose(),N.map=new nn(n.x,n.y,G),N.map.texture.name=z.name+".shadowMap",N.camera.updateProjectionMatrix()}s.setRenderTarget(N.map),s.clear();const q=N.getViewportCount();for(let G=0;G<q;G++){const K=N.getViewport(G);a.set(r.x*K.x,r.y*K.y,r.x*K.z,r.y*K.w),P.viewport(a),N.updateMatrices(z,G),i=N.getFrustum(),T(A,C,N.camera,z,this.type)}N.isPointLightShadow!==!0&&this.type===3&&E(N,C),N.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(x,y,D)};function E(R,A){const C=e.update(v);d.defines.VSM_SAMPLES!==R.blurSamples&&(d.defines.VSM_SAMPLES=R.blurSamples,f.defines.VSM_SAMPLES=R.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new nn(n.x,n.y)),d.uniforms.shadow_pass.value=R.map.texture,d.uniforms.resolution.value=R.mapSize,d.uniforms.radius.value=R.radius,s.setRenderTarget(R.mapPass),s.clear(),s.renderBufferDirect(A,null,C,d,v,null),f.uniforms.shadow_pass.value=R.mapPass.texture,f.uniforms.resolution.value=R.mapSize,f.uniforms.radius.value=R.radius,s.setRenderTarget(R.map),s.clear(),s.renderBufferDirect(A,null,C,f,v,null)}function _(R,A,C,x){let y=null;const D=C.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(D!==void 0)y=D;else if(y=C.isPointLight===!0?l:o,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const P=y.uuid,H=A.uuid;let w=c[P];w===void 0&&(w={},c[P]=w);let F=w[H];F===void 0&&(F=y.clone(),w[H]=F,A.addEventListener("dispose",b)),y=F}if(y.visible=A.visible,y.wireframe=A.wireframe,x===3?y.side=A.shadowSide!==null?A.shadowSide:A.side:y.side=A.shadowSide!==null?A.shadowSide:u[A.side],y.alphaMap=A.alphaMap,y.alphaTest=A.alphaTest,y.map=A.map,y.clipShadows=A.clipShadows,y.clippingPlanes=A.clippingPlanes,y.clipIntersection=A.clipIntersection,y.displacementMap=A.displacementMap,y.displacementScale=A.displacementScale,y.displacementBias=A.displacementBias,y.wireframeLinewidth=A.wireframeLinewidth,y.linewidth=A.linewidth,C.isPointLight===!0&&y.isMeshDistanceMaterial===!0){const P=s.properties.get(y);P.light=C}return y}function T(R,A,C,x,y){if(R.visible===!1)return;if(R.layers.test(A.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&y===3)&&(!R.frustumCulled||i.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,R.matrixWorld);const H=e.update(R),w=R.material;if(Array.isArray(w)){const F=H.groups;for(let O=0,z=F.length;O<z;O++){const N=F[O],k=w[N.materialIndex];if(k&&k.visible){const q=_(R,k,x,y);R.onBeforeShadow(s,R,A,C,H,q,N),s.renderBufferDirect(C,null,H,q,R,N),R.onAfterShadow(s,R,A,C,H,q,N)}}}else if(w.visible){const F=_(R,w,x,y);R.onBeforeShadow(s,R,A,C,H,F,null),s.renderBufferDirect(C,null,H,F,R,null),R.onAfterShadow(s,R,A,C,H,F,null)}}const P=R.children;for(let H=0,w=P.length;H<w;H++)T(P[H],A,C,x,y)}function b(R){R.target.removeEventListener("dispose",b);for(const C in c){const x=c[C],y=R.target.uuid;y in x&&(x[y].dispose(),delete x[y])}}}function zg(s,e,t){const i=t.isWebGL2;function n(){let U=!1;const fe=new Ft;let pe=null;const Pe=new Ft(0,0,0,0);return{setMask:function(Ce){pe!==Ce&&!U&&(s.colorMask(Ce,Ce,Ce,Ce),pe=Ce)},setLocked:function(Ce){U=Ce},setClear:function(Ce,lt,ct,wt,$t){$t===!0&&(Ce*=wt,lt*=wt,ct*=wt),fe.set(Ce,lt,ct,wt),Pe.equals(fe)===!1&&(s.clearColor(Ce,lt,ct,wt),Pe.copy(fe))},reset:function(){U=!1,pe=null,Pe.set(-1,0,0,0)}}}function r(){let U=!1,fe=null,pe=null,Pe=null;return{setTest:function(Ce){Ce?be(s.DEPTH_TEST):Te(s.DEPTH_TEST)},setMask:function(Ce){fe!==Ce&&!U&&(s.depthMask(Ce),fe=Ce)},setFunc:function(Ce){if(pe!==Ce){switch(Ce){case 0:s.depthFunc(s.NEVER);break;case 1:s.depthFunc(s.ALWAYS);break;case 2:s.depthFunc(s.LESS);break;case 3:s.depthFunc(s.LEQUAL);break;case 4:s.depthFunc(s.EQUAL);break;case 5:s.depthFunc(s.GEQUAL);break;case 6:s.depthFunc(s.GREATER);break;case 7:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}pe=Ce}},setLocked:function(Ce){U=Ce},setClear:function(Ce){Pe!==Ce&&(s.clearDepth(Ce),Pe=Ce)},reset:function(){U=!1,fe=null,pe=null,Pe=null}}}function a(){let U=!1,fe=null,pe=null,Pe=null,Ce=null,lt=null,ct=null,wt=null,$t=null;return{setTest:function(ht){U||(ht?be(s.STENCIL_TEST):Te(s.STENCIL_TEST))},setMask:function(ht){fe!==ht&&!U&&(s.stencilMask(ht),fe=ht)},setFunc:function(ht,zt,Ii){(pe!==ht||Pe!==zt||Ce!==Ii)&&(s.stencilFunc(ht,zt,Ii),pe=ht,Pe=zt,Ce=Ii)},setOp:function(ht,zt,Ii){(lt!==ht||ct!==zt||wt!==Ii)&&(s.stencilOp(ht,zt,Ii),lt=ht,ct=zt,wt=Ii)},setLocked:function(ht){U=ht},setClear:function(ht){$t!==ht&&(s.clearStencil(ht),$t=ht)},reset:function(){U=!1,fe=null,pe=null,Pe=null,Ce=null,lt=null,ct=null,wt=null,$t=null}}}const o=new n,l=new r,c=new a,h=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,v=[],m=null,g=!1,E=null,_=null,T=null,b=null,R=null,A=null,C=null,x=new st(0,0,0),y=0,D=!1,P=null,H=null,w=null,F=null,O=null;const z=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,k=0;const q=s.getParameter(s.VERSION);q.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(q)[1]),N=k>=1):q.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),N=k>=2);let G=null,K={};const $=s.getParameter(s.SCISSOR_BOX),ee=s.getParameter(s.VIEWPORT),ie=new Ft().fromArray($),oe=new Ft().fromArray(ee);function me(U,fe,pe,Pe){const Ce=new Uint8Array(4),lt=s.createTexture();s.bindTexture(U,lt),s.texParameteri(U,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(U,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ct=0;ct<pe;ct++)i&&(U===s.TEXTURE_3D||U===s.TEXTURE_2D_ARRAY)?s.texImage3D(fe,0,s.RGBA,1,1,Pe,0,s.RGBA,s.UNSIGNED_BYTE,Ce):s.texImage2D(fe+ct,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Ce);return lt}const xe={};xe[s.TEXTURE_2D]=me(s.TEXTURE_2D,s.TEXTURE_2D,1),xe[s.TEXTURE_CUBE_MAP]=me(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(xe[s.TEXTURE_2D_ARRAY]=me(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),xe[s.TEXTURE_3D]=me(s.TEXTURE_3D,s.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),be(s.DEPTH_TEST),l.setFunc(3),Me(!1),I(1),be(s.CULL_FACE),le(0);function be(U){d[U]!==!0&&(s.enable(U),d[U]=!0)}function Te(U){d[U]!==!1&&(s.disable(U),d[U]=!1)}function Ge(U,fe){return f[U]!==fe?(s.bindFramebuffer(U,fe),f[U]=fe,i&&(U===s.DRAW_FRAMEBUFFER&&(f[s.FRAMEBUFFER]=fe),U===s.FRAMEBUFFER&&(f[s.DRAW_FRAMEBUFFER]=fe)),!0):!1}function Y(U,fe){let pe=v,Pe=!1;if(U)if(pe=p.get(fe),pe===void 0&&(pe=[],p.set(fe,pe)),U.isWebGLMultipleRenderTargets){const Ce=U.texture;if(pe.length!==Ce.length||pe[0]!==s.COLOR_ATTACHMENT0){for(let lt=0,ct=Ce.length;lt<ct;lt++)pe[lt]=s.COLOR_ATTACHMENT0+lt;pe.length=Ce.length,Pe=!0}}else pe[0]!==s.COLOR_ATTACHMENT0&&(pe[0]=s.COLOR_ATTACHMENT0,Pe=!0);else pe[0]!==s.BACK&&(pe[0]=s.BACK,Pe=!0);Pe&&(t.isWebGL2?s.drawBuffers(pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function Rt(U){return m!==U?(s.useProgram(U),m=U,!0):!1}const Re={100:s.FUNC_ADD,101:s.FUNC_SUBTRACT,102:s.FUNC_REVERSE_SUBTRACT};if(i)Re[103]=s.MIN,Re[104]=s.MAX;else{const U=e.get("EXT_blend_minmax");U!==null&&(Re[103]=U.MIN_EXT,Re[104]=U.MAX_EXT)}const Ue={200:s.ZERO,201:s.ONE,202:s.SRC_COLOR,204:s.SRC_ALPHA,210:s.SRC_ALPHA_SATURATE,208:s.DST_COLOR,206:s.DST_ALPHA,203:s.ONE_MINUS_SRC_COLOR,205:s.ONE_MINUS_SRC_ALPHA,209:s.ONE_MINUS_DST_COLOR,207:s.ONE_MINUS_DST_ALPHA,211:s.CONSTANT_COLOR,212:s.ONE_MINUS_CONSTANT_COLOR,213:s.CONSTANT_ALPHA,214:s.ONE_MINUS_CONSTANT_ALPHA};function le(U,fe,pe,Pe,Ce,lt,ct,wt,$t,ht){if(U===0){g===!0&&(Te(s.BLEND),g=!1);return}if(g===!1&&(be(s.BLEND),g=!0),U!==5){if(U!==E||ht!==D){if((_!==100||R!==100)&&(s.blendEquation(s.FUNC_ADD),_=100,R=100),ht)switch(U){case 1:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case 2:s.blendFunc(s.ONE,s.ONE);break;case 3:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case 4:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case 1:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case 2:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case 3:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case 4:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}T=null,b=null,A=null,C=null,x.set(0,0,0),y=0,E=U,D=ht}return}Ce=Ce||fe,lt=lt||pe,ct=ct||Pe,(fe!==_||Ce!==R)&&(s.blendEquationSeparate(Re[fe],Re[Ce]),_=fe,R=Ce),(pe!==T||Pe!==b||lt!==A||ct!==C)&&(s.blendFuncSeparate(Ue[pe],Ue[Pe],Ue[lt],Ue[ct]),T=pe,b=Pe,A=lt,C=ct),(wt.equals(x)===!1||$t!==y)&&(s.blendColor(wt.r,wt.g,wt.b,$t),x.copy(wt),y=$t),E=U,D=!1}function $e(U,fe){U.side===2?Te(s.CULL_FACE):be(s.CULL_FACE);let pe=U.side===1;fe&&(pe=!pe),Me(pe),U.blending===1&&U.transparent===!1?le(0):le(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),l.setFunc(U.depthFunc),l.setTest(U.depthTest),l.setMask(U.depthWrite),o.setMask(U.colorWrite);const Pe=U.stencilWrite;c.setTest(Pe),Pe&&(c.setMask(U.stencilWriteMask),c.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),c.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),X(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?be(s.SAMPLE_ALPHA_TO_COVERAGE):Te(s.SAMPLE_ALPHA_TO_COVERAGE)}function Me(U){P!==U&&(U?s.frontFace(s.CW):s.frontFace(s.CCW),P=U)}function I(U){U!==0?(be(s.CULL_FACE),U!==H&&(U===1?s.cullFace(s.BACK):U===2?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Te(s.CULL_FACE),H=U}function M(U){U!==w&&(N&&s.lineWidth(U),w=U)}function X(U,fe,pe){U?(be(s.POLYGON_OFFSET_FILL),(F!==fe||O!==pe)&&(s.polygonOffset(fe,pe),F=fe,O=pe)):Te(s.POLYGON_OFFSET_FILL)}function ne(U){U?be(s.SCISSOR_TEST):Te(s.SCISSOR_TEST)}function re(U){U===void 0&&(U=s.TEXTURE0+z-1),G!==U&&(s.activeTexture(U),G=U)}function ae(U,fe,pe){pe===void 0&&(G===null?pe=s.TEXTURE0+z-1:pe=G);let Pe=K[pe];Pe===void 0&&(Pe={type:void 0,texture:void 0},K[pe]=Pe),(Pe.type!==U||Pe.texture!==fe)&&(G!==pe&&(s.activeTexture(pe),G=pe),s.bindTexture(U,fe||xe[U]),Pe.type=U,Pe.texture=fe)}function ye(){const U=K[G];U!==void 0&&U.type!==void 0&&(s.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function ue(){try{s.compressedTexImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function _e(){try{s.compressedTexImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ie(){try{s.texSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ke(){try{s.texSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function se(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ze(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Qe(){try{s.texStorage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ne(){try{s.texStorage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Le(){try{s.texImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Se(){try{s.texImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ze(U){ie.equals(U)===!1&&(s.scissor(U.x,U.y,U.z,U.w),ie.copy(U))}function tt(U){oe.equals(U)===!1&&(s.viewport(U.x,U.y,U.z,U.w),oe.copy(U))}function vt(U,fe){let pe=u.get(fe);pe===void 0&&(pe=new WeakMap,u.set(fe,pe));let Pe=pe.get(U);Pe===void 0&&(Pe=s.getUniformBlockIndex(fe,U.name),pe.set(U,Pe))}function qe(U,fe){const Pe=u.get(fe).get(U);h.get(fe)!==Pe&&(s.uniformBlockBinding(fe,Pe,U.__bindingPointIndex),h.set(fe,Pe))}function he(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),i===!0&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null)),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),d={},G=null,K={},f={},p=new WeakMap,v=[],m=null,g=!1,E=null,_=null,T=null,b=null,R=null,A=null,C=null,x=new st(0,0,0),y=0,D=!1,P=null,H=null,w=null,F=null,O=null,ie.set(0,0,s.canvas.width,s.canvas.height),oe.set(0,0,s.canvas.width,s.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:be,disable:Te,bindFramebuffer:Ge,drawBuffers:Y,useProgram:Rt,setBlending:le,setMaterial:$e,setFlipSided:Me,setCullFace:I,setLineWidth:M,setPolygonOffset:X,setScissorTest:ne,activeTexture:re,bindTexture:ae,unbindTexture:ye,compressedTexImage2D:ue,compressedTexImage3D:_e,texImage2D:Le,texImage3D:Se,updateUBOMapping:vt,uniformBlockBinding:qe,texStorage2D:Qe,texStorage3D:Ne,texSubImage2D:Ie,texSubImage3D:ke,compressedTexSubImage2D:se,compressedTexSubImage3D:Ze,scissor:ze,viewport:tt,reset:he}}function Wg(s,e,t,i,n,r,a){const o=n.isWebGL2,l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(I,M){return f?new OffscreenCanvas(I,M):Cs("canvas")}function v(I,M,X,ne){let re=1;if((I.width>ne||I.height>ne)&&(re=ne/Math.max(I.width,I.height)),re<1||M===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){const ae=M?ea:Math.floor,ye=ae(re*I.width),ue=ae(re*I.height);u===void 0&&(u=p(ye,ue));const _e=X?p(ye,ue):u;return _e.width=ye,_e.height=ue,_e.getContext("2d").drawImage(I,0,0,ye,ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+ye+"x"+ue+")."),_e}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function m(I){return Xo(I.width)&&Xo(I.height)}function g(I){return o?!1:I.wrapS!==1001||I.wrapT!==1001||I.minFilter!==1003&&I.minFilter!==1006}function E(I,M){return I.generateMipmaps&&M&&I.minFilter!==1003&&I.minFilter!==1006}function _(I){s.generateMipmap(I)}function T(I,M,X,ne,re=!1){if(o===!1)return M;if(I!==null){if(s[I]!==void 0)return s[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let ae=M;if(M===s.RED&&(X===s.FLOAT&&(ae=s.R32F),X===s.HALF_FLOAT&&(ae=s.R16F),X===s.UNSIGNED_BYTE&&(ae=s.R8)),M===s.RED_INTEGER&&(X===s.UNSIGNED_BYTE&&(ae=s.R8UI),X===s.UNSIGNED_SHORT&&(ae=s.R16UI),X===s.UNSIGNED_INT&&(ae=s.R32UI),X===s.BYTE&&(ae=s.R8I),X===s.SHORT&&(ae=s.R16I),X===s.INT&&(ae=s.R32I)),M===s.RG&&(X===s.FLOAT&&(ae=s.RG32F),X===s.HALF_FLOAT&&(ae=s.RG16F),X===s.UNSIGNED_BYTE&&(ae=s.RG8)),M===s.RGBA){const ye=re?Ms:nt.getTransfer(ne);X===s.FLOAT&&(ae=s.RGBA32F),X===s.HALF_FLOAT&&(ae=s.RGBA16F),X===s.UNSIGNED_BYTE&&(ae=ye===ut?s.SRGB8_ALPHA8:s.RGBA8),X===s.UNSIGNED_SHORT_4_4_4_4&&(ae=s.RGBA4),X===s.UNSIGNED_SHORT_5_5_5_1&&(ae=s.RGB5_A1)}return(ae===s.R16F||ae===s.R32F||ae===s.RG16F||ae===s.RG32F||ae===s.RGBA16F||ae===s.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function b(I,M,X){return E(I,X)===!0||I.isFramebufferTexture&&I.minFilter!==1003&&I.minFilter!==1006?Math.log2(Math.max(M.width,M.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?M.mipmaps.length:1}function R(I){return I===1003||I===1004||I===1005?s.NEAREST:s.LINEAR}function A(I){const M=I.target;M.removeEventListener("dispose",A),x(M),M.isVideoTexture&&h.delete(M)}function C(I){const M=I.target;M.removeEventListener("dispose",C),D(M)}function x(I){const M=i.get(I);if(M.__webglInit===void 0)return;const X=I.source,ne=d.get(X);if(ne){const re=ne[M.__cacheKey];re.usedTimes--,re.usedTimes===0&&y(I),Object.keys(ne).length===0&&d.delete(X)}i.remove(I)}function y(I){const M=i.get(I);s.deleteTexture(M.__webglTexture);const X=I.source,ne=d.get(X);delete ne[M.__cacheKey],a.memory.textures--}function D(I){const M=I.texture,X=i.get(I),ne=i.get(M);if(ne.__webglTexture!==void 0&&(s.deleteTexture(ne.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(X.__webglFramebuffer[re]))for(let ae=0;ae<X.__webglFramebuffer[re].length;ae++)s.deleteFramebuffer(X.__webglFramebuffer[re][ae]);else s.deleteFramebuffer(X.__webglFramebuffer[re]);X.__webglDepthbuffer&&s.deleteRenderbuffer(X.__webglDepthbuffer[re])}else{if(Array.isArray(X.__webglFramebuffer))for(let re=0;re<X.__webglFramebuffer.length;re++)s.deleteFramebuffer(X.__webglFramebuffer[re]);else s.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&s.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&s.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let re=0;re<X.__webglColorRenderbuffer.length;re++)X.__webglColorRenderbuffer[re]&&s.deleteRenderbuffer(X.__webglColorRenderbuffer[re]);X.__webglDepthRenderbuffer&&s.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let re=0,ae=M.length;re<ae;re++){const ye=i.get(M[re]);ye.__webglTexture&&(s.deleteTexture(ye.__webglTexture),a.memory.textures--),i.remove(M[re])}i.remove(M),i.remove(I)}let P=0;function H(){P=0}function w(){const I=P;return I>=n.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+n.maxTextures),P+=1,I}function F(I){const M=[];return M.push(I.wrapS),M.push(I.wrapT),M.push(I.wrapR||0),M.push(I.magFilter),M.push(I.minFilter),M.push(I.anisotropy),M.push(I.internalFormat),M.push(I.format),M.push(I.type),M.push(I.generateMipmaps),M.push(I.premultiplyAlpha),M.push(I.flipY),M.push(I.unpackAlignment),M.push(I.colorSpace),M.join()}function O(I,M){const X=i.get(I);if(I.isVideoTexture&&$e(I),I.isRenderTargetTexture===!1&&I.version>0&&X.__version!==I.version){const ne=I.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(X,I,M);return}}t.bindTexture(s.TEXTURE_2D,X.__webglTexture,s.TEXTURE0+M)}function z(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){ie(X,I,M);return}t.bindTexture(s.TEXTURE_2D_ARRAY,X.__webglTexture,s.TEXTURE0+M)}function N(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){ie(X,I,M);return}t.bindTexture(s.TEXTURE_3D,X.__webglTexture,s.TEXTURE0+M)}function k(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){oe(X,I,M);return}t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture,s.TEXTURE0+M)}const q={1e3:s.REPEAT,1001:s.CLAMP_TO_EDGE,1002:s.MIRRORED_REPEAT},G={1003:s.NEAREST,1004:s.NEAREST_MIPMAP_NEAREST,1005:s.NEAREST_MIPMAP_LINEAR,1006:s.LINEAR,1007:s.LINEAR_MIPMAP_NEAREST,1008:s.LINEAR_MIPMAP_LINEAR},K={512:s.NEVER,519:s.ALWAYS,513:s.LESS,515:s.LEQUAL,514:s.EQUAL,518:s.GEQUAL,516:s.GREATER,517:s.NOTEQUAL};function $(I,M,X){if(X?(s.texParameteri(I,s.TEXTURE_WRAP_S,q[M.wrapS]),s.texParameteri(I,s.TEXTURE_WRAP_T,q[M.wrapT]),(I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY)&&s.texParameteri(I,s.TEXTURE_WRAP_R,q[M.wrapR]),s.texParameteri(I,s.TEXTURE_MAG_FILTER,G[M.magFilter]),s.texParameteri(I,s.TEXTURE_MIN_FILTER,G[M.minFilter])):(s.texParameteri(I,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(I,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY)&&s.texParameteri(I,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(M.wrapS!==1001||M.wrapT!==1001)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(I,s.TEXTURE_MAG_FILTER,R(M.magFilter)),s.texParameteri(I,s.TEXTURE_MIN_FILTER,R(M.minFilter)),M.minFilter!==1003&&M.minFilter!==1006&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(s.texParameteri(I,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(I,s.TEXTURE_COMPARE_FUNC,K[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ne=e.get("EXT_texture_filter_anisotropic");if(M.magFilter===1003||M.minFilter!==1005&&M.minFilter!==1008||M.type===1015&&e.has("OES_texture_float_linear")===!1||o===!1&&M.type===1016&&e.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||i.get(M).__currentAnisotropy)&&(s.texParameterf(I,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,n.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy)}}function ee(I,M){let X=!1;I.__webglInit===void 0&&(I.__webglInit=!0,M.addEventListener("dispose",A));const ne=M.source;let re=d.get(ne);re===void 0&&(re={},d.set(ne,re));const ae=F(M);if(ae!==I.__cacheKey){re[ae]===void 0&&(re[ae]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,X=!0),re[ae].usedTimes++;const ye=re[I.__cacheKey];ye!==void 0&&(re[I.__cacheKey].usedTimes--,ye.usedTimes===0&&y(M)),I.__cacheKey=ae,I.__webglTexture=re[ae].texture}return X}function ie(I,M,X){let ne=s.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(ne=s.TEXTURE_2D_ARRAY),M.isData3DTexture&&(ne=s.TEXTURE_3D);const re=ee(I,M),ae=M.source;t.bindTexture(ne,I.__webglTexture,s.TEXTURE0+X);const ye=i.get(ae);if(ae.version!==ye.__version||re===!0){t.activeTexture(s.TEXTURE0+X);const ue=nt.getPrimaries(nt.workingColorSpace),_e=M.colorSpace===ri?null:nt.getPrimaries(M.colorSpace),Ie=M.colorSpace===ri||ue===_e?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ie);const ke=g(M)&&m(M.image)===!1;let se=v(M.image,ke,!1,n.maxTextureSize);se=Me(M,se);const Ze=m(se)||o,Qe=r.convert(M.format,M.colorSpace);let Ne=r.convert(M.type),Le=T(M.internalFormat,Qe,Ne,M.colorSpace,M.isVideoTexture);$(ne,M,Ze);let Se;const ze=M.mipmaps,tt=o&&M.isVideoTexture!==!0&&Le!==36196,vt=ye.__version===void 0||re===!0,qe=b(M,se,Ze);if(M.isDepthTexture)Le=s.DEPTH_COMPONENT,o?M.type===1015?Le=s.DEPTH_COMPONENT32F:M.type===1014?Le=s.DEPTH_COMPONENT24:M.type===1020?Le=s.DEPTH24_STENCIL8:Le=s.DEPTH_COMPONENT16:M.type===1015&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===1026&&Le===s.DEPTH_COMPONENT&&M.type!==1012&&M.type!==1014&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=1014,Ne=r.convert(M.type)),M.format===1027&&Le===s.DEPTH_COMPONENT&&(Le=s.DEPTH_STENCIL,M.type!==1020&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=1020,Ne=r.convert(M.type))),vt&&(tt?t.texStorage2D(s.TEXTURE_2D,1,Le,se.width,se.height):t.texImage2D(s.TEXTURE_2D,0,Le,se.width,se.height,0,Qe,Ne,null));else if(M.isDataTexture)if(ze.length>0&&Ze){tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Ne,Se.data):t.texImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Qe,Ne,Se.data);M.generateMipmaps=!1}else tt?(vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,se.width,se.height,Qe,Ne,se.data)):t.texImage2D(s.TEXTURE_2D,0,Le,se.width,se.height,0,Qe,Ne,se.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){tt&&vt&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,Le,ze[0].width,ze[0].height,se.depth);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],M.format!==1023?Qe!==null?tt?t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,he,0,0,0,Se.width,Se.height,se.depth,Qe,Se.data,0,0):t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,he,Le,Se.width,Se.height,se.depth,0,Se.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage3D(s.TEXTURE_2D_ARRAY,he,0,0,0,Se.width,Se.height,se.depth,Qe,Ne,Se.data):t.texImage3D(s.TEXTURE_2D_ARRAY,he,Le,Se.width,Se.height,se.depth,0,Qe,Ne,Se.data)}else{tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],M.format!==1023?Qe!==null?tt?t.compressedTexSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Se.data):t.compressedTexImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Ne,Se.data):t.texImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Qe,Ne,Se.data)}else if(M.isDataArrayTexture)tt?(vt&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,Le,se.width,se.height,se.depth),t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Qe,Ne,se.data)):t.texImage3D(s.TEXTURE_2D_ARRAY,0,Le,se.width,se.height,se.depth,0,Qe,Ne,se.data);else if(M.isData3DTexture)tt?(vt&&t.texStorage3D(s.TEXTURE_3D,qe,Le,se.width,se.height,se.depth),t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Qe,Ne,se.data)):t.texImage3D(s.TEXTURE_3D,0,Le,se.width,se.height,se.depth,0,Qe,Ne,se.data);else if(M.isFramebufferTexture){if(vt)if(tt)t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height);else{let he=se.width,U=se.height;for(let fe=0;fe<qe;fe++)t.texImage2D(s.TEXTURE_2D,fe,Le,he,U,0,Qe,Ne,null),he>>=1,U>>=1}}else if(ze.length>0&&Ze){tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Qe,Ne,Se):t.texImage2D(s.TEXTURE_2D,he,Le,Qe,Ne,Se);M.generateMipmaps=!1}else tt?(vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,Qe,Ne,se)):t.texImage2D(s.TEXTURE_2D,0,Le,Qe,Ne,se);E(M,Ze)&&_(ne),ye.__version=ae.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function oe(I,M,X){if(M.image.length!==6)return;const ne=ee(I,M),re=M.source;t.bindTexture(s.TEXTURE_CUBE_MAP,I.__webglTexture,s.TEXTURE0+X);const ae=i.get(re);if(re.version!==ae.__version||ne===!0){t.activeTexture(s.TEXTURE0+X);const ye=nt.getPrimaries(nt.workingColorSpace),ue=M.colorSpace===ri?null:nt.getPrimaries(M.colorSpace),_e=M.colorSpace===ri||ye===ue?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);const Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,ke=M.image[0]&&M.image[0].isDataTexture,se=[];for(let he=0;he<6;he++)!Ie&&!ke?se[he]=v(M.image[he],!1,!0,n.maxCubemapSize):se[he]=ke?M.image[he].image:M.image[he],se[he]=Me(M,se[he]);const Ze=se[0],Qe=m(Ze)||o,Ne=r.convert(M.format,M.colorSpace),Le=r.convert(M.type),Se=T(M.internalFormat,Ne,Le,M.colorSpace),ze=o&&M.isVideoTexture!==!0,tt=ae.__version===void 0||ne===!0;let vt=b(M,Ze,Qe);$(s.TEXTURE_CUBE_MAP,M,Qe);let qe;if(Ie){ze&&tt&&t.texStorage2D(s.TEXTURE_CUBE_MAP,vt,Se,Ze.width,Ze.height);for(let he=0;he<6;he++){qe=se[he].mipmaps;for(let U=0;U<qe.length;U++){const fe=qe[U];M.format!==1023?Ne!==null?ze?t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,0,0,fe.width,fe.height,Ne,fe.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,Se,fe.width,fe.height,0,fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,0,0,fe.width,fe.height,Ne,Le,fe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,Se,fe.width,fe.height,0,Ne,Le,fe.data)}}}else{qe=M.mipmaps,ze&&tt&&(qe.length>0&&vt++,t.texStorage2D(s.TEXTURE_CUBE_MAP,vt,Se,se[0].width,se[0].height));for(let he=0;he<6;he++)if(ke){ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,0,0,se[he].width,se[he].height,Ne,Le,se[he].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,Se,se[he].width,se[he].height,0,Ne,Le,se[he].data);for(let U=0;U<qe.length;U++){const pe=qe[U].image[he].image;ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,0,0,pe.width,pe.height,Ne,Le,pe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,Se,pe.width,pe.height,0,Ne,Le,pe.data)}}else{ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,0,0,Ne,Le,se[he]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,Se,Ne,Le,se[he]);for(let U=0;U<qe.length;U++){const fe=qe[U];ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,0,0,Ne,Le,fe.image[he]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,Se,Ne,Le,fe.image[he])}}}E(M,Qe)&&_(s.TEXTURE_CUBE_MAP),ae.__version=re.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function me(I,M,X,ne,re,ae){const ye=r.convert(X.format,X.colorSpace),ue=r.convert(X.type),_e=T(X.internalFormat,ye,ue,X.colorSpace);if(!i.get(M).__hasExternalTextures){const ke=Math.max(1,M.width>>ae),se=Math.max(1,M.height>>ae);re===s.TEXTURE_3D||re===s.TEXTURE_2D_ARRAY?t.texImage3D(re,ae,_e,ke,se,M.depth,0,ye,ue,null):t.texImage2D(re,ae,_e,ke,se,0,ye,ue,null)}t.bindFramebuffer(s.FRAMEBUFFER,I),le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ne,re,i.get(X).__webglTexture,0,Ue(M)):(re===s.TEXTURE_2D||re>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,ne,re,i.get(X).__webglTexture,ae),t.bindFramebuffer(s.FRAMEBUFFER,null)}function xe(I,M,X){if(s.bindRenderbuffer(s.RENDERBUFFER,I),M.depthBuffer&&!M.stencilBuffer){let ne=o===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(X||le(M)){const re=M.depthTexture;re&&re.isDepthTexture&&(re.type===1015?ne=s.DEPTH_COMPONENT32F:re.type===1014&&(ne=s.DEPTH_COMPONENT24));const ae=Ue(M);le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ae,ne,M.width,M.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,ae,ne,M.width,M.height)}else s.renderbufferStorage(s.RENDERBUFFER,ne,M.width,M.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,I)}else if(M.depthBuffer&&M.stencilBuffer){const ne=Ue(M);X&&le(M)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,ne,s.DEPTH24_STENCIL8,M.width,M.height):le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ne,s.DEPTH24_STENCIL8,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,M.width,M.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,I)}else{const ne=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let re=0;re<ne.length;re++){const ae=ne[re],ye=r.convert(ae.format,ae.colorSpace),ue=r.convert(ae.type),_e=T(ae.internalFormat,ye,ue,ae.colorSpace),Ie=Ue(M);X&&le(M)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ie,_e,M.width,M.height):le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ie,_e,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,_e,M.width,M.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function be(I,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,I),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),O(M.depthTexture,0);const ne=i.get(M.depthTexture).__webglTexture,re=Ue(M);if(M.depthTexture.format===1026)le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,ne,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,ne,0);else if(M.depthTexture.format===1027)le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,ne,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,ne,0);else throw new Error("Unknown depthTexture format")}function Te(I){const M=i.get(I),X=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!M.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");be(M.__webglFramebuffer,I)}else if(X){M.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[ne]),M.__webglDepthbuffer[ne]=s.createRenderbuffer(),xe(M.__webglDepthbuffer[ne],I,!1)}else t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer=s.createRenderbuffer(),xe(M.__webglDepthbuffer,I,!1);t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ge(I,M,X){const ne=i.get(I);M!==void 0&&me(ne.__webglFramebuffer,I,I.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),X!==void 0&&Te(I)}function Y(I){const M=I.texture,X=i.get(I),ne=i.get(M);I.addEventListener("dispose",C),I.isWebGLMultipleRenderTargets!==!0&&(ne.__webglTexture===void 0&&(ne.__webglTexture=s.createTexture()),ne.__version=M.version,a.memory.textures++);const re=I.isWebGLCubeRenderTarget===!0,ae=I.isWebGLMultipleRenderTargets===!0,ye=m(I)||o;if(re){X.__webglFramebuffer=[];for(let ue=0;ue<6;ue++)if(o&&M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer[ue]=[];for(let _e=0;_e<M.mipmaps.length;_e++)X.__webglFramebuffer[ue][_e]=s.createFramebuffer()}else X.__webglFramebuffer[ue]=s.createFramebuffer()}else{if(o&&M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer=[];for(let ue=0;ue<M.mipmaps.length;ue++)X.__webglFramebuffer[ue]=s.createFramebuffer()}else X.__webglFramebuffer=s.createFramebuffer();if(ae)if(n.drawBuffers){const ue=I.texture;for(let _e=0,Ie=ue.length;_e<Ie;_e++){const ke=i.get(ue[_e]);ke.__webglTexture===void 0&&(ke.__webglTexture=s.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&I.samples>0&&le(I)===!1){const ue=ae?M:[M];X.__webglMultisampledFramebuffer=s.createFramebuffer(),X.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let _e=0;_e<ue.length;_e++){const Ie=ue[_e];X.__webglColorRenderbuffer[_e]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,X.__webglColorRenderbuffer[_e]);const ke=r.convert(Ie.format,Ie.colorSpace),se=r.convert(Ie.type),Ze=T(Ie.internalFormat,ke,se,Ie.colorSpace,I.isXRRenderTarget===!0),Qe=Ue(I);s.renderbufferStorageMultisample(s.RENDERBUFFER,Qe,Ze,I.width,I.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+_e,s.RENDERBUFFER,X.__webglColorRenderbuffer[_e])}s.bindRenderbuffer(s.RENDERBUFFER,null),I.depthBuffer&&(X.__webglDepthRenderbuffer=s.createRenderbuffer(),xe(X.__webglDepthRenderbuffer,I,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(re){t.bindTexture(s.TEXTURE_CUBE_MAP,ne.__webglTexture),$(s.TEXTURE_CUBE_MAP,M,ye);for(let ue=0;ue<6;ue++)if(o&&M.mipmaps&&M.mipmaps.length>0)for(let _e=0;_e<M.mipmaps.length;_e++)me(X.__webglFramebuffer[ue][_e],I,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,_e);else me(X.__webglFramebuffer[ue],I,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0);E(M,ye)&&_(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){const ue=I.texture;for(let _e=0,Ie=ue.length;_e<Ie;_e++){const ke=ue[_e],se=i.get(ke);t.bindTexture(s.TEXTURE_2D,se.__webglTexture),$(s.TEXTURE_2D,ke,ye),me(X.__webglFramebuffer,I,ke,s.COLOR_ATTACHMENT0+_e,s.TEXTURE_2D,0),E(ke,ye)&&_(s.TEXTURE_2D)}t.unbindTexture()}else{let ue=s.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?ue=I.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(ue,ne.__webglTexture),$(ue,M,ye),o&&M.mipmaps&&M.mipmaps.length>0)for(let _e=0;_e<M.mipmaps.length;_e++)me(X.__webglFramebuffer[_e],I,M,s.COLOR_ATTACHMENT0,ue,_e);else me(X.__webglFramebuffer,I,M,s.COLOR_ATTACHMENT0,ue,0);E(M,ye)&&_(ue),t.unbindTexture()}I.depthBuffer&&Te(I)}function Rt(I){const M=m(I)||o,X=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ne=0,re=X.length;ne<re;ne++){const ae=X[ne];if(E(ae,M)){const ye=I.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,ue=i.get(ae).__webglTexture;t.bindTexture(ye,ue),_(ye),t.unbindTexture()}}}function Re(I){if(o&&I.samples>0&&le(I)===!1){const M=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],X=I.width,ne=I.height;let re=s.COLOR_BUFFER_BIT;const ae=[],ye=I.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ue=i.get(I),_e=I.isWebGLMultipleRenderTargets===!0;if(_e)for(let Ie=0;Ie<M.length;Ie++)t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){ae.push(s.COLOR_ATTACHMENT0+Ie),I.depthBuffer&&ae.push(ye);const ke=ue.__ignoreDepthValues!==void 0?ue.__ignoreDepthValues:!1;if(ke===!1&&(I.depthBuffer&&(re|=s.DEPTH_BUFFER_BIT),I.stencilBuffer&&(re|=s.STENCIL_BUFFER_BIT)),_e&&s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ue.__webglColorRenderbuffer[Ie]),ke===!0&&(s.invalidateFramebuffer(s.READ_FRAMEBUFFER,[ye]),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[ye])),_e){const se=i.get(M[Ie]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,se,0)}s.blitFramebuffer(0,0,X,ne,0,0,X,ne,re,s.NEAREST),c&&s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ae)}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),_e)for(let Ie=0;Ie<M.length;Ie++){t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.RENDERBUFFER,ue.__webglColorRenderbuffer[Ie]);const ke=i.get(M[Ie]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.TEXTURE_2D,ke,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}}function Ue(I){return Math.min(n.maxSamples,I.samples)}function le(I){const M=i.get(I);return o&&I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function $e(I){const M=a.render.frame;h.get(I)!==M&&(h.set(I,M),I.update())}function Me(I,M){const X=I.colorSpace,ne=I.format,re=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===1035||X!==Ci&&X!==ri&&(nt.getTransfer(X)===ut?o===!1?e.has("EXT_sRGB")===!0&&ne===1023?(I.format=1035,I.minFilter=1006,I.generateMipmaps=!1):M=Zo.sRGBToLinear(M):(ne!==1023||re!==1009)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),M}this.allocateTextureUnit=w,this.resetTextureUnits=H,this.setTexture2D=O,this.setTexture2DArray=z,this.setTexture3D=N,this.setTextureCube=k,this.rebindTextures=Ge,this.setupRenderTarget=Y,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Re,this.setupDepthRenderbuffer=Te,this.setupFrameBufferTexture=me,this.useMultisampledRTT=le}function Kg(s,e,t){const i=t.isWebGL2;function n(r,a=ri){let o;const l=nt.getTransfer(a);if(r===1009)return s.UNSIGNED_BYTE;if(r===1017)return s.UNSIGNED_SHORT_4_4_4_4;if(r===1018)return s.UNSIGNED_SHORT_5_5_5_1;if(r===1010)return s.BYTE;if(r===1011)return s.SHORT;if(r===1012)return s.UNSIGNED_SHORT;if(r===1013)return s.INT;if(r===1014)return s.UNSIGNED_INT;if(r===1015)return s.FLOAT;if(r===1016)return i?s.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===1021)return s.ALPHA;if(r===1023)return s.RGBA;if(r===1024)return s.LUMINANCE;if(r===1025)return s.LUMINANCE_ALPHA;if(r===1026)return s.DEPTH_COMPONENT;if(r===1027)return s.DEPTH_STENCIL;if(r===1035)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===1028)return s.RED;if(r===1029)return s.RED_INTEGER;if(r===1030)return s.RG;if(r===1031)return s.RG_INTEGER;if(r===1033)return s.RGBA_INTEGER;if(r===33776||r===33777||r===33778||r===33779)if(l===ut)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===33776)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===33777)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===33778)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===33779)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===33776)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===33777)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===33778)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===33779)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===35840||r===35841||r===35842||r===35843)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===35840)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===35841)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===35842)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===35843)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===36196)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===37492||r===37496)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(r===37492)return l===ut?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===37496)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===37808||r===37809||r===37810||r===37811||r===37812||r===37813||r===37814||r===37815||r===37816||r===37817||r===37818||r===37819||r===37820||r===37821)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(r===37808)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===37809)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===37810)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===37811)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===37812)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===37813)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===37814)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===37815)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===37816)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===37817)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===37818)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===37819)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===37820)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===37821)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===36492||r===36494||r===36495)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(r===36492)return l===ut?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===36494)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===36495)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===36283||r===36284||r===36285||r===36286)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(r===36492)return o.COMPRESSED_RED_RGTC1_EXT;if(r===36284)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===36285)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===36286)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===1020?i?s.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):s[r]!==void 0?s[r]:null}return{convert:n}}class Xg extends oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class sr extends Jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yg={type:"move"};class Ra{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Q),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(c,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,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,this.dispatchEvent(Yg)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new sr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class qg extends Sn{constructor(e,t){super();const i=this;let n=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,p=null;const v=t.getContextAttributes();let m=null,g=null;const E=[],_=[],T=new it;let b=null;const R=new oi;R.layers.enable(1),R.viewport=new Ft;const A=new oi;A.layers.enable(2),A.viewport=new Ft;const C=[R,A],x=new Xg;x.layers.enable(1),x.layers.enable(2);let y=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getGripSpace()},this.getHand=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getHandSpace()};function P($){const ee=_.indexOf($.inputSource);if(ee===-1)return;const ie=E[ee];ie!==void 0&&(ie.update($.inputSource,$.frame,c||a),ie.dispatchEvent({type:$.type,data:$.inputSource}))}function H(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",H),n.removeEventListener("inputsourceschange",w);for(let $=0;$<E.length;$++){const ee=_[$];ee!==null&&(_[$]=null,E[$].disconnect(ee))}y=null,D=null,e.setRenderTarget(m),f=null,d=null,u=null,n=null,g=null,K.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function($){if(n=$,n!==null){if(m=e.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",H),n.addEventListener("inputsourceschange",w),v.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(T),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ee={antialias:n.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(n,t,ee),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),g=new nn(f.framebufferWidth,f.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ee=null,ie=null,oe=null;v.depth&&(oe=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ee=v.stencil?1027:1026,ie=v.stencil?1020:1014);const me={colorFormat:t.RGBA8,depthFormat:oe,scaleFactor:r};u=new XRWebGLBinding(n,t),d=u.createProjectionLayer(me),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new nn(d.textureWidth,d.textureHeight,{format:1023,type:1009,depthTexture:new Cl(d.textureWidth,d.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const xe=e.properties.get(g);xe.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),K.setContext(n),K.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function w($){for(let ee=0;ee<$.removed.length;ee++){const ie=$.removed[ee],oe=_.indexOf(ie);oe>=0&&(_[oe]=null,E[oe].disconnect(ie))}for(let ee=0;ee<$.added.length;ee++){const ie=$.added[ee];let oe=_.indexOf(ie);if(oe===-1){for(let xe=0;xe<E.length;xe++)if(xe>=_.length){_.push(ie),oe=xe;break}else if(_[xe]===null){_[xe]=ie,oe=xe;break}if(oe===-1)break}const me=E[oe];me&&me.connect(ie)}}const F=new Q,O=new Q;function z($,ee,ie){F.setFromMatrixPosition(ee.matrixWorld),O.setFromMatrixPosition(ie.matrixWorld);const oe=F.distanceTo(O),me=ee.projectionMatrix.elements,xe=ie.projectionMatrix.elements,be=me[14]/(me[10]-1),Te=me[14]/(me[10]+1),Ge=(me[9]+1)/me[5],Y=(me[9]-1)/me[5],Rt=(me[8]-1)/me[0],Re=(xe[8]+1)/xe[0],Ue=be*Rt,le=be*Re,$e=oe/(-Rt+Re),Me=$e*-Rt;ee.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Me),$.translateZ($e),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert();const I=be+$e,M=Te+$e,X=Ue-Me,ne=le+(oe-Me),re=Ge*Te/M*I,ae=Y*Te/M*I;$.projectionMatrix.makePerspective(X,ne,re,ae,I,M),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}function N($,ee){ee===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ee.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(n===null)return;x.near=A.near=R.near=$.near,x.far=A.far=R.far=$.far,(y!==x.near||D!==x.far)&&(n.updateRenderState({depthNear:x.near,depthFar:x.far}),y=x.near,D=x.far);const ee=$.parent,ie=x.cameras;N(x,ee);for(let oe=0;oe<ie.length;oe++)N(ie[oe],ee);ie.length===2?z(x,R,A):x.projectionMatrix.copy(R.projectionMatrix),k($,x,ee)};function k($,ee,ie){ie===null?$.matrix.copy(ee.matrixWorld):($.matrix.copy(ie.matrixWorld),$.matrix.invert(),$.matrix.multiply(ee.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ee.projectionMatrix),$.projectionMatrixInverse.copy(ee.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Zr*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return x},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function($){l=$,d!==null&&(d.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)};let q=null;function G($,ee){if(h=ee.getViewerPose(c||a),p=ee,h!==null){const ie=h.views;f!==null&&(e.setRenderTargetFramebuffer(g,f.framebuffer),e.setRenderTarget(g));let oe=!1;ie.length!==x.cameras.length&&(x.cameras.length=0,oe=!0);for(let me=0;me<ie.length;me++){const xe=ie[me];let be=null;if(f!==null)be=f.getViewport(xe);else{const Ge=u.getViewSubImage(d,xe);be=Ge.viewport,me===0&&(e.setRenderTargetTextures(g,Ge.colorTexture,d.ignoreDepthValues?void 0:Ge.depthStencilTexture),e.setRenderTarget(g))}let Te=C[me];Te===void 0&&(Te=new oi,Te.layers.enable(me),Te.viewport=new Ft,C[me]=Te),Te.matrix.fromArray(xe.transform.matrix),Te.matrix.decompose(Te.position,Te.quaternion,Te.scale),Te.projectionMatrix.fromArray(xe.projectionMatrix),Te.projectionMatrixInverse.copy(Te.projectionMatrix).invert(),Te.viewport.set(be.x,be.y,be.width,be.height),me===0&&(x.matrix.copy(Te.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale)),oe===!0&&x.cameras.push(Te)}}for(let ie=0;ie<E.length;ie++){const oe=_[ie],me=E[ie];oe!==null&&me!==void 0&&me.update(oe,ee,c||a)}q&&q($,ee),ee.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ee}),p=null}const K=new yl;K.setAnimationLoop(G),this.setAnimationLoop=function($){q=$},this.dispose=function(){}}}function jg(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,_l(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,E,_,T){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,T)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?l(m,g,E,_):g.isSpriteMaterial?c(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===1&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===1&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const E=e.get(g).envMap;if(E&&(m.envMap.value=E,m.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const _=s._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*_,t(g.lightMap,m.lightMapTransform)}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,E,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*E,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,E){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===1&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=E.texture,m.transmissionSamplerSize.value.set(E.width,E.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const E=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function Qg(s,e,t,i){let n={},r={},a=[];const o=t.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(E,_){const T=_.program;i.uniformBlockBinding(E,T)}function c(E,_){let T=n[E.id];T===void 0&&(p(E),T=h(E),n[E.id]=T,E.addEventListener("dispose",m));const b=_.program;i.updateUBOMapping(E,b);const R=e.render.frame;r[E.id]!==R&&(d(E),r[E.id]=R)}function h(E){const _=u();E.__bindingPointIndex=_;const T=s.createBuffer(),b=E.__size,R=E.usage;return s.bindBuffer(s.UNIFORM_BUFFER,T),s.bufferData(s.UNIFORM_BUFFER,b,R),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,T),T}function u(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(E){const _=n[E.id],T=E.uniforms,b=E.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let R=0,A=T.length;R<A;R++){const C=Array.isArray(T[R])?T[R]:[T[R]];for(let x=0,y=C.length;x<y;x++){const D=C[x];if(f(D,R,x,b)===!0){const P=D.__offset,H=Array.isArray(D.value)?D.value:[D.value];let w=0;for(let F=0;F<H.length;F++){const O=H[F],z=v(O);typeof O=="number"||typeof O=="boolean"?(D.__data[0]=O,s.bufferSubData(s.UNIFORM_BUFFER,P+w,D.__data)):O.isMatrix3?(D.__data[0]=O.elements[0],D.__data[1]=O.elements[1],D.__data[2]=O.elements[2],D.__data[3]=0,D.__data[4]=O.elements[3],D.__data[5]=O.elements[4],D.__data[6]=O.elements[5],D.__data[7]=0,D.__data[8]=O.elements[6],D.__data[9]=O.elements[7],D.__data[10]=O.elements[8],D.__data[11]=0):(O.toArray(D.__data,w),w+=z.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,P,D.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(E,_,T,b){const R=E.value,A=_+"_"+T;if(b[A]===void 0)return typeof R=="number"||typeof R=="boolean"?b[A]=R:b[A]=R.clone(),!0;{const C=b[A];if(typeof R=="number"||typeof R=="boolean"){if(C!==R)return b[A]=R,!0}else if(C.equals(R)===!1)return C.copy(R),!0}return!1}function p(E){const _=E.uniforms;let T=0;const b=16;for(let A=0,C=_.length;A<C;A++){const x=Array.isArray(_[A])?_[A]:[_[A]];for(let y=0,D=x.length;y<D;y++){const P=x[y],H=Array.isArray(P.value)?P.value:[P.value];for(let w=0,F=H.length;w<F;w++){const O=H[w],z=v(O),N=T%b;N!==0&&b-N<z.boundary&&(T+=b-N),P.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=T,T+=z.storage}}}const R=T%b;return R>0&&(T+=b-R),E.__size=T,E.__cache={},this}function v(E){const _={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(_.boundary=4,_.storage=4):E.isVector2?(_.boundary=8,_.storage=8):E.isVector3||E.isColor?(_.boundary=16,_.storage=12):E.isVector4?(_.boundary=16,_.storage=16):E.isMatrix3?(_.boundary=48,_.storage=48):E.isMatrix4?(_.boundary=64,_.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),_}function m(E){const _=E.target;_.removeEventListener("dispose",m);const T=a.indexOf(_.__bindingPointIndex);a.splice(T,1),s.deleteBuffer(n[_.id]),delete n[_.id],delete r[_.id]}function g(){for(const E in n)s.deleteBuffer(n[E]);a=[],n={},r={}}return{bind:l,update:c,dispose:g}}class Ql{constructor(e={}){const{canvas:t=Ad(),context:i=null,depth:n=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;i!==null?d=i.getContextAttributes().alpha:d=a;const f=new Uint32Array(4),p=new Int32Array(4);let v=null,m=null;const g=[],E=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Mt,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let T=!1,b=0,R=0,A=null,C=-1,x=null;const y=new Ft,D=new Ft;let P=null;const H=new st(0);let w=0,F=t.width,O=t.height,z=1,N=null,k=null;const q=new Ft(0,0,F,O),G=new Ft(0,0,F,O);let K=!1;const $=new xl;let ee=!1,ie=!1,oe=null;const me=new Ot,xe=new it,be=new Q,Te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ge(){return A===null?z:1}let Y=i;function Rt(L,W){for(let Z=0;Z<L.length;Z++){const J=L[Z],j=t.getContext(J,W);if(j!==null)return j}return null}try{const L={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${qr}`),t.addEventListener("webglcontextlost",he,!1),t.addEventListener("webglcontextrestored",U,!1),t.addEventListener("webglcontextcreationerror",fe,!1),Y===null){const W=["webgl2","webgl","experimental-webgl"];if(_.isWebGL1Renderer===!0&&W.shift(),Y=Rt(W,L),Y===null)throw Rt(W)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&Y instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),Y.getShaderPrecisionFormat===void 0&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Re,Ue,le,$e,Me,I,M,X,ne,re,ae,ye,ue,_e,Ie,ke,se,Ze,Qe,Ne,Le,Se,ze,tt;function vt(){Re=new om(Y),Ue=new em(Y,Re,e),Re.init(Ue),Se=new Kg(Y,Re,Ue),le=new zg(Y,Re,Ue),$e=new hm(Y),Me=new Cg,I=new Wg(Y,Re,le,Me,Ue,Se,$e),M=new im(_),X=new am(_),ne=new jd(Y,Ue),ze=new Zp(Y,Re,ne,Ue),re=new lm(Y,ne,$e,ze),ae=new pm(Y,re,ne,$e),Qe=new fm(Y,Ue,I),ke=new tm(Me),ye=new Ig(_,M,X,Re,Ue,ze,ke),ue=new jg(_,Me),_e=new wg,Ie=new kg(Re,Ue),Ze=new Qp(_,M,X,le,ae,d,l),se=new $g(_,ae,Ue),tt=new Qg(Y,$e,Ue,le),Ne=new Jp(Y,Re,$e,Ue),Le=new cm(Y,Re,$e,Ue),$e.programs=ye.programs,_.capabilities=Ue,_.extensions=Re,_.properties=Me,_.renderLists=_e,_.shadowMap=se,_.state=le,_.info=$e}vt();const qe=new qg(_,Y);this.xr=qe,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const L=Re.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){const L=Re.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(L){L!==void 0&&(z=L,this.setSize(F,O,!1))},this.getSize=function(L){return L.set(F,O)},this.setSize=function(L,W,Z=!0){if(qe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}F=L,O=W,t.width=Math.floor(L*z),t.height=Math.floor(W*z),Z===!0&&(t.style.width=L+"px",t.style.height=W+"px"),this.setViewport(0,0,L,W)},this.getDrawingBufferSize=function(L){return L.set(F*z,O*z).floor()},this.setDrawingBufferSize=function(L,W,Z){F=L,O=W,z=Z,t.width=Math.floor(L*Z),t.height=Math.floor(W*Z),this.setViewport(0,0,L,W)},this.getCurrentViewport=function(L){return L.copy(y)},this.getViewport=function(L){return L.copy(q)},this.setViewport=function(L,W,Z,J){L.isVector4?q.set(L.x,L.y,L.z,L.w):q.set(L,W,Z,J),le.viewport(y.copy(q).multiplyScalar(z).floor())},this.getScissor=function(L){return L.copy(G)},this.setScissor=function(L,W,Z,J){L.isVector4?G.set(L.x,L.y,L.z,L.w):G.set(L,W,Z,J),le.scissor(D.copy(G).multiplyScalar(z).floor())},this.getScissorTest=function(){return K},this.setScissorTest=function(L){le.setScissorTest(K=L)},this.setOpaqueSort=function(L){N=L},this.setTransparentSort=function(L){k=L},this.getClearColor=function(L){return L.copy(Ze.getClearColor())},this.setClearColor=function(){Ze.setClearColor.apply(Ze,arguments)},this.getClearAlpha=function(){return Ze.getClearAlpha()},this.setClearAlpha=function(){Ze.setClearAlpha.apply(Ze,arguments)},this.clear=function(L=!0,W=!0,Z=!0){let J=0;if(L){let j=!1;if(A!==null){const ve=A.texture.format;j=ve===1033||ve===1031||ve===1029}if(j){const ve=A.texture.type,Ae=ve===1009||ve===1014||ve===1012||ve===1020||ve===1017||ve===1018,De=Ze.getClearColor(),Oe=Ze.getClearAlpha(),Ke=De.r,Be=De.g,Ve=De.b;Ae?(f[0]=Ke,f[1]=Be,f[2]=Ve,f[3]=Oe,Y.clearBufferuiv(Y.COLOR,0,f)):(p[0]=Ke,p[1]=Be,p[2]=Ve,p[3]=Oe,Y.clearBufferiv(Y.COLOR,0,p))}else J|=Y.COLOR_BUFFER_BIT}W&&(J|=Y.DEPTH_BUFFER_BIT),Z&&(J|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",he,!1),t.removeEventListener("webglcontextrestored",U,!1),t.removeEventListener("webglcontextcreationerror",fe,!1),_e.dispose(),Ie.dispose(),Me.dispose(),M.dispose(),X.dispose(),ae.dispose(),ze.dispose(),tt.dispose(),ye.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",$t),qe.removeEventListener("sessionend",ht),oe&&(oe.dispose(),oe=null),zt.stop()};function he(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function U(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const L=$e.autoReset,W=se.enabled,Z=se.autoUpdate,J=se.needsUpdate,j=se.type;vt(),$e.autoReset=L,se.enabled=W,se.autoUpdate=Z,se.needsUpdate=J,se.type=j}function fe(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function pe(L){const W=L.target;W.removeEventListener("dispose",pe),Pe(W)}function Pe(L){Ce(L),Me.remove(L)}function Ce(L){const W=Me.get(L).programs;W!==void 0&&(W.forEach(function(Z){ye.releaseProgram(Z)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,W,Z,J,j,ve){W===null&&(W=Te);const Ae=j.isMesh&&j.matrixWorld.determinant()<0,De=zS(L,W,Z,J,j);le.setMaterial(J,Ae);let Oe=Z.index,Ke=1;if(J.wireframe===!0){if(Oe=re.getWireframeAttribute(Z),Oe===void 0)return;Ke=2}const Be=Z.drawRange,Ve=Z.attributes.position;let St=Be.start*Ke,si=(Be.start+Be.count)*Ke;ve!==null&&(St=Math.max(St,ve.start*Ke),si=Math.min(si,(ve.start+ve.count)*Ke)),Oe!==null?(St=Math.max(St,0),si=Math.min(si,Oe.count)):Ve!=null&&(St=Math.max(St,0),si=Math.min(si,Ve.count));const Pt=si-St;if(Pt<0||Pt===1/0)return;ze.setup(j,J,De,Z,Oe);let zi,mt=Ne;if(Oe!==null&&(zi=ne.get(Oe),mt=Le,mt.setIndex(zi)),j.isMesh)J.wireframe===!0?(le.setLineWidth(J.wireframeLinewidth*Ge()),mt.setMode(Y.LINES)):mt.setMode(Y.TRIANGLES);else if(j.isLine){let je=J.linewidth;je===void 0&&(je=1),le.setLineWidth(je*Ge()),j.isLineSegments?mt.setMode(Y.LINES):j.isLineLoop?mt.setMode(Y.LINE_LOOP):mt.setMode(Y.LINE_STRIP)}else j.isPoints?mt.setMode(Y.POINTS):j.isSprite&&mt.setMode(Y.TRIANGLES);if(j.isBatchedMesh)mt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)mt.renderInstances(St,Pt,j.count);else if(Z.isInstancedBufferGeometry){const je=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Ho=Math.min(Z.instanceCount,je);mt.renderInstances(St,Pt,Ho)}else mt.render(St,Pt)};function lt(L,W,Z){L.transparent===!0&&L.side===2&&L.forceSinglePass===!1?(L.side=1,L.needsUpdate=!0,Yr(L,W,Z),L.side=0,L.needsUpdate=!0,Yr(L,W,Z),L.side=2):Yr(L,W,Z)}this.compile=function(L,W,Z=null){Z===null&&(Z=L),m=Ie.get(Z),m.init(),E.push(m),Z.traverseVisible(function(j){j.isLight&&j.layers.test(W.layers)&&(m.pushLight(j),j.castShadow&&m.pushShadow(j))}),L!==Z&&L.traverseVisible(function(j){j.isLight&&j.layers.test(W.layers)&&(m.pushLight(j),j.castShadow&&m.pushShadow(j))}),m.setupLights(_._useLegacyLights);const J=new Set;return L.traverse(function(j){const ve=j.material;if(ve)if(Array.isArray(ve))for(let Ae=0;Ae<ve.length;Ae++){const De=ve[Ae];lt(De,Z,j),J.add(De)}else lt(ve,Z,j),J.add(ve)}),E.pop(),m=null,J},this.compileAsync=function(L,W,Z=null){const J=this.compile(L,W,Z);return new Promise(j=>{function ve(){if(J.forEach(function(Ae){Me.get(Ae).currentProgram.isReady()&&J.delete(Ae)}),J.size===0){j(L);return}setTimeout(ve,10)}Re.get("KHR_parallel_shader_compile")!==null?ve():setTimeout(ve,10)})};let ct=null;function wt(L){ct&&ct(L)}function $t(){zt.stop()}function ht(){zt.start()}const zt=new yl;zt.setAnimationLoop(wt),typeof self<"u"&&zt.setContext(self),this.setAnimationLoop=function(L){ct=L,qe.setAnimationLoop(L),L===null?zt.stop():zt.start()},qe.addEventListener("sessionstart",$t),qe.addEventListener("sessionend",ht),this.render=function(L,W){if(W!==void 0&&W.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(W),W=qe.getCamera()),L.isScene===!0&&L.onBeforeRender(_,L,W,A),m=Ie.get(L,E.length),m.init(),E.push(m),me.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),$.setFromProjectionMatrix(me),ie=this.localClippingEnabled,ee=ke.init(this.clippingPlanes,ie),v=_e.get(L,g.length),v.init(),g.push(v),Ii(L,W,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(N,k),this.info.render.frame++,ee===!0&&ke.beginShadows();const Z=m.state.shadowsArray;if(se.render(Z,L,W),ee===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ze.render(v,L),m.setupLights(_._useLegacyLights),W.isArrayCamera){const J=W.cameras;for(let j=0,ve=J.length;j<ve;j++){const Ae=J[j];vd(v,L,Ae,Ae.viewport)}}else vd(v,L,W);A!==null&&(I.updateMultisampleRenderTarget(A),I.updateRenderTargetMipmap(A)),L.isScene===!0&&L.onAfterRender(_,L,W),ze.resetDefaultState(),C=-1,x=null,E.pop(),E.length>0?m=E[E.length-1]:m=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Ii(L,W,Z,J){if(L.visible===!1)return;if(L.layers.test(W.layers)){if(L.isGroup)Z=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(W);else if(L.isLight)m.pushLight(L),L.castShadow&&m.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||$.intersectsSprite(L)){J&&be.setFromMatrixPosition(L.matrixWorld).applyMatrix4(me);const Ae=ae.update(L),De=L.material;De.visible&&v.push(L,Ae,De,Z,be.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||$.intersectsObject(L))){const Ae=ae.update(L),De=L.material;if(J&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),be.copy(L.boundingSphere.center)):(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),be.copy(Ae.boundingSphere.center)),be.applyMatrix4(L.matrixWorld).applyMatrix4(me)),Array.isArray(De)){const Oe=Ae.groups;for(let Ke=0,Be=Oe.length;Ke<Be;Ke++){const Ve=Oe[Ke],St=De[Ve.materialIndex];St&&St.visible&&v.push(L,Ae,St,Z,be.z,Ve)}}else De.visible&&v.push(L,Ae,De,Z,be.z,null)}}const ve=L.children;for(let Ae=0,De=ve.length;Ae<De;Ae++)Ii(ve[Ae],W,Z,J)}function vd(L,W,Z,J){const j=L.opaque,ve=L.transmissive,Ae=L.transparent;m.setupLightsView(Z),ee===!0&&ke.setGlobalState(_.clippingPlanes,Z),ve.length>0&&$S(j,ve,W,Z),J&&le.viewport(y.copy(J)),j.length>0&&Xr(j,W,Z),ve.length>0&&Xr(ve,W,Z),Ae.length>0&&Xr(Ae,W,Z),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function $S(L,W,Z,J){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;const ve=Ue.isWebGL2;oe===null&&(oe=new nn(1,1,{generateMipmaps:!0,type:Re.has("EXT_color_buffer_half_float")?1016:1009,minFilter:1008,samples:ve?4:0})),_.getDrawingBufferSize(xe),ve?oe.setSize(xe.x,xe.y):oe.setSize(ea(xe.x),ea(xe.y));const Ae=_.getRenderTarget();_.setRenderTarget(oe),_.getClearColor(H),w=_.getClearAlpha(),w<1&&_.setClearColor(16777215,.5),_.clear();const De=_.toneMapping;_.toneMapping=0,Xr(L,Z,J),I.updateMultisampleRenderTarget(oe),I.updateRenderTargetMipmap(oe);let Oe=!1;for(let Ke=0,Be=W.length;Ke<Be;Ke++){const Ve=W[Ke],St=Ve.object,si=Ve.geometry,Pt=Ve.material,zi=Ve.group;if(Pt.side===2&&St.layers.test(J.layers)){const mt=Pt.side;Pt.side=1,Pt.needsUpdate=!0,_d(St,Z,J,si,Pt,zi),Pt.side=mt,Pt.needsUpdate=!0,Oe=!0}}Oe===!0&&(I.updateMultisampleRenderTarget(oe),I.updateRenderTargetMipmap(oe)),_.setRenderTarget(Ae),_.setClearColor(H,w),_.toneMapping=De}function Xr(L,W,Z){const J=W.isScene===!0?W.overrideMaterial:null;for(let j=0,ve=L.length;j<ve;j++){const Ae=L[j],De=Ae.object,Oe=Ae.geometry,Ke=J===null?Ae.material:J,Be=Ae.group;De.layers.test(Z.layers)&&_d(De,W,Z,Oe,Ke,Be)}}function _d(L,W,Z,J,j,ve){L.onBeforeRender(_,W,Z,J,j,ve),L.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),j.onBeforeRender(_,W,Z,J,L,ve),j.transparent===!0&&j.side===2&&j.forceSinglePass===!1?(j.side=1,j.needsUpdate=!0,_.renderBufferDirect(Z,W,J,j,L,ve),j.side=0,j.needsUpdate=!0,_.renderBufferDirect(Z,W,J,j,L,ve),j.side=2):_.renderBufferDirect(Z,W,J,j,L,ve),L.onAfterRender(_,W,Z,J,j,ve)}function Yr(L,W,Z){W.isScene!==!0&&(W=Te);const J=Me.get(L),j=m.state.lights,ve=m.state.shadowsArray,Ae=j.state.version,De=ye.getParameters(L,j.state,ve,W,Z),Oe=ye.getProgramCacheKey(De);let Ke=J.programs;J.environment=L.isMeshStandardMaterial?W.environment:null,J.fog=W.fog,J.envMap=(L.isMeshStandardMaterial?X:M).get(L.envMap||J.environment),Ke===void 0&&(L.addEventListener("dispose",pe),Ke=new Map,J.programs=Ke);let Be=Ke.get(Oe);if(Be!==void 0){if(J.currentProgram===Be&&J.lightsStateVersion===Ae)return Sd(L,De),Be}else De.uniforms=ye.getUniforms(L),L.onBuild(Z,De,_),L.onBeforeCompile(De,_),Be=ye.acquireProgram(De,Oe),Ke.set(Oe,Be),J.uniforms=De.uniforms;const Ve=J.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Ve.clippingPlanes=ke.uniform),Sd(L,De),J.needsLights=KS(L),J.lightsStateVersion=Ae,J.needsLights&&(Ve.ambientLightColor.value=j.state.ambient,Ve.lightProbe.value=j.state.probe,Ve.directionalLights.value=j.state.directional,Ve.directionalLightShadows.value=j.state.directionalShadow,Ve.spotLights.value=j.state.spot,Ve.spotLightShadows.value=j.state.spotShadow,Ve.rectAreaLights.value=j.state.rectArea,Ve.ltc_1.value=j.state.rectAreaLTC1,Ve.ltc_2.value=j.state.rectAreaLTC2,Ve.pointLights.value=j.state.point,Ve.pointLightShadows.value=j.state.pointShadow,Ve.hemisphereLights.value=j.state.hemi,Ve.directionalShadowMap.value=j.state.directionalShadowMap,Ve.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Ve.spotShadowMap.value=j.state.spotShadowMap,Ve.spotLightMatrix.value=j.state.spotLightMatrix,Ve.spotLightMap.value=j.state.spotLightMap,Ve.pointShadowMap.value=j.state.pointShadowMap,Ve.pointShadowMatrix.value=j.state.pointShadowMatrix),J.currentProgram=Be,J.uniformsList=null,Be}function Ed(L){if(L.uniformsList===null){const W=L.currentProgram.getUniforms();L.uniformsList=nr.seqWithValue(W.seq,L.uniforms)}return L.uniformsList}function Sd(L,W){const Z=Me.get(L);Z.outputColorSpace=W.outputColorSpace,Z.batching=W.batching,Z.instancing=W.instancing,Z.instancingColor=W.instancingColor,Z.skinning=W.skinning,Z.morphTargets=W.morphTargets,Z.morphNormals=W.morphNormals,Z.morphColors=W.morphColors,Z.morphTargetsCount=W.morphTargetsCount,Z.numClippingPlanes=W.numClippingPlanes,Z.numIntersection=W.numClipIntersection,Z.vertexAlphas=W.vertexAlphas,Z.vertexTangents=W.vertexTangents,Z.toneMapping=W.toneMapping}function zS(L,W,Z,J,j){W.isScene!==!0&&(W=Te),I.resetTextureUnits();const ve=W.fog,Ae=J.isMeshStandardMaterial?W.environment:null,De=A===null?_.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Ci,Oe=(J.isMeshStandardMaterial?X:M).get(J.envMap||Ae),Ke=J.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,Be=!!Z.attributes.tangent&&(!!J.normalMap||J.anisotropy>0),Ve=!!Z.morphAttributes.position,St=!!Z.morphAttributes.normal,si=!!Z.morphAttributes.color;let Pt=0;J.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Pt=_.toneMapping);const zi=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,mt=zi!==void 0?zi.length:0,je=Me.get(J),Ho=m.state.lights;if(ee===!0&&(ie===!0||L!==x)){const hi=L===x&&J.id===C;ke.setState(J,L,hi)}let _t=!1;J.version===je.__version?(je.needsLights&&je.lightsStateVersion!==Ho.state.version||je.outputColorSpace!==De||j.isBatchedMesh&&je.batching===!1||!j.isBatchedMesh&&je.batching===!0||j.isInstancedMesh&&je.instancing===!1||!j.isInstancedMesh&&je.instancing===!0||j.isSkinnedMesh&&je.skinning===!1||!j.isSkinnedMesh&&je.skinning===!0||j.isInstancedMesh&&je.instancingColor===!0&&j.instanceColor===null||j.isInstancedMesh&&je.instancingColor===!1&&j.instanceColor!==null||je.envMap!==Oe||J.fog===!0&&je.fog!==ve||je.numClippingPlanes!==void 0&&(je.numClippingPlanes!==ke.numPlanes||je.numIntersection!==ke.numIntersection)||je.vertexAlphas!==Ke||je.vertexTangents!==Be||je.morphTargets!==Ve||je.morphNormals!==St||je.morphColors!==si||je.toneMapping!==Pt||Ue.isWebGL2===!0&&je.morphTargetsCount!==mt)&&(_t=!0):(_t=!0,je.__version=J.version);let _n=je.currentProgram;_t===!0&&(_n=Yr(J,W,j));let xd=!1,bs=!1,$o=!1;const Bt=_n.getUniforms(),En=je.uniforms;if(le.useProgram(_n.program)&&(xd=!0,bs=!0,$o=!0),J.id!==C&&(C=J.id,bs=!0),xd||x!==L){Bt.setValue(Y,"projectionMatrix",L.projectionMatrix),Bt.setValue(Y,"viewMatrix",L.matrixWorldInverse);const hi=Bt.map.cameraPosition;hi!==void 0&&hi.setValue(Y,be.setFromMatrixPosition(L.matrixWorld)),Ue.logarithmicDepthBuffer&&Bt.setValue(Y,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Bt.setValue(Y,"isOrthographic",L.isOrthographicCamera===!0),x!==L&&(x=L,bs=!0,$o=!0)}if(j.isSkinnedMesh){Bt.setOptional(Y,j,"bindMatrix"),Bt.setOptional(Y,j,"bindMatrixInverse");const hi=j.skeleton;hi&&(Ue.floatVertexTextures?(hi.boneTexture===null&&hi.computeBoneTexture(),Bt.setValue(Y,"boneTexture",hi.boneTexture,I)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}j.isBatchedMesh&&(Bt.setOptional(Y,j,"batchingTexture"),Bt.setValue(Y,"batchingTexture",j._matricesTexture,I));const zo=Z.morphAttributes;if((zo.position!==void 0||zo.normal!==void 0||zo.color!==void 0&&Ue.isWebGL2===!0)&&Qe.update(j,Z,_n),(bs||je.receiveShadow!==j.receiveShadow)&&(je.receiveShadow=j.receiveShadow,Bt.setValue(Y,"receiveShadow",j.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(En.envMap.value=Oe,En.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),bs&&(Bt.setValue(Y,"toneMappingExposure",_.toneMappingExposure),je.needsLights&&WS(En,$o),ve&&J.fog===!0&&ue.refreshFogUniforms(En,ve),ue.refreshMaterialUniforms(En,J,z,O,oe),nr.upload(Y,Ed(je),En,I)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(nr.upload(Y,Ed(je),En,I),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Bt.setValue(Y,"center",j.center),Bt.setValue(Y,"modelViewMatrix",j.modelViewMatrix),Bt.setValue(Y,"normalMatrix",j.normalMatrix),Bt.setValue(Y,"modelMatrix",j.matrixWorld),J.isShaderMaterial||J.isRawShaderMaterial){const hi=J.uniformsGroups;for(let Wo=0,XS=hi.length;Wo<XS;Wo++)if(Ue.isWebGL2){const yd=hi[Wo];tt.update(yd,_n),tt.bind(yd,_n)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return _n}function WS(L,W){L.ambientLightColor.needsUpdate=W,L.lightProbe.needsUpdate=W,L.directionalLights.needsUpdate=W,L.directionalLightShadows.needsUpdate=W,L.pointLights.needsUpdate=W,L.pointLightShadows.needsUpdate=W,L.spotLights.needsUpdate=W,L.spotLightShadows.needsUpdate=W,L.rectAreaLights.needsUpdate=W,L.hemisphereLights.needsUpdate=W}function KS(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(L,W,Z){Me.get(L.texture).__webglTexture=W,Me.get(L.depthTexture).__webglTexture=Z;const J=Me.get(L);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=Z===void 0,J.__autoAllocateDepthBuffer||Re.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,W){const Z=Me.get(L);Z.__webglFramebuffer=W,Z.__useDefaultFramebuffer=W===void 0},this.setRenderTarget=function(L,W=0,Z=0){A=L,b=W,R=Z;let J=!0,j=null,ve=!1,Ae=!1;if(L){const Oe=Me.get(L);Oe.__useDefaultFramebuffer!==void 0?(le.bindFramebuffer(Y.FRAMEBUFFER,null),J=!1):Oe.__webglFramebuffer===void 0?I.setupRenderTarget(L):Oe.__hasExternalTextures&&I.rebindTextures(L,Me.get(L.texture).__webglTexture,Me.get(L.depthTexture).__webglTexture);const Ke=L.texture;(Ke.isData3DTexture||Ke.isDataArrayTexture||Ke.isCompressedArrayTexture)&&(Ae=!0);const Be=Me.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(Be[W])?j=Be[W][Z]:j=Be[W],ve=!0):Ue.isWebGL2&&L.samples>0&&I.useMultisampledRTT(L)===!1?j=Me.get(L).__webglMultisampledFramebuffer:Array.isArray(Be)?j=Be[Z]:j=Be,y.copy(L.viewport),D.copy(L.scissor),P=L.scissorTest}else y.copy(q).multiplyScalar(z).floor(),D.copy(G).multiplyScalar(z).floor(),P=K;if(le.bindFramebuffer(Y.FRAMEBUFFER,j)&&Ue.drawBuffers&&J&&le.drawBuffers(L,j),le.viewport(y),le.scissor(D),le.setScissorTest(P),ve){const Oe=Me.get(L.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+W,Oe.__webglTexture,Z)}else if(Ae){const Oe=Me.get(L.texture),Ke=W||0;Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Oe.__webglTexture,Z||0,Ke)}C=-1},this.readRenderTargetPixels=function(L,W,Z,J,j,ve,Ae){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=Me.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ae!==void 0&&(De=De[Ae]),De){le.bindFramebuffer(Y.FRAMEBUFFER,De);try{const Oe=L.texture,Ke=Oe.format,Be=Oe.type;if(Ke!==1023&&Se.convert(Ke)!==Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ve=Be===1016&&(Re.has("EXT_color_buffer_half_float")||Ue.isWebGL2&&Re.has("EXT_color_buffer_float"));if(Be!==1009&&Se.convert(Be)!==Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Be===1015&&(Ue.isWebGL2||Re.has("OES_texture_float")||Re.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=L.width-J&&Z>=0&&Z<=L.height-j&&Y.readPixels(W,Z,J,j,Se.convert(Ke),Se.convert(Be),ve)}finally{const Oe=A!==null?Me.get(A).__webglFramebuffer:null;le.bindFramebuffer(Y.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(L,W,Z=0){const J=Math.pow(2,-Z),j=Math.floor(W.image.width*J),ve=Math.floor(W.image.height*J);I.setTexture2D(W,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Z,0,0,L.x,L.y,j,ve),le.unbindTexture()},this.copyTextureToTexture=function(L,W,Z,J=0){const j=W.image.width,ve=W.image.height,Ae=Se.convert(Z.format),De=Se.convert(Z.type);I.setTexture2D(Z,0),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,Z.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,Z.unpackAlignment),W.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,j,ve,Ae,De,W.image.data):W.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,W.mipmaps[0].width,W.mipmaps[0].height,Ae,W.mipmaps[0].data):Y.texSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,Ae,De,W.image),J===0&&Z.generateMipmaps&&Y.generateMipmap(Y.TEXTURE_2D),le.unbindTexture()},this.copyTextureToTexture3D=function(L,W,Z,J,j=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ve=L.max.x-L.min.x+1,Ae=L.max.y-L.min.y+1,De=L.max.z-L.min.z+1,Oe=Se.convert(J.format),Ke=Se.convert(J.type);let Be;if(J.isData3DTexture)I.setTexture3D(J,0),Be=Y.TEXTURE_3D;else if(J.isDataArrayTexture||J.isCompressedArrayTexture)I.setTexture2DArray(J,0),Be=Y.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,J.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,J.unpackAlignment);const Ve=Y.getParameter(Y.UNPACK_ROW_LENGTH),St=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),si=Y.getParameter(Y.UNPACK_SKIP_PIXELS),Pt=Y.getParameter(Y.UNPACK_SKIP_ROWS),zi=Y.getParameter(Y.UNPACK_SKIP_IMAGES),mt=Z.isCompressedTexture?Z.mipmaps[j]:Z.image;Y.pixelStorei(Y.UNPACK_ROW_LENGTH,mt.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,mt.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,L.min.x),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,L.min.y),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,L.min.z),Z.isDataTexture||Z.isData3DTexture?Y.texSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,Ke,mt.data):Z.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,mt.data)):Y.texSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,Ke,mt),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Ve),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,St),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,si),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,zi),j===0&&J.generateMipmaps&&Y.generateMipmap(Be),le.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?I.setTextureCube(L,0):L.isData3DTexture?I.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?I.setTexture2DArray(L,0):I.setTexture2D(L,0),le.unbindTexture()},this.resetState=function(){b=0,R=0,A=null,le.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===jr?"display-p3":"srgb",t.unpackColorSpace=nt.workingColorSpace===Rs?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Mt?3001:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===3001?Mt:Ci}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Zg extends Ql{}Zg.prototype.isWebGL1Renderer=!0;class Jg extends Jt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class e0 extends Xt{constructor(e,t,i,n,r,a,o,l,c){super(e,t,i,n,r,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:1006,this.magFilter=r!==void 0?r:1006,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class rr extends ji{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new Q,d=new Q,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const E=[],_=g/i;let T=0;g===0&&a===0?T=.5/t:g===i&&l===Math.PI&&(T=-.5/t);for(let b=0;b<=t;b++){const R=b/t;u.x=-e*Math.cos(n+R*r)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(n+R*r)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(R+T,1-_),E.push(c++)}h.push(E)}for(let g=0;g<i;g++)for(let E=0;E<t;E++){const _=h[g][E+1],T=h[g][E],b=h[g+1][E],R=h[g+1][E+1];(g!==0||a>0)&&f.push(_,T,R),(g!==i-1||l<Math.PI)&&f.push(T,b,R)}this.setIndex(f),this.setAttribute("position",new Si(p,3)),this.setAttribute("normal",new Si(v,3)),this.setAttribute("uv",new Si(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qr}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qr);class Vn{static createButton(e){const t=document.createElement("button");function i(){let l=null;async function c(d){d.addEventListener("end",h),await e.xr.setSession(d),t.textContent="EXIT VR",l=d}function h(){l.removeEventListener("end",h),t.textContent="ENTER VR",l=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR";const u={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){l===null?navigator.xr.requestSession("immersive-vr",u).then(c):(l.end(),navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",u).then(c))},navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",u).then(c)}function n(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(){n(),t.textContent="VR NOT SUPPORTED"}function a(l){n(),console.warn("Exception when trying to call xr.isSessionSupported",l),t.textContent="VR NOT ALLOWED"}function o(l){l.style.position="absolute",l.style.bottom="20px",l.style.padding="12px 6px",l.style.border="1px solid #fff",l.style.borderRadius="4px",l.style.background="rgba(0,0,0,0.1)",l.style.color="#fff",l.style.font="normal 13px sans-serif",l.style.textAlign="center",l.style.opacity="0.5",l.style.outline="none",l.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",o(t),navigator.xr.isSessionSupported("immersive-vr").then(function(l){l?i():r(),l&&Vn.xrSessionIsGranted&&t.click()}).catch(a),t;{const l=document.createElement("a");return window.isSecureContext===!1?(l.href=document.location.href.replace(/^http:/,"https:"),l.innerHTML="WEBXR NEEDS HTTPS"):(l.href="https://immersiveweb.dev/",l.innerHTML="WEBXR NOT AVAILABLE"),l.style.left="calc(50% - 90px)",l.style.width="180px",l.style.textDecoration="none",o(l),l}}static registerSessionGrantedListener(){if(typeof navigator<"u"&&"xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Vn.xrSessionIsGranted=!0})}}}Vn.xrSessionIsGranted=!1,Vn.registerSessionGrantedListener();const Ui={"180-sbs":{geom:"sphere180",split:"sbs",stereo:!0},"180-mono":{geom:"sphere180",split:"mono",stereo:!1},"360-mono":{geom:"sphere360",split:"mono",stereo:!1},"360-sbs":{geom:"sphere360",split:"sbs",stereo:!0},"360-tb":{geom:"sphere360",split:"tb",stereo:!0},"flat-2d":{geom:"plane",split:"mono",stereo:!1,flat:!0,aspect:"full"},"flat-sbs-full":{geom:"plane",split:"sbs",stereo:!0,flat:!0,aspect:"per-eye"},"flat-sbs-half":{geom:"plane",split:"sbs",stereo:!0,flat:!0,aspect:"full"}},Zl=[{value:"180-sbs",label:"180° SBS (VR180)"},{value:"180-mono",label:"180° Mono"},{value:"360-mono",label:"360° Mono"},{value:"360-sbs",label:"360° SBS"},{value:"360-tb",label:"360° Top-Bottom"},{value:"flat-2d",label:"Flat 2D (regular movie)"},{value:"flat-sbs-full",label:"Flat 3D — Full SBS"},{value:"flat-sbs-half",label:"Flat 3D — Half SBS"}];function t0(s){var e;return!!((e=Ui[s])!=null&&e.flat)}function Jl(s){const e=String(s).toLowerCase(),t=/(^|[^a-z])(tb|ou|top.?bottom|over.?under)([^a-z]|$)/.test(e),i=/(sbs|side.?by.?side)/.test(e);return e.includes("360")?t?"360-tb":i?"360-sbs":"360-mono":e.includes("180")||e.includes("vr180")?e.includes("mono")?"180-mono":"180-sbs":i?e.includes("half")?"flat-sbs-half":"flat-sbs-full":null}class ec{constructor(e){this.scene=new Jg,this.meshes=[],this.frameCbs=[],this.resize=()=>{const l=this.w(),c=this.h();this.camera.aspect=l/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(l,c,!1)};const{canvas:t,video:i,projection:n="180-sbs",swapEyes:r=!1,fov:a=70,supersampling:o=1.5}=e;this.canvas=t,this.video=i,this.currentMode=Ui[n]?n:"180-sbs",this.currentSwap=r,this.renderer=new Ql({canvas:t,antialias:!0}),this.renderer.setPixelRatio(this.pixelRatioFor(o)),this.renderer.setSize(this.w(),this.h(),!1),this.renderer.xr.enabled=!0,this.camera=new oi(a,this.w()/this.h(),.1,1e3),this.camera.position.set(0,0,0),this.camera.layers.enable(1),this.maxAnisotropy=this.renderer.capabilities.getMaxAnisotropy(),this.texture=new e0(i),this.texture.colorSpace=Mt,this.texture.minFilter=1006,this.texture.magFilter=1006,this.texture.anisotropy=this.maxAnisotropy,this.applyProjection(this.currentMode,this.currentSwap),i.addEventListener("loadedmetadata",()=>{Ui[this.currentMode].flat&&this.applyProjection(this.currentMode,this.currentSwap)}),this.renderer.setAnimationLoop(()=>{for(const l of this.frameCbs)l();this.renderer.render(this.scene,this.camera)}),this.vrButton=Vn.createButton(this.renderer),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(t)}w(){return this.canvas.clientWidth||1}h(){return this.canvas.clientHeight||1}pixelRatioFor(e){return Math.min(window.devicePixelRatio*e,4)}planeAspect(e){const t=this.video.videoWidth,i=this.video.videoHeight;return!t||!i?1.7777777777777777:Ui[e].aspect==="per-eye"?t/2/i:t/i}buildGeometry(e){const t=Ui[e].geom;if(t==="sphere180"){const a=new rr(500,60,40,-Math.PI,Math.PI,0,Math.PI);return a.scale(-1,1,1),a}if(t==="sphere360"){const a=new rr(500,60,40);return a.scale(-1,1,1),a}const i=2.4,n=i*this.planeAspect(e),r=new Js(n,i);return r.translate(0,0,-2),r}splitUV(e,t,i){if(t==="mono")return;const n=e.attributes.uv.array;for(let r=0;r<n.length;r+=2)t==="sbs"?n[r]=n[r]*.5+(i==="right"?.5:0):t==="tb"&&(n[r+1]=n[r+1]*.5+(i==="left"?.5:0));e.attributes.uv.needsUpdate=!0}clearMeshes(){for(const e of this.meshes)this.scene.remove(e),e.geometry.dispose(),e.material.dispose();this.meshes.length=0}applyProjection(e,t){Ui[e]||(e="180-sbs"),this.clearMeshes();const i=Ui[e];if(i.stereo){const n=this.buildGeometry(e);this.splitUV(n,i.split,"left");const r=this.buildGeometry(e);this.splitUV(r,i.split,"right");const a=new mi(n,new hs({map:this.texture})),o=new mi(r,new hs({map:this.texture}));a.layers.set(t?2:1),o.layers.set(t?1:2),this.scene.add(a,o),this.meshes.push(a,o)}else{const n=new mi(this.buildGeometry(e),new hs({map:this.texture}));n.layers.set(0),this.scene.add(n),this.meshes.push(n)}this.currentMode=e,this.currentSwap=t}setProjection(e){this.applyProjection(e,this.currentSwap)}setSwapEyes(e){this.applyProjection(this.currentMode,e)}setFov(e){this.camera.fov=e,this.camera.updateProjectionMatrix()}setSupersampling(e){this.renderer.setPixelRatio(this.pixelRatioFor(e)),this.renderer.setSize(this.w(),this.h(),!1)}getProjection(){return this.currentMode}isFlat(){return!!Ui[this.currentMode].flat}onFrame(e){this.frameCbs.push(e)}dispose(){this.ro.disconnect(),this.renderer.setAnimationLoop(null),this.texture.dispose(),this.clearMeshes(),this.renderer.dispose()}}const tc=Math.PI/180;function ic(s,e){return{lon:Math.max(-90,Math.min(90,s)),lat:Math.max(-85,Math.min(85,e))}}class nc{constructor(e,t,i={}){this.camera=e,this.dom=t,this.lon=0,this.lat=0,this.dragging=!1,this.px=0,this.py=0,this.enabled=!0,this.onDown=n=>{this.enabled&&(this.dragging=!0,this.px=n.clientX,this.py=n.clientY,this.capture("setPointerCapture",n.pointerId))},this.onMove=n=>{if(!this.dragging)return;const r=n.clientX-this.px,a=n.clientY-this.py;this.px=n.clientX,this.py=n.clientY,{lon:this.lon,lat:this.lat}=ic(this.lon-r*.15,this.lat+a*.15)},this.onUp=n=>{this.dragging=!1,this.capture("releasePointerCapture",n.pointerId)},this.isPresenting=i.isPresenting??(()=>!1),this.dom.addEventListener("pointerdown",this.onDown),this.dom.addEventListener("pointermove",this.onMove),this.dom.addEventListener("pointerup",this.onUp),this.dom.addEventListener("pointercancel",this.onUp)}capture(e,t){var i,n;try{(n=(i=this.dom)[e])==null||n.call(i,t)}catch{}}update(){if(this.isPresenting()||!this.enabled)return;const e=(90-this.lat)*tc,t=this.lon*tc;this.camera.lookAt(Math.sin(e)*Math.sin(t),Math.cos(e),-Math.sin(e)*Math.cos(t))}reset(){this.lon=0,this.lat=0}setEnabled(e){this.enabled=e,e||(this.lon=0,this.lat=0,this.camera.lookAt(0,0,-1))}getAngles(){return{lon:this.lon,lat:this.lat}}dispose(){this.dom.removeEventListener("pointerdown",this.onDown),this.dom.removeEventListener("pointermove",this.onMove),this.dom.removeEventListener("pointerup",this.onUp),this.dom.removeEventListener("pointercancel",this.onUp)}}class sc{constructor(){this.hls=null}async attach(e,t){this.dispose(),e.crossOrigin=e.crossOrigin??"anonymous",e.playsInline=!0;const{url:i,format:n}=t,r=n==="hls"||n==="dash",a=e.canPlayType("application/vnd.apple.mpegurl")!=="";return new Promise((o,l)=>{const c=()=>{e.removeEventListener("loadedmetadata",h),e.removeEventListener("error",u)},h=()=>{c(),o()},u=()=>{c();const d=e.error?e.error.code:"unknown";l(new Error(`Video failed to load (media error ${d}). Is the source reachable and CORS-clean?`))};e.addEventListener("loadedmetadata",h),e.addEventListener("error",u),r&&!a?Promise.resolve().then(()=>HS).then(({default:d})=>{if(!d.isSupported()){c(),l(new Error("HLS/DASH stream needs hls.js, which is unsupported in this browser."));return}this.hls=new d({enableWorker:!0}),this.hls.on(d.Events.ERROR,(f,p)=>{p.fatal&&(c(),this.dispose(),l(new Error(`HLS fatal error: ${p.type} / ${p.details}`)))}),this.hls.loadSource(i),this.hls.attachMedia(e)}).catch(()=>{c(),l(new Error('This looks like an HLS/DASH stream but hls.js could not be loaded. Install "hls.js".'))}):(e.src=i,e.load())})}dispose(){this.hls&&(this.hls.destroy(),this.hls=null)}}function rc(s){let e=s;try{e=new URL(s).pathname}catch{}const t=e.toLowerCase();return t.endsWith(".m3u8")?"hls":t.endsWith(".mpd")?"dash":"progressive"}const i0={progressive:"/proxy/stream",hls:"/proxy/hls/manifest.m3u8",dash:"/proxy/mpd/manifest.m3u8"};function ac(s,e){const t=rc(s);if(!e||!e.url)return{url:s,format:t};const i=e.url.replace(/\/+$/,""),n=new URLSearchParams;n.set("d",s),e.apiPassword&&n.set("api_password",e.apiPassword);for(const[r,a]of Object.entries(e.headers??{}))a!=null&&a!==""&&n.set(`h_${r}`,a);return{url:`${i}${i0[t]}?${n.toString()}`,format:t}}function oc(s){if(!Number.isFinite(s)||s<0)return"0:00";const e=Math.floor(s%60),t=Math.floor(s/60%60),i=Math.floor(s/3600),n=String(e).padStart(2,"0");return i>0?`${i}:${String(t).padStart(2,"0")}:${n}`:`${t}:${n}`}function dt(s,e={},t=[]){const i=document.createElement(s),{class:n,...r}=e;n&&(i.className=n),Object.assign(i,r);for(const a of t)i.append(a);return i}class n0{constructor(e,t){this.nodes=[],this.disposers=[];const i=t.video,n=dt("button",{class:"tvp-btn tvp-play",title:"Play/Pause",textContent:"▶"}),r=dt("input",{class:"tvp-seek",type:"range",min:"0",max:"1000",value:"0"}),a=dt("span",{class:"tvp-time",textContent:"0:00 / 0:00"}),o=dt("button",{class:"tvp-btn tvp-mute",title:"Volume",textContent:"🔊"}),l=dt("input",{class:"tvp-volume",type:"range",min:"0",max:"1",step:"0.01",value:"1"}),c=dt("div",{class:"tvp-volpopup",hidden:!0},[l]),h=dt("span",{class:"tvp-volwrap"},[o,c]),u=dt("span",{class:"tvp-vrslot"}),d=dt("button",{class:"tvp-btn tvp-projbtn",title:"Projection",textContent:"🌐"}),f=dt("div",{class:"tvp-projmenu",hidden:!0});for(const P of Zl){const H=dt("button",{textContent:P.label});H.dataset.mode=P.value,f.append(H)}const p=dt("span",{class:"tvp-projwrap"},[d,f]),v=dt("button",{class:"tvp-btn tvp-settingsbtn",title:"Settings",textContent:"⚙"}),m=dt("button",{class:"tvp-btn tvp-fullscreen",title:"Fullscreen",textContent:"⛶"}),g=dt("footer",{class:"tvp-controls"},[n,r,a,h,u,p,v,m]),E=dt("input",{type:"checkbox",checked:t.initial.swapEyes}),_=dt("input",{type:"range",min:"30",max:"100",step:"1",value:String(t.initial.fov)}),T=dt("span",{textContent:String(t.initial.fov)}),b=dt("input",{type:"range",min:"1",max:"2",step:"0.25",value:String(t.initial.supersampling)}),R=dt("span",{textContent:String(t.initial.supersampling)}),A=dt("section",{class:"tvp-settings"},[dt("label",{class:"row"},[E,"Swap eyes (if depth looks wrong)"]),dt("label",{},[lc("Field of view (zoom): ",T,"°"),_]),dt("label",{},[lc("Supersampling: ",R,"× (sharpness)"),b])]),C=dt("div",{class:"tvp-toast"});this.nodes.push(g,A,C);for(const P of this.nodes)e.append(P);const x=(P,H,w,F)=>{P.addEventListener(H,w,F),this.disposers.push(()=>P.removeEventListener(H,w,F))},y=P=>r.style.setProperty("--seek",`${P}%`);x(n,"click",()=>{i.paused?i.play():i.pause()}),x(i,"play",()=>{n.textContent="⏸"}),x(i,"pause",()=>{n.textContent="▶"}),x(i,"timeupdate",()=>{if(i.duration){const P=i.currentTime/i.duration*100;r.value=String(P*10),y(P),a.textContent=`${oc(i.currentTime)} / ${oc(i.duration)}`}}),x(r,"input",()=>{y(Number(r.value)/10),i.duration&&(i.currentTime=Number(r.value)/1e3*i.duration)}),x(o,"click",P=>{P.stopPropagation(),c.hidden=!c.hidden}),x(l,"input",()=>{i.volume=Number(l.value),i.muted=i.volume===0,o.textContent=i.muted?"🔇":"🔊"});const D=()=>{const P=t.getProjection();let H="Projection";f.querySelectorAll("button").forEach(w=>{const F=w.dataset.mode===P;w.classList.toggle("active",F),F&&(H=`Projection: ${w.textContent}`)}),d.title=H};x(d,"click",P=>{P.stopPropagation(),f.hidden=!f.hidden}),x(f,"click",P=>{const H=P.target.closest("button[data-mode]");H&&(t.setProjection(H.dataset.mode),D(),f.hidden=!0)}),D(),x(v,"click",P=>{P.stopPropagation(),A.classList.toggle("open")}),x(E,"change",()=>t.setSwapEyes(E.checked)),x(_,"input",()=>{const P=Number(_.value);T.textContent=String(P),t.setFov(P)}),x(b,"input",()=>{const P=Number(b.value);R.textContent=String(P),t.setSupersampling(P)}),x(t.surface,"wheel",P=>{P.preventDefault();const H=Math.max(30,Math.min(100,Number(_.value)+Math.sign(P.deltaY)*3));_.value=String(H),T.textContent=String(H),t.setFov(H)},{passive:!1}),x(m,"click",()=>{var H,w;const P=t.fullscreenTarget;document.fullscreenElement?(w=document.exitFullscreen)==null||w.call(document):(H=P.requestFullscreen)==null||H.call(P)}),x(document,"click",P=>{const H=P.composedPath();!c.hidden&&!H.includes(c)&&!H.includes(o)&&(c.hidden=!0),!f.hidden&&!H.includes(f)&&!H.includes(d)&&(f.hidden=!0)}),t.vrSupported().then(P=>{P&&(Object.assign(t.vrButton.style,{position:"static",left:"auto",bottom:"auto",transform:"none",margin:"0"}),u.append(t.vrButton))})}dispose(){for(const e of this.disposers)e();for(const e of this.nodes)e.remove()}}function lc(s,e,t){const i=document.createDocumentFragment();return i.append(s,e,t),i}const cc=":host,:host *,.tvp,.tvp *{box-sizing:border-box}.tvp-canvas{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}.tvp-canvas:active{cursor:grabbing}.tvp-video{display:none}.tvp-controls{position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;gap:10px;padding:12px;background:linear-gradient(transparent,#000c);z-index:5;font:14px system-ui,Segoe UI,Roboto,sans-serif;color:#e8eaed}.tvp-btn{padding:4px;border:0;background:none;color:#e8eaed;cursor:pointer;font-size:22px;line-height:1}.tvp-btn:hover{opacity:.7}.tvp-seek{flex:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;height:14px;background:transparent;cursor:pointer;margin:0}.tvp-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px;background:linear-gradient(to right,#4f8cff var(--seek,0%),#3a4150 var(--seek,0%))}.tvp-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-4px;width:12px;height:12px;border-radius:50%;background:#fff;cursor:pointer}.tvp-seek::-moz-range-track{height:4px;border-radius:2px;background:#3a4150}.tvp-seek::-moz-range-progress{height:4px;border-radius:2px;background:#4f8cff}.tvp-seek::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff;cursor:pointer}.tvp-time{font-variant-numeric:tabular-nums;min-width:96px;text-align:center;color:#cfd6e2}.tvp-volwrap,.tvp-projwrap{position:relative;display:inline-flex}.tvp-volpopup{position:absolute;bottom:calc(100% + 10px);left:50%;transform:translate(-50%);width:40px;height:132px;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:10px;z-index:8;box-shadow:0 8px 24px #0009}.tvp-volpopup[hidden]{display:none}.tvp-volume{position:absolute;top:50%;left:50%;width:104px;height:14px;margin:0;transform:translate(-50%,-50%) rotate(-90deg);-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.tvp-volume::-webkit-slider-runnable-track{height:4px;border-radius:2px;background:#3a4150}.tvp-volume::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-4px;width:12px;height:12px;border-radius:50%;background:#fff;cursor:pointer}.tvp-volume::-moz-range-track{height:4px;border-radius:2px;background:#3a4150}.tvp-volume::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff;cursor:pointer}.tvp-projmenu{position:absolute;bottom:calc(100% + 8px);right:0;min-width:210px;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:10px;padding:6px;display:flex;flex-direction:column;gap:2px;z-index:8;box-shadow:0 8px 24px #0009}.tvp-projmenu[hidden]{display:none}.tvp-projmenu button{text-align:left;background:transparent;border:0;color:#e8eaed;padding:8px 10px;border-radius:7px;cursor:pointer;font:inherit;white-space:nowrap}.tvp-projmenu button:hover{background:#252b39}.tvp-projmenu button.active{background:#4f8cff;color:#fff}.tvp-vrslot button{position:static!important}.tvp-settings{position:absolute;bottom:62px;right:10px;width:300px;max-width:calc(100% - 20px);max-height:70%;overflow-y:auto;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:12px;padding:14px;display:none;flex-direction:column;gap:12px;z-index:6;font:14px system-ui,Segoe UI,Roboto,sans-serif;color:#e8eaed}.tvp-settings.open{display:flex}.tvp-settings label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:#aab2c0}.tvp-settings label.row{flex-direction:row;align-items:center;gap:8px;color:#e8eaed;font-size:13px}.tvp-settings input[type=range]{width:100%;accent-color:#4f8cff}.tvp-toast{position:absolute;left:50%;bottom:74px;transform:translate(-50%);max-width:80%;padding:10px 16px;border-radius:10px;background:#1b1f2aed;border:1px solid #2a2f3a;color:#e8eaed;opacity:0;pointer-events:none;transition:opacity .2s;z-index:7;font:13px system-ui}.tvp-toast.show{opacity:1}",hc="three-vr-player:settings";class uc{constructor(e,t={}){this.source=new sc,this.listeners=new Map,this.readyEmitted=!1,this.opts=t;const i=t.persistSettings?this.loadSettings():null;this.view={projection:t.projection??(i==null?void 0:i.projection)??"180-sbs",swapEyes:t.swapEyes??(i==null?void 0:i.swapEyes)??!1,fov:t.fov??(i==null?void 0:i.fov)??70,supersampling:t.supersampling??(i==null?void 0:i.supersampling)??1.5},this.wrap=document.createElement("div"),this.wrap.className="tvp",this.wrap.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;",e.appendChild(this.wrap);let n;if(t.shadowDom!==!1){const r=this.wrap.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=cc,r.appendChild(a),n=r}else{if(!document.getElementById("tvp-styles")){const r=document.createElement("style");r.id="tvp-styles",r.textContent=cc,document.head.appendChild(r)}n=this.wrap}this.canvas=document.createElement("canvas"),this.canvas.className="tvp-canvas",this.video=document.createElement("video"),this.video.className="tvp-video",this.video.playsInline=!0,t.crossOrigin!==null&&(this.video.crossOrigin=t.crossOrigin??"anonymous"),n.append(this.canvas,this.video),this.scene=new ec({canvas:this.canvas,video:this.video,projection:this.view.projection,swapEyes:this.view.swapEyes,fov:this.view.fov,supersampling:this.view.supersampling}),this.look=new nc(this.scene.camera,this.canvas,{isPresenting:()=>this.scene.renderer.xr.isPresenting}),this.scene.onFrame(()=>this.look.update()),this.look.setEnabled(!this.scene.isFlat()),t.controls!==!1&&(this.ui=new n0(n,{video:this.video,surface:this.canvas,fullscreenTarget:this.wrap,vrButton:this.scene.vrButton,vrSupported:()=>this.vrSupported(),getProjection:()=>this.scene.getProjection(),setProjection:r=>this.setProjection(r),setSwapEyes:r=>this.setSwapEyes(r),setFov:r=>this.setFov(r),setSupersampling:r=>this.setSupersampling(r),initial:{swapEyes:this.view.swapEyes,fov:this.view.fov,supersampling:this.view.supersampling}})),this.video.addEventListener("play",()=>this.emit("play")),this.video.addEventListener("pause",()=>this.emit("pause")),this.video.addEventListener("ended",()=>this.emit("ended")),this.video.addEventListener("timeupdate",()=>this.emit("timeupdate",this.video.currentTime)),this.video.addEventListener("error",()=>this.emit("error",this.video.error)),this.video.addEventListener("loadedmetadata",()=>{this.readyEmitted||(this.readyEmitted=!0,this.emit("ready"))}),this.scene.renderer.xr.addEventListener("sessionstart",()=>this.emit("enterxr")),this.scene.renderer.xr.addEventListener("sessionend",()=>this.emit("exitxr")),t.src&&this.load(t.src,{projection:t.projection})}vrSupported(){return this.opts.vrButton===!1||!navigator.xr?Promise.resolve(!1):navigator.xr.isSessionSupported("immersive-vr").catch(()=>!1)}async load(e,t={}){const i=t.projection??(this.opts.autoDetect!==!1?Jl(e):null);i&&this.setProjection(i);const{url:n,format:r}=ac(e,this.opts.proxy);try{await this.source.attach(this.video,{url:n,format:r}),await this.video.play().catch(()=>{})}catch(a){throw this.emit("error",a),a}}async play(){await this.video.play()}pause(){this.video.pause()}setProjection(e){this.scene.setProjection(e),this.look.setEnabled(!this.scene.isFlat()),this.look.reset(),this.view.projection=e,this.persist(),this.emit("projectionchange",e)}setSwapEyes(e){this.scene.setSwapEyes(e),this.view.swapEyes=e,this.persist()}setFov(e){this.scene.setFov(e),this.view.fov=e,this.persist()}setSupersampling(e){this.scene.setSupersampling(e),this.view.supersampling=e,this.persist()}async enterVR(){var t;const e=this.scene.vrButton;(t=e==null?void 0:e.click)==null||t.call(e)}get three(){return{renderer:this.scene.renderer,scene:this.scene.scene,camera:this.scene.camera}}on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),this}off(e,t){var i;return(i=this.listeners.get(e))==null||i.delete(t),this}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(n=>n(t))}persist(){if(this.opts.persistSettings)try{localStorage.setItem(hc,JSON.stringify(this.view))}catch{}}loadSettings(){try{const e=localStorage.getItem(hc);return e?JSON.parse(e):null}catch{return null}}dispose(){var e;(e=this.ui)==null||e.dispose(),this.look.dispose(),this.source.dispose(),this.scene.dispose(),this.video.remove(),this.canvas.remove(),this.wrap.remove(),this.listeners.clear()}}class dc extends HTMLElement{static get observedAttributes(){return["src","projection"]}connectedCallback(){this.player||(this.style.display||(this.style.display="block"),this.player=new uc(this,{src:this.getAttribute("src")??void 0,projection:this.getAttribute("projection")??void 0,controls:this.hasAttribute("controls"),swapEyes:this.hasAttribute("swap-eyes"),autoDetect:this.getAttribute("auto-detect")!=="false",fov:this.numAttr("fov"),supersampling:this.numAttr("supersampling"),proxy:this.getAttribute("proxy-url")?{url:this.getAttribute("proxy-url"),apiPassword:this.getAttribute("proxy-password")??void 0}:void 0}))}attributeChangedCallback(e,t,i){!this.player||i==null||(e==="src"&&this.player.load(i),e==="projection"&&this.player.setProjection(i))}disconnectedCallback(){var e;(e=this.player)==null||e.dispose(),this.player=void 0}numAttr(e){const t=this.getAttribute(e);return t==null?void 0:Number(t)}get api(){return this.player}}function fc(s="three-video"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,dc)}fc();const de=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},s0=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=r0},r0=Number.MAX_SAFE_INTEGER||9007199254740991;let Ee=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),V=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s}({}),S=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s}({});var Ye={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Hn{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class a0{constructor(e,t,i,n=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Hn(e),this.fast_=new Hn(t),this.defaultTTFB_=n,this.ttfb_=new Hn(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Hn(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new Hn(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Hn(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,r=i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function o0(s,e,t){return(e=c0(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function rt(){return rt=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},rt.apply(null,arguments)}function pc(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),t.push.apply(t,i)}return t}function Je(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pc(Object(t),!0).forEach(function(i){o0(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):pc(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function l0(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function c0(s){var e=l0(s,"string");return typeof e=="symbol"?e:e+""}class li{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=Qi,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const Qi=function(){},h0={trace:Qi,debug:Qi,log:Qi,warn:Qi,info:Qi,error:Qi};function Ma(){return rt({},h0)}function u0(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Qi}function mc(s,e,t){return e[s]?e[s].bind(e):u0(s,t)}const La=Ma();function d0(s,e,t){const i=Ma();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=mc(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.16`)}catch{return Ma()}n.forEach(r=>{La[r]=mc(r,s)})}else rt(La,i);return i}const et=La;function Ni(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function f0(s){return typeof self<"u"&&s===self.ManagedMediaSource}function gc(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(a=>i.indexOf(a)===-1)}function ti(s,e=!1){if(typeof TextDecoder<"u"){const c=new TextDecoder("utf-8").decode(s);if(e){const h=c.indexOf("\0");return h!==-1?c.substring(0,h):c}return c.replace(/\0/g,"")}const t=s.length;let i,n,r,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=s[o++],a+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[o++],r=s[o++],a+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return a}function Ut(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function vc(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function p0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ia={exports:{}},_c;function m0(){return _c||(_c=1,function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,c,h){if(h=h||{},l=l.trim(),c=c.trim(),!c){if(!h.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var d=o.parseURL(c);if(!d)throw new Error("Error trying to parse relative URL.");if(d.scheme)return h.alwaysNormalize?(d.path=o.normalizePath(d.path),o.buildURLFromParts(d)):c;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var p=n.exec(f.path);f.netLoc=p[1],f.path=p[2]}f.netLoc&&!f.path&&(f.path="/");var v={scheme:f.scheme,netLoc:d.netLoc,path:null,params:d.params,query:d.query,fragment:d.fragment};if(!d.netLoc&&(v.netLoc=f.netLoc,d.path[0]!=="/"))if(!d.path)v.path=f.path,d.params||(v.params=f.params,d.query||(v.query=f.query));else{var m=f.path,g=m.substring(0,m.lastIndexOf("/")+1)+d.path;v.path=o.normalizePath(g)}return v.path===null&&(v.path=h.alwaysNormalize?o.normalizePath(d.path):d.path),o.buildURLFromParts(v)},parseURL:function(l){var c=i.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};s.exports=o})()}(Ia)),Ia.exports}var Ca=m0();class ar{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 at={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Da{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,g0(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let n;i.length===1?n=(t==null?void 0:t.byteRangeEndOffset)||0:n=parseInt(i[1]),this._byteRange=[n,parseInt(i[0])+n]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[at.AUDIO]:null,[at.VIDEO]:null,[at.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new ar),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ca.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[at.AUDIO]=null,e[at.VIDEO]=null,e[at.AUDIOVIDEO]=null}}function Et(s){return s.sn!=="initSegment"}class or extends Da{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(de(e)&&de(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=de(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),n=i.length;if(n>1||n===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!de(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return Et(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const n=t[e];n&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=n.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,r,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,n),l.endDTS=Math.max(l.endDTS,r)}}class Ec extends Da{constructor(e,t,i,n,r){super(i),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.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Sc(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||Sc(t,e)}}function g0(s,e){const t=Sc(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const xc=Math.pow(2,32)-1,v0=[].push,yc={video:1,audio:2,id3:3,text:4};function At(s){return String.fromCharCode.apply(null,s)}function Tc(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function we(s,e){const t=bc(s,e);return t<0?4294967296+t:t}function Ac(s,e){let t=we(s,e);return t*=Math.pow(2,32),t+=we(s,e+4),t}function bc(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function _0(s){const e=s.byteLength;for(let t=0;t<e;){const i=we(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return!0;t=i>1?t+i:e}return!1}function We(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=we(s,n),a=At(s.subarray(n+4,n+8)),o=r>1?n+r:i;if(a===e[0])if(e.length===1)t.push(s.subarray(n+8,o));else{const l=We(s.subarray(n+8,o),e.slice(1));l.length&&v0.apply(t,l)}n=o}return t}function E0(s){const e=[],t=s[0];let i=8;const n=we(s,i);i+=4;let r=0,a=0;t===0?(r=we(s,i),a=we(s,i+4),i+=8):(r=Ac(s,i),a=Ac(s,i+8),i+=16),i+=2;let o=s.length+a;const l=Tc(s,i);i+=2;for(let c=0;c<l;c++){let h=i;const u=we(s,h);h+=4;const d=u&2147483647;if((u&2147483648)>>>31===1)return et.warn("SIDX has hierarchical references (not supported)"),null;const p=we(s,h);h+=4,e.push({referenceSize:d,subsegmentDuration:p,info:{duration:p/n,start:o,end:o+d-1}}),o+=d,h+=4,i=h}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:l,references:e}}function Rc(s){const e=[],t=We(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],a=We(r,["tkhd"])[0];if(a){let o=a[0];const l=we(a,o===0?12:20),c=We(r,["mdia","mdhd"])[0];if(c){o=c[0];const h=we(c,o===0?12:20),u=We(r,["mdia","hdlr"])[0];if(u){const d=At(u.subarray(8,12)),f={soun:at.AUDIO,vide:at.VIDEO}[d],p=We(r,["mdia","minf","stbl","stsd"])[0],v=S0(p);f?(e[l]={timescale:h,type:f,stsd:v},e[f]=Je({timescale:h,id:l},v)):e[l]={timescale:h,type:d,stsd:v}}}}}return We(s,["moov","mvex","trex"]).forEach(n=>{const r=we(n,4),a=e[r];a&&(a.default={duration:we(n,12),flags:we(n,20)})}),e}function S0(s){const e=s.subarray(8),t=e.subarray(86),i=At(e.subarray(4,8));let n=i,r;const a=i==="enca"||i==="encv";if(a){const c=We(e,[i])[0].subarray(i==="enca"?28:78);We(c,["sinf"]).forEach(u=>{const d=We(u,["schm"])[0];if(d){const f=At(d.subarray(4,8));if(f==="cbcs"||f==="cenc"){const p=We(u,["frma"])[0];p&&(n=At(p))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const l=We(t,["avcC"])[0];l&&l.length>3&&(n+="."+cr(l[1])+cr(l[2])+cr(l[3]),r=lr(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const l=We(e,[i])[0],c=We(l.subarray(28),["esds"])[0];if(c&&c.length>7){let h=4;if(c[h++]!==3)break;h=wa(c,h),h+=2;const u=c[h++];if(u&128&&(h+=2),u&64&&(h+=c[h++]),c[h++]!==4)break;h=wa(c,h);const d=c[h++];if(d===64)n+="."+cr(d);else break;if(h+=12,c[h++]!==5)break;h=wa(c,h);const f=c[h++];let p=(f&248)>>3;p===31&&(p+=1+((f&7)<<3)+((c[h]&224)>>5)),n+="."+p}break}case"hvc1":case"hev1":{const l=We(t,["hvcC"])[0];if(l&&l.length>12){const c=l[1],h=["","A","B","C"][c>>6],u=c&31,d=we(l,2),f=(c&32)>>5?"H":"L",p=l[12],v=l.subarray(6,12);n+="."+h+u,n+="."+x0(d).toString(16).toUpperCase(),n+="."+f+p;let m="";for(let g=v.length;g--;){const E=v[g];(E||m)&&(m="."+E.toString(16).toUpperCase()+m)}n+=m}r=lr(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=lr(n,t)||n;break}case"vp09":{const l=We(t,["vpcC"])[0];if(l&&l.length>6){const c=l[4],h=l[5],u=l[6]>>4&15;n+="."+yi(c)+"."+yi(h)+"."+yi(u)}break}case"av01":{const l=We(t,["av1C"])[0];if(l&&l.length>2){const c=l[1]>>>5,h=l[1]&31,u=l[2]>>>7?"H":"M",d=(l[2]&64)>>6,f=(l[2]&32)>>5,p=c===2&&d?f?12:10:d?10:8,v=(l[2]&16)>>4,m=(l[2]&8)>>3,g=(l[2]&4)>>2,E=l[2]&3;n+="."+c+"."+yi(h)+u+"."+yi(p)+"."+v+"."+m+g+E+"."+yi(1)+"."+yi(1)+"."+yi(1)+"."+0,r=lr("dav1",t)}break}}return{codec:n,encrypted:a,supplemental:r}}function lr(s,e){const t=We(e,["dvvC"]),i=t.length?t[0]:We(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+yi(n)+"."+yi(r)}}function x0(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function wa(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function cr(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function yi(s){return(s<10?"0":"")+s}function y0(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Mc(s,(i,n)=>{const r=i.subarray(8,24);r.some(a=>a!==0)||(et.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${Ut(r)} -> ${Ut(t)}`),i.set(t,8))})}function T0(s){const e=[];return Mc(s,t=>e.push(t.subarray(8,24))),e}function Mc(s,e){We(s,["moov","trak"]).forEach(i=>{const n=We(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let a=We(r,["enca"]);const o=a.length>0;o||(a=We(r,["encv"])),a.forEach(l=>{const c=o?l.subarray(28):l.subarray(78);We(c,["sinf"]).forEach(u=>{const d=Lc(u);d&&e(d,o)})})})}function Lc(s){const e=We(s,["schm"])[0];if(e){const t=At(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=We(s,["schi","tenc"])[0];if(i)return i}}}function A0(s,e,t){const i={},n=We(s,["moof","traf"]);for(let r=0;r<n.length;r++){const a=n[r],o=We(a,["tfhd"])[0],l=we(o,4),c=e[l];if(!c)continue;i[l]||(i[l]={start:NaN,duration:0,sampleCount:0,timescale:c.timescale,type:c.type});const h=i[l],u=We(a,["tfdt"])[0];if(u){const _=u[0];let T=we(u,4);_===1&&(T===xc?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(T*=xc+1,T+=we(u,8))),de(T)&&(!de(h.start)||T<h.start)&&(h.start=T)}const d=c.default,f=we(o,0)|(d==null?void 0:d.flags);let p=(d==null?void 0:d.duration)||0;f&8&&(f&2?p=we(o,12):p=we(o,8));const v=We(a,["trun"]);let m=h.start||0,g=0,E=p;for(let _=0;_<v.length;_++){const T=v[_],b=we(T,4),R=h.sampleCount;h.sampleCount+=b;const A=T[3]&1,C=T[3]&4,x=T[2]&1,y=T[2]&2,D=T[2]&4,P=T[2]&8;let H=8,w=b;for(A&&(H+=4),C&&b&&(!(T[H+1]&1)&&h.keyFrameIndex===void 0&&(h.keyFrameIndex=R),H+=4,x?(E=we(T,H),H+=4):E=p,y&&(H+=4),P&&(H+=4),m+=E,g+=E,w--);w--;)x?(E=we(T,H),H+=4):E=p,y&&(H+=4),D&&(T[H+1]&1||h.keyFrameIndex===void 0&&(h.keyFrameIndex=h.sampleCount-(w+1),h.keyFrameStart=m),H+=4),P&&(H+=4),m+=E,g+=E;!g&&p&&(g+=p*b)}h.duration+=g}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,a=0;const o=We(s,["sidx"]);for(let l=0;l<o.length;l++){const c=E0(o[l]);if(c!=null&&c.references){r=Math.min(r,c.earliestPresentationTime/c.timescale);const h=c.references.reduce((u,d)=>u+d.info.duration||0,0);a=Math.max(a,h+c.earliestPresentationTime/c.timescale)}}a&&de(a)&&Object.keys(i).forEach(l=>{i[l].duration||(i[l].duration=a*i[l].timescale-i[l].start)})}return i}function b0(s){const e={valid:null,remainder:null},t=We(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function ci(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function Ic(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let a=!1;return We(i,["moof"]).map(l=>{const c=l.byteOffset-8;We(l,["traf"]).map(u=>{const d=We(u,["tfdt"]).map(f=>{const p=f[0];let v=we(f,4);return p===1&&(v*=Math.pow(2,32),v+=we(f,8)),v/n})[0];return d!==void 0&&(s=d),We(u,["tfhd"]).map(f=>{const p=we(f,4),v=we(f,0)&16777215,m=(v&1)!==0,g=(v&2)!==0,E=(v&8)!==0;let _=0;const T=(v&16)!==0;let b=0;const R=(v&32)!==0;let A=8;p===r&&(m&&(A+=8),g&&(A+=4),E&&(_=we(f,A),A+=4),T&&(b=we(f,A),A+=4),R&&(A+=4),e.type==="video"&&(a=hr(e.codec)),We(u,["trun"]).map(C=>{const x=C[0],y=we(C,0)&16777215,D=(y&1)!==0;let P=0;const H=(y&4)!==0,w=(y&256)!==0;let F=0;const O=(y&512)!==0;let z=0;const N=(y&1024)!==0,k=(y&2048)!==0;let q=0;const G=we(C,4);let K=8;D&&(P=we(C,K),K+=4),H&&(K+=4);let $=P+c;for(let ee=0;ee<G;ee++){if(w?(F=we(C,K),K+=4):F=_,O?(z=we(C,K),K+=4):z=b,N&&(K+=4),k&&(x===0?q=we(C,K):q=bc(C,K),K+=4),e.type===at.VIDEO){let ie=0;for(;ie<z;){const oe=we(i,$);if($+=4,R0(a,i[$])){const me=i.subarray($,$+oe);Pa(me,a?2:1,s+q/n,t)}$+=oe,ie+=oe+4}}s+=F/n}}))})})}),t}function hr(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function R0(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Pa(s,e,t,i){const n=Cc(s);let r=0;r+=e;let a=0,o=0,l=0;for(;r<n.length;){a=0;do{if(r>=n.length)break;l=n[r++],a+=l}while(l===255);o=0;do{if(r>=n.length)break;l=n[r++],o+=l}while(l===255);const c=n.length-r;let h=r;if(o<c)r+=o;else if(o>c){et.error(`Malformed SEI payload. ${o} is too small, only ${c} bytes left to parse.`);break}if(a===4){if(n[h++]===181){const d=Tc(n,h);if(h+=2,d===49){const f=we(n,h);if(h+=4,f===1195456820){const p=n[h++];if(p===3){const v=n[h++],m=31&v,g=64&v,E=g?2+m*3:0,_=new Uint8Array(E);if(g){_[0]=v;for(let T=1;T<E;T++)_[T]=n[h++]}i.push({type:p,payloadType:a,pts:t,bytes:_})}}}}}else if(a===5&&o>16){const u=[];for(let p=0;p<16;p++){const v=n[h++].toString(16);u.push(v.length==1?"0"+v:v),(p===3||p===5||p===7||p===9)&&u.push("-")}const d=o-16,f=new Uint8Array(d);for(let p=0;p<d;p++)f[p]=n[h++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:ti(f),userDataBytes:f})}}}function Cc(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const n=e-t.length,r=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=s[a];return r}function M0(s){const e=s[0];let t="",i="",n=0,r=0,a=0,o=0,l=0,c=0;if(e===0){for(;At(s.subarray(c,c+1))!=="\0";)t+=At(s.subarray(c,c+1)),c+=1;for(t+=At(s.subarray(c,c+1)),c+=1;At(s.subarray(c,c+1))!=="\0";)i+=At(s.subarray(c,c+1)),c+=1;i+=At(s.subarray(c,c+1)),c+=1,n=we(s,12),r=we(s,16),o=we(s,20),l=we(s,24),c=28}else if(e===1){c+=4,n=we(s,c),c+=4;const u=we(s,c);c+=4;const d=we(s,c);for(c+=4,a=4294967296*u+d,s0(a)||(a=Number.MAX_SAFE_INTEGER,et.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=we(s,c),c+=4,l=we(s,c),c+=4;At(s.subarray(c,c+1))!=="\0";)t+=At(s.subarray(c,c+1)),c+=1;for(t+=At(s.subarray(c,c+1)),c+=1;At(s.subarray(c,c+1))!=="\0";)i+=At(s.subarray(c,c+1)),c+=1;i+=At(s.subarray(c,c+1)),c+=1}const h=s.subarray(c,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}function L0(s,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(s,4),n=0,i=8;n<t;n++)r.set(e[n],i),i+=e[n].byteLength;return r}function I0(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;i=0,n=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),L0([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,a,t)}function C0(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const n=new DataView(s,i),r=D0(n);e.push(r),i+=r.size}}return e}function D0(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const r=s.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const a=s.buffer,o=Ut(new Uint8Array(a,t+12,16));let l=null,c=null,h=0;if(r===0)h=28;else{const d=s.getUint32(28);if(!d||i<32+d*16)return{offset:t,size:e};l=[];for(let f=0;f<d;f++)l.push(new Uint8Array(a,t+32+f*16,16));h=32+d*16}if(!h)return{offset:t,size:e};const u=s.getUint32(h);return e-32<u?{offset:t,size:e}:(c=new Uint8Array(a,t+h+4,u),{version:r,systemId:o,kids:l,data:c,offset:t,size:e})}const Dc=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),$n={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Fa(s,e){const t=$n[e];return!!t&&!!t[s.slice(0,4)]}function fs(s,e,t=!0){return!s.split(",").some(i=>!Oa(i,e,t))}function Oa(s,e,t=!0){var i;const n=Ni(t);return(i=n==null?void 0:n.isTypeSupported(ps(s,e)))!=null?i:!1}function ps(s,e){return`${e}/mp4;codecs=${s}`}function wc(s){if(s){const e=s.substring(0,4);return $n.video[e]}return 2}function ur(s){const e=Dc();return s.split(",").reduce((t,i)=>{const r=e&&hr(i)?9:$n.video[i];return r?(r*2+t)/(t?3:2):($n.audio[i]+t)/(t?2:1)},0)}const Ua={};function w0(s,e=!0){if(Ua[s])return Ua[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let n=0;n<t.length;n++){var i;if(Oa(t[n],"audio",e))return Ua[s]=t[n],t[n];if(t[n]==="mp3"&&(i=Ni(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const P0=/flac|opus|mp4a\.40\.34/i;function dr(s,e=!0){return s.replace(P0,t=>w0(t.toLowerCase(),e))}function F0(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)Fa(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function fr(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Pc(s,"audio")||Pc(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Pc(s,e){return Fa(s,e)&&Oa(s,e)}function O0(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function U0(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Fc(s){const e=Ni(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Na(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const N0={supported:!0,powerEfficient:!0,smooth:!0},k0={supported:!1,smooth:!1,powerEfficient:!1},Oc={supported:!0,configurations:[],decodingInfoResults:[N0]};function Uc(s,e){return{supported:!1,configurations:e,decodingInfoResults:[k0],error:s}}function B0(s,e,t,i,n,r){const a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,l=r==null?void 0:r.audioCodec,c=r==null?void 0:r.channels,h=c?parseInt(c):l?1/0:2;let u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((d,f)=>{if(f){const p=e.groups[f];if(!p)throw new Error(`Audio track group ${f} not found`);Object.keys(p.channels).forEach(v=>{d[v]=(d[v]||0)+p.channels[v]})}return d},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(d=>hr(d))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(n,8e6))||!!u&&de(h)&&Object.keys(u).some(d=>parseInt(d)>h)}function Nc(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(Oc);const r=[],a=G0(s),o=a.length,l=V0(s,e,o>0),c=l.length;for(let h=o||1*c||1;h--;){const u={type:"media-source"};if(o&&(u.video=a[h%o]),c){u.audio=l[h%c];const d=u.audio.bitrate;u.video&&d&&(u.video.bitrate-=d)}r.push(u)}if(n){const h=navigator.userAgent;if(n.split(",").some(u=>hr(u))&&Dc())return Promise.resolve(Uc(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),r))}return Promise.all(r.map(h=>{const u=$0(h);return i[u]||(i[u]=t.decodingInfo(h))})).then(h=>({supported:!h.some(u=>!u.supported),configurations:r,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:r,decodingInfoResults:[],error:h}))}function G0(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=kc(s),n=s.width||640,r=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(l=>{const c={contentType:ps(U0(l),"video"),width:n,height:r,bitrate:i,framerate:a};return o!=="sdr"&&(c.transferFunction=o),c}):[]}function V0(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=kc(s);return n&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var l;const c=o?(l=e.groups[o])==null?void 0:l.tracks:null;return c?c.reduce((h,u)=>{if(u.groupId===o){const d=parseFloat(u.channels||"");n.forEach(f=>{const p={contentType:ps(f,"audio"),bitrate:t?H0(f,r):r};d&&(p.channels=""+d),h.push(p)})}return h},a):a},[]):[]}function H0(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function kc(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function $0(s){let e="";const{audio:t,video:i}=s;if(i){const n=Na(i.contentType);e+=`${n}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const n=Na(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const ka=["NONE","TYPE-0","TYPE-1",null];function z0(s){return ka.indexOf(s)>-1}const pr=["SDR","PQ","HLG"];function W0(s){return!!s&&pr.indexOf(s)>-1}var ms={No:"",Yes:"YES",v2:"v2"};function Bc(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?ms.v2:ms.Yes:ms.No}class Ba{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class zn{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Gc(this._audioGroups,e)}hasSubtitleGroup(e){return Gc(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Gc(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function K0(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function X0(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||pr.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&K0(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const Y0=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},ot=(s,e)=>JSON.stringify(s,Y0(e));function q0(s,e,t,i,n){const r=Object.keys(s),a=i==null?void 0:i.channels,o=i==null?void 0:i.audioCodec,l=n==null?void 0:n.videoCodec,c=a&&parseInt(a)===2;let h=!1,u=!1,d=1/0,f=1/0,p=1/0,v=1/0,m=0,g=[];const{preferHDR:E,allowedVideoRanges:_}=X0(e,n);for(let C=r.length;C--;){const x=s[r[C]];h||(h=x.channels[2]>0),d=Math.min(d,x.minHeight),f=Math.min(f,x.minFramerate),p=Math.min(p,x.minBitrate),_.filter(D=>x.videoRanges[D]>0).length>0&&(u=!0)}d=de(d)?d:0,f=de(f)?f:0;const T=Math.max(1080,d),b=Math.max(30,f);p=de(p)?p:t,t=Math.max(p,t),u||(e=void 0);const R=r.length>1;return{codecSet:r.reduce((C,x)=>{const y=s[x];if(x===C)return C;if(g=u?_.filter(D=>y.videoRanges[D]>0):[],R){if(y.minBitrate>t)return Ti(x,`min bitrate of ${y.minBitrate} > current estimate of ${t}`),C;if(!y.hasDefaultAudio)return Ti(x,"no renditions with default or auto-select sound found"),C;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Ti(x,`audio codec preference "${o}" not found`),C;if(a&&!c){if(!y.channels[a])return Ti(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(y.channels)})`),C}else if((!o||c)&&h&&y.channels[2]===0)return Ti(x,"no renditions with stereo sound found"),C;if(y.minHeight>T)return Ti(x,`min resolution of ${y.minHeight} > maximum of ${T}`),C;if(y.minFramerate>b)return Ti(x,`min framerate of ${y.minFramerate} > maximum of ${b}`),C;if(!g.some(D=>y.videoRanges[D]>0))return Ti(x,`no variants with VIDEO-RANGE of ${ot(g)} found`),C;if(l&&x.indexOf(l.substring(0,4))%5!==0)return Ti(x,`video codec preference "${l}" not found`),C;if(y.maxScore<m)return Ti(x,`max score of ${y.maxScore} < selected max of ${m}`),C}return C&&(ur(x)>=ur(C)||y.fragmentError>s[C].fragmentError)?C:(v=y.minIndex,m=y.maxScore,x)},void 0),videoRanges:g,preferHDR:E,minFramerate:f,minBitrate:p,minIndex:v}}function Ti(s,e){et.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function Vc(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function j0(s,e,t,i){return s.slice(t,i+1).reduce((n,r,a)=>{if(!r.codecSet)return n;const o=r.audioGroups;let l=n[r.codecSet];l||(n[r.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,r.bitrate);const c=Math.min(r.height,r.width);return l.minHeight=Math.min(l.minHeight,c),l.minFramerate=Math.min(l.minFramerate,r.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,r.score),l.fragmentError+=r.fragmentError,l.videoRanges[r.videoRange]=(l.videoRanges[r.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const u=e.groups[h];u&&(l.hasDefaultAudio=l.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(d=>{l.channels[d]=(l.channels[d]||0)+u.channels[d]}))}),n},{})}function Hc(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}=s;return{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}}function Ai(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const n=e[i];if(dn(s,n,t))return i}return-1}function dn(s,e,t){const{groupId:i,name:n,lang:r,assocLang:a,default:o}=s,l=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||Q0(r,e.lang))&&(r===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in s)||Z0(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function Q0(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function Z0(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function fn(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function J0(s,e,t,i,n){const r=e[i],o=e.reduce((d,f,p)=>{const v=f.uri;return(d[v]||(d[v]=[])).push(p),d},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const l=r.videoRange,c=r.frameRate,h=r.codecSet.substring(0,4),u=$c(e,i,d=>{if(d.videoRange!==l||d.frameRate!==c||d.codecSet.substring(0,4)!==h)return!1;const f=d.audioGroups,p=t.filter(v=>!f||f.indexOf(v.groupId)!==-1);return Ai(s,p,n)>-1});return u>-1?u:$c(e,i,d=>{const f=d.audioGroups,p=t.filter(v=>!f||f.indexOf(v.groupId)!==-1);return Ai(s,p,n)>-1})}function $c(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function mr(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class zc extends li{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:n,partCurrent:r,hls:a}=this,{autoLevelEnabled:o,media:l}=a;if(!n||!l)return;const c=performance.now(),h=r?r.stats:n.stats,u=r?r.duration:n.duration,d=c-h.loading.start,f=a.minAutoLevel,p=n.level,v=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||p<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const m=v>-1&&v!==p,g=!!t||m;if(!g&&(l.paused||!l.playbackRate||!l.readyState))return;const E=a.mainForwardBufferInfo;if(!g&&E===null)return;const _=this.bwEstimator.getEstimateTTFB(),T=Math.abs(l.playbackRate);if(d<=Math.max(_,1e3*(u/(T*2))))return;const b=E?E.len/T:0,R=h.loading.first?h.loading.first-h.loading.start:-1,A=h.loaded&&R>-1,C=this.getBwEstimate(),x=a.levels,y=x[p],D=Math.max(h.loaded,Math.round(u*(n.bitrate||y.averageBitrate)/8));let P=A?d-R:d;P<1&&A&&(P=Math.min(d,h.loaded*8/C));const H=A?h.loaded*1e3/P:0,w=_/1e3,F=H?(D-h.loaded)/H:D*8/C+w;if(F<=b)return;const O=H?H*8:C,z=((i=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,N=this.hls.config.abrBandWidthUpFactor;let k=Number.POSITIVE_INFINITY,q;for(q=p-1;q>f;q--){const ee=x[q].maxBitrate,ie=!x[q].details||z;if(k=this.getTimeToLoadFrag(w,O,u*ee,ie),k<Math.min(b,u+w))break}if(k>=F||k>u*10)return;A?this.bwEstimator.sample(d-Math.min(_,R),h.loaded):this.bwEstimator.sampleTTFB(d);const G=x[q].maxBitrate;this.getBwEstimate()*N>G&&this.resetEstimator(G);const K=this.findBestLevel(G,f,q,0,b,1,1);K>-1&&(q=K),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${p} is loading too slowly;
|
|
3686
|
+
}`;function $g(s,e,t){let i=new xl;const n=new it,r=new it,a=new Ft,o=new Bg({depthPacking:3201}),l=new Gg,c={},h=t.maxTextureSize,u={0:1,1:0,2:2},d=new on({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new it},radius:{value:4}},vertexShader:Vg,fragmentShader:Hg}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ji;p.setAttribute("position",new Ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new mi(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let g=this.type;this.render=function(R,A,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||R.length===0)return;const x=s.getRenderTarget(),y=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(0),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const H=g!==3&&this.type===3,w=g===3&&this.type!==3;for(let F=0,O=R.length;F<O;F++){const z=R[F],N=z.shadow;if(N===void 0){console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");continue}if(N.autoUpdate===!1&&N.needsUpdate===!1)continue;n.copy(N.mapSize);const k=N.getFrameExtents();if(n.multiply(k),r.copy(N.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/k.x),n.x=r.x*k.x,N.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/k.y),n.y=r.y*k.y,N.mapSize.y=r.y)),N.map===null||H===!0||w===!0){const G=this.type!==3?{minFilter:1003,magFilter:1003}:{};N.map!==null&&N.map.dispose(),N.map=new nn(n.x,n.y,G),N.map.texture.name=z.name+".shadowMap",N.camera.updateProjectionMatrix()}s.setRenderTarget(N.map),s.clear();const q=N.getViewportCount();for(let G=0;G<q;G++){const K=N.getViewport(G);a.set(r.x*K.x,r.y*K.y,r.x*K.z,r.y*K.w),P.viewport(a),N.updateMatrices(z,G),i=N.getFrustum(),T(A,C,N.camera,z,this.type)}N.isPointLightShadow!==!0&&this.type===3&&E(N,C),N.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(x,y,D)};function E(R,A){const C=e.update(v);d.defines.VSM_SAMPLES!==R.blurSamples&&(d.defines.VSM_SAMPLES=R.blurSamples,f.defines.VSM_SAMPLES=R.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),R.mapPass===null&&(R.mapPass=new nn(n.x,n.y)),d.uniforms.shadow_pass.value=R.map.texture,d.uniforms.resolution.value=R.mapSize,d.uniforms.radius.value=R.radius,s.setRenderTarget(R.mapPass),s.clear(),s.renderBufferDirect(A,null,C,d,v,null),f.uniforms.shadow_pass.value=R.mapPass.texture,f.uniforms.resolution.value=R.mapSize,f.uniforms.radius.value=R.radius,s.setRenderTarget(R.map),s.clear(),s.renderBufferDirect(A,null,C,f,v,null)}function _(R,A,C,x){let y=null;const D=C.isPointLight===!0?R.customDistanceMaterial:R.customDepthMaterial;if(D!==void 0)y=D;else if(y=C.isPointLight===!0?l:o,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const P=y.uuid,H=A.uuid;let w=c[P];w===void 0&&(w={},c[P]=w);let F=w[H];F===void 0&&(F=y.clone(),w[H]=F,A.addEventListener("dispose",b)),y=F}if(y.visible=A.visible,y.wireframe=A.wireframe,x===3?y.side=A.shadowSide!==null?A.shadowSide:A.side:y.side=A.shadowSide!==null?A.shadowSide:u[A.side],y.alphaMap=A.alphaMap,y.alphaTest=A.alphaTest,y.map=A.map,y.clipShadows=A.clipShadows,y.clippingPlanes=A.clippingPlanes,y.clipIntersection=A.clipIntersection,y.displacementMap=A.displacementMap,y.displacementScale=A.displacementScale,y.displacementBias=A.displacementBias,y.wireframeLinewidth=A.wireframeLinewidth,y.linewidth=A.linewidth,C.isPointLight===!0&&y.isMeshDistanceMaterial===!0){const P=s.properties.get(y);P.light=C}return y}function T(R,A,C,x,y){if(R.visible===!1)return;if(R.layers.test(A.layers)&&(R.isMesh||R.isLine||R.isPoints)&&(R.castShadow||R.receiveShadow&&y===3)&&(!R.frustumCulled||i.intersectsObject(R))){R.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,R.matrixWorld);const H=e.update(R),w=R.material;if(Array.isArray(w)){const F=H.groups;for(let O=0,z=F.length;O<z;O++){const N=F[O],k=w[N.materialIndex];if(k&&k.visible){const q=_(R,k,x,y);R.onBeforeShadow(s,R,A,C,H,q,N),s.renderBufferDirect(C,null,H,q,R,N),R.onAfterShadow(s,R,A,C,H,q,N)}}}else if(w.visible){const F=_(R,w,x,y);R.onBeforeShadow(s,R,A,C,H,F,null),s.renderBufferDirect(C,null,H,F,R,null),R.onAfterShadow(s,R,A,C,H,F,null)}}const P=R.children;for(let H=0,w=P.length;H<w;H++)T(P[H],A,C,x,y)}function b(R){R.target.removeEventListener("dispose",b);for(const C in c){const x=c[C],y=R.target.uuid;y in x&&(x[y].dispose(),delete x[y])}}}function zg(s,e,t){const i=t.isWebGL2;function n(){let U=!1;const fe=new Ft;let pe=null;const Pe=new Ft(0,0,0,0);return{setMask:function(Ce){pe!==Ce&&!U&&(s.colorMask(Ce,Ce,Ce,Ce),pe=Ce)},setLocked:function(Ce){U=Ce},setClear:function(Ce,lt,ct,wt,$t){$t===!0&&(Ce*=wt,lt*=wt,ct*=wt),fe.set(Ce,lt,ct,wt),Pe.equals(fe)===!1&&(s.clearColor(Ce,lt,ct,wt),Pe.copy(fe))},reset:function(){U=!1,pe=null,Pe.set(-1,0,0,0)}}}function r(){let U=!1,fe=null,pe=null,Pe=null;return{setTest:function(Ce){Ce?be(s.DEPTH_TEST):Te(s.DEPTH_TEST)},setMask:function(Ce){fe!==Ce&&!U&&(s.depthMask(Ce),fe=Ce)},setFunc:function(Ce){if(pe!==Ce){switch(Ce){case 0:s.depthFunc(s.NEVER);break;case 1:s.depthFunc(s.ALWAYS);break;case 2:s.depthFunc(s.LESS);break;case 3:s.depthFunc(s.LEQUAL);break;case 4:s.depthFunc(s.EQUAL);break;case 5:s.depthFunc(s.GEQUAL);break;case 6:s.depthFunc(s.GREATER);break;case 7:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}pe=Ce}},setLocked:function(Ce){U=Ce},setClear:function(Ce){Pe!==Ce&&(s.clearDepth(Ce),Pe=Ce)},reset:function(){U=!1,fe=null,pe=null,Pe=null}}}function a(){let U=!1,fe=null,pe=null,Pe=null,Ce=null,lt=null,ct=null,wt=null,$t=null;return{setTest:function(ht){U||(ht?be(s.STENCIL_TEST):Te(s.STENCIL_TEST))},setMask:function(ht){fe!==ht&&!U&&(s.stencilMask(ht),fe=ht)},setFunc:function(ht,zt,Ii){(pe!==ht||Pe!==zt||Ce!==Ii)&&(s.stencilFunc(ht,zt,Ii),pe=ht,Pe=zt,Ce=Ii)},setOp:function(ht,zt,Ii){(lt!==ht||ct!==zt||wt!==Ii)&&(s.stencilOp(ht,zt,Ii),lt=ht,ct=zt,wt=Ii)},setLocked:function(ht){U=ht},setClear:function(ht){$t!==ht&&(s.clearStencil(ht),$t=ht)},reset:function(){U=!1,fe=null,pe=null,Pe=null,Ce=null,lt=null,ct=null,wt=null,$t=null}}}const o=new n,l=new r,c=new a,h=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,v=[],m=null,g=!1,E=null,_=null,T=null,b=null,R=null,A=null,C=null,x=new st(0,0,0),y=0,D=!1,P=null,H=null,w=null,F=null,O=null;const z=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let N=!1,k=0;const q=s.getParameter(s.VERSION);q.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(q)[1]),N=k>=1):q.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),N=k>=2);let G=null,K={};const $=s.getParameter(s.SCISSOR_BOX),ee=s.getParameter(s.VIEWPORT),ie=new Ft().fromArray($),oe=new Ft().fromArray(ee);function me(U,fe,pe,Pe){const Ce=new Uint8Array(4),lt=s.createTexture();s.bindTexture(U,lt),s.texParameteri(U,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(U,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let ct=0;ct<pe;ct++)i&&(U===s.TEXTURE_3D||U===s.TEXTURE_2D_ARRAY)?s.texImage3D(fe,0,s.RGBA,1,1,Pe,0,s.RGBA,s.UNSIGNED_BYTE,Ce):s.texImage2D(fe+ct,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Ce);return lt}const xe={};xe[s.TEXTURE_2D]=me(s.TEXTURE_2D,s.TEXTURE_2D,1),xe[s.TEXTURE_CUBE_MAP]=me(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(xe[s.TEXTURE_2D_ARRAY]=me(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),xe[s.TEXTURE_3D]=me(s.TEXTURE_3D,s.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),l.setClear(1),c.setClear(0),be(s.DEPTH_TEST),l.setFunc(3),Me(!1),I(1),be(s.CULL_FACE),le(0);function be(U){d[U]!==!0&&(s.enable(U),d[U]=!0)}function Te(U){d[U]!==!1&&(s.disable(U),d[U]=!1)}function Ge(U,fe){return f[U]!==fe?(s.bindFramebuffer(U,fe),f[U]=fe,i&&(U===s.DRAW_FRAMEBUFFER&&(f[s.FRAMEBUFFER]=fe),U===s.FRAMEBUFFER&&(f[s.DRAW_FRAMEBUFFER]=fe)),!0):!1}function Y(U,fe){let pe=v,Pe=!1;if(U)if(pe=p.get(fe),pe===void 0&&(pe=[],p.set(fe,pe)),U.isWebGLMultipleRenderTargets){const Ce=U.texture;if(pe.length!==Ce.length||pe[0]!==s.COLOR_ATTACHMENT0){for(let lt=0,ct=Ce.length;lt<ct;lt++)pe[lt]=s.COLOR_ATTACHMENT0+lt;pe.length=Ce.length,Pe=!0}}else pe[0]!==s.COLOR_ATTACHMENT0&&(pe[0]=s.COLOR_ATTACHMENT0,Pe=!0);else pe[0]!==s.BACK&&(pe[0]=s.BACK,Pe=!0);Pe&&(t.isWebGL2?s.drawBuffers(pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(pe))}function Rt(U){return m!==U?(s.useProgram(U),m=U,!0):!1}const Re={100:s.FUNC_ADD,101:s.FUNC_SUBTRACT,102:s.FUNC_REVERSE_SUBTRACT};if(i)Re[103]=s.MIN,Re[104]=s.MAX;else{const U=e.get("EXT_blend_minmax");U!==null&&(Re[103]=U.MIN_EXT,Re[104]=U.MAX_EXT)}const Ue={200:s.ZERO,201:s.ONE,202:s.SRC_COLOR,204:s.SRC_ALPHA,210:s.SRC_ALPHA_SATURATE,208:s.DST_COLOR,206:s.DST_ALPHA,203:s.ONE_MINUS_SRC_COLOR,205:s.ONE_MINUS_SRC_ALPHA,209:s.ONE_MINUS_DST_COLOR,207:s.ONE_MINUS_DST_ALPHA,211:s.CONSTANT_COLOR,212:s.ONE_MINUS_CONSTANT_COLOR,213:s.CONSTANT_ALPHA,214:s.ONE_MINUS_CONSTANT_ALPHA};function le(U,fe,pe,Pe,Ce,lt,ct,wt,$t,ht){if(U===0){g===!0&&(Te(s.BLEND),g=!1);return}if(g===!1&&(be(s.BLEND),g=!0),U!==5){if(U!==E||ht!==D){if((_!==100||R!==100)&&(s.blendEquation(s.FUNC_ADD),_=100,R=100),ht)switch(U){case 1:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case 2:s.blendFunc(s.ONE,s.ONE);break;case 3:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case 4:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}else switch(U){case 1:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case 2:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case 3:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case 4:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",U);break}T=null,b=null,A=null,C=null,x.set(0,0,0),y=0,E=U,D=ht}return}Ce=Ce||fe,lt=lt||pe,ct=ct||Pe,(fe!==_||Ce!==R)&&(s.blendEquationSeparate(Re[fe],Re[Ce]),_=fe,R=Ce),(pe!==T||Pe!==b||lt!==A||ct!==C)&&(s.blendFuncSeparate(Ue[pe],Ue[Pe],Ue[lt],Ue[ct]),T=pe,b=Pe,A=lt,C=ct),(wt.equals(x)===!1||$t!==y)&&(s.blendColor(wt.r,wt.g,wt.b,$t),x.copy(wt),y=$t),E=U,D=!1}function $e(U,fe){U.side===2?Te(s.CULL_FACE):be(s.CULL_FACE);let pe=U.side===1;fe&&(pe=!pe),Me(pe),U.blending===1&&U.transparent===!1?le(0):le(U.blending,U.blendEquation,U.blendSrc,U.blendDst,U.blendEquationAlpha,U.blendSrcAlpha,U.blendDstAlpha,U.blendColor,U.blendAlpha,U.premultipliedAlpha),l.setFunc(U.depthFunc),l.setTest(U.depthTest),l.setMask(U.depthWrite),o.setMask(U.colorWrite);const Pe=U.stencilWrite;c.setTest(Pe),Pe&&(c.setMask(U.stencilWriteMask),c.setFunc(U.stencilFunc,U.stencilRef,U.stencilFuncMask),c.setOp(U.stencilFail,U.stencilZFail,U.stencilZPass)),X(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),U.alphaToCoverage===!0?be(s.SAMPLE_ALPHA_TO_COVERAGE):Te(s.SAMPLE_ALPHA_TO_COVERAGE)}function Me(U){P!==U&&(U?s.frontFace(s.CW):s.frontFace(s.CCW),P=U)}function I(U){U!==0?(be(s.CULL_FACE),U!==H&&(U===1?s.cullFace(s.BACK):U===2?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Te(s.CULL_FACE),H=U}function M(U){U!==w&&(N&&s.lineWidth(U),w=U)}function X(U,fe,pe){U?(be(s.POLYGON_OFFSET_FILL),(F!==fe||O!==pe)&&(s.polygonOffset(fe,pe),F=fe,O=pe)):Te(s.POLYGON_OFFSET_FILL)}function ne(U){U?be(s.SCISSOR_TEST):Te(s.SCISSOR_TEST)}function re(U){U===void 0&&(U=s.TEXTURE0+z-1),G!==U&&(s.activeTexture(U),G=U)}function ae(U,fe,pe){pe===void 0&&(G===null?pe=s.TEXTURE0+z-1:pe=G);let Pe=K[pe];Pe===void 0&&(Pe={type:void 0,texture:void 0},K[pe]=Pe),(Pe.type!==U||Pe.texture!==fe)&&(G!==pe&&(s.activeTexture(pe),G=pe),s.bindTexture(U,fe||xe[U]),Pe.type=U,Pe.texture=fe)}function ye(){const U=K[G];U!==void 0&&U.type!==void 0&&(s.bindTexture(U.type,null),U.type=void 0,U.texture=void 0)}function ue(){try{s.compressedTexImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function _e(){try{s.compressedTexImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ie(){try{s.texSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ke(){try{s.texSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function se(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ze(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Qe(){try{s.texStorage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Ne(){try{s.texStorage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Le(){try{s.texImage2D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function Se(){try{s.texImage3D.apply(s,arguments)}catch(U){console.error("THREE.WebGLState:",U)}}function ze(U){ie.equals(U)===!1&&(s.scissor(U.x,U.y,U.z,U.w),ie.copy(U))}function tt(U){oe.equals(U)===!1&&(s.viewport(U.x,U.y,U.z,U.w),oe.copy(U))}function vt(U,fe){let pe=u.get(fe);pe===void 0&&(pe=new WeakMap,u.set(fe,pe));let Pe=pe.get(U);Pe===void 0&&(Pe=s.getUniformBlockIndex(fe,U.name),pe.set(U,Pe))}function qe(U,fe){const Pe=u.get(fe).get(U);h.get(fe)!==Pe&&(s.uniformBlockBinding(fe,Pe,U.__bindingPointIndex),h.set(fe,Pe))}function he(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),i===!0&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null)),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),d={},G=null,K={},f={},p=new WeakMap,v=[],m=null,g=!1,E=null,_=null,T=null,b=null,R=null,A=null,C=null,x=new st(0,0,0),y=0,D=!1,P=null,H=null,w=null,F=null,O=null,ie.set(0,0,s.canvas.width,s.canvas.height),oe.set(0,0,s.canvas.width,s.canvas.height),o.reset(),l.reset(),c.reset()}return{buffers:{color:o,depth:l,stencil:c},enable:be,disable:Te,bindFramebuffer:Ge,drawBuffers:Y,useProgram:Rt,setBlending:le,setMaterial:$e,setFlipSided:Me,setCullFace:I,setLineWidth:M,setPolygonOffset:X,setScissorTest:ne,activeTexture:re,bindTexture:ae,unbindTexture:ye,compressedTexImage2D:ue,compressedTexImage3D:_e,texImage2D:Le,texImage3D:Se,updateUBOMapping:vt,uniformBlockBinding:qe,texStorage2D:Qe,texStorage3D:Ne,texSubImage2D:Ie,texSubImage3D:ke,compressedTexSubImage2D:se,compressedTexSubImage3D:Ze,scissor:ze,viewport:tt,reset:he}}function Wg(s,e,t,i,n,r,a){const o=n.isWebGL2,l=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(I,M){return f?new OffscreenCanvas(I,M):Cs("canvas")}function v(I,M,X,ne){let re=1;if((I.width>ne||I.height>ne)&&(re=ne/Math.max(I.width,I.height)),re<1||M===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){const ae=M?ea:Math.floor,ye=ae(re*I.width),ue=ae(re*I.height);u===void 0&&(u=p(ye,ue));const _e=X?p(ye,ue):u;return _e.width=ye,_e.height=ue,_e.getContext("2d").drawImage(I,0,0,ye,ue),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+ye+"x"+ue+")."),_e}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function m(I){return Xo(I.width)&&Xo(I.height)}function g(I){return o?!1:I.wrapS!==1001||I.wrapT!==1001||I.minFilter!==1003&&I.minFilter!==1006}function E(I,M){return I.generateMipmaps&&M&&I.minFilter!==1003&&I.minFilter!==1006}function _(I){s.generateMipmap(I)}function T(I,M,X,ne,re=!1){if(o===!1)return M;if(I!==null){if(s[I]!==void 0)return s[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let ae=M;if(M===s.RED&&(X===s.FLOAT&&(ae=s.R32F),X===s.HALF_FLOAT&&(ae=s.R16F),X===s.UNSIGNED_BYTE&&(ae=s.R8)),M===s.RED_INTEGER&&(X===s.UNSIGNED_BYTE&&(ae=s.R8UI),X===s.UNSIGNED_SHORT&&(ae=s.R16UI),X===s.UNSIGNED_INT&&(ae=s.R32UI),X===s.BYTE&&(ae=s.R8I),X===s.SHORT&&(ae=s.R16I),X===s.INT&&(ae=s.R32I)),M===s.RG&&(X===s.FLOAT&&(ae=s.RG32F),X===s.HALF_FLOAT&&(ae=s.RG16F),X===s.UNSIGNED_BYTE&&(ae=s.RG8)),M===s.RGBA){const ye=re?Ms:nt.getTransfer(ne);X===s.FLOAT&&(ae=s.RGBA32F),X===s.HALF_FLOAT&&(ae=s.RGBA16F),X===s.UNSIGNED_BYTE&&(ae=ye===ut?s.SRGB8_ALPHA8:s.RGBA8),X===s.UNSIGNED_SHORT_4_4_4_4&&(ae=s.RGBA4),X===s.UNSIGNED_SHORT_5_5_5_1&&(ae=s.RGB5_A1)}return(ae===s.R16F||ae===s.R32F||ae===s.RG16F||ae===s.RG32F||ae===s.RGBA16F||ae===s.RGBA32F)&&e.get("EXT_color_buffer_float"),ae}function b(I,M,X){return E(I,X)===!0||I.isFramebufferTexture&&I.minFilter!==1003&&I.minFilter!==1006?Math.log2(Math.max(M.width,M.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?M.mipmaps.length:1}function R(I){return I===1003||I===1004||I===1005?s.NEAREST:s.LINEAR}function A(I){const M=I.target;M.removeEventListener("dispose",A),x(M),M.isVideoTexture&&h.delete(M)}function C(I){const M=I.target;M.removeEventListener("dispose",C),D(M)}function x(I){const M=i.get(I);if(M.__webglInit===void 0)return;const X=I.source,ne=d.get(X);if(ne){const re=ne[M.__cacheKey];re.usedTimes--,re.usedTimes===0&&y(I),Object.keys(ne).length===0&&d.delete(X)}i.remove(I)}function y(I){const M=i.get(I);s.deleteTexture(M.__webglTexture);const X=I.source,ne=d.get(X);delete ne[M.__cacheKey],a.memory.textures--}function D(I){const M=I.texture,X=i.get(I),ne=i.get(M);if(ne.__webglTexture!==void 0&&(s.deleteTexture(ne.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(X.__webglFramebuffer[re]))for(let ae=0;ae<X.__webglFramebuffer[re].length;ae++)s.deleteFramebuffer(X.__webglFramebuffer[re][ae]);else s.deleteFramebuffer(X.__webglFramebuffer[re]);X.__webglDepthbuffer&&s.deleteRenderbuffer(X.__webglDepthbuffer[re])}else{if(Array.isArray(X.__webglFramebuffer))for(let re=0;re<X.__webglFramebuffer.length;re++)s.deleteFramebuffer(X.__webglFramebuffer[re]);else s.deleteFramebuffer(X.__webglFramebuffer);if(X.__webglDepthbuffer&&s.deleteRenderbuffer(X.__webglDepthbuffer),X.__webglMultisampledFramebuffer&&s.deleteFramebuffer(X.__webglMultisampledFramebuffer),X.__webglColorRenderbuffer)for(let re=0;re<X.__webglColorRenderbuffer.length;re++)X.__webglColorRenderbuffer[re]&&s.deleteRenderbuffer(X.__webglColorRenderbuffer[re]);X.__webglDepthRenderbuffer&&s.deleteRenderbuffer(X.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let re=0,ae=M.length;re<ae;re++){const ye=i.get(M[re]);ye.__webglTexture&&(s.deleteTexture(ye.__webglTexture),a.memory.textures--),i.remove(M[re])}i.remove(M),i.remove(I)}let P=0;function H(){P=0}function w(){const I=P;return I>=n.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+n.maxTextures),P+=1,I}function F(I){const M=[];return M.push(I.wrapS),M.push(I.wrapT),M.push(I.wrapR||0),M.push(I.magFilter),M.push(I.minFilter),M.push(I.anisotropy),M.push(I.internalFormat),M.push(I.format),M.push(I.type),M.push(I.generateMipmaps),M.push(I.premultiplyAlpha),M.push(I.flipY),M.push(I.unpackAlignment),M.push(I.colorSpace),M.join()}function O(I,M){const X=i.get(I);if(I.isVideoTexture&&$e(I),I.isRenderTargetTexture===!1&&I.version>0&&X.__version!==I.version){const ne=I.image;if(ne===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ne.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(X,I,M);return}}t.bindTexture(s.TEXTURE_2D,X.__webglTexture,s.TEXTURE0+M)}function z(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){ie(X,I,M);return}t.bindTexture(s.TEXTURE_2D_ARRAY,X.__webglTexture,s.TEXTURE0+M)}function N(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){ie(X,I,M);return}t.bindTexture(s.TEXTURE_3D,X.__webglTexture,s.TEXTURE0+M)}function k(I,M){const X=i.get(I);if(I.version>0&&X.__version!==I.version){oe(X,I,M);return}t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture,s.TEXTURE0+M)}const q={1e3:s.REPEAT,1001:s.CLAMP_TO_EDGE,1002:s.MIRRORED_REPEAT},G={1003:s.NEAREST,1004:s.NEAREST_MIPMAP_NEAREST,1005:s.NEAREST_MIPMAP_LINEAR,1006:s.LINEAR,1007:s.LINEAR_MIPMAP_NEAREST,1008:s.LINEAR_MIPMAP_LINEAR},K={512:s.NEVER,519:s.ALWAYS,513:s.LESS,515:s.LEQUAL,514:s.EQUAL,518:s.GEQUAL,516:s.GREATER,517:s.NOTEQUAL};function $(I,M,X){if(X?(s.texParameteri(I,s.TEXTURE_WRAP_S,q[M.wrapS]),s.texParameteri(I,s.TEXTURE_WRAP_T,q[M.wrapT]),(I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY)&&s.texParameteri(I,s.TEXTURE_WRAP_R,q[M.wrapR]),s.texParameteri(I,s.TEXTURE_MAG_FILTER,G[M.magFilter]),s.texParameteri(I,s.TEXTURE_MIN_FILTER,G[M.minFilter])):(s.texParameteri(I,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(I,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY)&&s.texParameteri(I,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(M.wrapS!==1001||M.wrapT!==1001)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(I,s.TEXTURE_MAG_FILTER,R(M.magFilter)),s.texParameteri(I,s.TEXTURE_MIN_FILTER,R(M.minFilter)),M.minFilter!==1003&&M.minFilter!==1006&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(s.texParameteri(I,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(I,s.TEXTURE_COMPARE_FUNC,K[M.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ne=e.get("EXT_texture_filter_anisotropic");if(M.magFilter===1003||M.minFilter!==1005&&M.minFilter!==1008||M.type===1015&&e.has("OES_texture_float_linear")===!1||o===!1&&M.type===1016&&e.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||i.get(M).__currentAnisotropy)&&(s.texParameterf(I,ne.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,n.getMaxAnisotropy())),i.get(M).__currentAnisotropy=M.anisotropy)}}function ee(I,M){let X=!1;I.__webglInit===void 0&&(I.__webglInit=!0,M.addEventListener("dispose",A));const ne=M.source;let re=d.get(ne);re===void 0&&(re={},d.set(ne,re));const ae=F(M);if(ae!==I.__cacheKey){re[ae]===void 0&&(re[ae]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,X=!0),re[ae].usedTimes++;const ye=re[I.__cacheKey];ye!==void 0&&(re[I.__cacheKey].usedTimes--,ye.usedTimes===0&&y(M)),I.__cacheKey=ae,I.__webglTexture=re[ae].texture}return X}function ie(I,M,X){let ne=s.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(ne=s.TEXTURE_2D_ARRAY),M.isData3DTexture&&(ne=s.TEXTURE_3D);const re=ee(I,M),ae=M.source;t.bindTexture(ne,I.__webglTexture,s.TEXTURE0+X);const ye=i.get(ae);if(ae.version!==ye.__version||re===!0){t.activeTexture(s.TEXTURE0+X);const ue=nt.getPrimaries(nt.workingColorSpace),_e=M.colorSpace===ri?null:nt.getPrimaries(M.colorSpace),Ie=M.colorSpace===ri||ue===_e?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ie);const ke=g(M)&&m(M.image)===!1;let se=v(M.image,ke,!1,n.maxTextureSize);se=Me(M,se);const Ze=m(se)||o,Qe=r.convert(M.format,M.colorSpace);let Ne=r.convert(M.type),Le=T(M.internalFormat,Qe,Ne,M.colorSpace,M.isVideoTexture);$(ne,M,Ze);let Se;const ze=M.mipmaps,tt=o&&M.isVideoTexture!==!0&&Le!==36196,vt=ye.__version===void 0||re===!0,qe=b(M,se,Ze);if(M.isDepthTexture)Le=s.DEPTH_COMPONENT,o?M.type===1015?Le=s.DEPTH_COMPONENT32F:M.type===1014?Le=s.DEPTH_COMPONENT24:M.type===1020?Le=s.DEPTH24_STENCIL8:Le=s.DEPTH_COMPONENT16:M.type===1015&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===1026&&Le===s.DEPTH_COMPONENT&&M.type!==1012&&M.type!==1014&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=1014,Ne=r.convert(M.type)),M.format===1027&&Le===s.DEPTH_COMPONENT&&(Le=s.DEPTH_STENCIL,M.type!==1020&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=1020,Ne=r.convert(M.type))),vt&&(tt?t.texStorage2D(s.TEXTURE_2D,1,Le,se.width,se.height):t.texImage2D(s.TEXTURE_2D,0,Le,se.width,se.height,0,Qe,Ne,null));else if(M.isDataTexture)if(ze.length>0&&Ze){tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Ne,Se.data):t.texImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Qe,Ne,Se.data);M.generateMipmaps=!1}else tt?(vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,se.width,se.height,Qe,Ne,se.data)):t.texImage2D(s.TEXTURE_2D,0,Le,se.width,se.height,0,Qe,Ne,se.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){tt&&vt&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,Le,ze[0].width,ze[0].height,se.depth);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],M.format!==1023?Qe!==null?tt?t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,he,0,0,0,Se.width,Se.height,se.depth,Qe,Se.data,0,0):t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,he,Le,Se.width,Se.height,se.depth,0,Se.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage3D(s.TEXTURE_2D_ARRAY,he,0,0,0,Se.width,Se.height,se.depth,Qe,Ne,Se.data):t.texImage3D(s.TEXTURE_2D_ARRAY,he,Le,Se.width,Se.height,se.depth,0,Qe,Ne,Se.data)}else{tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],M.format!==1023?Qe!==null?tt?t.compressedTexSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Se.data):t.compressedTexImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Se.width,Se.height,Qe,Ne,Se.data):t.texImage2D(s.TEXTURE_2D,he,Le,Se.width,Se.height,0,Qe,Ne,Se.data)}else if(M.isDataArrayTexture)tt?(vt&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,Le,se.width,se.height,se.depth),t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,se.width,se.height,se.depth,Qe,Ne,se.data)):t.texImage3D(s.TEXTURE_2D_ARRAY,0,Le,se.width,se.height,se.depth,0,Qe,Ne,se.data);else if(M.isData3DTexture)tt?(vt&&t.texStorage3D(s.TEXTURE_3D,qe,Le,se.width,se.height,se.depth),t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,se.width,se.height,se.depth,Qe,Ne,se.data)):t.texImage3D(s.TEXTURE_3D,0,Le,se.width,se.height,se.depth,0,Qe,Ne,se.data);else if(M.isFramebufferTexture){if(vt)if(tt)t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height);else{let he=se.width,U=se.height;for(let fe=0;fe<qe;fe++)t.texImage2D(s.TEXTURE_2D,fe,Le,he,U,0,Qe,Ne,null),he>>=1,U>>=1}}else if(ze.length>0&&Ze){tt&&vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,ze[0].width,ze[0].height);for(let he=0,U=ze.length;he<U;he++)Se=ze[he],tt?t.texSubImage2D(s.TEXTURE_2D,he,0,0,Qe,Ne,Se):t.texImage2D(s.TEXTURE_2D,he,Le,Qe,Ne,Se);M.generateMipmaps=!1}else tt?(vt&&t.texStorage2D(s.TEXTURE_2D,qe,Le,se.width,se.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,Qe,Ne,se)):t.texImage2D(s.TEXTURE_2D,0,Le,Qe,Ne,se);E(M,Ze)&&_(ne),ye.__version=ae.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function oe(I,M,X){if(M.image.length!==6)return;const ne=ee(I,M),re=M.source;t.bindTexture(s.TEXTURE_CUBE_MAP,I.__webglTexture,s.TEXTURE0+X);const ae=i.get(re);if(re.version!==ae.__version||ne===!0){t.activeTexture(s.TEXTURE0+X);const ye=nt.getPrimaries(nt.workingColorSpace),ue=M.colorSpace===ri?null:nt.getPrimaries(M.colorSpace),_e=M.colorSpace===ri||ye===ue?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,M.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,M.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,_e);const Ie=M.isCompressedTexture||M.image[0].isCompressedTexture,ke=M.image[0]&&M.image[0].isDataTexture,se=[];for(let he=0;he<6;he++)!Ie&&!ke?se[he]=v(M.image[he],!1,!0,n.maxCubemapSize):se[he]=ke?M.image[he].image:M.image[he],se[he]=Me(M,se[he]);const Ze=se[0],Qe=m(Ze)||o,Ne=r.convert(M.format,M.colorSpace),Le=r.convert(M.type),Se=T(M.internalFormat,Ne,Le,M.colorSpace),ze=o&&M.isVideoTexture!==!0,tt=ae.__version===void 0||ne===!0;let vt=b(M,Ze,Qe);$(s.TEXTURE_CUBE_MAP,M,Qe);let qe;if(Ie){ze&&tt&&t.texStorage2D(s.TEXTURE_CUBE_MAP,vt,Se,Ze.width,Ze.height);for(let he=0;he<6;he++){qe=se[he].mipmaps;for(let U=0;U<qe.length;U++){const fe=qe[U];M.format!==1023?Ne!==null?ze?t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,0,0,fe.width,fe.height,Ne,fe.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,Se,fe.width,fe.height,0,fe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,0,0,fe.width,fe.height,Ne,Le,fe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U,Se,fe.width,fe.height,0,Ne,Le,fe.data)}}}else{qe=M.mipmaps,ze&&tt&&(qe.length>0&&vt++,t.texStorage2D(s.TEXTURE_CUBE_MAP,vt,Se,se[0].width,se[0].height));for(let he=0;he<6;he++)if(ke){ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,0,0,se[he].width,se[he].height,Ne,Le,se[he].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,Se,se[he].width,se[he].height,0,Ne,Le,se[he].data);for(let U=0;U<qe.length;U++){const pe=qe[U].image[he].image;ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,0,0,pe.width,pe.height,Ne,Le,pe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,Se,pe.width,pe.height,0,Ne,Le,pe.data)}}else{ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,0,0,Ne,Le,se[he]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,0,Se,Ne,Le,se[he]);for(let U=0;U<qe.length;U++){const fe=qe[U];ze?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,0,0,Ne,Le,fe.image[he]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+he,U+1,Se,Ne,Le,fe.image[he])}}}E(M,Qe)&&_(s.TEXTURE_CUBE_MAP),ae.__version=re.version,M.onUpdate&&M.onUpdate(M)}I.__version=M.version}function me(I,M,X,ne,re,ae){const ye=r.convert(X.format,X.colorSpace),ue=r.convert(X.type),_e=T(X.internalFormat,ye,ue,X.colorSpace);if(!i.get(M).__hasExternalTextures){const ke=Math.max(1,M.width>>ae),se=Math.max(1,M.height>>ae);re===s.TEXTURE_3D||re===s.TEXTURE_2D_ARRAY?t.texImage3D(re,ae,_e,ke,se,M.depth,0,ye,ue,null):t.texImage2D(re,ae,_e,ke,se,0,ye,ue,null)}t.bindFramebuffer(s.FRAMEBUFFER,I),le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,ne,re,i.get(X).__webglTexture,0,Ue(M)):(re===s.TEXTURE_2D||re>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&re<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,ne,re,i.get(X).__webglTexture,ae),t.bindFramebuffer(s.FRAMEBUFFER,null)}function xe(I,M,X){if(s.bindRenderbuffer(s.RENDERBUFFER,I),M.depthBuffer&&!M.stencilBuffer){let ne=o===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(X||le(M)){const re=M.depthTexture;re&&re.isDepthTexture&&(re.type===1015?ne=s.DEPTH_COMPONENT32F:re.type===1014&&(ne=s.DEPTH_COMPONENT24));const ae=Ue(M);le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ae,ne,M.width,M.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,ae,ne,M.width,M.height)}else s.renderbufferStorage(s.RENDERBUFFER,ne,M.width,M.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,I)}else if(M.depthBuffer&&M.stencilBuffer){const ne=Ue(M);X&&le(M)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,ne,s.DEPTH24_STENCIL8,M.width,M.height):le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,ne,s.DEPTH24_STENCIL8,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,M.width,M.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,I)}else{const ne=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let re=0;re<ne.length;re++){const ae=ne[re],ye=r.convert(ae.format,ae.colorSpace),ue=r.convert(ae.type),_e=T(ae.internalFormat,ye,ue,ae.colorSpace),Ie=Ue(M);X&&le(M)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ie,_e,M.width,M.height):le(M)?l.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ie,_e,M.width,M.height):s.renderbufferStorage(s.RENDERBUFFER,_e,M.width,M.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function be(I,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,I),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),O(M.depthTexture,0);const ne=i.get(M.depthTexture).__webglTexture,re=Ue(M);if(M.depthTexture.format===1026)le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,ne,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,ne,0);else if(M.depthTexture.format===1027)le(M)?l.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,ne,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,ne,0);else throw new Error("Unknown depthTexture format")}function Te(I){const M=i.get(I),X=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!M.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");be(M.__webglFramebuffer,I)}else if(X){M.__webglDepthbuffer=[];for(let ne=0;ne<6;ne++)t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer[ne]),M.__webglDepthbuffer[ne]=s.createRenderbuffer(),xe(M.__webglDepthbuffer[ne],I,!1)}else t.bindFramebuffer(s.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer=s.createRenderbuffer(),xe(M.__webglDepthbuffer,I,!1);t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ge(I,M,X){const ne=i.get(I);M!==void 0&&me(ne.__webglFramebuffer,I,I.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),X!==void 0&&Te(I)}function Y(I){const M=I.texture,X=i.get(I),ne=i.get(M);I.addEventListener("dispose",C),I.isWebGLMultipleRenderTargets!==!0&&(ne.__webglTexture===void 0&&(ne.__webglTexture=s.createTexture()),ne.__version=M.version,a.memory.textures++);const re=I.isWebGLCubeRenderTarget===!0,ae=I.isWebGLMultipleRenderTargets===!0,ye=m(I)||o;if(re){X.__webglFramebuffer=[];for(let ue=0;ue<6;ue++)if(o&&M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer[ue]=[];for(let _e=0;_e<M.mipmaps.length;_e++)X.__webglFramebuffer[ue][_e]=s.createFramebuffer()}else X.__webglFramebuffer[ue]=s.createFramebuffer()}else{if(o&&M.mipmaps&&M.mipmaps.length>0){X.__webglFramebuffer=[];for(let ue=0;ue<M.mipmaps.length;ue++)X.__webglFramebuffer[ue]=s.createFramebuffer()}else X.__webglFramebuffer=s.createFramebuffer();if(ae)if(n.drawBuffers){const ue=I.texture;for(let _e=0,Ie=ue.length;_e<Ie;_e++){const ke=i.get(ue[_e]);ke.__webglTexture===void 0&&(ke.__webglTexture=s.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&I.samples>0&&le(I)===!1){const ue=ae?M:[M];X.__webglMultisampledFramebuffer=s.createFramebuffer(),X.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let _e=0;_e<ue.length;_e++){const Ie=ue[_e];X.__webglColorRenderbuffer[_e]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,X.__webglColorRenderbuffer[_e]);const ke=r.convert(Ie.format,Ie.colorSpace),se=r.convert(Ie.type),Ze=T(Ie.internalFormat,ke,se,Ie.colorSpace,I.isXRRenderTarget===!0),Qe=Ue(I);s.renderbufferStorageMultisample(s.RENDERBUFFER,Qe,Ze,I.width,I.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+_e,s.RENDERBUFFER,X.__webglColorRenderbuffer[_e])}s.bindRenderbuffer(s.RENDERBUFFER,null),I.depthBuffer&&(X.__webglDepthRenderbuffer=s.createRenderbuffer(),xe(X.__webglDepthRenderbuffer,I,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(re){t.bindTexture(s.TEXTURE_CUBE_MAP,ne.__webglTexture),$(s.TEXTURE_CUBE_MAP,M,ye);for(let ue=0;ue<6;ue++)if(o&&M.mipmaps&&M.mipmaps.length>0)for(let _e=0;_e<M.mipmaps.length;_e++)me(X.__webglFramebuffer[ue][_e],I,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,_e);else me(X.__webglFramebuffer[ue],I,M,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0);E(M,ye)&&_(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){const ue=I.texture;for(let _e=0,Ie=ue.length;_e<Ie;_e++){const ke=ue[_e],se=i.get(ke);t.bindTexture(s.TEXTURE_2D,se.__webglTexture),$(s.TEXTURE_2D,ke,ye),me(X.__webglFramebuffer,I,ke,s.COLOR_ATTACHMENT0+_e,s.TEXTURE_2D,0),E(ke,ye)&&_(s.TEXTURE_2D)}t.unbindTexture()}else{let ue=s.TEXTURE_2D;if((I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?ue=I.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(ue,ne.__webglTexture),$(ue,M,ye),o&&M.mipmaps&&M.mipmaps.length>0)for(let _e=0;_e<M.mipmaps.length;_e++)me(X.__webglFramebuffer[_e],I,M,s.COLOR_ATTACHMENT0,ue,_e);else me(X.__webglFramebuffer,I,M,s.COLOR_ATTACHMENT0,ue,0);E(M,ye)&&_(ue),t.unbindTexture()}I.depthBuffer&&Te(I)}function Rt(I){const M=m(I)||o,X=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ne=0,re=X.length;ne<re;ne++){const ae=X[ne];if(E(ae,M)){const ye=I.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,ue=i.get(ae).__webglTexture;t.bindTexture(ye,ue),_(ye),t.unbindTexture()}}}function Re(I){if(o&&I.samples>0&&le(I)===!1){const M=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],X=I.width,ne=I.height;let re=s.COLOR_BUFFER_BIT;const ae=[],ye=I.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ue=i.get(I),_e=I.isWebGLMultipleRenderTargets===!0;if(_e)for(let Ie=0;Ie<M.length;Ie++)t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ue.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ue.__webglFramebuffer);for(let Ie=0;Ie<M.length;Ie++){ae.push(s.COLOR_ATTACHMENT0+Ie),I.depthBuffer&&ae.push(ye);const ke=ue.__ignoreDepthValues!==void 0?ue.__ignoreDepthValues:!1;if(ke===!1&&(I.depthBuffer&&(re|=s.DEPTH_BUFFER_BIT),I.stencilBuffer&&(re|=s.STENCIL_BUFFER_BIT)),_e&&s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ue.__webglColorRenderbuffer[Ie]),ke===!0&&(s.invalidateFramebuffer(s.READ_FRAMEBUFFER,[ye]),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[ye])),_e){const se=i.get(M[Ie]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,se,0)}s.blitFramebuffer(0,0,X,ne,0,0,X,ne,re,s.NEAREST),c&&s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ae)}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),_e)for(let Ie=0;Ie<M.length;Ie++){t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.RENDERBUFFER,ue.__webglColorRenderbuffer[Ie]);const ke=i.get(M[Ie]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ue.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ie,s.TEXTURE_2D,ke,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ue.__webglMultisampledFramebuffer)}}function Ue(I){return Math.min(n.maxSamples,I.samples)}function le(I){const M=i.get(I);return o&&I.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function $e(I){const M=a.render.frame;h.get(I)!==M&&(h.set(I,M),I.update())}function Me(I,M){const X=I.colorSpace,ne=I.format,re=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===1035||X!==Ci&&X!==ri&&(nt.getTransfer(X)===ut?o===!1?e.has("EXT_sRGB")===!0&&ne===1023?(I.format=1035,I.minFilter=1006,I.generateMipmaps=!1):M=Zo.sRGBToLinear(M):(ne!==1023||re!==1009)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),M}this.allocateTextureUnit=w,this.resetTextureUnits=H,this.setTexture2D=O,this.setTexture2DArray=z,this.setTexture3D=N,this.setTextureCube=k,this.rebindTextures=Ge,this.setupRenderTarget=Y,this.updateRenderTargetMipmap=Rt,this.updateMultisampleRenderTarget=Re,this.setupDepthRenderbuffer=Te,this.setupFrameBufferTexture=me,this.useMultisampledRTT=le}function Kg(s,e,t){const i=t.isWebGL2;function n(r,a=ri){let o;const l=nt.getTransfer(a);if(r===1009)return s.UNSIGNED_BYTE;if(r===1017)return s.UNSIGNED_SHORT_4_4_4_4;if(r===1018)return s.UNSIGNED_SHORT_5_5_5_1;if(r===1010)return s.BYTE;if(r===1011)return s.SHORT;if(r===1012)return s.UNSIGNED_SHORT;if(r===1013)return s.INT;if(r===1014)return s.UNSIGNED_INT;if(r===1015)return s.FLOAT;if(r===1016)return i?s.HALF_FLOAT:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===1021)return s.ALPHA;if(r===1023)return s.RGBA;if(r===1024)return s.LUMINANCE;if(r===1025)return s.LUMINANCE_ALPHA;if(r===1026)return s.DEPTH_COMPONENT;if(r===1027)return s.DEPTH_STENCIL;if(r===1035)return o=e.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===1028)return s.RED;if(r===1029)return s.RED_INTEGER;if(r===1030)return s.RG;if(r===1031)return s.RG_INTEGER;if(r===1033)return s.RGBA_INTEGER;if(r===33776||r===33777||r===33778||r===33779)if(l===ut)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===33776)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===33777)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===33778)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===33779)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===33776)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===33777)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===33778)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===33779)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===35840||r===35841||r===35842||r===35843)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===35840)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===35841)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===35842)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===35843)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===36196)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===37492||r===37496)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(r===37492)return l===ut?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===37496)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===37808||r===37809||r===37810||r===37811||r===37812||r===37813||r===37814||r===37815||r===37816||r===37817||r===37818||r===37819||r===37820||r===37821)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(r===37808)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===37809)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===37810)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===37811)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===37812)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===37813)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===37814)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===37815)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===37816)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===37817)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===37818)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===37819)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===37820)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===37821)return l===ut?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===36492||r===36494||r===36495)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(r===36492)return l===ut?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===36494)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===36495)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===36283||r===36284||r===36285||r===36286)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(r===36492)return o.COMPRESSED_RED_RGTC1_EXT;if(r===36284)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===36285)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===36286)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===1020?i?s.UNSIGNED_INT_24_8:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):s[r]!==void 0?s[r]:null}return{convert:n}}class Xg extends oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class sr extends Jt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yg={type:"move"};class Ra{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new sr,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new sr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new sr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Q),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,i),g=this._getHandJoint(c,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;c.inputState.pinching&&d>f+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(n=t.getPose(e.targetRaySpace,i),n===null&&r!==null&&(n=r),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,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,this.dispatchEvent(Yg)))}return o!==null&&(o.visible=n!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new sr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class qg extends Sn{constructor(e,t){super();const i=this;let n=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,p=null;const v=t.getContextAttributes();let m=null,g=null;const E=[],_=[],T=new it;let b=null;const R=new oi;R.layers.enable(1),R.viewport=new Ft;const A=new oi;A.layers.enable(2),A.viewport=new Ft;const C=[R,A],x=new Xg;x.layers.enable(1),x.layers.enable(2);let y=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getGripSpace()},this.getHand=function($){let ee=E[$];return ee===void 0&&(ee=new Ra,E[$]=ee),ee.getHandSpace()};function P($){const ee=_.indexOf($.inputSource);if(ee===-1)return;const ie=E[ee];ie!==void 0&&(ie.update($.inputSource,$.frame,c||a),ie.dispatchEvent({type:$.type,data:$.inputSource}))}function H(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",H),n.removeEventListener("inputsourceschange",w);for(let $=0;$<E.length;$++){const ee=_[$];ee!==null&&(_[$]=null,E[$].disconnect(ee))}y=null,D=null,e.setRenderTarget(m),f=null,d=null,u=null,n=null,g=null,K.stop(),i.isPresenting=!1,e.setPixelRatio(b),e.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function($){if(n=$,n!==null){if(m=e.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",H),n.addEventListener("inputsourceschange",w),v.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(T),n.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ee={antialias:n.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(n,t,ee),n.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),g=new nn(f.framebufferWidth,f.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let ee=null,ie=null,oe=null;v.depth&&(oe=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ee=v.stencil?1027:1026,ie=v.stencil?1020:1014);const me={colorFormat:t.RGBA8,depthFormat:oe,scaleFactor:r};u=new XRWebGLBinding(n,t),d=u.createProjectionLayer(me),n.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new nn(d.textureWidth,d.textureHeight,{format:1023,type:1009,depthTexture:new Cl(d.textureWidth,d.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const xe=e.properties.get(g);xe.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),K.setContext(n),K.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode};function w($){for(let ee=0;ee<$.removed.length;ee++){const ie=$.removed[ee],oe=_.indexOf(ie);oe>=0&&(_[oe]=null,E[oe].disconnect(ie))}for(let ee=0;ee<$.added.length;ee++){const ie=$.added[ee];let oe=_.indexOf(ie);if(oe===-1){for(let xe=0;xe<E.length;xe++)if(xe>=_.length){_.push(ie),oe=xe;break}else if(_[xe]===null){_[xe]=ie,oe=xe;break}if(oe===-1)break}const me=E[oe];me&&me.connect(ie)}}const F=new Q,O=new Q;function z($,ee,ie){F.setFromMatrixPosition(ee.matrixWorld),O.setFromMatrixPosition(ie.matrixWorld);const oe=F.distanceTo(O),me=ee.projectionMatrix.elements,xe=ie.projectionMatrix.elements,be=me[14]/(me[10]-1),Te=me[14]/(me[10]+1),Ge=(me[9]+1)/me[5],Y=(me[9]-1)/me[5],Rt=(me[8]-1)/me[0],Re=(xe[8]+1)/xe[0],Ue=be*Rt,le=be*Re,$e=oe/(-Rt+Re),Me=$e*-Rt;ee.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Me),$.translateZ($e),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert();const I=be+$e,M=Te+$e,X=Ue-Me,ne=le+(oe-Me),re=Ge*Te/M*I,ae=Y*Te/M*I;$.projectionMatrix.makePerspective(X,ne,re,ae,I,M),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}function N($,ee){ee===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(ee.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(n===null)return;x.near=A.near=R.near=$.near,x.far=A.far=R.far=$.far,(y!==x.near||D!==x.far)&&(n.updateRenderState({depthNear:x.near,depthFar:x.far}),y=x.near,D=x.far);const ee=$.parent,ie=x.cameras;N(x,ee);for(let oe=0;oe<ie.length;oe++)N(ie[oe],ee);ie.length===2?z(x,R,A):x.projectionMatrix.copy(R.projectionMatrix),k($,x,ee)};function k($,ee,ie){ie===null?$.matrix.copy(ee.matrixWorld):($.matrix.copy(ie.matrixWorld),$.matrix.invert(),$.matrix.multiply(ee.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(ee.projectionMatrix),$.projectionMatrixInverse.copy(ee.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Zr*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return x},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function($){l=$,d!==null&&(d.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)};let q=null;function G($,ee){if(h=ee.getViewerPose(c||a),p=ee,h!==null){const ie=h.views;f!==null&&(e.setRenderTargetFramebuffer(g,f.framebuffer),e.setRenderTarget(g));let oe=!1;ie.length!==x.cameras.length&&(x.cameras.length=0,oe=!0);for(let me=0;me<ie.length;me++){const xe=ie[me];let be=null;if(f!==null)be=f.getViewport(xe);else{const Ge=u.getViewSubImage(d,xe);be=Ge.viewport,me===0&&(e.setRenderTargetTextures(g,Ge.colorTexture,d.ignoreDepthValues?void 0:Ge.depthStencilTexture),e.setRenderTarget(g))}let Te=C[me];Te===void 0&&(Te=new oi,Te.layers.enable(me),Te.viewport=new Ft,C[me]=Te),Te.matrix.fromArray(xe.transform.matrix),Te.matrix.decompose(Te.position,Te.quaternion,Te.scale),Te.projectionMatrix.fromArray(xe.projectionMatrix),Te.projectionMatrixInverse.copy(Te.projectionMatrix).invert(),Te.viewport.set(be.x,be.y,be.width,be.height),me===0&&(x.matrix.copy(Te.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale)),oe===!0&&x.cameras.push(Te)}}for(let ie=0;ie<E.length;ie++){const oe=_[ie],me=E[ie];oe!==null&&me!==void 0&&me.update(oe,ee,c||a)}q&&q($,ee),ee.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ee}),p=null}const K=new yl;K.setAnimationLoop(G),this.setAnimationLoop=function($){q=$},this.dispose=function(){}}}function jg(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,_l(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,E,_,T){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,T)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?l(m,g,E,_):g.isSpriteMaterial?c(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===1&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===1&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const E=e.get(g).envMap;if(E&&(m.envMap.value=E,m.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;const _=s._useLegacyLights===!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*_,t(g.lightMap,m.lightMapTransform)}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,E,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*E,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),e.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,E){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===1&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=E.texture,m.transmissionSamplerSize.value.set(E.width,E.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const E=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(E.matrixWorld),m.nearDistance.value=E.shadow.camera.near,m.farDistance.value=E.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function Qg(s,e,t,i){let n={},r={},a=[];const o=t.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(E,_){const T=_.program;i.uniformBlockBinding(E,T)}function c(E,_){let T=n[E.id];T===void 0&&(p(E),T=h(E),n[E.id]=T,E.addEventListener("dispose",m));const b=_.program;i.updateUBOMapping(E,b);const R=e.render.frame;r[E.id]!==R&&(d(E),r[E.id]=R)}function h(E){const _=u();E.__bindingPointIndex=_;const T=s.createBuffer(),b=E.__size,R=E.usage;return s.bindBuffer(s.UNIFORM_BUFFER,T),s.bufferData(s.UNIFORM_BUFFER,b,R),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,T),T}function u(){for(let E=0;E<o;E++)if(a.indexOf(E)===-1)return a.push(E),E;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(E){const _=n[E.id],T=E.uniforms,b=E.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let R=0,A=T.length;R<A;R++){const C=Array.isArray(T[R])?T[R]:[T[R]];for(let x=0,y=C.length;x<y;x++){const D=C[x];if(f(D,R,x,b)===!0){const P=D.__offset,H=Array.isArray(D.value)?D.value:[D.value];let w=0;for(let F=0;F<H.length;F++){const O=H[F],z=v(O);typeof O=="number"||typeof O=="boolean"?(D.__data[0]=O,s.bufferSubData(s.UNIFORM_BUFFER,P+w,D.__data)):O.isMatrix3?(D.__data[0]=O.elements[0],D.__data[1]=O.elements[1],D.__data[2]=O.elements[2],D.__data[3]=0,D.__data[4]=O.elements[3],D.__data[5]=O.elements[4],D.__data[6]=O.elements[5],D.__data[7]=0,D.__data[8]=O.elements[6],D.__data[9]=O.elements[7],D.__data[10]=O.elements[8],D.__data[11]=0):(O.toArray(D.__data,w),w+=z.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,P,D.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(E,_,T,b){const R=E.value,A=_+"_"+T;if(b[A]===void 0)return typeof R=="number"||typeof R=="boolean"?b[A]=R:b[A]=R.clone(),!0;{const C=b[A];if(typeof R=="number"||typeof R=="boolean"){if(C!==R)return b[A]=R,!0}else if(C.equals(R)===!1)return C.copy(R),!0}return!1}function p(E){const _=E.uniforms;let T=0;const b=16;for(let A=0,C=_.length;A<C;A++){const x=Array.isArray(_[A])?_[A]:[_[A]];for(let y=0,D=x.length;y<D;y++){const P=x[y],H=Array.isArray(P.value)?P.value:[P.value];for(let w=0,F=H.length;w<F;w++){const O=H[w],z=v(O),N=T%b;N!==0&&b-N<z.boundary&&(T+=b-N),P.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),P.__offset=T,T+=z.storage}}}const R=T%b;return R>0&&(T+=b-R),E.__size=T,E.__cache={},this}function v(E){const _={boundary:0,storage:0};return typeof E=="number"||typeof E=="boolean"?(_.boundary=4,_.storage=4):E.isVector2?(_.boundary=8,_.storage=8):E.isVector3||E.isColor?(_.boundary=16,_.storage=12):E.isVector4?(_.boundary=16,_.storage=16):E.isMatrix3?(_.boundary=48,_.storage=48):E.isMatrix4?(_.boundary=64,_.storage=64):E.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",E),_}function m(E){const _=E.target;_.removeEventListener("dispose",m);const T=a.indexOf(_.__bindingPointIndex);a.splice(T,1),s.deleteBuffer(n[_.id]),delete n[_.id],delete r[_.id]}function g(){for(const E in n)s.deleteBuffer(n[E]);a=[],n={},r={}}return{bind:l,update:c,dispose:g}}class Ql{constructor(e={}){const{canvas:t=Ad(),context:i=null,depth:n=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;i!==null?d=i.getContextAttributes().alpha:d=a;const f=new Uint32Array(4),p=new Int32Array(4);let v=null,m=null;const g=[],E=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Mt,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let T=!1,b=0,R=0,A=null,C=-1,x=null;const y=new Ft,D=new Ft;let P=null;const H=new st(0);let w=0,F=t.width,O=t.height,z=1,N=null,k=null;const q=new Ft(0,0,F,O),G=new Ft(0,0,F,O);let K=!1;const $=new xl;let ee=!1,ie=!1,oe=null;const me=new Ot,xe=new it,be=new Q,Te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ge(){return A===null?z:1}let Y=i;function Rt(L,W){for(let Z=0;Z<L.length;Z++){const J=L[Z],j=t.getContext(J,W);if(j!==null)return j}return null}try{const L={alpha:!0,depth:n,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${qr}`),t.addEventListener("webglcontextlost",he,!1),t.addEventListener("webglcontextrestored",U,!1),t.addEventListener("webglcontextcreationerror",fe,!1),Y===null){const W=["webgl2","webgl","experimental-webgl"];if(_.isWebGL1Renderer===!0&&W.shift(),Y=Rt(W,L),Y===null)throw Rt(W)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&Y instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),Y.getShaderPrecisionFormat===void 0&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Re,Ue,le,$e,Me,I,M,X,ne,re,ae,ye,ue,_e,Ie,ke,se,Ze,Qe,Ne,Le,Se,ze,tt;function vt(){Re=new om(Y),Ue=new em(Y,Re,e),Re.init(Ue),Se=new Kg(Y,Re,Ue),le=new zg(Y,Re,Ue),$e=new hm(Y),Me=new Cg,I=new Wg(Y,Re,le,Me,Ue,Se,$e),M=new im(_),X=new am(_),ne=new jd(Y,Ue),ze=new Zp(Y,Re,ne,Ue),re=new lm(Y,ne,$e,ze),ae=new pm(Y,re,ne,$e),Qe=new fm(Y,Ue,I),ke=new tm(Me),ye=new Ig(_,M,X,Re,Ue,ze,ke),ue=new jg(_,Me),_e=new wg,Ie=new kg(Re,Ue),Ze=new Qp(_,M,X,le,ae,d,l),se=new $g(_,ae,Ue),tt=new Qg(Y,$e,Ue,le),Ne=new Jp(Y,Re,$e,Ue),Le=new cm(Y,Re,$e,Ue),$e.programs=ye.programs,_.capabilities=Ue,_.extensions=Re,_.properties=Me,_.renderLists=_e,_.shadowMap=se,_.state=le,_.info=$e}vt();const qe=new qg(_,Y);this.xr=qe,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){const L=Re.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){const L=Re.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(L){L!==void 0&&(z=L,this.setSize(F,O,!1))},this.getSize=function(L){return L.set(F,O)},this.setSize=function(L,W,Z=!0){if(qe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}F=L,O=W,t.width=Math.floor(L*z),t.height=Math.floor(W*z),Z===!0&&(t.style.width=L+"px",t.style.height=W+"px"),this.setViewport(0,0,L,W)},this.getDrawingBufferSize=function(L){return L.set(F*z,O*z).floor()},this.setDrawingBufferSize=function(L,W,Z){F=L,O=W,z=Z,t.width=Math.floor(L*Z),t.height=Math.floor(W*Z),this.setViewport(0,0,L,W)},this.getCurrentViewport=function(L){return L.copy(y)},this.getViewport=function(L){return L.copy(q)},this.setViewport=function(L,W,Z,J){L.isVector4?q.set(L.x,L.y,L.z,L.w):q.set(L,W,Z,J),le.viewport(y.copy(q).multiplyScalar(z).floor())},this.getScissor=function(L){return L.copy(G)},this.setScissor=function(L,W,Z,J){L.isVector4?G.set(L.x,L.y,L.z,L.w):G.set(L,W,Z,J),le.scissor(D.copy(G).multiplyScalar(z).floor())},this.getScissorTest=function(){return K},this.setScissorTest=function(L){le.setScissorTest(K=L)},this.setOpaqueSort=function(L){N=L},this.setTransparentSort=function(L){k=L},this.getClearColor=function(L){return L.copy(Ze.getClearColor())},this.setClearColor=function(){Ze.setClearColor.apply(Ze,arguments)},this.getClearAlpha=function(){return Ze.getClearAlpha()},this.setClearAlpha=function(){Ze.setClearAlpha.apply(Ze,arguments)},this.clear=function(L=!0,W=!0,Z=!0){let J=0;if(L){let j=!1;if(A!==null){const ve=A.texture.format;j=ve===1033||ve===1031||ve===1029}if(j){const ve=A.texture.type,Ae=ve===1009||ve===1014||ve===1012||ve===1020||ve===1017||ve===1018,De=Ze.getClearColor(),Oe=Ze.getClearAlpha(),Ke=De.r,Be=De.g,Ve=De.b;Ae?(f[0]=Ke,f[1]=Be,f[2]=Ve,f[3]=Oe,Y.clearBufferuiv(Y.COLOR,0,f)):(p[0]=Ke,p[1]=Be,p[2]=Ve,p[3]=Oe,Y.clearBufferiv(Y.COLOR,0,p))}else J|=Y.COLOR_BUFFER_BIT}W&&(J|=Y.DEPTH_BUFFER_BIT),Z&&(J|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",he,!1),t.removeEventListener("webglcontextrestored",U,!1),t.removeEventListener("webglcontextcreationerror",fe,!1),_e.dispose(),Ie.dispose(),Me.dispose(),M.dispose(),X.dispose(),ae.dispose(),ze.dispose(),tt.dispose(),ye.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",$t),qe.removeEventListener("sessionend",ht),oe&&(oe.dispose(),oe=null),zt.stop()};function he(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function U(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const L=$e.autoReset,W=se.enabled,Z=se.autoUpdate,J=se.needsUpdate,j=se.type;vt(),$e.autoReset=L,se.enabled=W,se.autoUpdate=Z,se.needsUpdate=J,se.type=j}function fe(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function pe(L){const W=L.target;W.removeEventListener("dispose",pe),Pe(W)}function Pe(L){Ce(L),Me.remove(L)}function Ce(L){const W=Me.get(L).programs;W!==void 0&&(W.forEach(function(Z){ye.releaseProgram(Z)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,W,Z,J,j,ve){W===null&&(W=Te);const Ae=j.isMesh&&j.matrixWorld.determinant()<0,De=zS(L,W,Z,J,j);le.setMaterial(J,Ae);let Oe=Z.index,Ke=1;if(J.wireframe===!0){if(Oe=re.getWireframeAttribute(Z),Oe===void 0)return;Ke=2}const Be=Z.drawRange,Ve=Z.attributes.position;let St=Be.start*Ke,si=(Be.start+Be.count)*Ke;ve!==null&&(St=Math.max(St,ve.start*Ke),si=Math.min(si,(ve.start+ve.count)*Ke)),Oe!==null?(St=Math.max(St,0),si=Math.min(si,Oe.count)):Ve!=null&&(St=Math.max(St,0),si=Math.min(si,Ve.count));const Pt=si-St;if(Pt<0||Pt===1/0)return;ze.setup(j,J,De,Z,Oe);let zi,mt=Ne;if(Oe!==null&&(zi=ne.get(Oe),mt=Le,mt.setIndex(zi)),j.isMesh)J.wireframe===!0?(le.setLineWidth(J.wireframeLinewidth*Ge()),mt.setMode(Y.LINES)):mt.setMode(Y.TRIANGLES);else if(j.isLine){let je=J.linewidth;je===void 0&&(je=1),le.setLineWidth(je*Ge()),j.isLineSegments?mt.setMode(Y.LINES):j.isLineLoop?mt.setMode(Y.LINE_LOOP):mt.setMode(Y.LINE_STRIP)}else j.isPoints?mt.setMode(Y.POINTS):j.isSprite&&mt.setMode(Y.TRIANGLES);if(j.isBatchedMesh)mt.renderMultiDraw(j._multiDrawStarts,j._multiDrawCounts,j._multiDrawCount);else if(j.isInstancedMesh)mt.renderInstances(St,Pt,j.count);else if(Z.isInstancedBufferGeometry){const je=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Ho=Math.min(Z.instanceCount,je);mt.renderInstances(St,Pt,Ho)}else mt.render(St,Pt)};function lt(L,W,Z){L.transparent===!0&&L.side===2&&L.forceSinglePass===!1?(L.side=1,L.needsUpdate=!0,Yr(L,W,Z),L.side=0,L.needsUpdate=!0,Yr(L,W,Z),L.side=2):Yr(L,W,Z)}this.compile=function(L,W,Z=null){Z===null&&(Z=L),m=Ie.get(Z),m.init(),E.push(m),Z.traverseVisible(function(j){j.isLight&&j.layers.test(W.layers)&&(m.pushLight(j),j.castShadow&&m.pushShadow(j))}),L!==Z&&L.traverseVisible(function(j){j.isLight&&j.layers.test(W.layers)&&(m.pushLight(j),j.castShadow&&m.pushShadow(j))}),m.setupLights(_._useLegacyLights);const J=new Set;return L.traverse(function(j){const ve=j.material;if(ve)if(Array.isArray(ve))for(let Ae=0;Ae<ve.length;Ae++){const De=ve[Ae];lt(De,Z,j),J.add(De)}else lt(ve,Z,j),J.add(ve)}),E.pop(),m=null,J},this.compileAsync=function(L,W,Z=null){const J=this.compile(L,W,Z);return new Promise(j=>{function ve(){if(J.forEach(function(Ae){Me.get(Ae).currentProgram.isReady()&&J.delete(Ae)}),J.size===0){j(L);return}setTimeout(ve,10)}Re.get("KHR_parallel_shader_compile")!==null?ve():setTimeout(ve,10)})};let ct=null;function wt(L){ct&&ct(L)}function $t(){zt.stop()}function ht(){zt.start()}const zt=new yl;zt.setAnimationLoop(wt),typeof self<"u"&&zt.setContext(self),this.setAnimationLoop=function(L){ct=L,qe.setAnimationLoop(L),L===null?zt.stop():zt.start()},qe.addEventListener("sessionstart",$t),qe.addEventListener("sessionend",ht),this.render=function(L,W){if(W!==void 0&&W.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),W.parent===null&&W.matrixWorldAutoUpdate===!0&&W.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(W),W=qe.getCamera()),L.isScene===!0&&L.onBeforeRender(_,L,W,A),m=Ie.get(L,E.length),m.init(),E.push(m),me.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),$.setFromProjectionMatrix(me),ie=this.localClippingEnabled,ee=ke.init(this.clippingPlanes,ie),v=_e.get(L,g.length),v.init(),g.push(v),Ii(L,W,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(N,k),this.info.render.frame++,ee===!0&&ke.beginShadows();const Z=m.state.shadowsArray;if(se.render(Z,L,W),ee===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ze.render(v,L),m.setupLights(_._useLegacyLights),W.isArrayCamera){const J=W.cameras;for(let j=0,ve=J.length;j<ve;j++){const Ae=J[j];vd(v,L,Ae,Ae.viewport)}}else vd(v,L,W);A!==null&&(I.updateMultisampleRenderTarget(A),I.updateRenderTargetMipmap(A)),L.isScene===!0&&L.onAfterRender(_,L,W),ze.resetDefaultState(),C=-1,x=null,E.pop(),E.length>0?m=E[E.length-1]:m=null,g.pop(),g.length>0?v=g[g.length-1]:v=null};function Ii(L,W,Z,J){if(L.visible===!1)return;if(L.layers.test(W.layers)){if(L.isGroup)Z=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(W);else if(L.isLight)m.pushLight(L),L.castShadow&&m.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||$.intersectsSprite(L)){J&&be.setFromMatrixPosition(L.matrixWorld).applyMatrix4(me);const Ae=ae.update(L),De=L.material;De.visible&&v.push(L,Ae,De,Z,be.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||$.intersectsObject(L))){const Ae=ae.update(L),De=L.material;if(J&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),be.copy(L.boundingSphere.center)):(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),be.copy(Ae.boundingSphere.center)),be.applyMatrix4(L.matrixWorld).applyMatrix4(me)),Array.isArray(De)){const Oe=Ae.groups;for(let Ke=0,Be=Oe.length;Ke<Be;Ke++){const Ve=Oe[Ke],St=De[Ve.materialIndex];St&&St.visible&&v.push(L,Ae,St,Z,be.z,Ve)}}else De.visible&&v.push(L,Ae,De,Z,be.z,null)}}const ve=L.children;for(let Ae=0,De=ve.length;Ae<De;Ae++)Ii(ve[Ae],W,Z,J)}function vd(L,W,Z,J){const j=L.opaque,ve=L.transmissive,Ae=L.transparent;m.setupLightsView(Z),ee===!0&&ke.setGlobalState(_.clippingPlanes,Z),ve.length>0&&$S(j,ve,W,Z),J&&le.viewport(y.copy(J)),j.length>0&&Xr(j,W,Z),ve.length>0&&Xr(ve,W,Z),Ae.length>0&&Xr(Ae,W,Z),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function $S(L,W,Z,J){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;const ve=Ue.isWebGL2;oe===null&&(oe=new nn(1,1,{generateMipmaps:!0,type:Re.has("EXT_color_buffer_half_float")?1016:1009,minFilter:1008,samples:ve?4:0})),_.getDrawingBufferSize(xe),ve?oe.setSize(xe.x,xe.y):oe.setSize(ea(xe.x),ea(xe.y));const Ae=_.getRenderTarget();_.setRenderTarget(oe),_.getClearColor(H),w=_.getClearAlpha(),w<1&&_.setClearColor(16777215,.5),_.clear();const De=_.toneMapping;_.toneMapping=0,Xr(L,Z,J),I.updateMultisampleRenderTarget(oe),I.updateRenderTargetMipmap(oe);let Oe=!1;for(let Ke=0,Be=W.length;Ke<Be;Ke++){const Ve=W[Ke],St=Ve.object,si=Ve.geometry,Pt=Ve.material,zi=Ve.group;if(Pt.side===2&&St.layers.test(J.layers)){const mt=Pt.side;Pt.side=1,Pt.needsUpdate=!0,_d(St,Z,J,si,Pt,zi),Pt.side=mt,Pt.needsUpdate=!0,Oe=!0}}Oe===!0&&(I.updateMultisampleRenderTarget(oe),I.updateRenderTargetMipmap(oe)),_.setRenderTarget(Ae),_.setClearColor(H,w),_.toneMapping=De}function Xr(L,W,Z){const J=W.isScene===!0?W.overrideMaterial:null;for(let j=0,ve=L.length;j<ve;j++){const Ae=L[j],De=Ae.object,Oe=Ae.geometry,Ke=J===null?Ae.material:J,Be=Ae.group;De.layers.test(Z.layers)&&_d(De,W,Z,Oe,Ke,Be)}}function _d(L,W,Z,J,j,ve){L.onBeforeRender(_,W,Z,J,j,ve),L.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),j.onBeforeRender(_,W,Z,J,L,ve),j.transparent===!0&&j.side===2&&j.forceSinglePass===!1?(j.side=1,j.needsUpdate=!0,_.renderBufferDirect(Z,W,J,j,L,ve),j.side=0,j.needsUpdate=!0,_.renderBufferDirect(Z,W,J,j,L,ve),j.side=2):_.renderBufferDirect(Z,W,J,j,L,ve),L.onAfterRender(_,W,Z,J,j,ve)}function Yr(L,W,Z){W.isScene!==!0&&(W=Te);const J=Me.get(L),j=m.state.lights,ve=m.state.shadowsArray,Ae=j.state.version,De=ye.getParameters(L,j.state,ve,W,Z),Oe=ye.getProgramCacheKey(De);let Ke=J.programs;J.environment=L.isMeshStandardMaterial?W.environment:null,J.fog=W.fog,J.envMap=(L.isMeshStandardMaterial?X:M).get(L.envMap||J.environment),Ke===void 0&&(L.addEventListener("dispose",pe),Ke=new Map,J.programs=Ke);let Be=Ke.get(Oe);if(Be!==void 0){if(J.currentProgram===Be&&J.lightsStateVersion===Ae)return Sd(L,De),Be}else De.uniforms=ye.getUniforms(L),L.onBuild(Z,De,_),L.onBeforeCompile(De,_),Be=ye.acquireProgram(De,Oe),Ke.set(Oe,Be),J.uniforms=De.uniforms;const Ve=J.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Ve.clippingPlanes=ke.uniform),Sd(L,De),J.needsLights=KS(L),J.lightsStateVersion=Ae,J.needsLights&&(Ve.ambientLightColor.value=j.state.ambient,Ve.lightProbe.value=j.state.probe,Ve.directionalLights.value=j.state.directional,Ve.directionalLightShadows.value=j.state.directionalShadow,Ve.spotLights.value=j.state.spot,Ve.spotLightShadows.value=j.state.spotShadow,Ve.rectAreaLights.value=j.state.rectArea,Ve.ltc_1.value=j.state.rectAreaLTC1,Ve.ltc_2.value=j.state.rectAreaLTC2,Ve.pointLights.value=j.state.point,Ve.pointLightShadows.value=j.state.pointShadow,Ve.hemisphereLights.value=j.state.hemi,Ve.directionalShadowMap.value=j.state.directionalShadowMap,Ve.directionalShadowMatrix.value=j.state.directionalShadowMatrix,Ve.spotShadowMap.value=j.state.spotShadowMap,Ve.spotLightMatrix.value=j.state.spotLightMatrix,Ve.spotLightMap.value=j.state.spotLightMap,Ve.pointShadowMap.value=j.state.pointShadowMap,Ve.pointShadowMatrix.value=j.state.pointShadowMatrix),J.currentProgram=Be,J.uniformsList=null,Be}function Ed(L){if(L.uniformsList===null){const W=L.currentProgram.getUniforms();L.uniformsList=nr.seqWithValue(W.seq,L.uniforms)}return L.uniformsList}function Sd(L,W){const Z=Me.get(L);Z.outputColorSpace=W.outputColorSpace,Z.batching=W.batching,Z.instancing=W.instancing,Z.instancingColor=W.instancingColor,Z.skinning=W.skinning,Z.morphTargets=W.morphTargets,Z.morphNormals=W.morphNormals,Z.morphColors=W.morphColors,Z.morphTargetsCount=W.morphTargetsCount,Z.numClippingPlanes=W.numClippingPlanes,Z.numIntersection=W.numClipIntersection,Z.vertexAlphas=W.vertexAlphas,Z.vertexTangents=W.vertexTangents,Z.toneMapping=W.toneMapping}function zS(L,W,Z,J,j){W.isScene!==!0&&(W=Te),I.resetTextureUnits();const ve=W.fog,Ae=J.isMeshStandardMaterial?W.environment:null,De=A===null?_.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Ci,Oe=(J.isMeshStandardMaterial?X:M).get(J.envMap||Ae),Ke=J.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,Be=!!Z.attributes.tangent&&(!!J.normalMap||J.anisotropy>0),Ve=!!Z.morphAttributes.position,St=!!Z.morphAttributes.normal,si=!!Z.morphAttributes.color;let Pt=0;J.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Pt=_.toneMapping);const zi=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,mt=zi!==void 0?zi.length:0,je=Me.get(J),Ho=m.state.lights;if(ee===!0&&(ie===!0||L!==x)){const hi=L===x&&J.id===C;ke.setState(J,L,hi)}let _t=!1;J.version===je.__version?(je.needsLights&&je.lightsStateVersion!==Ho.state.version||je.outputColorSpace!==De||j.isBatchedMesh&&je.batching===!1||!j.isBatchedMesh&&je.batching===!0||j.isInstancedMesh&&je.instancing===!1||!j.isInstancedMesh&&je.instancing===!0||j.isSkinnedMesh&&je.skinning===!1||!j.isSkinnedMesh&&je.skinning===!0||j.isInstancedMesh&&je.instancingColor===!0&&j.instanceColor===null||j.isInstancedMesh&&je.instancingColor===!1&&j.instanceColor!==null||je.envMap!==Oe||J.fog===!0&&je.fog!==ve||je.numClippingPlanes!==void 0&&(je.numClippingPlanes!==ke.numPlanes||je.numIntersection!==ke.numIntersection)||je.vertexAlphas!==Ke||je.vertexTangents!==Be||je.morphTargets!==Ve||je.morphNormals!==St||je.morphColors!==si||je.toneMapping!==Pt||Ue.isWebGL2===!0&&je.morphTargetsCount!==mt)&&(_t=!0):(_t=!0,je.__version=J.version);let _n=je.currentProgram;_t===!0&&(_n=Yr(J,W,j));let xd=!1,bs=!1,$o=!1;const Bt=_n.getUniforms(),En=je.uniforms;if(le.useProgram(_n.program)&&(xd=!0,bs=!0,$o=!0),J.id!==C&&(C=J.id,bs=!0),xd||x!==L){Bt.setValue(Y,"projectionMatrix",L.projectionMatrix),Bt.setValue(Y,"viewMatrix",L.matrixWorldInverse);const hi=Bt.map.cameraPosition;hi!==void 0&&hi.setValue(Y,be.setFromMatrixPosition(L.matrixWorld)),Ue.logarithmicDepthBuffer&&Bt.setValue(Y,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Bt.setValue(Y,"isOrthographic",L.isOrthographicCamera===!0),x!==L&&(x=L,bs=!0,$o=!0)}if(j.isSkinnedMesh){Bt.setOptional(Y,j,"bindMatrix"),Bt.setOptional(Y,j,"bindMatrixInverse");const hi=j.skeleton;hi&&(Ue.floatVertexTextures?(hi.boneTexture===null&&hi.computeBoneTexture(),Bt.setValue(Y,"boneTexture",hi.boneTexture,I)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}j.isBatchedMesh&&(Bt.setOptional(Y,j,"batchingTexture"),Bt.setValue(Y,"batchingTexture",j._matricesTexture,I));const zo=Z.morphAttributes;if((zo.position!==void 0||zo.normal!==void 0||zo.color!==void 0&&Ue.isWebGL2===!0)&&Qe.update(j,Z,_n),(bs||je.receiveShadow!==j.receiveShadow)&&(je.receiveShadow=j.receiveShadow,Bt.setValue(Y,"receiveShadow",j.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(En.envMap.value=Oe,En.flipEnvMap.value=Oe.isCubeTexture&&Oe.isRenderTargetTexture===!1?-1:1),bs&&(Bt.setValue(Y,"toneMappingExposure",_.toneMappingExposure),je.needsLights&&WS(En,$o),ve&&J.fog===!0&&ue.refreshFogUniforms(En,ve),ue.refreshMaterialUniforms(En,J,z,O,oe),nr.upload(Y,Ed(je),En,I)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(nr.upload(Y,Ed(je),En,I),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Bt.setValue(Y,"center",j.center),Bt.setValue(Y,"modelViewMatrix",j.modelViewMatrix),Bt.setValue(Y,"normalMatrix",j.normalMatrix),Bt.setValue(Y,"modelMatrix",j.matrixWorld),J.isShaderMaterial||J.isRawShaderMaterial){const hi=J.uniformsGroups;for(let Wo=0,XS=hi.length;Wo<XS;Wo++)if(Ue.isWebGL2){const yd=hi[Wo];tt.update(yd,_n),tt.bind(yd,_n)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return _n}function WS(L,W){L.ambientLightColor.needsUpdate=W,L.lightProbe.needsUpdate=W,L.directionalLights.needsUpdate=W,L.directionalLightShadows.needsUpdate=W,L.pointLights.needsUpdate=W,L.pointLightShadows.needsUpdate=W,L.spotLights.needsUpdate=W,L.spotLightShadows.needsUpdate=W,L.rectAreaLights.needsUpdate=W,L.hemisphereLights.needsUpdate=W}function KS(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(L,W,Z){Me.get(L.texture).__webglTexture=W,Me.get(L.depthTexture).__webglTexture=Z;const J=Me.get(L);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=Z===void 0,J.__autoAllocateDepthBuffer||Re.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,W){const Z=Me.get(L);Z.__webglFramebuffer=W,Z.__useDefaultFramebuffer=W===void 0},this.setRenderTarget=function(L,W=0,Z=0){A=L,b=W,R=Z;let J=!0,j=null,ve=!1,Ae=!1;if(L){const Oe=Me.get(L);Oe.__useDefaultFramebuffer!==void 0?(le.bindFramebuffer(Y.FRAMEBUFFER,null),J=!1):Oe.__webglFramebuffer===void 0?I.setupRenderTarget(L):Oe.__hasExternalTextures&&I.rebindTextures(L,Me.get(L.texture).__webglTexture,Me.get(L.depthTexture).__webglTexture);const Ke=L.texture;(Ke.isData3DTexture||Ke.isDataArrayTexture||Ke.isCompressedArrayTexture)&&(Ae=!0);const Be=Me.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(Be[W])?j=Be[W][Z]:j=Be[W],ve=!0):Ue.isWebGL2&&L.samples>0&&I.useMultisampledRTT(L)===!1?j=Me.get(L).__webglMultisampledFramebuffer:Array.isArray(Be)?j=Be[Z]:j=Be,y.copy(L.viewport),D.copy(L.scissor),P=L.scissorTest}else y.copy(q).multiplyScalar(z).floor(),D.copy(G).multiplyScalar(z).floor(),P=K;if(le.bindFramebuffer(Y.FRAMEBUFFER,j)&&Ue.drawBuffers&&J&&le.drawBuffers(L,j),le.viewport(y),le.scissor(D),le.setScissorTest(P),ve){const Oe=Me.get(L.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+W,Oe.__webglTexture,Z)}else if(Ae){const Oe=Me.get(L.texture),Ke=W||0;Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Oe.__webglTexture,Z||0,Ke)}C=-1},this.readRenderTargetPixels=function(L,W,Z,J,j,ve,Ae){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=Me.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&Ae!==void 0&&(De=De[Ae]),De){le.bindFramebuffer(Y.FRAMEBUFFER,De);try{const Oe=L.texture,Ke=Oe.format,Be=Oe.type;if(Ke!==1023&&Se.convert(Ke)!==Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ve=Be===1016&&(Re.has("EXT_color_buffer_half_float")||Ue.isWebGL2&&Re.has("EXT_color_buffer_float"));if(Be!==1009&&Se.convert(Be)!==Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Be===1015&&(Ue.isWebGL2||Re.has("OES_texture_float")||Re.has("WEBGL_color_buffer_float")))&&!Ve){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}W>=0&&W<=L.width-J&&Z>=0&&Z<=L.height-j&&Y.readPixels(W,Z,J,j,Se.convert(Ke),Se.convert(Be),ve)}finally{const Oe=A!==null?Me.get(A).__webglFramebuffer:null;le.bindFramebuffer(Y.FRAMEBUFFER,Oe)}}},this.copyFramebufferToTexture=function(L,W,Z=0){const J=Math.pow(2,-Z),j=Math.floor(W.image.width*J),ve=Math.floor(W.image.height*J);I.setTexture2D(W,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Z,0,0,L.x,L.y,j,ve),le.unbindTexture()},this.copyTextureToTexture=function(L,W,Z,J=0){const j=W.image.width,ve=W.image.height,Ae=Se.convert(Z.format),De=Se.convert(Z.type);I.setTexture2D(Z,0),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,Z.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Z.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,Z.unpackAlignment),W.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,j,ve,Ae,De,W.image.data):W.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,W.mipmaps[0].width,W.mipmaps[0].height,Ae,W.mipmaps[0].data):Y.texSubImage2D(Y.TEXTURE_2D,J,L.x,L.y,Ae,De,W.image),J===0&&Z.generateMipmaps&&Y.generateMipmap(Y.TEXTURE_2D),le.unbindTexture()},this.copyTextureToTexture3D=function(L,W,Z,J,j=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ve=L.max.x-L.min.x+1,Ae=L.max.y-L.min.y+1,De=L.max.z-L.min.z+1,Oe=Se.convert(J.format),Ke=Se.convert(J.type);let Be;if(J.isData3DTexture)I.setTexture3D(J,0),Be=Y.TEXTURE_3D;else if(J.isDataArrayTexture||J.isCompressedArrayTexture)I.setTexture2DArray(J,0),Be=Y.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,J.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,J.unpackAlignment);const Ve=Y.getParameter(Y.UNPACK_ROW_LENGTH),St=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),si=Y.getParameter(Y.UNPACK_SKIP_PIXELS),Pt=Y.getParameter(Y.UNPACK_SKIP_ROWS),zi=Y.getParameter(Y.UNPACK_SKIP_IMAGES),mt=Z.isCompressedTexture?Z.mipmaps[j]:Z.image;Y.pixelStorei(Y.UNPACK_ROW_LENGTH,mt.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,mt.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,L.min.x),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,L.min.y),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,L.min.z),Z.isDataTexture||Z.isData3DTexture?Y.texSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,Ke,mt.data):Z.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Y.compressedTexSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,mt.data)):Y.texSubImage3D(Be,j,W.x,W.y,W.z,ve,Ae,De,Oe,Ke,mt),Y.pixelStorei(Y.UNPACK_ROW_LENGTH,Ve),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,St),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,si),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,Pt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,zi),j===0&&J.generateMipmaps&&Y.generateMipmap(Be),le.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?I.setTextureCube(L,0):L.isData3DTexture?I.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?I.setTexture2DArray(L,0):I.setTexture2D(L,0),le.unbindTexture()},this.resetState=function(){b=0,R=0,A=null,le.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===jr?"display-p3":"srgb",t.unpackColorSpace=nt.workingColorSpace===Rs?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Mt?3001:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===3001?Mt:Ci}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Zg extends Ql{}Zg.prototype.isWebGL1Renderer=!0;class Jg extends Jt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class e0 extends Xt{constructor(e,t,i,n,r,a,o,l,c){super(e,t,i,n,r,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:1006,this.magFilter=r!==void 0?r:1006,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class rr extends ji{constructor(e=1,t=32,i=16,n=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new Q,d=new Q,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const E=[],_=g/i;let T=0;g===0&&a===0?T=.5/t:g===i&&l===Math.PI&&(T=-.5/t);for(let b=0;b<=t;b++){const R=b/t;u.x=-e*Math.cos(n+R*r)*Math.sin(a+_*o),u.y=e*Math.cos(a+_*o),u.z=e*Math.sin(n+R*r)*Math.sin(a+_*o),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(R+T,1-_),E.push(c++)}h.push(E)}for(let g=0;g<i;g++)for(let E=0;E<t;E++){const _=h[g][E+1],T=h[g][E],b=h[g+1][E],R=h[g+1][E+1];(g!==0||a>0)&&f.push(_,T,R),(g!==i-1||l<Math.PI)&&f.push(T,b,R)}this.setIndex(f),this.setAttribute("position",new Si(p,3)),this.setAttribute("normal",new Si(v,3)),this.setAttribute("uv",new Si(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:qr}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=qr);class Vn{static createButton(e){const t=document.createElement("button");function i(){let l=null;async function c(d){d.addEventListener("end",h),await e.xr.setSession(d),t.textContent="EXIT VR",l=d}function h(){l.removeEventListener("end",h),t.textContent="ENTER VR",l=null}t.style.display="",t.style.cursor="pointer",t.style.left="calc(50% - 50px)",t.style.width="100px",t.textContent="ENTER VR";const u={optionalFeatures:["local-floor","bounded-floor","hand-tracking","layers"]};t.onmouseenter=function(){t.style.opacity="1.0"},t.onmouseleave=function(){t.style.opacity="0.5"},t.onclick=function(){l===null?navigator.xr.requestSession("immersive-vr",u).then(c):(l.end(),navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",u).then(c))},navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",u).then(c)}function n(){t.style.display="",t.style.cursor="auto",t.style.left="calc(50% - 75px)",t.style.width="150px",t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function r(){n(),t.textContent="VR NOT SUPPORTED"}function a(l){n(),console.warn("Exception when trying to call xr.isSessionSupported",l),t.textContent="VR NOT ALLOWED"}function o(l){l.style.position="absolute",l.style.bottom="20px",l.style.padding="12px 6px",l.style.border="1px solid #fff",l.style.borderRadius="4px",l.style.background="rgba(0,0,0,0.1)",l.style.color="#fff",l.style.font="normal 13px sans-serif",l.style.textAlign="center",l.style.opacity="0.5",l.style.outline="none",l.style.zIndex="999"}if("xr"in navigator)return t.id="VRButton",t.style.display="none",o(t),navigator.xr.isSessionSupported("immersive-vr").then(function(l){l?i():r(),l&&Vn.xrSessionIsGranted&&t.click()}).catch(a),t;{const l=document.createElement("a");return window.isSecureContext===!1?(l.href=document.location.href.replace(/^http:/,"https:"),l.innerHTML="WEBXR NEEDS HTTPS"):(l.href="https://immersiveweb.dev/",l.innerHTML="WEBXR NOT AVAILABLE"),l.style.left="calc(50% - 90px)",l.style.width="180px",l.style.textDecoration="none",o(l),l}}static registerSessionGrantedListener(){if(typeof navigator<"u"&&"xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Vn.xrSessionIsGranted=!0})}}}Vn.xrSessionIsGranted=!1,Vn.registerSessionGrantedListener();const Ui={"180-sbs":{geom:"sphere180",split:"sbs",stereo:!0},"180-mono":{geom:"sphere180",split:"mono",stereo:!1},"360-mono":{geom:"sphere360",split:"mono",stereo:!1},"360-sbs":{geom:"sphere360",split:"sbs",stereo:!0},"360-tb":{geom:"sphere360",split:"tb",stereo:!0},"flat-2d":{geom:"plane",split:"mono",stereo:!1,flat:!0,aspect:"full"},"flat-sbs-full":{geom:"plane",split:"sbs",stereo:!0,flat:!0,aspect:"per-eye"},"flat-sbs-half":{geom:"plane",split:"sbs",stereo:!0,flat:!0,aspect:"full"}},Zl=[{value:"180-sbs",label:"180° SBS (VR180)"},{value:"180-mono",label:"180° Mono"},{value:"360-mono",label:"360° Mono"},{value:"360-sbs",label:"360° SBS"},{value:"360-tb",label:"360° Top-Bottom"},{value:"flat-2d",label:"Flat 2D (regular movie)"},{value:"flat-sbs-full",label:"Flat 3D — Full SBS"},{value:"flat-sbs-half",label:"Flat 3D — Half SBS"}];function t0(s){var e;return!!((e=Ui[s])!=null&&e.flat)}function Jl(s){const e=String(s).toLowerCase(),t=/(^|[^a-z])(tb|ou|top.?bottom|over.?under)([^a-z]|$)/.test(e),i=/(sbs|side.?by.?side)/.test(e);return e.includes("360")?t?"360-tb":i?"360-sbs":"360-mono":e.includes("180")||e.includes("vr180")?e.includes("mono")?"180-mono":"180-sbs":i?e.includes("half")?"flat-sbs-half":"flat-sbs-full":null}class ec{constructor(e){this.scene=new Jg,this.meshes=[],this.frameCbs=[],this.animate=()=>{for(const l of this.frameCbs)l();this.renderer.render(this.scene,this.camera)},this.resize=()=>{const l=this.w(),c=this.h();this.camera.aspect=l/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(l,c,!1)};const{canvas:t,video:i,projection:n="180-sbs",swapEyes:r=!1,fov:a=70,supersampling:o=1.5}=e;this.canvas=t,this.video=i,this.currentMode=Ui[n]?n:"180-sbs",this.currentSwap=r,this.renderer=new Ql({canvas:t,antialias:!0}),this.renderer.setPixelRatio(this.pixelRatioFor(o)),this.renderer.setSize(this.w(),this.h(),!1),this.renderer.xr.enabled=!0,this.camera=new oi(a,this.w()/this.h(),.1,1e3),this.camera.position.set(0,0,0),this.camera.layers.enable(1),this.maxAnisotropy=this.renderer.capabilities.getMaxAnisotropy(),this.texture=new e0(i),this.texture.colorSpace=Mt,this.texture.minFilter=1006,this.texture.magFilter=1006,this.texture.anisotropy=this.maxAnisotropy,this.applyProjection(this.currentMode,this.currentSwap),i.addEventListener("loadedmetadata",()=>{Ui[this.currentMode].flat&&this.applyProjection(this.currentMode,this.currentSwap)}),this.renderer.setAnimationLoop(this.animate),this.vrButton=Vn.createButton(this.renderer),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(t)}w(){return this.canvas.clientWidth||1}h(){return this.canvas.clientHeight||1}pixelRatioFor(e){return Math.min(window.devicePixelRatio*e,4)}planeAspect(e){const t=this.video.videoWidth,i=this.video.videoHeight;return!t||!i?1.7777777777777777:Ui[e].aspect==="per-eye"?t/2/i:t/i}buildGeometry(e){const t=Ui[e].geom;if(t==="sphere180"){const a=new rr(500,60,40,-Math.PI,Math.PI,0,Math.PI);return a.scale(-1,1,1),a}if(t==="sphere360"){const a=new rr(500,60,40);return a.scale(-1,1,1),a}const i=2.4,n=i*this.planeAspect(e),r=new Js(n,i);return r.translate(0,0,-2),r}splitUV(e,t,i){if(t==="mono")return;const n=e.attributes.uv.array;for(let r=0;r<n.length;r+=2)t==="sbs"?n[r]=n[r]*.5+(i==="right"?.5:0):t==="tb"&&(n[r+1]=n[r+1]*.5+(i==="left"?.5:0));e.attributes.uv.needsUpdate=!0}clearMeshes(){for(const e of this.meshes)this.scene.remove(e),e.geometry.dispose(),e.material.dispose();this.meshes.length=0}applyProjection(e,t){Ui[e]||(e="180-sbs"),this.clearMeshes();const i=Ui[e];if(i.stereo){const n=this.buildGeometry(e);this.splitUV(n,i.split,"left");const r=this.buildGeometry(e);this.splitUV(r,i.split,"right");const a=new mi(n,new hs({map:this.texture})),o=new mi(r,new hs({map:this.texture}));a.layers.set(t?2:1),o.layers.set(t?1:2),this.scene.add(a,o),this.meshes.push(a,o)}else{const n=new mi(this.buildGeometry(e),new hs({map:this.texture}));n.layers.set(0),this.scene.add(n),this.meshes.push(n)}this.currentMode=e,this.currentSwap=t}setProjection(e){this.applyProjection(e,this.currentSwap)}setSwapEyes(e){this.applyProjection(this.currentMode,e)}setFov(e){this.camera.fov=e,this.camera.updateProjectionMatrix()}setSupersampling(e){this.renderer.setPixelRatio(this.pixelRatioFor(e)),this.renderer.setSize(this.w(),this.h(),!1)}getProjection(){return this.currentMode}isFlat(){return!!Ui[this.currentMode].flat}onFrame(e){this.frameCbs.push(e)}pauseRendering(){this.renderer.setAnimationLoop(null)}resumeRendering(){this.renderer.setAnimationLoop(this.animate)}dispose(){this.ro.disconnect(),this.renderer.setAnimationLoop(null),this.texture.dispose(),this.clearMeshes(),this.renderer.dispose()}}const tc=Math.PI/180;function ic(s,e){return{lon:Math.max(-90,Math.min(90,s)),lat:Math.max(-85,Math.min(85,e))}}class nc{constructor(e,t,i={}){this.camera=e,this.dom=t,this.lon=0,this.lat=0,this.dragging=!1,this.px=0,this.py=0,this.enabled=!0,this.onDown=n=>{this.enabled&&(this.dragging=!0,this.px=n.clientX,this.py=n.clientY,this.capture("setPointerCapture",n.pointerId))},this.onMove=n=>{if(!this.dragging)return;const r=n.clientX-this.px,a=n.clientY-this.py;this.px=n.clientX,this.py=n.clientY,{lon:this.lon,lat:this.lat}=ic(this.lon-r*.15,this.lat+a*.15)},this.onUp=n=>{this.dragging=!1,this.capture("releasePointerCapture",n.pointerId)},this.isPresenting=i.isPresenting??(()=>!1),this.dom.addEventListener("pointerdown",this.onDown),this.dom.addEventListener("pointermove",this.onMove),this.dom.addEventListener("pointerup",this.onUp),this.dom.addEventListener("pointercancel",this.onUp)}capture(e,t){var i,n;try{(n=(i=this.dom)[e])==null||n.call(i,t)}catch{}}update(){if(this.isPresenting()||!this.enabled)return;const e=(90-this.lat)*tc,t=this.lon*tc;this.camera.lookAt(Math.sin(e)*Math.sin(t),Math.cos(e),-Math.sin(e)*Math.cos(t))}reset(){this.lon=0,this.lat=0}setEnabled(e){this.enabled=e,e||(this.lon=0,this.lat=0,this.camera.lookAt(0,0,-1))}getAngles(){return{lon:this.lon,lat:this.lat}}dispose(){this.dom.removeEventListener("pointerdown",this.onDown),this.dom.removeEventListener("pointermove",this.onMove),this.dom.removeEventListener("pointerup",this.onUp),this.dom.removeEventListener("pointercancel",this.onUp)}}class sc{constructor(){this.hls=null}async attach(e,t,i={}){this.dispose();const n=i.crossOrigin===void 0?"anonymous":i.crossOrigin;n===null?e.removeAttribute("crossorigin"):e.crossOrigin=n,e.playsInline=!0;const{url:r,format:a}=t,o=a==="hls"||a==="dash",l=e.canPlayType("application/vnd.apple.mpegurl")!=="";return new Promise((c,h)=>{const u=()=>{e.removeEventListener("loadedmetadata",d),e.removeEventListener("error",f)},d=()=>{u(),c()},f=()=>{u();const p=e.error?e.error.code:"unknown";h(new Error(`Video failed to load (media error ${p}). Is the source reachable and CORS-clean?`))};e.addEventListener("loadedmetadata",d),e.addEventListener("error",f),o&&!l?Promise.resolve().then(()=>HS).then(({default:p})=>{if(!p.isSupported()){u(),h(new Error("HLS/DASH stream needs hls.js, which is unsupported in this browser."));return}this.hls=new p({enableWorker:!0}),this.hls.on(p.Events.ERROR,(v,m)=>{m.fatal&&(u(),this.dispose(),h(new Error(`HLS fatal error: ${m.type} / ${m.details}`)))}),this.hls.loadSource(r),this.hls.attachMedia(e)}).catch(()=>{u(),h(new Error('This looks like an HLS/DASH stream but hls.js could not be loaded. Install "hls.js".'))}):(e.src=r,e.load())})}dispose(){this.hls&&(this.hls.destroy(),this.hls=null)}}function rc(s){let e=s;try{e=new URL(s).pathname}catch{}const t=e.toLowerCase();return t.endsWith(".m3u8")?"hls":t.endsWith(".mpd")?"dash":"progressive"}const i0={progressive:"/proxy/stream",hls:"/proxy/hls/manifest.m3u8",dash:"/proxy/mpd/manifest.m3u8"};function ac(s,e){const t=rc(s);if(!e||!e.url)return{url:s,format:t};const i=e.url.replace(/\/+$/,""),n=new URLSearchParams;n.set("d",s),e.apiPassword&&n.set("api_password",e.apiPassword);for(const[r,a]of Object.entries(e.headers??{}))a!=null&&a!==""&&n.set(`h_${r}`,a);return{url:`${i}${i0[t]}?${n.toString()}`,format:t}}function oc(s){if(!Number.isFinite(s)||s<0)return"0:00";const e=Math.floor(s%60),t=Math.floor(s/60%60),i=Math.floor(s/3600),n=String(e).padStart(2,"0");return i>0?`${i}:${String(t).padStart(2,"0")}:${n}`:`${t}:${n}`}function dt(s,e={},t=[]){const i=document.createElement(s),{class:n,...r}=e;n&&(i.className=n),Object.assign(i,r);for(const a of t)i.append(a);return i}class n0{constructor(e,t){this.nodes=[],this.disposers=[];const i=t.video,n=dt("button",{class:"tvp-btn tvp-play",title:"Play/Pause",textContent:"▶"}),r=dt("input",{class:"tvp-seek",type:"range",min:"0",max:"1000",value:"0"}),a=dt("span",{class:"tvp-time",textContent:"0:00 / 0:00"}),o=dt("button",{class:"tvp-btn tvp-mute",title:"Volume",textContent:"🔊"}),l=dt("input",{class:"tvp-volume",type:"range",min:"0",max:"1",step:"0.01",value:"1"}),c=dt("div",{class:"tvp-volpopup",hidden:!0},[l]),h=dt("span",{class:"tvp-volwrap"},[o,c]),u=dt("span",{class:"tvp-vrslot"}),d=dt("button",{class:"tvp-btn tvp-projbtn",title:"Projection",textContent:"🌐"}),f=dt("div",{class:"tvp-projmenu",hidden:!0});for(const P of Zl){const H=dt("button",{textContent:P.label});H.dataset.mode=P.value,f.append(H)}const p=dt("span",{class:"tvp-projwrap"},[d,f]),v=dt("button",{class:"tvp-btn tvp-settingsbtn",title:"Settings",textContent:"⚙"}),m=dt("button",{class:"tvp-btn tvp-fullscreen",title:"Fullscreen",textContent:"⛶"}),g=dt("footer",{class:"tvp-controls"},[n,r,a,h,u,p,v,m]),E=dt("input",{type:"checkbox",checked:t.initial.swapEyes}),_=dt("input",{type:"range",min:"30",max:"100",step:"1",value:String(t.initial.fov)}),T=dt("span",{textContent:String(t.initial.fov)}),b=dt("input",{type:"range",min:"1",max:"2",step:"0.25",value:String(t.initial.supersampling)}),R=dt("span",{textContent:String(t.initial.supersampling)}),A=dt("section",{class:"tvp-settings"},[dt("label",{class:"row"},[E,"Swap eyes (if depth looks wrong)"]),dt("label",{},[lc("Field of view (zoom): ",T,"°"),_]),dt("label",{},[lc("Supersampling: ",R,"× (sharpness)"),b])]),C=dt("div",{class:"tvp-toast"});this.nodes.push(g,A,C);for(const P of this.nodes)e.append(P);const x=(P,H,w,F)=>{P.addEventListener(H,w,F),this.disposers.push(()=>P.removeEventListener(H,w,F))},y=P=>r.style.setProperty("--seek",`${P}%`);x(n,"click",()=>{i.paused?i.play():i.pause()}),x(i,"play",()=>{n.textContent="⏸"}),x(i,"pause",()=>{n.textContent="▶"}),x(i,"timeupdate",()=>{if(i.duration){const P=i.currentTime/i.duration*100;r.value=String(P*10),y(P),a.textContent=`${oc(i.currentTime)} / ${oc(i.duration)}`}}),x(r,"input",()=>{y(Number(r.value)/10),i.duration&&(i.currentTime=Number(r.value)/1e3*i.duration)}),x(o,"click",P=>{P.stopPropagation(),c.hidden=!c.hidden}),x(l,"input",()=>{i.volume=Number(l.value),i.muted=i.volume===0,o.textContent=i.muted?"🔇":"🔊"});const D=()=>{const P=t.getProjection();let H="Projection";f.querySelectorAll("button").forEach(w=>{const F=w.dataset.mode===P;w.classList.toggle("active",F),F&&(H=`Projection: ${w.textContent}`)}),d.title=H};x(d,"click",P=>{P.stopPropagation(),f.hidden=!f.hidden}),x(f,"click",P=>{const H=P.target.closest("button[data-mode]");H&&(t.setProjection(H.dataset.mode),D(),f.hidden=!0)}),D(),x(v,"click",P=>{P.stopPropagation(),A.classList.toggle("open")}),x(E,"change",()=>t.setSwapEyes(E.checked)),x(_,"input",()=>{const P=Number(_.value);T.textContent=String(P),t.setFov(P)}),x(b,"input",()=>{const P=Number(b.value);R.textContent=String(P),t.setSupersampling(P)}),x(t.surface,"wheel",P=>{P.preventDefault();const H=Math.max(30,Math.min(100,Number(_.value)+Math.sign(P.deltaY)*3));_.value=String(H),T.textContent=String(H),t.setFov(H)},{passive:!1}),x(m,"click",()=>{var H,w;const P=t.fullscreenTarget;document.fullscreenElement?(w=document.exitFullscreen)==null||w.call(document):(H=P.requestFullscreen)==null||H.call(P)}),x(document,"click",P=>{const H=P.composedPath();!c.hidden&&!H.includes(c)&&!H.includes(o)&&(c.hidden=!0),!f.hidden&&!H.includes(f)&&!H.includes(d)&&(f.hidden=!0)}),t.vrSupported().then(P=>{P&&(Object.assign(t.vrButton.style,{position:"static",left:"auto",bottom:"auto",transform:"none",margin:"0"}),u.append(t.vrButton))})}dispose(){for(const e of this.disposers)e();for(const e of this.nodes)e.remove()}}function lc(s,e,t){const i=document.createDocumentFragment();return i.append(s,e,t),i}const cc=":host,:host *,.tvp,.tvp *{box-sizing:border-box}.tvp-canvas{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}.tvp-canvas:active{cursor:grabbing}.tvp-video{display:none}.tvp-controls{position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;gap:10px;padding:12px;background:linear-gradient(transparent,#000c);z-index:5;font:14px system-ui,Segoe UI,Roboto,sans-serif;color:#e8eaed}.tvp-btn{padding:4px;border:0;background:none;color:#e8eaed;cursor:pointer;font-size:22px;line-height:1}.tvp-btn:hover{opacity:.7}.tvp-seek{flex:1;-webkit-appearance:none;-moz-appearance:none;appearance:none;height:14px;background:transparent;cursor:pointer;margin:0}.tvp-seek::-webkit-slider-runnable-track{height:4px;border-radius:2px;background:linear-gradient(to right,#4f8cff var(--seek,0%),#3a4150 var(--seek,0%))}.tvp-seek::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-4px;width:12px;height:12px;border-radius:50%;background:#fff;cursor:pointer}.tvp-seek::-moz-range-track{height:4px;border-radius:2px;background:#3a4150}.tvp-seek::-moz-range-progress{height:4px;border-radius:2px;background:#4f8cff}.tvp-seek::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff;cursor:pointer}.tvp-time{font-variant-numeric:tabular-nums;min-width:96px;text-align:center;color:#cfd6e2}.tvp-volwrap,.tvp-projwrap{position:relative;display:inline-flex}.tvp-volpopup{position:absolute;bottom:calc(100% + 10px);left:50%;transform:translate(-50%);width:40px;height:132px;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:10px;z-index:8;box-shadow:0 8px 24px #0009}.tvp-volpopup[hidden]{display:none}.tvp-volume{position:absolute;top:50%;left:50%;width:104px;height:14px;margin:0;transform:translate(-50%,-50%) rotate(-90deg);-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;cursor:pointer}.tvp-volume::-webkit-slider-runnable-track{height:4px;border-radius:2px;background:#3a4150}.tvp-volume::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-top:-4px;width:12px;height:12px;border-radius:50%;background:#fff;cursor:pointer}.tvp-volume::-moz-range-track{height:4px;border-radius:2px;background:#3a4150}.tvp-volume::-moz-range-thumb{width:12px;height:12px;border:0;border-radius:50%;background:#fff;cursor:pointer}.tvp-projmenu{position:absolute;bottom:calc(100% + 8px);right:0;min-width:210px;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:10px;padding:6px;display:flex;flex-direction:column;gap:2px;z-index:8;box-shadow:0 8px 24px #0009}.tvp-projmenu[hidden]{display:none}.tvp-projmenu button{text-align:left;background:transparent;border:0;color:#e8eaed;padding:8px 10px;border-radius:7px;cursor:pointer;font:inherit;white-space:nowrap}.tvp-projmenu button:hover{background:#252b39}.tvp-projmenu button.active{background:#4f8cff;color:#fff}.tvp-vrslot button{position:static!important}.tvp-settings{position:absolute;bottom:62px;right:10px;width:300px;max-width:calc(100% - 20px);max-height:70%;overflow-y:auto;background:#121418eb;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid #2a2f3a;border-radius:12px;padding:14px;display:none;flex-direction:column;gap:12px;z-index:6;font:14px system-ui,Segoe UI,Roboto,sans-serif;color:#e8eaed}.tvp-settings.open{display:flex}.tvp-settings label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:#aab2c0}.tvp-settings label.row{flex-direction:row;align-items:center;gap:8px;color:#e8eaed;font-size:13px}.tvp-settings input[type=range]{width:100%;accent-color:#4f8cff}.tvp-toast{position:absolute;left:50%;bottom:74px;transform:translate(-50%);max-width:80%;padding:10px 16px;border-radius:10px;background:#1b1f2aed;border:1px solid #2a2f3a;color:#e8eaed;opacity:0;pointer-events:none;transition:opacity .2s;z-index:7;font:13px system-ui}.tvp-toast.show{opacity:1}",hc="three-vr-player:settings";class uc{constructor(e,t={}){this.source=new sc,this.listeners=new Map,this.readyEmitted=!1,this.native=!1,this.loading=!1,this.opts=t;const i=t.persistSettings?this.loadSettings():null;this.view={projection:t.projection??(i==null?void 0:i.projection)??"180-sbs",swapEyes:t.swapEyes??(i==null?void 0:i.swapEyes)??!1,fov:t.fov??(i==null?void 0:i.fov)??70,supersampling:t.supersampling??(i==null?void 0:i.supersampling)??1.5},this.wrap=document.createElement("div"),this.wrap.className="tvp",this.wrap.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;",e.appendChild(this.wrap);let n;if(t.shadowDom!==!1){const r=this.wrap.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=cc,r.appendChild(a),n=r}else{if(!document.getElementById("tvp-styles")){const r=document.createElement("style");r.id="tvp-styles",r.textContent=cc,document.head.appendChild(r)}n=this.wrap}this.canvas=document.createElement("canvas"),this.canvas.className="tvp-canvas",this.video=document.createElement("video"),this.video.className="tvp-video",this.video.playsInline=!0,t.crossOrigin!==null&&(this.video.crossOrigin=t.crossOrigin??"anonymous"),n.append(this.canvas,this.video),this.scene=new ec({canvas:this.canvas,video:this.video,projection:this.view.projection,swapEyes:this.view.swapEyes,fov:this.view.fov,supersampling:this.view.supersampling}),this.look=new nc(this.scene.camera,this.canvas,{isPresenting:()=>this.scene.renderer.xr.isPresenting}),this.scene.onFrame(()=>this.look.update()),this.look.setEnabled(!this.scene.isFlat()),t.controls!==!1&&(this.ui=new n0(n,{video:this.video,surface:this.canvas,fullscreenTarget:this.wrap,vrButton:this.scene.vrButton,vrSupported:()=>this.vrSupported(),getProjection:()=>this.scene.getProjection(),setProjection:r=>this.setProjection(r),setSwapEyes:r=>this.setSwapEyes(r),setFov:r=>this.setFov(r),setSupersampling:r=>this.setSupersampling(r),initial:{swapEyes:this.view.swapEyes,fov:this.view.fov,supersampling:this.view.supersampling}})),this.video.addEventListener("play",()=>this.emit("play")),this.video.addEventListener("pause",()=>this.emit("pause")),this.video.addEventListener("ended",()=>this.emit("ended")),this.video.addEventListener("timeupdate",()=>this.emit("timeupdate",this.video.currentTime)),this.video.addEventListener("error",()=>{this.loading||this.emit("error",this.video.error)}),this.video.addEventListener("loadedmetadata",()=>{this.readyEmitted||(this.readyEmitted=!0,this.emit("ready"))}),this.scene.renderer.xr.addEventListener("sessionstart",()=>this.emit("enterxr")),this.scene.renderer.xr.addEventListener("sessionend",()=>this.emit("exitxr")),t.src&&this.load(t.src,{projection:t.projection})}vrSupported(){return this.opts.vrButton===!1||!navigator.xr?Promise.resolve(!1):navigator.xr.isSessionSupported("immersive-vr").catch(()=>!1)}async load(e,t={}){const i=t.projection??(this.opts.autoDetect!==!1?Jl(e):null);i&&this.setProjection(i);const{url:n,format:r}=ac(e,this.opts.proxy),a=this.opts.crossOrigin===void 0?"anonymous":this.opts.crossOrigin;this.loading=!0;try{await this.source.attach(this.video,{url:n,format:r},{crossOrigin:a}),this.setNativeFallback(!1),await this.video.play().catch(()=>{})}catch(o){if(this.opts.nativeFallback!==!1&&r==="progressive"&&a!==null)try{this.setNativeFallback(!0),await this.source.attach(this.video,{url:n,format:r},{crossOrigin:null}),await this.video.play().catch(()=>{}),this.emit("fallback");return}catch(l){throw this.setNativeFallback(!1),this.emit("error",l),l}throw this.setNativeFallback(!1),this.emit("error",o),o}finally{this.loading=!1}}setNativeFallback(e){e!==this.native&&(this.native=e,e?(this.scene.pauseRendering(),this.canvas.style.display="none",Object.assign(this.video.style,{display:"block",position:"absolute",inset:"0",width:"100%",height:"100%",objectFit:"contain",background:"#000",zIndex:"1"})):(this.canvas.style.display="",this.video.style.cssText="",this.scene.resumeRendering()))}async play(){await this.video.play()}pause(){this.video.pause()}setProjection(e){this.scene.setProjection(e),this.look.setEnabled(!this.scene.isFlat()),this.look.reset(),this.view.projection=e,this.persist(),this.emit("projectionchange",e)}setSwapEyes(e){this.scene.setSwapEyes(e),this.view.swapEyes=e,this.persist()}setFov(e){this.scene.setFov(e),this.view.fov=e,this.persist()}setSupersampling(e){this.scene.setSupersampling(e),this.view.supersampling=e,this.persist()}async enterVR(){var t;const e=this.scene.vrButton;(t=e==null?void 0:e.click)==null||t.call(e)}get three(){return{renderer:this.scene.renderer,scene:this.scene.scene,camera:this.scene.camera}}on(e,t){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(t),this}off(e,t){var i;return(i=this.listeners.get(e))==null||i.delete(t),this}emit(e,t){var i;(i=this.listeners.get(e))==null||i.forEach(n=>n(t))}persist(){if(this.opts.persistSettings)try{localStorage.setItem(hc,JSON.stringify(this.view))}catch{}}loadSettings(){try{const e=localStorage.getItem(hc);return e?JSON.parse(e):null}catch{return null}}dispose(){var e;(e=this.ui)==null||e.dispose(),this.look.dispose(),this.source.dispose(),this.scene.dispose(),this.video.remove(),this.canvas.remove(),this.wrap.remove(),this.listeners.clear()}}class dc extends HTMLElement{static get observedAttributes(){return["src","projection"]}connectedCallback(){this.player||(this.style.display||(this.style.display="block"),this.player=new uc(this,{src:this.getAttribute("src")??void 0,projection:this.getAttribute("projection")??void 0,controls:this.hasAttribute("controls"),swapEyes:this.hasAttribute("swap-eyes"),autoDetect:this.getAttribute("auto-detect")!=="false",fov:this.numAttr("fov"),supersampling:this.numAttr("supersampling"),proxy:this.getAttribute("proxy-url")?{url:this.getAttribute("proxy-url"),apiPassword:this.getAttribute("proxy-password")??void 0}:void 0}))}attributeChangedCallback(e,t,i){!this.player||i==null||(e==="src"&&this.player.load(i),e==="projection"&&this.player.setProjection(i))}disconnectedCallback(){var e;(e=this.player)==null||e.dispose(),this.player=void 0}numAttr(e){const t=this.getAttribute(e);return t==null?void 0:Number(t)}get api(){return this.player}}function fc(s="three-video"){typeof customElements<"u"&&!customElements.get(s)&&customElements.define(s,dc)}fc();const de=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},s0=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=r0},r0=Number.MAX_SAFE_INTEGER||9007199254740991;let Ee=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),V=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.UNKNOWN="unknown",s}({}),S=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s}({});var Ye={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ge={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class Hn{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class a0{constructor(e,t,i,n=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Hn(e),this.fast_=new Hn(t),this.defaultTTFB_=n,this.ttfb_=new Hn(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Hn(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new Hn(t,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Hn(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,r=i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function o0(s,e,t){return(e=c0(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function rt(){return rt=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},rt.apply(null,arguments)}function pc(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),t.push.apply(t,i)}return t}function Je(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pc(Object(t),!0).forEach(function(i){o0(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):pc(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function l0(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function c0(s){var e=l0(s,"string");return typeof e=="symbol"?e:e+""}class li{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=Qi,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const Qi=function(){},h0={trace:Qi,debug:Qi,log:Qi,warn:Qi,info:Qi,error:Qi};function Ma(){return rt({},h0)}function u0(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):Qi}function mc(s,e,t){return e[s]?e[s].bind(e):u0(s,t)}const La=Ma();function d0(s,e,t){const i=Ma();if(typeof console=="object"&&s===!0||typeof s=="object"){const n=["debug","log","info","warn","error"];n.forEach(r=>{i[r]=mc(r,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.16`)}catch{return Ma()}n.forEach(r=>{La[r]=mc(r,s)})}else rt(La,i);return i}const et=La;function Ni(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function f0(s){return typeof self<"u"&&s===self.ManagedMediaSource}function gc(s,e){const t=Object.keys(s),i=Object.keys(e),n=t.length,r=i.length;return!n||!r||n===r&&!t.some(a=>i.indexOf(a)===-1)}function ti(s,e=!1){if(typeof TextDecoder<"u"){const c=new TextDecoder("utf-8").decode(s);if(e){const h=c.indexOf("\0");return h!==-1?c.substring(0,h):c}return c.replace(/\0/g,"")}const t=s.length;let i,n,r,a="",o=0;for(;o<t;){if(i=s[o++],i===0&&e)return a;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:n=s[o++],a+=String.fromCharCode((i&31)<<6|n&63);break;case 14:n=s[o++],r=s[o++],a+=String.fromCharCode((i&15)<<12|(n&63)<<6|(r&63)<<0);break}}return a}function Ut(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function vc(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function p0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ia={exports:{}},_c;function m0(){return _c||(_c=1,function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,c,h){if(h=h||{},l=l.trim(),c=c.trim(),!c){if(!h.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var d=o.parseURL(c);if(!d)throw new Error("Error trying to parse relative URL.");if(d.scheme)return h.alwaysNormalize?(d.path=o.normalizePath(d.path),o.buildURLFromParts(d)):c;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var p=n.exec(f.path);f.netLoc=p[1],f.path=p[2]}f.netLoc&&!f.path&&(f.path="/");var v={scheme:f.scheme,netLoc:d.netLoc,path:null,params:d.params,query:d.query,fragment:d.fragment};if(!d.netLoc&&(v.netLoc=f.netLoc,d.path[0]!=="/"))if(!d.path)v.path=f.path,d.params||(v.params=f.params,d.query||(v.query=f.query));else{var m=f.path,g=m.substring(0,m.lastIndexOf("/")+1)+d.path;v.path=o.normalizePath(g)}return v.path===null&&(v.path=h.alwaysNormalize?o.normalizePath(d.path):d.path),o.buildURLFromParts(v)},parseURL:function(l){var c=i.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(r,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};s.exports=o})()}(Ia)),Ia.exports}var Ca=m0();class ar{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 at={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Da{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,g0(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let n;i.length===1?n=(t==null?void 0:t.byteRangeEndOffset)||0:n=parseInt(i[1]),this._byteRange=[n,parseInt(i[0])+n]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[at.AUDIO]:null,[at.VIDEO]:null,[at.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new ar),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ca.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[at.AUDIO]=null,e[at.VIDEO]=null,e[at.AUDIOVIDEO]=null}}function Et(s){return s.sn!=="initSegment"}class or extends Da{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(de(e)&&de(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=de(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),n=i.length;if(n>1||n===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!de(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return Et(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const n=t[e];n&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=n.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,r,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:r,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,n),l.endDTS=Math.max(l.endDTS,r)}}class Ec extends Da{constructor(e,t,i,n,r){super(i),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.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Sc(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||Sc(t,e)}}function g0(s,e){const t=Sc(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}const xc=Math.pow(2,32)-1,v0=[].push,yc={video:1,audio:2,id3:3,text:4};function At(s){return String.fromCharCode.apply(null,s)}function Tc(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function we(s,e){const t=bc(s,e);return t<0?4294967296+t:t}function Ac(s,e){let t=we(s,e);return t*=Math.pow(2,32),t+=we(s,e+4),t}function bc(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function _0(s){const e=s.byteLength;for(let t=0;t<e;){const i=we(s,t);if(i>8&&s[t+4]===109&&s[t+5]===111&&s[t+6]===111&&s[t+7]===102)return!0;t=i>1?t+i:e}return!1}function We(s,e){const t=[];if(!e.length)return t;const i=s.byteLength;for(let n=0;n<i;){const r=we(s,n),a=At(s.subarray(n+4,n+8)),o=r>1?n+r:i;if(a===e[0])if(e.length===1)t.push(s.subarray(n+8,o));else{const l=We(s.subarray(n+8,o),e.slice(1));l.length&&v0.apply(t,l)}n=o}return t}function E0(s){const e=[],t=s[0];let i=8;const n=we(s,i);i+=4;let r=0,a=0;t===0?(r=we(s,i),a=we(s,i+4),i+=8):(r=Ac(s,i),a=Ac(s,i+8),i+=16),i+=2;let o=s.length+a;const l=Tc(s,i);i+=2;for(let c=0;c<l;c++){let h=i;const u=we(s,h);h+=4;const d=u&2147483647;if((u&2147483648)>>>31===1)return et.warn("SIDX has hierarchical references (not supported)"),null;const p=we(s,h);h+=4,e.push({referenceSize:d,subsegmentDuration:p,info:{duration:p/n,start:o,end:o+d-1}}),o+=d,h+=4,i=h}return{earliestPresentationTime:r,timescale:n,version:t,referencesCount:l,references:e}}function Rc(s){const e=[],t=We(s,["moov","trak"]);for(let n=0;n<t.length;n++){const r=t[n],a=We(r,["tkhd"])[0];if(a){let o=a[0];const l=we(a,o===0?12:20),c=We(r,["mdia","mdhd"])[0];if(c){o=c[0];const h=we(c,o===0?12:20),u=We(r,["mdia","hdlr"])[0];if(u){const d=At(u.subarray(8,12)),f={soun:at.AUDIO,vide:at.VIDEO}[d],p=We(r,["mdia","minf","stbl","stsd"])[0],v=S0(p);f?(e[l]={timescale:h,type:f,stsd:v},e[f]=Je({timescale:h,id:l},v)):e[l]={timescale:h,type:d,stsd:v}}}}}return We(s,["moov","mvex","trex"]).forEach(n=>{const r=we(n,4),a=e[r];a&&(a.default={duration:we(n,12),flags:we(n,20)})}),e}function S0(s){const e=s.subarray(8),t=e.subarray(86),i=At(e.subarray(4,8));let n=i,r;const a=i==="enca"||i==="encv";if(a){const c=We(e,[i])[0].subarray(i==="enca"?28:78);We(c,["sinf"]).forEach(u=>{const d=We(u,["schm"])[0];if(d){const f=At(d.subarray(4,8));if(f==="cbcs"||f==="cenc"){const p=We(u,["frma"])[0];p&&(n=At(p))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const l=We(t,["avcC"])[0];l&&l.length>3&&(n+="."+cr(l[1])+cr(l[2])+cr(l[3]),r=lr(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const l=We(e,[i])[0],c=We(l.subarray(28),["esds"])[0];if(c&&c.length>7){let h=4;if(c[h++]!==3)break;h=wa(c,h),h+=2;const u=c[h++];if(u&128&&(h+=2),u&64&&(h+=c[h++]),c[h++]!==4)break;h=wa(c,h);const d=c[h++];if(d===64)n+="."+cr(d);else break;if(h+=12,c[h++]!==5)break;h=wa(c,h);const f=c[h++];let p=(f&248)>>3;p===31&&(p+=1+((f&7)<<3)+((c[h]&224)>>5)),n+="."+p}break}case"hvc1":case"hev1":{const l=We(t,["hvcC"])[0];if(l&&l.length>12){const c=l[1],h=["","A","B","C"][c>>6],u=c&31,d=we(l,2),f=(c&32)>>5?"H":"L",p=l[12],v=l.subarray(6,12);n+="."+h+u,n+="."+x0(d).toString(16).toUpperCase(),n+="."+f+p;let m="";for(let g=v.length;g--;){const E=v[g];(E||m)&&(m="."+E.toString(16).toUpperCase()+m)}n+=m}r=lr(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{n=lr(n,t)||n;break}case"vp09":{const l=We(t,["vpcC"])[0];if(l&&l.length>6){const c=l[4],h=l[5],u=l[6]>>4&15;n+="."+yi(c)+"."+yi(h)+"."+yi(u)}break}case"av01":{const l=We(t,["av1C"])[0];if(l&&l.length>2){const c=l[1]>>>5,h=l[1]&31,u=l[2]>>>7?"H":"M",d=(l[2]&64)>>6,f=(l[2]&32)>>5,p=c===2&&d?f?12:10:d?10:8,v=(l[2]&16)>>4,m=(l[2]&8)>>3,g=(l[2]&4)>>2,E=l[2]&3;n+="."+c+"."+yi(h)+u+"."+yi(p)+"."+v+"."+m+g+E+"."+yi(1)+"."+yi(1)+"."+yi(1)+"."+0,r=lr("dav1",t)}break}}return{codec:n,encrypted:a,supplemental:r}}function lr(s,e){const t=We(e,["dvvC"]),i=t.length?t[0]:We(e,["dvcC"])[0];if(i){const n=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return s+"."+yi(n)+"."+yi(r)}}function x0(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function wa(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function cr(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function yi(s){return(s<10?"0":"")+s}function y0(s,e){if(!s||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Mc(s,(i,n)=>{const r=i.subarray(8,24);r.some(a=>a!==0)||(et.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${Ut(r)} -> ${Ut(t)}`),i.set(t,8))})}function T0(s){const e=[];return Mc(s,t=>e.push(t.subarray(8,24))),e}function Mc(s,e){We(s,["moov","trak"]).forEach(i=>{const n=We(i,["mdia","minf","stbl","stsd"])[0];if(!n)return;const r=n.subarray(8);let a=We(r,["enca"]);const o=a.length>0;o||(a=We(r,["encv"])),a.forEach(l=>{const c=o?l.subarray(28):l.subarray(78);We(c,["sinf"]).forEach(u=>{const d=Lc(u);d&&e(d,o)})})})}function Lc(s){const e=We(s,["schm"])[0];if(e){const t=At(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=We(s,["schi","tenc"])[0];if(i)return i}}}function A0(s,e,t){const i={},n=We(s,["moof","traf"]);for(let r=0;r<n.length;r++){const a=n[r],o=We(a,["tfhd"])[0],l=we(o,4),c=e[l];if(!c)continue;i[l]||(i[l]={start:NaN,duration:0,sampleCount:0,timescale:c.timescale,type:c.type});const h=i[l],u=We(a,["tfdt"])[0];if(u){const _=u[0];let T=we(u,4);_===1&&(T===xc?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(T*=xc+1,T+=we(u,8))),de(T)&&(!de(h.start)||T<h.start)&&(h.start=T)}const d=c.default,f=we(o,0)|(d==null?void 0:d.flags);let p=(d==null?void 0:d.duration)||0;f&8&&(f&2?p=we(o,12):p=we(o,8));const v=We(a,["trun"]);let m=h.start||0,g=0,E=p;for(let _=0;_<v.length;_++){const T=v[_],b=we(T,4),R=h.sampleCount;h.sampleCount+=b;const A=T[3]&1,C=T[3]&4,x=T[2]&1,y=T[2]&2,D=T[2]&4,P=T[2]&8;let H=8,w=b;for(A&&(H+=4),C&&b&&(!(T[H+1]&1)&&h.keyFrameIndex===void 0&&(h.keyFrameIndex=R),H+=4,x?(E=we(T,H),H+=4):E=p,y&&(H+=4),P&&(H+=4),m+=E,g+=E,w--);w--;)x?(E=we(T,H),H+=4):E=p,y&&(H+=4),D&&(T[H+1]&1||h.keyFrameIndex===void 0&&(h.keyFrameIndex=h.sampleCount-(w+1),h.keyFrameStart=m),H+=4),P&&(H+=4),m+=E,g+=E;!g&&p&&(g+=p*b)}h.duration+=g}if(!Object.keys(i).some(r=>i[r].duration)){let r=1/0,a=0;const o=We(s,["sidx"]);for(let l=0;l<o.length;l++){const c=E0(o[l]);if(c!=null&&c.references){r=Math.min(r,c.earliestPresentationTime/c.timescale);const h=c.references.reduce((u,d)=>u+d.info.duration||0,0);a=Math.max(a,h+c.earliestPresentationTime/c.timescale)}}a&&de(a)&&Object.keys(i).forEach(l=>{i[l].duration||(i[l].duration=a*i[l].timescale-i[l].start)})}return i}function b0(s){const e={valid:null,remainder:null},t=We(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function ci(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function Ic(s,e){const t=[],i=e.samples,n=e.timescale,r=e.id;let a=!1;return We(i,["moof"]).map(l=>{const c=l.byteOffset-8;We(l,["traf"]).map(u=>{const d=We(u,["tfdt"]).map(f=>{const p=f[0];let v=we(f,4);return p===1&&(v*=Math.pow(2,32),v+=we(f,8)),v/n})[0];return d!==void 0&&(s=d),We(u,["tfhd"]).map(f=>{const p=we(f,4),v=we(f,0)&16777215,m=(v&1)!==0,g=(v&2)!==0,E=(v&8)!==0;let _=0;const T=(v&16)!==0;let b=0;const R=(v&32)!==0;let A=8;p===r&&(m&&(A+=8),g&&(A+=4),E&&(_=we(f,A),A+=4),T&&(b=we(f,A),A+=4),R&&(A+=4),e.type==="video"&&(a=hr(e.codec)),We(u,["trun"]).map(C=>{const x=C[0],y=we(C,0)&16777215,D=(y&1)!==0;let P=0;const H=(y&4)!==0,w=(y&256)!==0;let F=0;const O=(y&512)!==0;let z=0;const N=(y&1024)!==0,k=(y&2048)!==0;let q=0;const G=we(C,4);let K=8;D&&(P=we(C,K),K+=4),H&&(K+=4);let $=P+c;for(let ee=0;ee<G;ee++){if(w?(F=we(C,K),K+=4):F=_,O?(z=we(C,K),K+=4):z=b,N&&(K+=4),k&&(x===0?q=we(C,K):q=bc(C,K),K+=4),e.type===at.VIDEO){let ie=0;for(;ie<z;){const oe=we(i,$);if($+=4,R0(a,i[$])){const me=i.subarray($,$+oe);Pa(me,a?2:1,s+q/n,t)}$+=oe,ie+=oe+4}}s+=F/n}}))})})}),t}function hr(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function R0(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Pa(s,e,t,i){const n=Cc(s);let r=0;r+=e;let a=0,o=0,l=0;for(;r<n.length;){a=0;do{if(r>=n.length)break;l=n[r++],a+=l}while(l===255);o=0;do{if(r>=n.length)break;l=n[r++],o+=l}while(l===255);const c=n.length-r;let h=r;if(o<c)r+=o;else if(o>c){et.error(`Malformed SEI payload. ${o} is too small, only ${c} bytes left to parse.`);break}if(a===4){if(n[h++]===181){const d=Tc(n,h);if(h+=2,d===49){const f=we(n,h);if(h+=4,f===1195456820){const p=n[h++];if(p===3){const v=n[h++],m=31&v,g=64&v,E=g?2+m*3:0,_=new Uint8Array(E);if(g){_[0]=v;for(let T=1;T<E;T++)_[T]=n[h++]}i.push({type:p,payloadType:a,pts:t,bytes:_})}}}}}else if(a===5&&o>16){const u=[];for(let p=0;p<16;p++){const v=n[h++].toString(16);u.push(v.length==1?"0"+v:v),(p===3||p===5||p===7||p===9)&&u.push("-")}const d=o-16,f=new Uint8Array(d);for(let p=0;p<d;p++)f[p]=n[h++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:ti(f),userDataBytes:f})}}}function Cc(s){const e=s.byteLength,t=[];let i=1;for(;i<e-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return s;const n=e-t.length,r=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===t[0]&&(a++,t.shift()),r[i]=s[a];return r}function M0(s){const e=s[0];let t="",i="",n=0,r=0,a=0,o=0,l=0,c=0;if(e===0){for(;At(s.subarray(c,c+1))!=="\0";)t+=At(s.subarray(c,c+1)),c+=1;for(t+=At(s.subarray(c,c+1)),c+=1;At(s.subarray(c,c+1))!=="\0";)i+=At(s.subarray(c,c+1)),c+=1;i+=At(s.subarray(c,c+1)),c+=1,n=we(s,12),r=we(s,16),o=we(s,20),l=we(s,24),c=28}else if(e===1){c+=4,n=we(s,c),c+=4;const u=we(s,c);c+=4;const d=we(s,c);for(c+=4,a=4294967296*u+d,s0(a)||(a=Number.MAX_SAFE_INTEGER,et.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=we(s,c),c+=4,l=we(s,c),c+=4;At(s.subarray(c,c+1))!=="\0";)t+=At(s.subarray(c,c+1)),c+=1;for(t+=At(s.subarray(c,c+1)),c+=1;At(s.subarray(c,c+1))!=="\0";)i+=At(s.subarray(c,c+1)),c+=1;i+=At(s.subarray(c,c+1)),c+=1}const h=s.subarray(c,s.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:r,eventDuration:o,id:l,payload:h}}function L0(s,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(s,4),n=0,i=8;n<t;n++)r.set(e[n],i),i+=e[n].byteLength;return r}function I0(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;i=0,n=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),L0([112,115,115,104],new Uint8Array([i,0,0,0]),s,r,n,a,t)}function C0(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const n=new DataView(s,i),r=D0(n);e.push(r),i+=r.size}}return e}function D0(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const r=s.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const a=s.buffer,o=Ut(new Uint8Array(a,t+12,16));let l=null,c=null,h=0;if(r===0)h=28;else{const d=s.getUint32(28);if(!d||i<32+d*16)return{offset:t,size:e};l=[];for(let f=0;f<d;f++)l.push(new Uint8Array(a,t+32+f*16,16));h=32+d*16}if(!h)return{offset:t,size:e};const u=s.getUint32(h);return e-32<u?{offset:t,size:e}:(c=new Uint8Array(a,t+h+4,u),{version:r,systemId:o,kids:l,data:c,offset:t,size:e})}const Dc=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),$n={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Fa(s,e){const t=$n[e];return!!t&&!!t[s.slice(0,4)]}function fs(s,e,t=!0){return!s.split(",").some(i=>!Oa(i,e,t))}function Oa(s,e,t=!0){var i;const n=Ni(t);return(i=n==null?void 0:n.isTypeSupported(ps(s,e)))!=null?i:!1}function ps(s,e){return`${e}/mp4;codecs=${s}`}function wc(s){if(s){const e=s.substring(0,4);return $n.video[e]}return 2}function ur(s){const e=Dc();return s.split(",").reduce((t,i)=>{const r=e&&hr(i)?9:$n.video[i];return r?(r*2+t)/(t?3:2):($n.audio[i]+t)/(t?2:1)},0)}const Ua={};function w0(s,e=!0){if(Ua[s])return Ua[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let n=0;n<t.length;n++){var i;if(Oa(t[n],"audio",e))return Ua[s]=t[n],t[n];if(t[n]==="mp3"&&(i=Ni(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const P0=/flac|opus|mp4a\.40\.34/i;function dr(s,e=!0){return s.replace(P0,t=>w0(t.toLowerCase(),e))}function F0(s,e){const t=[];if(s){const i=s.split(",");for(let n=0;n<i.length;n++)Fa(i[n],"video")||t.push(i[n])}return e&&t.push(e),t.join(",")}function fr(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Pc(s,"audio")||Pc(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Pc(s,e){return Fa(s,e)&&Oa(s,e)}function O0(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function U0(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Fc(s){const e=Ni(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Na(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const N0={supported:!0,powerEfficient:!0,smooth:!0},k0={supported:!1,smooth:!1,powerEfficient:!1},Oc={supported:!0,configurations:[],decodingInfoResults:[N0]};function Uc(s,e){return{supported:!1,configurations:e,decodingInfoResults:[k0],error:s}}function B0(s,e,t,i,n,r){const a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,l=r==null?void 0:r.audioCodec,c=r==null?void 0:r.channels,h=c?parseInt(c):l?1/0:2;let u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((d,f)=>{if(f){const p=e.groups[f];if(!p)throw new Error(`Audio track group ${f} not found`);Object.keys(p.channels).forEach(v=>{d[v]=(d[v]||0)+p.channels[v]})}return d},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(d=>hr(d))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(n,8e6))||!!u&&de(h)&&Object.keys(u).some(d=>parseInt(d)>h)}function Nc(s,e,t,i={}){const n=s.videoCodec;if(!n&&!s.audioCodec||!t)return Promise.resolve(Oc);const r=[],a=G0(s),o=a.length,l=V0(s,e,o>0),c=l.length;for(let h=o||1*c||1;h--;){const u={type:"media-source"};if(o&&(u.video=a[h%o]),c){u.audio=l[h%c];const d=u.audio.bitrate;u.video&&d&&(u.video.bitrate-=d)}r.push(u)}if(n){const h=navigator.userAgent;if(n.split(",").some(u=>hr(u))&&Dc())return Promise.resolve(Uc(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${h})`),r))}return Promise.all(r.map(h=>{const u=$0(h);return i[u]||(i[u]=t.decodingInfo(h))})).then(h=>({supported:!h.some(u=>!u.supported),configurations:r,decodingInfoResults:h})).catch(h=>({supported:!1,configurations:r,decodingInfoResults:[],error:h}))}function G0(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=kc(s),n=s.width||640,r=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(l=>{const c={contentType:ps(U0(l),"video"),width:n,height:r,bitrate:i,framerate:a};return o!=="sdr"&&(c.transferFunction=o),c}):[]}function V0(s,e,t){var i;const n=(i=s.audioCodec)==null?void 0:i.split(","),r=kc(s);return n&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var l;const c=o?(l=e.groups[o])==null?void 0:l.tracks:null;return c?c.reduce((h,u)=>{if(u.groupId===o){const d=parseFloat(u.channels||"");n.forEach(f=>{const p={contentType:ps(f,"audio"),bitrate:t?H0(f,r):r};d&&(p.channels=""+d),h.push(p)})}return h},a):a},[]):[]}function H0(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function kc(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function $0(s){let e="";const{audio:t,video:i}=s;if(i){const n=Na(i.contentType);e+=`${n}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const n=Na(t.contentType);e+=`${i?"_":""}${n}_c${t.channels}`}return e}const ka=["NONE","TYPE-0","TYPE-1",null];function z0(s){return ka.indexOf(s)>-1}const pr=["SDR","PQ","HLG"];function W0(s){return!!s&&pr.indexOf(s)>-1}var ms={No:"",Yes:"YES",v2:"v2"};function Bc(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,n=i<e/2;return e&&n?t?ms.v2:ms.Yes:ms.No}class Ba{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class zn{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=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.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Gc(this._audioGroups,e)}hasSubtitleGroup(e){return Gc(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Gc(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function K0(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function X0(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||pr.slice(0);const n=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:n&&K0(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const Y0=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},ot=(s,e)=>JSON.stringify(s,Y0(e));function q0(s,e,t,i,n){const r=Object.keys(s),a=i==null?void 0:i.channels,o=i==null?void 0:i.audioCodec,l=n==null?void 0:n.videoCodec,c=a&&parseInt(a)===2;let h=!1,u=!1,d=1/0,f=1/0,p=1/0,v=1/0,m=0,g=[];const{preferHDR:E,allowedVideoRanges:_}=X0(e,n);for(let C=r.length;C--;){const x=s[r[C]];h||(h=x.channels[2]>0),d=Math.min(d,x.minHeight),f=Math.min(f,x.minFramerate),p=Math.min(p,x.minBitrate),_.filter(D=>x.videoRanges[D]>0).length>0&&(u=!0)}d=de(d)?d:0,f=de(f)?f:0;const T=Math.max(1080,d),b=Math.max(30,f);p=de(p)?p:t,t=Math.max(p,t),u||(e=void 0);const R=r.length>1;return{codecSet:r.reduce((C,x)=>{const y=s[x];if(x===C)return C;if(g=u?_.filter(D=>y.videoRanges[D]>0):[],R){if(y.minBitrate>t)return Ti(x,`min bitrate of ${y.minBitrate} > current estimate of ${t}`),C;if(!y.hasDefaultAudio)return Ti(x,"no renditions with default or auto-select sound found"),C;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Ti(x,`audio codec preference "${o}" not found`),C;if(a&&!c){if(!y.channels[a])return Ti(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(y.channels)})`),C}else if((!o||c)&&h&&y.channels[2]===0)return Ti(x,"no renditions with stereo sound found"),C;if(y.minHeight>T)return Ti(x,`min resolution of ${y.minHeight} > maximum of ${T}`),C;if(y.minFramerate>b)return Ti(x,`min framerate of ${y.minFramerate} > maximum of ${b}`),C;if(!g.some(D=>y.videoRanges[D]>0))return Ti(x,`no variants with VIDEO-RANGE of ${ot(g)} found`),C;if(l&&x.indexOf(l.substring(0,4))%5!==0)return Ti(x,`video codec preference "${l}" not found`),C;if(y.maxScore<m)return Ti(x,`max score of ${y.maxScore} < selected max of ${m}`),C}return C&&(ur(x)>=ur(C)||y.fragmentError>s[C].fragmentError)?C:(v=y.minIndex,m=y.maxScore,x)},void 0),videoRanges:g,preferHDR:E,minFramerate:f,minBitrate:p,minIndex:v}}function Ti(s,e){et.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function Vc(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function j0(s,e,t,i){return s.slice(t,i+1).reduce((n,r,a)=>{if(!r.codecSet)return n;const o=r.audioGroups;let l=n[r.codecSet];l||(n[r.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,r.bitrate);const c=Math.min(r.height,r.width);return l.minHeight=Math.min(l.minHeight,c),l.minFramerate=Math.min(l.minFramerate,r.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,r.score),l.fragmentError+=r.fragmentError,l.videoRanges[r.videoRange]=(l.videoRanges[r.videoRange]||0)+1,o&&o.forEach(h=>{if(!h)return;const u=e.groups[h];u&&(l.hasDefaultAudio=l.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(d=>{l.channels[d]=(l.channels[d]||0)+u.channels[d]}))}),n},{})}function Hc(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}=s;return{lang:e,assocLang:t,characteristics:i,channels:n,audioCodec:r}}function Ai(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const n=e[i];if(dn(s,n,t))return i}return-1}function dn(s,e,t){const{groupId:i,name:n,lang:r,assocLang:a,default:o}=s,l=s.forced;return(i===void 0||e.groupId===i)&&(n===void 0||e.name===n)&&(r===void 0||Q0(r,e.lang))&&(r===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in s)||Z0(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function Q0(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function Z0(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(n=>i.indexOf(n)===-1)}function fn(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function J0(s,e,t,i,n){const r=e[i],o=e.reduce((d,f,p)=>{const v=f.uri;return(d[v]||(d[v]=[])).push(p),d},{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const l=r.videoRange,c=r.frameRate,h=r.codecSet.substring(0,4),u=$c(e,i,d=>{if(d.videoRange!==l||d.frameRate!==c||d.codecSet.substring(0,4)!==h)return!1;const f=d.audioGroups,p=t.filter(v=>!f||f.indexOf(v.groupId)!==-1);return Ai(s,p,n)>-1});return u>-1?u:$c(e,i,d=>{const f=d.audioGroups,p=t.filter(v=>!f||f.indexOf(v.groupId)!==-1);return Ai(s,p,n)>-1})}function $c(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function mr(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}class zc extends li{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:n,partCurrent:r,hls:a}=this,{autoLevelEnabled:o,media:l}=a;if(!n||!l)return;const c=performance.now(),h=r?r.stats:n.stats,u=r?r.duration:n.duration,d=c-h.loading.start,f=a.minAutoLevel,p=n.level,v=this._nextAutoLevel;if(h.aborted||h.loaded&&h.loaded===h.total||p<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const m=v>-1&&v!==p,g=!!t||m;if(!g&&(l.paused||!l.playbackRate||!l.readyState))return;const E=a.mainForwardBufferInfo;if(!g&&E===null)return;const _=this.bwEstimator.getEstimateTTFB(),T=Math.abs(l.playbackRate);if(d<=Math.max(_,1e3*(u/(T*2))))return;const b=E?E.len/T:0,R=h.loading.first?h.loading.first-h.loading.start:-1,A=h.loaded&&R>-1,C=this.getBwEstimate(),x=a.levels,y=x[p],D=Math.max(h.loaded,Math.round(u*(n.bitrate||y.averageBitrate)/8));let P=A?d-R:d;P<1&&A&&(P=Math.min(d,h.loaded*8/C));const H=A?h.loaded*1e3/P:0,w=_/1e3,F=H?(D-h.loaded)/H:D*8/C+w;if(F<=b)return;const O=H?H*8:C,z=((i=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,N=this.hls.config.abrBandWidthUpFactor;let k=Number.POSITIVE_INFINITY,q;for(q=p-1;q>f;q--){const ee=x[q].maxBitrate,ie=!x[q].details||z;if(k=this.getTimeToLoadFrag(w,O,u*ee,ie),k<Math.min(b,u+w))break}if(k>=F||k>u*10)return;A?this.bwEstimator.sample(d-Math.min(_,R),h.loaded):this.bwEstimator.sampleTTFB(d);const G=x[q].maxBitrate;this.getBwEstimate()*N>G&&this.resetEstimator(G);const K=this.findBestLevel(G,f,q,0,b,1,1);K>-1&&(q=K),this.warn(`Fragment ${n.sn}${r?" part "+r.index:""} of level ${p} is loading too slowly;
|
|
3687
3687
|
Fragment duration: ${n.duration.toFixed(3)}
|
|
3688
3688
|
Time to underbuffer: ${b.toFixed(3)} s
|
|
3689
3689
|
Estimated load time for current fragment: ${F.toFixed(3)} s
|