@needle-tools/engine 4.17.0-alpha.1 → 4.17.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1113,4 +1113,4 @@ void main() {
1113
1113
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
1114
1114
 
1115
1115
  #include <fog_vertex>
1116
- }`;class Oh extends Hc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new A.BufferGeometry,this.indexBuffer=new A.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Dn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Xs(this.settings.material.map.channel),e.map=new A.Uniform$1(this.settings.material.map),e.mapTransform=new A.Uniform$1(new It().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new A.ShaderMaterial({uniforms:e,defines:t,vertexShader:Ah,fragmentShader:Rh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||A.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const T=c[x],g=T.uvTile%f,v=Math.floor(T.uvTile/f+.001),_=T.previous.values();let b=_.next(),M=b.value,C=M;b.done||(b=_.next());let P;b.value!==void 0?P=b.value:P=C;for(let E=0;E<T.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(T.parentMatrix?this.vector_.copy(C.position).applyMatrix4(T.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.previousBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(T.parentMatrix?this.vector_.copy(M.position).applyMatrix4(T.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(T.parentMatrix?this.vector_.copy(P.position).applyMatrix4(T.parentMatrix):this.vector_.copy(P.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else if(T.parentMatrix)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else{const z=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,C.size*z),this.widthBuffer.setX(e+1,C.size*z)}this.uvBuffer.setXY(e,(E/T.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/T.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,C.color.x,C.color.y,C.color.z,C.color.w),this.colorBuffer.setXYZW(e+1,C.color.x,C.color.y,C.color.z,C.color.w),E+1<T.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),M=C,C=P,b.done||(b=_.next(),b.value!==void 0&&(P=b.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ji{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new A.Triangle;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new A.Vector3,this._tempB=new A.Vector3,this._tempC=new A.Vector3,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ji(t.geometries[e.geometry])}clone(){return new Ji(this._geometry)}update(e,t){}}lh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ji,loadJSON:Ji.fromJSON}],behaviors:[]});class yo extends A.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(yo.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new Oh(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new kh(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const zh=yo;vh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const qc=Math.sqrt(5),Ih=(qc-1)/4,Ue=(5-qc)/20,sr=r=>Math.floor(r)|0,or=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Bh(r=Math.random){const e=Nh(r),t=new Float64Array(e).map(a=>or[a%32*4]),n=new Float64Array(e).map(a=>or[a%32*4+1]),i=new Float64Array(e).map(a=>or[a%32*4+2]),s=new Float64Array(e).map(a=>or[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,T;const g=(o+c+l+u)*Ih,v=sr(o+g),_=sr(c+g),b=sr(l+g),M=sr(u+g),C=(v+_+b+M)*Ue,P=v-C,E=_-C,z=b-C,I=M-C,R=o-P,N=c-E,O=l-z,U=u-I;let F=0,J=0,W=0,K=0;R>N?F++:J++,R>O?F++:W++,R>U?F++:K++,N>O?J++:W++,N>U?J++:K++,O>U?W++:K++;const $=F>=3?1:0,me=J>=3?1:0,ne=W>=3?1:0,ue=K>=3?1:0,re=F>=2?1:0,ge=J>=2?1:0,be=W>=2?1:0,se=K>=2?1:0,he=F>=1?1:0,oe=J>=1?1:0,Xe=W>=1?1:0,Ve=K>=1?1:0,Je=R-$+Ue,Ye=N-me+Ue,xe=O-ne+Ue,ye=U-ue+Ue,ae=R-re+2*Ue,ut=N-ge+2*Ue,ke=O-be+2*Ue,fe=U-se+2*Ue,it=R-he+3*Ue,vt=N-oe+3*Ue,St=O-Xe+3*Ue,rt=U-Ve+3*Ue,xt=R-1+4*Ue,ht=N-1+4*Ue,ft=O-1+4*Ue,_t=U-1+4*Ue,Re=v&255,Ze=_&255,ct=b&255,Ke=M&255;let Q=.6-R*R-N*N-O*O-U*U;if(Q<0)f=0;else{const le=Re+e[Ze+e[ct+e[Ke]]];Q*=Q,f=Q*Q*(t[le]*R+n[le]*N+i[le]*O+s[le]*U)}let bt=.6-Je*Je-Ye*Ye-xe*xe-ye*ye;if(bt<0)p=0;else{const le=Re+$+e[Ze+me+e[ct+ne+e[Ke+ue]]];bt*=bt,p=bt*bt*(t[le]*Je+n[le]*Ye+i[le]*xe+s[le]*ye)}let Nt=.6-ae*ae-ut*ut-ke*ke-fe*fe;if(Nt<0)m=0;else{const le=Re+re+e[Ze+ge+e[ct+be+e[Ke+se]]];Nt*=Nt,m=Nt*Nt*(t[le]*ae+n[le]*ut+i[le]*ke+s[le]*fe)}let Tt=.6-it*it-vt*vt-St*St-rt*rt;if(Tt<0)x=0;else{const le=Re+he+e[Ze+oe+e[ct+Xe+e[Ke+Ve]]];Tt*=Tt,x=Tt*Tt*(t[le]*it+n[le]*vt+i[le]*St+s[le]*rt)}let Ut=.6-xt*xt-ht*ht-ft*ft-_t*_t;if(Ut<0)T=0;else{const le=Re+1+e[Ze+1+e[ct+1+e[Ke+1]]];Ut*=Ut,T=Ut*Ut*(t[le]*xt+n[le]*ht+i[le]*ft+s[le]*_t)}return 27*(f+p+m+x+T)}}function Nh(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Uh=Object.defineProperty,Dh=(r,e,t)=>e in r?Uh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Dh(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class T extends r{}class g extends r{}class v extends r{}class _ extends r{}class b extends r{}class M extends r{}class C extends r{}class P extends r{}class E extends r{}class z extends r{}class I{constructor(d){Ce(this,"input"),Ce(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);d.push(w),y+=String.fromCodePoint(w).length}return d}}function R(h){return h===10}function N(h){return R(h)||h===8192||h===32}function O(h){return h>=48&&h<=57}function U(h){return O(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return F(h)||O(h)||h===45}function W(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function K(h,d){return h===92&&!R(d)}function $(h,d,y){return h===45?F(d)||d===45||K(d,y):!!F(h)||h===92&&K(h,d)}function me(h,d,y){return h===43||h===45?O(d)||d===46&&O(y):O(h===46?d:h)}function ne(h){const d=h.consume();if(U(d)){let y=[d];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function ue(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const w=h.peek()[0];w===void 0||(R(w)?h.consume():y.value+=String.fromCodePoint(ne(h)))}else y.value+=String.fromCodePoint(S)}}function re(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!K(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ne(h))}}}function ge(h){let d=(function(y){let S="integer",w="";for([43,45].includes(y.peek()[0])&&(w+=String.fromCodePoint(y.consume()));O(...y.peek());)w+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&O(y.peek()[1]))for(w+=String.fromCodePoint(y.consume(),y.consume()),S="number";O(...y.peek());)w+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&O(y.peek()[2])?(w+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):O(y.peek()[1])&&(w+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(w),type:S}})(h);return $(...h.peek())?new p(d.value,d.type,re(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function be(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;K(...h.peek())&&ne(h)}}function se(h){const d=re(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const w=y.consume();if(w===41||w===void 0)return S;if(N(w)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(be(y),new c)}if([34,39,40].includes(w)||W(w))return be(y),new c;if(w===92){if(!K(...y.peek()))return be(y),new c;S.value+=ne(y)}else S.value+=String.fromCodePoint(w)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function he(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return ue(h,d);if(d===35){if(J(y[0])||K(...y)){const S=new i;return $(...y)&&(S.type="id"),S.value=re(h),S}return new l(String.fromCodePoint(d))}return d===39?ue(h,d):d===40?new C:d===41?new P:d===43?me(...y)?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?me(...h.peek())?(h.reconsume(d),ge(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new T):$(...h.peek())?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===46?me(...h.peek())?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?$(...y)?new n(re(h)):new l(String.fromCodePoint(d)):d===91?new b:d===92?K(...y)?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===93?new M:d===123?new E:d===125?new z:O(d)?(h.reconsume(d),ge(h)):F(d)?(h.reconsume(d),se(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function Xe(h){return oe.has(h.toLowerCase())}function Ve(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function Je(h){const d=[];let y=0;function S(){let k=0;const B=y;for(;y<h.length;){const L=h.slice(y,y+1);if(/\s/.test(L)&&k===0)break;if(L==="(")k+=1;else if(L===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(B,y)}function w(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?w():d.push(S())}return d}function Ye(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function xe(h,d){const y=[],S=[];for(const w of h)d(w)?y.push(w):S.push(w);return[y,S]}function ye(h,d={}){function y(S){return Array.from(S).map((w=>ye(w,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const w=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(w,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(ye(h.value,d));break;case"clamp":h=new CSSMathClamp(ye(h.lower,d),ye(h.value,d),ye(h.upper,d));break;case"invert":h=new CSSMathInvert(ye(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&Xe(w.unit)&&w.unit===S[0].unit))){const w=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[w,k]=xe(S,(L=>L instanceof CSSUnitValue&&L.unit!=="percent")),B=Array.from(Ye(w,"unit").values());if(B.some((L=>L.length>0))){const L=B.map((D=>{const V=Math[h.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...L,...k):new CSSMathMax(...L,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const B=k.filter((L=>L instanceof CSSUnitValue));return[...k.filter((L=>!(L instanceof CSSUnitValue))),...Array.from(Ye(B,"unit").entries()).map((([L,D])=>{const V=D.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,L)}))]},w=[];for(const k of h.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(h instanceof CSSMathProduct){let S=[];for(const B of h.values)B instanceof CSSMathProduct?S.push(...B.values):S.push(B);const[w,k]=xe(S,(B=>B instanceof CSSUnitValue&&B.unit==="number"));if(w.length>1){const B=w.reduce(((L,{value:D})=>L*D),1);S=[new CSSUnitValue(B,"number"),...k]}if(S.length===2){let B,L;for(const D of S)D instanceof CSSUnitValue&&D.unit==="number"?B=D:D instanceof CSSMathSum&&[...D.values].every((V=>V instanceof CSSUnitValue))&&(L=D);if(B&&L)return new CSSMathSum(...[...L.values].map((D=>new CSSUnitValue(D.value*B.value,D.unit))))}if(S.every((B=>B instanceof CSSUnitValue&&Xe(B.unit)||B instanceof CSSMathInvert&&B.value instanceof CSSUnitValue&&Xe(B.value.unit)))){const B=new CSSMathProduct(...S).toSum();if(B&&B.values.length===1)return B.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,ut=["percent","length","angle","time","frequency","resolution","flex"],ke={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},fe=new Map;for(const h of Object.values(ke))if(h.compatible)for(const d of h.units)fe.set(d,h);function it(h){return fe.get(h)}function vt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function St(h){return h==="number"?{}:h==="percent"?{percent:1}:ke.absoluteLengths.units.has(h)||ke.fontRelativeLengths.units.has(h)||ke.viewportRelativeLengths.units.has(h)?{length:1}:ke.angle.units.has(h)?{angle:1}:ke.time.units.has(h)?{time:1}:ke.frequency.units.has(h)?{frequency:1}:ke.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function rt(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=it(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=rt(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=rt(y),w=[];if(S===ae)return ae;for(const k of d)for(const B of S)w.push([k[0]*B[0],vt(k[1],B[1])]);d=w}return d}throw new Error("Not implemented")}function xt(h,d){if(St(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=rt(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(w,k){const B=w.unit,L=w.value,D=it(B),V=it(k);return!V||D!==V?ae:new CSSUnitValue(L*V.ratios[B]/V.ratios[k],k)})(ht(y[0]),d);if(S===ae)throw new TypeError;return S}function ht(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const w=S[0];return w[1]!==1?ae:new CSSUnitValue(d,w[0])}function ft(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=rt(h).map((S=>ht(S)));if(y.some((S=>S===ae)))throw new TypeError("Type error");return new CSSMathSum(...y)}function _t(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of ut)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Re{constructor(d,y){Ce(this,"name"),Ce(this,"values"),this.name=d,this.values=y}}class Ze{constructor(d,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=d,this.associatedToken=y}}function ct(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new I(d),S=[];for(;;){const w=he(y);if(w===void 0)return S;S.push(w)}})(h);throw new TypeError("Invalid input type "+typeof h)}function Ke(h){const d=h.shift();return d instanceof E||d instanceof b||d instanceof C?(function(y,S){let w;if(S instanceof E)w=z;else if(S instanceof C)w=P;else{if(!(S instanceof b))return;w=M}const k=new Ze([],S);for(;;){const B=y.shift();if(B instanceof w||B===void 0)return k;y.unshift(B),k.value.push(Ke(y))}})(h,d):d instanceof t?(function(y,S){const w=new Re(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return w;S.unshift(k),w.values.push(Ke(S))}})(d,h):d}function Q(h){if(h instanceof C||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function bt(h){return h[h.length-1]}function Nt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",w=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function Tt(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>Tt(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>Tt(d))));if(h.type==="NEGATE")return new CSSMathNegate(Tt(h.value));if(h.type==="INVERT")return new CSSMathInvert(Tt(h.value));if(h instanceof Ze)return Ut(new Re("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return le(h)}function Ut(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((w=>!(w instanceof m||w instanceof _))).map((w=>ye(Ut(new Re("calc",w)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=Tt((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof u||B instanceof p||B instanceof f||B instanceof Re||B instanceof Ze||B instanceof e)k.push(B);else if(B instanceof l&&["*","/","+","-"].includes(B.value)){for(;w.length&&!(bt(w)instanceof C)&&Q(bt(w))>Q(B);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}w.push(B)}else if(B instanceof C)w.push(B);else if(B instanceof P){if(!w.length)return null;for(;!(bt(w)instanceof C);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}if(!(bt(w)instanceof C))return null;w.pop()}else if(!(B instanceof m))return null}for(;w.length;){if(bt(w)instanceof C)return null;const B=w.pop(),L=k.pop(),D=k.pop();k.push(Nt(B,D,L))}return k[0]})([...h.values]));let y;try{y=ye(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function le(h){return h instanceof Re&&["calc","min","max","clamp"].includes(h.name)?Ut(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function ol(h){const d=(function(y){const S=ct(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const w=Ke(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?w:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Re||new CSSStyleSheet().insertRule("error",0),d instanceof p&&St(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),le(d)}(function(){let h=new WeakMap;function d(k){const B=[];for(let D=0;D<k.length;D++)B[D]=typeof(L=k[D])=="number"?new CSSUnitValue(L,"number"):L;var L;return B}class y{static parse(B){return B instanceof y?B:ye(ol(B),{})}}class S extends y{constructor(B,L,D,V){super(),h.set(this,{values:d(B),operator:L,name:D||L,delimiter:V||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const B=h.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),h.set(this,{value:k,unit:B})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ft(this,...k)}type(){return St(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${(function(B){switch(B){case"percent":return"%";case"number":return"";default:return B.toLowerCase()}})(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ft(this,...k)}type(){return h.get(this).values.map((k=>k.type())).reduce(_t)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const B={};for(const L of ut)B[L]=-1*k[L];return B})(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:B=>new CSSUnitValue(B,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,B]of Object.entries(w))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:B}))throw Error(`Error installing CSSOM support for ${k}`)})();const bo="block";let je=new WeakMap,Dt=new WeakMap;const $i=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function To(h){return h===document.scrollingElement?document:h}function sn(h){Xr(h);let d=je.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Mo(h,d){if(!h)return null;const y=Dt.get(h).sourceMeasurements,S=getComputedStyle(h);let w=y.scrollTop;return Ve(d,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function qr(h,d){const y=ye(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function Xr(h){if(!(h instanceof _n))return void(function(y){const S=je.get(y);if(!S.anonymousSource)return;const w=wo(S.anonymousSource,S.anonymousTarget);xn(y,w)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void xn(h,null);xn(h,ts(d))}function Co(h){return["block","inline","x","y"].includes(h)}function Yr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function Zr(h,d){if(!h||!d)return;let y=0,S=0,w=d;const k=h.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const B=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:B.fontSize}}function Wi(h){let d=Dt.get(h);d.sourceMeasurements=Yr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof _n&&(je.get(S).subjectMeasurements=Zr(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&sn(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function xn(h,d){const y=je.get(h),S=y.source;if(S!=d){if(S){const w=Dt.get(S);if(w){w.timelineRefs.delete(h);const k=Array.from(w.timelineRefs).filter((B=>B.deref()===void 0));for(const B of k)w.timelineRefs.delete(B);w.timelineRefs.size===0&&(w.disconnect(),Dt.delete(S))}}if(y.source=d,d){let w=Dt.get(d);if(!w){w={timelineRefs:new Set,sourceMeasurements:Yr(d)},Dt.set(d,w);const k=new ResizeObserver((D=>{for(const V of D)Wi(y.source)}));k.observe(d);for(const D of d.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)Wi(V.target)}));B.observe(d,{attributes:!0,attributeFilter:["style","class"]});const L=()=>{w.sourceMeasurements.scrollLeft=d.scrollLeft,w.sourceMeasurements.scrollTop=d.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&sn(V)}};To(d).addEventListener("scroll",L),w.disconnect=()=>{k.disconnect(),B.disconnect(),To(d).removeEventListener("scroll",L)}}w.timelineRefs.add(new WeakRef(h))}}}function Kr(h,d){let y=je.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Qr(h,d,y){let S=je.get(h).animations;for(let w=0;w<S.length;w++)if(S[w].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{sn(h)}))}class Qe{constructor(d){if(je.set(this,{source:null,axis:bo,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),xn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=bo){if(!Co(d.axis))throw TypeError("Invalid axis");je.get(this).axis=d.axis}sn(this)}set source(d){xn(this,d),sn(this)}get source(){return je.get(this).source}set axis(d){if(!Co(d))throw TypeError("Invalid axis");je.get(this).axis=d,sn(this)}get axis(){return je.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const w=this.axis,k=Mo(y,w),B=(function(L,D){const V=Dt.get(L).sourceMeasurements,H=getComputedStyle(L).writingMode=="horizontal-tb";return D==="block"?D=H?"y":"x":D==="inline"&&(D=H?"x":"y"),D==="y"?V.scrollHeight-V.clientHeight:D==="x"?V.scrollWidth-V.clientWidth:void 0})(y,w);return B>0?CSS.percent(100*k/B):CSS.percent(100)}get __polyfill(){return!0}}function es(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function wo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return ts(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function al(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Po(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function cl(h){return getComputedStyle(h).position!="static"||Po(h)}function ll(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return es(h,al);case"absolute":return es(h,cl);case"fixed":return es(h,Po)}}function ts(h){if(h&&h.isConnected){for(;h=ll(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function Gn(h,d){const y=je.get(h),S=y.subjectMeasurements,w=Dt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof _n?ns(d,w,S,y.axis,y.inset):null}function ns(h,d,y,S,w){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let B,L,D={fontSize:y.fontSize};Ve(S,d)==="x"?(B=y.offsetWidth,L=y.left,D.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(L+=d.scrollWidth-d.clientWidth,D.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),D.containerSize=d.clientWidth):(B=y.offsetHeight,L=y.top,D.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],D.containerSize=d.clientHeight);const V=(function(os,Zi){const _l={start:0,end:0};if(!os)return _l;const[bl,Tl]=[os.start,os.end].map(((Jo,jo)=>Jo==="auto"?Zi.scrollPadding[jo]==="auto"?0:parseFloat(Zi.scrollPadding[jo]):qr(Jo,{percentageReference:CSS.px(Zi.containerSize),fontSize:CSS.px(parseFloat(Zi.fontSize))})));return{start:bl,end:Tl}})(w,D),H=L-D.containerSize+V.end,X=L+B-V.start,Y=H+B,de=X-B,Te=Math.min(Y,de),st=Math.max(Y,de);let Mt,dt;const Vo=B>D.containerSize-V.start-V.end;switch(h){case"cover":Mt=H,dt=X;break;case"contain":Mt=Te,dt=st;break;case"entry":Mt=H,dt=Te;break;case"exit":Mt=st,dt=X;break;case"entry-crossing":Mt=H,dt=Vo?st:Te;break;case"exit-crossing":Mt=Vo?Te:st,dt=X}return{start:Mt,end:dt}}function Eo(h,d){if(h instanceof _n){const{rangeName:y,offset:S}=d;return ko(Gn(h,y),S,Gn(h,"cover"),h.subject)}if(h instanceof Qe){const{axis:y,source:S}=h,{sourceMeasurements:w}=Dt.get(S);let k;return k=Ve(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,qr(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function ko(h,d,y,S){if(!h||!y)return 0;let w=getComputedStyle(S);return(qr(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(w.fontSize))})+h.start-y.start)/(y.end-y.start)}let _n=class extends Qe{constructor(d){super(d);const y=je.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let w;if(w=typeof S=="string"?Je(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],w.length===0||w.length>2)throw TypeError("Invalid inset");for(const k of w){if(k==="auto")continue;const B=k.type();if(B.length!==1&&B.percent!==1)throw TypeError("Invalid inset")}return{start:w[0],end:w[1]??w[0]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{Wi(y.source)})).observe(y.subject),new MutationObserver((()=>{Wi(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),Xr(this),y.subjectMeasurements=Zr(y.source,y.subject),sn(this)}get source(){return Xr(this),je.get(this).source}set source(d){throw new Error("Cannot set the source of a view timeline")}get subject(){return je.get(this).subject}get axis(){return je.get(this).axis}get currentTime(){const y=Mo(this.source,this.axis);if(y==null)return null;const S=Gn(this,"cover");if(!S)return null;const w=(y-S.start)/(S.end-S.start);return CSS.percent(100*w)}get startOffset(){return CSS.px(Gn(this,"cover").start)}get endOffset(){return CSS.px(Gn(this,"cover").end)}};const ul=document.getAnimations,hl=window.Element.prototype.getAnimations,fl=window.Element.prototype.animate,Ro=window.Animation;class bn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function $n(h){h.readyPromise=new bn,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Hi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&zo(h):Oo(h))}))}function Ao(){return new DOMException("The user aborted a request","AbortError")}function on(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Ft(h),w=S?y*d/S:0;return CSS.percent(w)}function ve(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Ft(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Oo(h){const d=ve(h,h.timeline.currentTime);if(h.holdTime!=null)kt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;kt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Lt(h,!1,!1),Vt(h),h.pendingTask=null}function zo(h){const d=ve(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),kt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Lt(h,!1,!1),Vt(h),h.pendingTask=null}function Io(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function Tn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function kt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Bo(h){if(!h.timeline)return null;const d=ve(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Lt(h,d,y){if(!h.timeline)return;let S=d?ve(h,h.proxy.currentTime):Bo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const w=Tn(h),k=Ft(h);let B=h.previousCurrentTime;w>0&&S>=k&&h.previousCurrentTime!=null?((B===null||B<k)&&(B=k),h.holdTime=d?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),h.holdTime=d?S:B):w!=0&&(d&&h.holdTime!==null&&(h.startTime=(function(L,D){if(!L.timeline)return null;const V=ve(L,L.timeline.currentTime);return V==null?null:V-D/L.animation.playbackRate})(h,h.holdTime)),h.holdTime=null)}Vt(h),h.previousCurrentTime=ve(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new bn),h.finishedPromise.state=="pending"&&(y?Io(h):Promise.resolve().then((()=>{Io(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new bn),h.animation.playState!="paused"&&h.animation.pause())}function Ft(h){const d=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Vt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;is(h,(ve(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&is(h,h.holdTime)}function is(h,d){const y=h.timeline,S=h.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+w}function rs(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,w=ve(h,h.proxy.currentTime);Tn(h)==0&&w==null&&(h.holdTime=0),w==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Vt(h),h.readyPromise||$n(h),h.pendingTask="play",Qr(h.timeline,h.animation,ss.bind(h.proxy)),Lt(h,!1,!1))}function ss(h){const d=q.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Hi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&zo(d):Oo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(d,h);is(d,(S-ve(d,this.startTime))*this.playbackRate),Lt(d,!1,!1)}}function No(h){h.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(h=>{q=new WeakMap}),!1);let Uo=new WeakMap;function Hi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Do(k.timeline):k.animationRange.start;return Eo(k.timeline,B)})(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const B=k.animationRange.end==="normal"?Lo(k.timeline):k.animationRange.end;return 1-Eo(k.timeline,B)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const w=Tn(h);h.startTime=ve(h,w>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&No(h)}function qi(h){throw new Error("Unsupported timeline class")}function Do(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof Qe?CSS.percent(0):void qi()}function Lo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof Qe?CSS.percent(100):void qi()}function dl(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Do(h),end:Lo(h)};if(h instanceof ViewTimeline){const S=Je(d),w=[],k=[];if(S.forEach((B=>{if($i.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${d}"`)}})),w.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return w.length&&(y.start.rangeName=w[0],y.end.rangeName=w.length>1?w[1]:w[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof Qe){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}qi()}function Xi(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(w=d.offset);else{const k=Je(d);k.length===1?$i.includes(k[0])?S=k[0]:w=ye(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],w=ye(CSSNumericValue.parse(k[1]),{}))}if(!$i.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(h instanceof Qe)return CSSNumericValue.parse(d);qi()}class Yi{constructor(d,y,S={}){const w=y instanceof Qe,k=d instanceof Ro?d:new Ro(d,w?void 0:y);Uo.set(k,this),q.set(this,{animation:k,timeline:w?y:void 0,playState:w?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:w?dl(y,S["animation-range"]):null,proxy:this})}get effect(){const d=q.get(this);return d.timeline?(d.effect||(d.effect=(function(y){const S=y.animation.effect,w=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=on(y,H.localTime),H.endTime=on(y,H.endTime),H.activeDuration=on(y,H.activeDuration);const Y=Ft(y),de=H.iterations?(Y-H.delay-H.endDelay)/H.iterations:0;H.duration=Y?CSS.percent(X*de/Y):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},B={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Y=Object.assign({},y.specifiedTiming);if(Y.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Y.duration===null||Y.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Y.delay=0,Y.endDelay=0,X=Y.iterations?1e5:0,Y.duration=Y.iterations?(X-Y.delay-Y.endDelay)/Y.iterations:0,Y.duration<0&&(Y.duration=0,Y.endDelay=X-Y.delay),w.apply(S,[Y])),y.normalizedTiming=Y,y.specifiedTiming}},L={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Y=X[0],de=Y.duration;if(de===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Y.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");de!==void 0&&de!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),No(y)}}},D=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return D.getComputedTiming=new Proxy(S.getComputedTiming,k),D.getTiming=new Proxy(S.getTiming,B),D.updateTiming=new Proxy(S.updateTiming,L),D})(d)),d.effect):d.animation.effect}set effect(d){const y=q.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=q.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=q.get(this),S=this.timeline;if(S==d)return;const w=this.playState,k=this.currentTime;let B,L=Ft(y);B=k===null?null:L===0?0:ve(y,k)/L;const D=S instanceof Qe,V=d instanceof Qe,H=this.pending;if(D&&Kr(y.timeline,y.animation),V)return y.timeline=d,kt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||$n(y),y.pendingTask="play",Qr(y.timeline,y.animation,ss.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*L),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||$n(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Lt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Kr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Ft(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=q.get(this);return d.timeline?on(d,d.startTime):d.animation.startTime}set startTime(d){const y=q.get(this);if(d=ve(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ve(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Vt(y));const S=ve(y,this.currentTime);kt(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1),Vt(y)}get currentTime(){const d=q.get(this);return d.timeline?d.holdTime!=null?on(d,d.holdTime):on(d,Bo(d)):d.animation.currentTime}set currentTime(d){const y=q.get(this);y.timeline?((function(S,w){if(w==null&&S.currentTime!==null)throw new TypeError;w=ve(S,w),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=w:S.startTime=ve(S,S.timeline.currentTime)-w/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,d),y.pendingTask=="pause"&&(y.holdTime=ve(y,d),kt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(d){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=q.get(this);if(!d.timeline)return d.animation.playState;const y=ve(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Ft(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=q.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof Qe&&(y.animationRange.start=Xi(y.timeline,d,"start"),Hi(y),Vt(y))}get rangeEnd(){var d;return((d=q.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof Qe&&(y.animationRange.end=Xi(y.timeline,d,"end"),Hi(y),Vt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const d=q.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=q.get(this);if(!d.timeline)return void d.animation.finish();const y=Tn(d),S=Ft(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");kt(d);const w=y<0?0:S;this.currentTime=on(d,w);const k=ve(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-w/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Lt(d,!0,!0)}play(){const d=q.get(this);d.timeline?rs(d):d.animation.play()}pause(){const d=q.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||$n(d),d.pendingTask="pause",Qr(d.timeline,d.animation,ss.bind(d.proxy))):d.animation.pause()}reverse(){const d=q.get(this),y=Tn(d),S=ve(d,this.currentTime),w=Ft(d)==1/0,k=y!=0&&(y<0||S>0||!w);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-Tn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),rs(d)}updatePlaybackRate(d){const y=q.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":kt(y);break;case"finished":const w=ve(y,y.timeline.currentTime),k=w!==null?(w-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?w:w!=null&&k!=null?(w-k)/d:null,kt(y),Lt(y,!1,!1),Vt(y);break;default:rs(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(d){q.get(this).animation.id=d}cancel(){const d=q.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,kt(y),y.readyPromise.reject(Ao()),$n(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Ao()),d.finishedPromise=new bn,d.animation.cancel()),d.startTime=null,d.holdTime=null,Kr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(d){q.get(this).animation.onfinish=d}get oncancel(){return q.get(this).animation.oncancel}set oncancel(d){q.get(this).animation.oncancel=d}get onremove(){return q.get(this).animation.onremove}set onremove(d){q.get(this).animation.onremove=d}get finished(){const d=q.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new bn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=q.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new bn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){q.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){q.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){q.get(this).animation.dispatchEvent(d)}}function pl(h,d){const y=d.timeline;y instanceof Qe&&delete d.timeline;const S=fl.apply(this,[h,d]),w=new Yi(S,y);return y instanceof Qe&&(S.pause(),q.get(w).animationRange={start:Xi(y,d.rangeStart,"start"),end:Xi(y,d.rangeEnd,"end")},w.play()),w}function Fo(h){for(let d=0;d<h.length;++d){let y=Uo.get(h[d]);y&&(h[d]=y)}return h}function ml(h){return Fo(hl.apply(this,[h]))}function yl(h){return Fo(ul.apply(this,[h]))}const Ae={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Mn=["block","inline","x","y"],gl=["nearest","root","self"],Xt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const w=this.parseQualifiedRule(S);w&&(d?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:wo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),w=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!w)return;let k=[],B=[],L=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(B=this.extractMatches(h.block.contents,Ae.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(h.block.contents,Ae.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(D," 1s "+D),L=!0))})),L&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,B)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let w=[];if(d){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE);for(const L of B){const D=this.split(L);let V={selector:h.selector,name:""};D.length==1?V.name=D[0]:D.length==2&&(Mn.includes(D[0])?(V.axis=D[0],V.name=D[1]):(V.axis=D[1],V.name=D[0])),w.push(V)}}if(y){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE_NAME);for(let L=0;L<B.length;L++)if(L<w.length)w[L].name=B[L];else{let D={selector:h.selector,name:B[L]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE_AXIS);if(k=B.filter((L=>Mn.includes(L))),k.length!=B.length)throw new Error("Invalid axis")}for(let B=0;B<w.length;B++)k.length&&(w[B].axis=k[B%w.length]);this.sourceSelectorToScrollTimeline.push(...w)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),w=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let X={selector:h.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(Mn.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_NAME);for(let V=0;V<D.length;V++)if(V<k.length)k[V].name=D[V];else{let H={selector:h.selector,name:D[V],inset:null};k.push(H)}}let B=[],L=[];if(w&&(B=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_AXIS);if(L=D.filter((V=>Mn.includes(V))),L.length!=D.length)throw new Error("Invalid axis")}for(let D=0;D<k.length;D++)B.length&&(k[D].inset=B[D%k.length]),L.length&&(k[D].axis=L[D%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter((d=>{return y=d,Ae.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,Ae.ANIMATION_TIME_RANGE));const w=Math.max(d.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=Ae.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map((S=>S.trim())).forEach((S=>{if((function(w){return(w.startsWith("scroll")||w.startsWith("view"))&&w.includes("(")})(S)){const w=this.saveAnonymousTimelineName(S);y.push(w)}else y.push(S)})),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=Ae.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Mn.includes(w)?S.axis=w:gl.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(h){const d=Ae.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Mn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){Ae.IDENTIFIER.lastIndex=h.index;const d=Ae.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(D){return $i.some((V=>D.startsWith(V)))}const S=h.block.contents,w=(function(D){let V=0,H=-1,X=-1;const Y=[];for(let de=0;de<D.length;de++)D[de]=="{"?V++:D[de]=="}"&&V--,V==1&&D[de]!="{"&&D[de]!="}"&&H==-1&&(H=de),V==2&&D[de]=="{"&&(X=de,Y.push({start:H,end:X}),H=X=-1);return Y})(S);if(w.length==0)return new Map;const k=new Map;let B=!1;const L=[];L.push(S.substring(0,w[0].start));for(let D=0;D<w.length;D++){const V=S.substring(w[D].start,w[D].end);let H=[];V.split(",").forEach((X=>{const Y=X.split(" ").map((Te=>Te.trim())).filter((Te=>Te!="")).join(" "),de=k.size;k.set(de,Y),H.push(`${de}%`),y(Y)&&(B=!0)})),L.push(H.join(",")),D==w.length-1?L.push(S.substring(w[D].end)):L.push(S.substring(w[D].end,w[D+1].start))}return B?(h.block.contents=L.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const w=S.index-d;S.index=h+y.length+w}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){Ae.WHITE_SPACE.lastIndex=h.index;const d=Ae.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function vl(h,d,y,S,w,k){const B=Yr(d),L=Zr(d,y);return ko(ns(h,B,L,S,w),k,ns("cover",B,L,S,w),y)}function Sl(h,d,y){const S=Xt.getAnimationTimelineOptions(d,y);if(!S)return null;const w=S["animation-timeline"];if(!w)return null;let k=Xt.getScrollTimelineOptions(w,y)||Xt.getViewTimelineOptions(w,y);return k?(k.subject&&(function(B,L){const D=ts(L.subject),V=L.axis||L.axis;function H(Y,de){let Te=null;for(const[st,Mt]of Y)if(st==100*de.offset){if(Mt=="from")Te=0;else if(Mt=="to")Te=100;else{const dt=Mt.split(" ");Te=dt.length==1?parseFloat(dt[0]):100*vl(dt[0],D,L.subject,V,L.inset,CSS.percent(parseFloat(dt[1])))}break}return Te}const X=Xt.keyframeNamesSelectors.get(B.animationName);if(X&&X.size){const Y=[];B.effect.getKeyframes().forEach((Te=>{const st=H(X,Te);st!==null&&st>=0&&st<=100&&(Te.offset=st/100,Y.push(Te))}));const de=Y.sort(((Te,st)=>Te.offset<st.offset?-1:Te.affset>st.offset?1:0));B.effect.setKeyframes(de)}})(h,k),{timeline:k.source?new Qe(k):new _n(k),animOptions:S}):null}function xl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let w=Xt.transpileStyleSheet(S.innerHTML,!0);w=Xt.transpileStyleSheet(w,!1),S.innerHTML=w}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async w=>{const k=await w.text();let B=Xt.transpileStyleSheet(k,!0);if(B=Xt.transpileStyleSheet(k,!1),B!=k){const L=new Blob([B],{type:"text/css"}),D=URL.createObjectURL(L);S.setAttribute("href",D)}}))}new MutationObserver((S=>{for(const w of S)for(const k of w.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=Sl(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof Yi)y.timeline=S.timeline;else{const w=new Yi(y,S.timeline,S.animOptions);y.pause(),w.play()}}))}))}(function(){if(!xl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:Qe}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:_n}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Yi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:ml}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:yl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Lh{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class Xc{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(ce.open,b),this.handleErrorEvent=b=>this.handleEvent(ce.error,b),this.handleCloseEvent=b=>this.handleEvent(ce.close,b),this.handleMessageEvent=b=>this.handleEvent(ce.message,b),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(ce.retry,{detail:n});this.handleEvent(ce.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class Fh{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new Xc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_,b,M,C,P,E,z;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(T=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&T!==void 0?T:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(C=(M=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||M===void 0?void 0:M.reconnect)!==null&&C!==void 0?C:[],[e]:[...(z=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&z!==void 0?z:[],{listener:t,options:n}]}}),this}}const Vh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Lh,Websocket:Xc,WebsocketBuilder:Fh,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),go=0,Yc=1,Zc=2,Ys=2,ws=1.25,ka=1,$e=32,Pe=$e/4,Kc=65535,kr=Math.pow(2,-24),$r=Symbol("SKIP_GENERATION"),Qc={strategy:go,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$r]:!1};function Se(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Ra(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Aa(r,e){e.set(r)}function Oa(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function ar(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Xn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function Ee(r,e){return e[r+15]===Kc}function We(r,e){return e[r+6]}function tt(r,e){return e[r+14]}function Ie(r){return r+Pe}function Be(r,e){const t=e[r+6];return r+t*Pe}function vo(r,e){return e[r+7]}function Ps(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,T=-1/0,g=-1/0;const v=r.offset||0;for(let _=(e-v)*6,b=(e+t-v)*6;_<b;_+=6){const M=r[_+0],C=r[_+1],P=M-C,E=M+C;P<s&&(s=P),E>c&&(c=E),M<f&&(f=M),M>x&&(x=M);const z=r[_+2],I=r[_+3],R=z-I,N=z+I;R<a&&(a=R),N>l&&(l=N),z<p&&(p=z),z>T&&(T=z);const O=r[_+4],U=r[_+5],F=O-U,J=O+U;F<o&&(o=F),J>u&&(u=J),O<m&&(m=O),O>g&&(g=O)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=T,i[5]=g}const Jt=32,Jh=(r,e)=>r.candidate-e.candidate,Kt=new Array(Jt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),cr=new Float32Array(6);function jh(r,e,t,n,i,s){let a=-1,o=0;if(s===go)a=Ra(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Yc)a=Ra(r),a!==-1&&(o=Gh(t,n,i,a));else if(s===Zc){const c=Xn(r);let l=ws*i;const u=t.offset||0,f=(n-u)*6,p=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],v=(e[m+3]-x)/Jt;if(i<Jt/4){const _=[...Kt];_.length=i;let b=0;for(let C=f;C<p;C+=6,b++){const P=_[b];P.candidate=t[C+2*m],P.count=0;const{bounds:E,leftCacheBounds:z,rightCacheBounds:I}=P;for(let R=0;R<3;R++)I[R]=1/0,I[R+3]=-1/0,z[R]=1/0,z[R+3]=-1/0,E[R]=1/0,E[R+3]=-1/0;ar(C,t,E)}_.sort(Jh);let M=i;for(let C=0;C<M;C++){const P=_[C];for(;C+1<M&&_[C+1].candidate===P.candidate;)_.splice(C+1,1),M--}for(let C=f;C<p;C+=6){const P=t[C+2*m];for(let E=0;E<M;E++){const z=_[E];P>=z.candidate?ar(C,t,z.rightCacheBounds):(ar(C,t,z.leftCacheBounds),z.count++)}}for(let C=0;C<M;C++){const P=_[C],E=P.count,z=i-P.count,I=P.leftCacheBounds,R=P.rightCacheBounds;let N=0;E!==0&&(N=Xn(I)/c);let O=0;z!==0&&(O=Xn(R)/c);const U=ka+ws*(N*E+O*z);U<l&&(a=m,l=U,o=P.candidate)}}else{for(let M=0;M<Jt;M++){const C=Kt[M];C.count=0,C.candidate=x+v+M*v;const P=C.bounds;for(let E=0;E<3;E++)P[E]=1/0,P[E+3]=-1/0}for(let M=f;M<p;M+=6){let E=~~((t[M+2*m]-x)/v);E>=Jt&&(E=Jt-1);const z=Kt[E];z.count++,ar(M,t,z.bounds)}const _=Kt[Jt-1];Aa(_.bounds,_.rightCacheBounds);for(let M=Jt-2;M>=0;M--){const C=Kt[M],P=Kt[M+1];Oa(C.bounds,P.rightCacheBounds,C.rightCacheBounds)}let b=0;for(let M=0;M<Jt-1;M++){const C=Kt[M],P=C.count,E=C.bounds,I=Kt[M+1].rightCacheBounds;P!==0&&(b===0?Aa(E,cr):Oa(E,cr,cr)),b+=P;let R=0,N=0;b!==0&&(R=Xn(cr)/c);const O=i-b;O!==0&&(N=Xn(I)/c);const U=ka+ws*(R*b+N*O);U<l&&(a=m,l=U,o=C.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Gh(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class Es{constructor(){this.boundingData=new Float32Array(6)}}function $h(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let f=0;f<e;f++){let p=r[a*e+f];r[a*e+f]=r[o*e+f],r[o*e+f]=p}for(let f=0;f<6;f++){const p=a-u,m=o-u,x=t[p*6+f];t[p*6+f]=t[m*6+f],t[m*6+f]=x}a++,o--}else return a}}let el,Rr,Zs,tl;const Wh=Math.pow(2,32);function Ks(r){return"count"in r?1:1+Ks(r.left)+Ks(r.right)}function Hh(r,e,t){return el=new Float32Array(t),Rr=new Uint32Array(t),Zs=new Uint16Array(t),tl=new Uint8Array(t),Qs(r,e)}function Qs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)el[t+a]=s[a];if(i)return e.buffer?(tl.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Rr[t+6]=e.offset,Zs[n+14]=e.count,Zs[n+15]=Kc,r+$e);{const{left:a,right:o,splitAxis:c}=e,l=r+$e;let u=Qs(l,a);const f=r/$e,m=u/$e-f;if(m>Wh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Rr[t+6]=m,Rr[t+7]=c,Qs(u,o)}}function qh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,u=r.primitiveBuffer,f=r.primitiveBufferStride,p=new Float32Array(6);let m=!1;const x=new Es;return Ps(e,t,n,x.boundingData,p),g(x,t,n,p),x;function T(v){l&&l(v/n)}function g(v,_,b,M=null,C=0){if(!m&&C>=s&&(m=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),b<=o||C>=s)return T(_+b),v.offset=_,v.count=b,v;const P=jh(v.boundingData,M,e,_,b,c);if(P.axis===-1)return T(_+b),v.offset=_,v.count=b,v;const E=$h(u,f,e,_,b,P);if(E===_||E===_+b)T(_+b),v.offset=_,v.count=b;else{v.splitAxis=P.axis;const z=new Es,I=_,R=E-_;v.left=z,Ps(e,I,R,z.boundingData,p),g(z,I,R,p,C+1);const N=new Es,O=E,U=b-R;v.right=N,Ps(e,O,U,N.boundingData,p),g(N,O,U,p,C+1)}return v}}function Xh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=qh(r,o,c.offset,c.count,e),u=Ks(l),f=new t($e*u);return Hh(0,l,f),f})}class So{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Yh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const pe=new Yh;let nn,Un;const wn=[],lr=new So(()=>new A.Box3);function Zh(r,e,t,n,i,s){nn=lr.getPrimitive(),Un=lr.getPrimitive(),wn.push(nn,Un),pe.setBuffer(r._roots[e]);const a=eo(0,r.geometry,t,n,i,s);pe.clearBuffer(),lr.releasePrimitive(nn),lr.releasePrimitive(Un),wn.pop(),wn.pop();const o=wn.length;return o>0&&(Un=wn[o-1],nn=wn[o-2]),a}function eo(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=pe;let u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);return Se(r,o,nn),n(p,m,!1,a,s+r/Pe,nn)}else{let R=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Ie(O),J=O*2;return We(O,F)},N=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Be(O,F),J=O*2;return We(O,F)+tt(J,U)};const p=Ie(r),m=Be(r,l);let x=p,T=m,g,v,_,b;if(i&&(_=nn,b=Un,Se(x,o,_),Se(T,o,b),g=i(_),v=i(b),v<g)){x=m,T=p;const O=g;g=v,v=O,_=b}_||(_=nn,Se(x,o,_));const M=Ee(x*2,c),C=t(_,M,g,a+1,s+x/Pe);let P;if(C===Ys){const O=R(x),F=N(x)-O;P=n(O,F,!0,a+1,s+x/Pe,_)}else P=C&&eo(x,e,t,n,i,s,a+1);if(P)return!0;b=Un,Se(T,o,b);const E=Ee(T*2,c),z=t(b,E,v,a+1,s+T/Pe);let I;if(z===Ys){const O=R(T),F=N(T)-O;I=n(O,F,!0,a+1,s+T/Pe,b)}else I=z&&eo(T,e,t,n,i,s,a+1);return!!I}}const ci=new pe.constructor,Fr=new pe.constructor,en=new So(()=>new A.Box3),Pn=new A.Box3,En=new A.Box3,ks=new A.Box3,Rs=new A.Box3;let As=!1;function Kh(r,e,t,n){if(As)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");As=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new A.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){ci.setBuffer(i[u]),c=0;const p=en.getPrimitive();Se(0,ci.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Fr.setBuffer(s[m]),a=wt(0,0,t,l,n,o,c,0,0,p),Fr.clearBuffer(),c+=s[m].byteLength/$e,!a);m++);if(en.releasePrimitive(p),ci.clearBuffer(),o+=i[u].byteLength/$e,a)break}return As=!1,a}function wt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Fr,p=ci):(f=ci,p=Fr);const m=f.float32Array,x=f.uint32Array,T=f.uint16Array,g=p.float32Array,v=p.uint32Array,_=p.uint16Array,b=r*2,M=e*2,C=Ee(b,T),P=Ee(M,_);let E=!1;if(P&&C)u?E=i(We(e,v),tt(e*2,_),We(r,x),tt(r*2,T),c,a+e/Pe,o,s+r/Pe):E=i(We(r,x),tt(r*2,T),We(e,v),tt(e*2,_),o,s+r/Pe,c,a+e/Pe);else if(P){const z=en.getPrimitive();Se(e,g,z),z.applyMatrix4(t);const I=Ie(r),R=Be(r,x);Se(I,m,Pn),Se(R,m,En);const N=z.intersectsBox(Pn),O=z.intersectsBox(En);E=N&&wt(e,I,n,t,i,a,s,c,o+1,z,!u)||O&&wt(e,R,n,t,i,a,s,c,o+1,z,!u),en.releasePrimitive(z)}else{const z=Ie(e),I=Be(e,v);Se(z,g,ks),Se(I,g,Rs);const R=l.intersectsBox(ks),N=l.intersectsBox(Rs);if(R&&N)E=wt(r,z,t,n,i,s,a,o,c+1,l,u)||wt(r,I,t,n,i,s,a,o,c+1,l,u);else if(R)if(C)E=wt(r,z,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(ks).applyMatrix4(t);const U=Ie(r),F=Be(r,x);Se(U,m,Pn),Se(F,m,En);const J=O.intersectsBox(Pn),W=O.intersectsBox(En);E=J&&wt(z,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(z,F,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}else if(N)if(C)E=wt(r,I,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(Rs).applyMatrix4(t);const U=Ie(r),F=Be(r,x);Se(U,m,Pn),Se(F,m,En);const J=O.intersectsBox(Pn),W=O.intersectsBox(En);E=J&&wt(I,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(I,F,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}}return E}const za=new A.Box3,kn=new Float32Array(6);class nl{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Qc,...e},Xh(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0;for(let f=e,p=e+t;f<p;f++){this.writePrimitiveBounds(f,kn,0);const[m,x,T,g,v,_]=kn;m<s&&(s=m),g>c&&(c=g),x<a&&(a=x),v>l&&(l=v),T<o&&(o=T),_>u&&(u=_)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,kn,0);const[o,c,l,u,f,p]=kn,m=(o+u)/2,x=(c+f)/2,T=(l+p)/2,g=(u-o)/2,v=(f-c)/2,_=(p-l)/2,b=(s-i)*6;n[b+0]=m,n[b+1]=g+(Math.abs(m)+g)*kr,n[b+2]=x,n[b+3]=v+(Math.abs(x)+v)*kr,n[b+4]=T,n[b+5]=_+(Math.abs(T)+_)*kr}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/$e;for(let l=0;l<c;l++){const u=Pe*l,f=2*u;Ee(f,o)&&(a[u+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=Ee(l,s);if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=Ie(o),p=Be(o,i),m=vo(o,i);e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/$e;for(let l=c-1;l>=0;l--){const u=l*Pe,f=u*2;if(Ee(f,a)){const m=We(u,s),x=tt(f,a);this.writePrimitiveRangeBounds(m,x,kn,0),o.set(kn,u)}else{const m=Ie(u),x=Be(u,s);for(let T=0;T<3;T++){const g=o[m+T],v=o[m+T+3],_=o[x+T],b=o[x+T+3];o[u+T]=g<_?g:_,o[u+T+3]=v>b?v:b}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),za),e.union(za)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const f=i;i=(p,m,x,T,g)=>f(p,m,x,T,g)?!0:o(p,m,this,s,x,T,a)}else i||(s?i=(f,p,m,x)=>o(f,p,this,s,m,x,a):i=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=Zh(this,f,n,i,t,l),c)break;l+=m.byteLength/$e}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Kh(this,e,t,i)}}function Qh(){return typeof SharedArrayBuffer<"u"}function xo(r){return r.index?r.index.count:r.attributes.position.count}function Wr(r){return xo(r)/3}function ef(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function tf(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=ef(t,n);r.setIndex(new A.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function nf(r,e,t){const n=xo(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function rf(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Ia(r,e,t){const n=nf(r,e,t),i=rf(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=xo(r)/t,l=[];for(const p of i){const{offset:m,count:x}=p,T=m,g=isFinite(x)?x:c-m,v=m+g;T<o&&v>a&&(l.push({pos:Math.max(a,T),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((p,m)=>p.pos!==m.pos?p.pos-m.pos:p.type==="end"?-1:1);let u=0,f=null;for(const p of l){const m=p.pos;u!==0&&m!==f&&s.push({offset:f,count:m-f}),u+=p.isStart?1:-1,f=m}return s}function il(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:u,count:f}=r[l];for(let p=0;p<f;p++)o[c+p]=u+p;c+=f}return o}class rl extends nl{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Qh())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Qc,...t},t[$r]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Ia(t,e.range,n),s=il(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else tf(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new A.Box3))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Ia(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class qt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const c=e[s][t];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}qt.prototype.setFromBox=(function(){const r=new A.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const sf=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,_;g!==0?v=(f*p-x*m)/g:v=0,_=(f+v*p)/m,a.x=v,a.y=_}})(),_o=(function(){const r=new A.Vector2,e=new A.Vector3,t=new A.Vector3;return function(i,s,a,o){sf(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),of=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Plane,n=new A.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),af=["x","y","z"],Gt=1e-15,Ba=Gt*Gt;function pt(r){return Math.abs(r)<Gt}class gt extends A.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A.Vector3),this.satBounds=new Array(4).fill().map(()=>new qt),this.points=[this.a,this.b,this.c],this.plane=new A.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new A.Line3,this.needsUpdate=!0}intersectsSphere(e){return of(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const T=l.length(),g=f.length(),v=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,T<Gt?g<Gt||v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<Gt?v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<Gt&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}gt.prototype.closestPointToSegment=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),_o(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();gt.prototype.intersectsTriangle=(function(){const r=new gt,e=new qt,t=new qt,n=new A.Vector3,i=new A.Vector3,s=new A.Vector3,a=new A.Vector3,o=new A.Line3,c=new A.Line3,l=new A.Vector3,u=new A.Vector2,f=new A.Vector2;function p(b,M,C,P){const E=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?E.copy(b.plane.normal):E.copy(M.plane.normal);const z=b.satBounds,I=b.satAxes;for(let O=1;O<4;O++){const U=z[O],F=I[O];if(e.setFromPoints(F,M.points),U.isSeparated(e)||(a.copy(E).cross(F),e.setFromPoints(a,b.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}const R=M.satBounds,N=M.satAxes;for(let O=1;O<4;O++){const U=R[O],F=N[O];if(e.setFromPoints(F,b.points),U.isSeparated(e)||(a.crossVectors(E,F),e.setFromPoints(a,b.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}return C&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),C.start.set(0,0,0),C.end.set(0,0,0)),!0}function m(b,M,C,P,E,z,I,R,N,O,U){let F=I/(I-R);O.x=P+(E-P)*F,U.start.subVectors(M,b).multiplyScalar(F).add(b),F=I/(I-N),O.y=P+(z-P)*F,U.end.subVectors(C,b).multiplyScalar(F).add(b)}function x(b,M,C,P,E,z,I,R,N,O,U){if(E>0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else if(z>0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(R*N>0||I!=0)m(b.a,b.b,b.c,M,C,P,I,R,N,O,U);else if(R!=0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(N!=0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else return!0;return!1}function T(b,M,C,P){const E=M.degenerateSegment,z=b.plane.distanceToPoint(E.start),I=b.plane.distanceToPoint(E.end);return pt(z)?pt(I)?p(b,M,C,P):(C&&(C.start.copy(E.start),C.end.copy(E.start)),b.containsPoint(E.start)):pt(I)?(C&&(C.start.copy(E.end),C.end.copy(E.end)),b.containsPoint(E.end)):b.plane.intersectLine(E,n)!=null?(C&&(C.start.copy(n),C.end.copy(n)),b.containsPoint(n)):!1}function g(b,M,C){const P=M.a;return pt(b.plane.distanceToPoint(P))&&b.containsPoint(P)?(C&&(C.start.copy(P),C.end.copy(P)),!0):!1}function v(b,M,C){const P=b.degenerateSegment,E=M.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<Ba?(C&&(C.start.copy(E),C.end.copy(E)),!0):!1}function _(b,M,C,P){if(b.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const E=b.degenerateSegment,z=M.degenerateSegment,I=i,R=s;E.delta(I),z.delta(R);const N=n.subVectors(z.start,E.start),O=I.x*R.y-I.y*R.x;if(pt(O))return!1;const U=(N.x*R.y-N.y*R.x)/O,F=-(I.x*N.y-I.y*N.x)/O;if(U<0||U>1||F<0||F>1)return!1;const J=E.start.z+I.z*U,W=z.start.z+R.z*F;return pt(J-W)?(C&&(C.start.copy(E.start).addScaledVector(I,U),C.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return M.isDegenerateIntoPoint?v(b,M,C):T(M,b,C,P);else{if(b.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(b.a)<Ba?(C&&(C.start.copy(b.a),C.end.copy(b.a)),!0):!1:M.isDegenerateIntoSegment?v(M,b,C):g(M,b,C);if(M.isDegenerateIntoPoint)return g(b,M,C);if(M.isDegenerateIntoSegment)return T(b,M,C,P)}}return function(M,C=null,P=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(r.copy(M),r.update(),M=r);const E=_(this,M,C,P);if(E!==void 0)return E;const z=this.plane,I=M.plane;let R=I.distanceToPoint(this.a),N=I.distanceToPoint(this.b),O=I.distanceToPoint(this.c);pt(R)&&(R=0),pt(N)&&(N=0),pt(O)&&(O=0);const U=R*N,F=R*O;if(U>0&&F>0)return!1;let J=z.distanceToPoint(M.a),W=z.distanceToPoint(M.b),K=z.distanceToPoint(M.c);pt(J)&&(J=0),pt(W)&&(W=0),pt(K)&&(K=0);const $=J*W,me=J*K;if($>0&&me>0)return!1;i.copy(z.normal),s.copy(I.normal);const ne=i.cross(s);let ue=0,re=Math.abs(ne.x);const ge=Math.abs(ne.y);ge>re&&(re=ge,ue=1),Math.abs(ne.z)>re&&(ue=2);const se=af[ue],he=this.a[se],oe=this.b[se],Xe=this.c[se],Ve=M.a[se],Je=M.b[se],Ye=M.c[se];if(x(this,he,oe,Xe,U,F,R,N,O,u,o))return p(this,M,C,P);if(x(M,Ve,Je,Ye,$,me,J,W,K,f,c))return p(this,M,C,P);if(u.y<u.x){const xe=u.y;u.y=u.x,u.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(f.y<f.x){const xe=f.y;f.y=f.x,f.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<f.x||f.y<u.x?!1:(C&&(f.x>u.x?C.start.copy(c.start):C.start.copy(o.start),f.y<u.y?C.end.copy(c.end):C.end.copy(o.end)),!0)}})();gt.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();gt.prototype.distanceToTriangle=(function(){const r=new A.Vector3,e=new A.Vector3,t=["a","b","c"],n=new A.Line3,i=new A.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const T=this[m];a.closestPointToPoint(T,r),p=T.distanceToSquared(r),p<u&&(u=p,o&&o.copy(T),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const T=t[x],g=t[(x+1)%3];i.set(a[T],a[g]),_o(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();class qe{constructor(e,t,n){this.isOrientedBox=!0,this.min=new A.Vector3,this.max=new A.Vector3,this.matrix=new A.Matrix4,this.invMatrix=new A.Matrix4,this.points=new Array(8).fill().map(()=>new A.Vector3),this.satAxes=new Array(3).fill().map(()=>new A.Vector3),this.satBounds=new Array(3).fill().map(()=>new qt),this.alignedSatBounds=new Array(3).fill().map(()=>new qt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}qe.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();qe.prototype.intersectsBox=(function(){const r=new qt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(r.setFromBox(l,t),u.isSeparated(r))return!1}return!0}})();qe.prototype.intersectsTriangle=(function(){const r=new gt,e=new Array(3),t=new qt,n=new qt,i=new A.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const T=u[x];if(i.crossVectors(m,T),t.setFromPoints(i,e),n.setFromPoints(i,f),t.isSeparated(n))return!1}}return!0}})();qe.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();qe.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();qe.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new A.Line3),t=new Array(12).fill().map(()=>new A.Line3),n=new A.Vector3,i=new A.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const _=v.distanceToSquared(i);if(_<x&&(x=_,c&&c.copy(v),l&&l.copy(i),_<u))return Math.sqrt(_)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){const b=(g+1)%3,M=(g+2)%3,C=v<<b|_<<M,P=1<<g|v<<b|_<<M,E=m[C],z=m[P];e[T].set(E,z);const R=r[g],N=r[b],O=r[M],U=t[T],F=U.start,J=U.end;F[R]=f[R],F[N]=v?f[N]:p[N],F[O]=_?f[O]:p[N],J[R]=p[R],J[N]=v?f[N]:p[N],J[O]=_?f[O]:p[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=_?p.z:f.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<x&&(x=b,c&&c.copy(n),l&&l.copy(i),b<u))return Math.sqrt(b)}for(let g=0;g<12;g++){const v=e[g];for(let _=0;_<12;_++){const b=t[_];_o(v,b,n,i);const M=n.distanceToSquared(i);if(M<x&&(x=M,c&&c.copy(n),l&&l.copy(i),M<u))return Math.sqrt(M)}}return Math.sqrt(x)}})();class cf extends So{constructor(){super(()=>new gt)}}const yt=new cf,Yn=new A.Vector3,Os=new A.Vector3;function lf(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(Yn.copy(e).clamp(u.min,u.max),Yn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Yn);const p=e.distanceToSquared(Yn);return p<o&&(Os.copy(Yn),o=p,c=f),p<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Os):t.point=Os.clone(),t.distance=l,t.faceIndex=c,t}const ur=parseInt(A.REVISION)>=169,uf=parseInt(A.REVISION)<=161,ln=new A.Vector3,un=new A.Vector3,hn=new A.Vector3,hr=new A.Vector2,fr=new A.Vector2,dr=new A.Vector2,Na=new A.Vector3,Ua=new A.Vector3,Da=new A.Vector3,Zn=new A.Vector3;function hf(r,e,t,n,i,s,a,o){let c;if(s===A.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==A.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function La(r,e,t,n,i,s,a,o,c,l,u){ln.fromBufferAttribute(e,s),un.fromBufferAttribute(e,a),hn.fromBufferAttribute(e,o);const f=hf(r,ln,un,hn,Zn,c,l,u);if(f){if(n){hr.fromBufferAttribute(n,s),fr.fromBufferAttribute(n,a),dr.fromBufferAttribute(n,o),f.uv=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv);ur||(f.uv=m)}if(i){hr.fromBufferAttribute(i,s),fr.fromBufferAttribute(i,a),dr.fromBufferAttribute(i,o),f.uv1=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv1);ur||(f.uv1=m),uf&&(f.uv2=f.uv1)}if(t){Na.fromBufferAttribute(t,s),Ua.fromBufferAttribute(t,a),Da.fromBufferAttribute(t,o),f.normal=new A.Vector3;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,Na,Ua,Da,f.normal);f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1),ur||(f.normal=m)}const p={a:s,b:a,c:o,normal:new A.Vector3,materialIndex:0};if(A.Triangle.getNormal(ln,un,hn,p.normal),f.face=p,f.faceIndex=s,ur){const m=new A.Vector3;A.Triangle.getBarycoord(Zn,ln,un,hn,m),f.barycoord=m}}return f}function Fa(r){return r&&r.isMaterial?r.side:r}function Hr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:f,groups:p}=r;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:m,normal:x,uv:T,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let _=0,b=p.length;_<b;_++){const{start:M,count:C,materialIndex:P}=p[_];if(v>=M&&v<M+C){const E=Fa(e[P]),z=La(t,m,x,T,g,c,l,u,E,s,a);if(z)if(z.faceIndex=n,z.face.materialIndex=P,i)i.push(z);else return z}}}else{const v=Fa(e),_=La(t,m,x,T,g,c,l,u,v,s,a);if(_)if(_.faceIndex=n,_.face.materialIndex=0,i)i.push(_);else return _}return null}function we(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function ff(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Hr(c,e,t,u,s,a,o)}function df(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function pf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function mf(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=3*g,I=3*(g+v);z<I;z++){let R=n[z];const N=i.getX(R),O=i.getY(R),U=i.getZ(R);N<_&&(_=N),N>C&&(C=N),O<b&&(b=O),O>P&&(P=O),U<M&&(M=U),U>E&&(E=U)}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=F>W?F:W}return I}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],b=e[r+1],M=e[r+3+1],C=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(_-x)*f):(s=(_-x)*f,a=(v-x)*f),p>=0?(o=(b-T)*p,c=(M-T)*p):(o=(M-T)*p,c=(b-T)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(C-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(C-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function yf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Hr(c,e,t,p,s,a,o)}}function gf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function vf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function Sf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),to(0,r,t,n,i,s,a),pe.clearBuffer()}function to(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);ff(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&to(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&to(m,e,t,n,i,s,a)}}const xf=["x","y","z"];function _f(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=no(0,r,t,n,i,s);return pe.clearBuffer(),a}function no(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return df(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=xf[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?no(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?no(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const pr=new A.Box3,Rn=new gt,An=new gt,Kn=new A.Matrix4,Va=new qe,mr=new qe;function bf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=io(0,r,t,n);return pe.clearBuffer(),i}function io(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Va.set(t.boundingBox.min,t.boundingBox.max,n),i=Va),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(r,o),g=tt(c,a);if(Kn.copy(n).invert(),t.boundsTree)return Se(r,s,mr),mr.matrix.copy(Kn),mr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>mr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T*3,M=(g+T)*3;b<M;b+=3)if(we(An,b,f,p),An.needsUpdate=!0,_.intersectsTriangle(An))return!0;return!1}});{const v=Wr(t);for(let _=T*3,b=(g+T)*3;_<b;_+=3){we(Rn,_,f,p),Rn.a.applyMatrix4(Kn),Rn.b.applyMatrix4(Kn),Rn.c.applyMatrix4(Kn),Rn.needsUpdate=!0;for(let M=0,C=v*3;M<C;M+=3)if(we(An,M,m,x),An.needsUpdate=!0,Rn.intersectsTriangle(An))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,pr),!!(i.intersectsBox(pr)&&io(u,e,t,n,i)||(Se(f,s,pr),i.intersectsBox(pr)&&io(f,e,t,n,i)))}}const yr=new A.Matrix4,zs=new qe,Qn=new qe,Tf=new A.Vector3,Mf=new A.Vector3,Cf=new A.Vector3,wf=new A.Vector3;function Pf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),zs.set(e.boundingBox.min,e.boundingBox.max,t),zs.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=Tf,T=Mf,g=null,v=null;i&&(g=Cf,v=wf);let _=1/0,b=null,M=null;return yr.copy(t).invert(),Qn.matrix.copy(yr),r.shapecast({boundsTraverseOrder:C=>zs.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&E<a?(P&&(Qn.min.copy(C.min),Qn.max.copy(C.max),Qn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>Qn.distanceToBox(z),intersectsBounds:(z,I,R)=>R<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){we(m,3*R,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let O=C,U=C+P;O<U;O++){we(p,3*O,l,c),p.needsUpdate=!0;const F=p.distanceToTriangle(m,x,g);if(F<_&&(T.copy(x),v&&v.copy(g),_=F,b=O,M=R),F<s)return!0}}}});{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){we(p,3*R,l,c),p.needsUpdate=!0;const O=p.distanceToTriangle(m,x,g);if(O<_&&(T.copy(x),v&&v.copy(g),_=O,b=R,M=z),O<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(yr),T.applyMatrix4(yr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function Ef(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=g,I=g+v;z<I;z++){const R=3*r.resolveTriangleIndex(z);for(let N=0;N<3;N++){let O=R+N;O=n?n[O]:O;const U=i.getX(O),F=i.getY(O),J=i.getZ(O);U<_&&(_=U),U>C&&(C=U),F<b&&(b=F),F>P&&(P=F),J<M&&(M=J),J>E&&(E=J)}}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=F>W?F:W}return I}}}function kf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),ro(0,r,t,n,i,s,a),pe.clearBuffer()}function ro(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);yf(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&ro(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&ro(m,e,t,n,i,s,a)}}const Rf=["x","y","z"];function Af(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=so(0,r,t,n,i,s);return pe.clearBuffer(),a}function so(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return gf(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=Rf[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?so(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?so(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const gr=new A.Box3,On=new gt,zn=new gt,ei=new A.Matrix4,Ja=new qe,vr=new qe;function Of(r,e,t,n){pe.setBuffer(r._roots[e]);const i=oo(0,r,t,n);return pe.clearBuffer(),i}function oo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ja.set(t.boundingBox.min,t.boundingBox.max,n),i=Ja),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(r,o),g=tt(c,a);if(ei.copy(n).invert(),t.boundsTree)return Se(r,s,vr),vr.matrix.copy(ei),vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>vr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T,M=g+T;b<M;b++)if(we(zn,3*e.resolveTriangleIndex(b),f,p),zn.needsUpdate=!0,_.intersectsTriangle(zn))return!0;return!1}});{const v=Wr(t);for(let _=T,b=g+T;_<b;_++){const M=e.resolveTriangleIndex(_);we(On,3*M,f,p),On.a.applyMatrix4(ei),On.b.applyMatrix4(ei),On.c.applyMatrix4(ei),On.needsUpdate=!0;for(let C=0,P=v*3;C<P;C+=3)if(we(zn,C,m,x),zn.needsUpdate=!0,On.intersectsTriangle(zn))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,gr),!!(i.intersectsBox(gr)&&oo(u,e,t,n,i)||(Se(f,s,gr),i.intersectsBox(gr)&&oo(f,e,t,n,i)))}}const Sr=new A.Matrix4,Is=new qe,ti=new qe,zf=new A.Vector3,If=new A.Vector3,Bf=new A.Vector3,Nf=new A.Vector3;function Uf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Is.set(e.boundingBox.min,e.boundingBox.max,t),Is.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=zf,T=If,g=null,v=null;i&&(g=Bf,v=Nf);let _=1/0,b=null,M=null;return Sr.copy(t).invert(),ti.matrix.copy(Sr),r.shapecast({boundsTraverseOrder:C=>Is.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&E<a?(P&&(ti.min.copy(C.min),ti.max.copy(C.max),ti.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:z=>ti.distanceToBox(z),intersectsBounds:(z,I,R)=>R<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){const O=E.resolveTriangleIndex(R);we(m,3*O,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=C,F=C+P;U<F;U++){const J=r.resolveTriangleIndex(U);we(p,3*J,l,c),p.needsUpdate=!0;const W=p.distanceToTriangle(m,x,g);if(W<_&&(T.copy(x),v&&v.copy(g),_=W,b=U,M=R),W<s)return!0}}}})}else{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){const O=r.resolveTriangleIndex(R);we(p,3*O,l,c),p.needsUpdate=!0;const U=p.distanceToTriangle(m,x,g);if(U<_&&(T.copy(x),v&&v.copy(g),_=U,b=R,M=z),U<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Sr),T.applyMatrix4(Sr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function ja(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const xr=new qe,_r=new A.Ray,Ga=new A.Vector3,$a=new A.Matrix4,Wa=new A.Vector3,Bs=["getX","getY","getZ"];class Vn extends rl{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Vn(t,{...n,[$r]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new A.BufferAttribute(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const f=l[u],p=new Uint32Array(f),m=new Uint16Array(f);for(let x=0,T=f.byteLength/$e;x<T;x++){const g=Pe*x,v=2*g;Ee(v,m)||(p[g+6]=p[g+6]/Pe-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,l=(s?s[e]:e)*3;let u=l+0,f=l+1,p=l+2;o&&(u=o[u],f=o[f],p=o[p]);for(let m=0;m<3;m++){const x=a[Bs[m]](u),T=a[Bs[m]](f),g=a[Bs[m]](p);let v=x;T<v&&(v=T),g<v&&(v=g);let _=x;T>_&&(_=T),g>_&&(_=g),t[n+m]=v,t[n+m+3]=_}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,u=a.offset||0;let f=3;a.isInterleavedBufferAttribute&&(f=a.data.stride);const p=["getX","getY","getZ"],m=n.offset;for(let x=e,T=e+t;x<T;x++){const v=(s?s[x]:x)*3,_=(x-m)*6;let b=v+0,M=v+1,C=v+2;o&&(b=o[b],M=o[M],C=o[C]),c||(b=b*f+u,M=M*f+u,C=C*f+u);for(let P=0;P<3;P++){let E,z,I;c?(E=a[p[P]](b),z=a[p[P]](M),I=a[p[P]](C)):(E=l[b+P],z=l[M+P],I=l[C+P]);let R=E;z<R&&(R=z),I<R&&(R=I);let N=E;z>N&&(N=z),I>N&&(N=I);const O=(N-R)/2,U=P*2;n[_+U+0]=R+O,n[_+U+1]=O+(Math.abs(R)+O)*kr}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;$a.copy(e.matrixWorld).invert(),_r.copy(t.ray).applyMatrix4($a),Wa.setFromMatrixScale(e.matrixWorld),Ga.copy(_r.direction).multiply(Wa);const s=Ga.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(_r,i,a,o);c=ja(c,e,t),c&&n.push(c)}else{const c=this.raycast(_r,i,a,o);for(let l=0,u=c.length;l<u;l++){const f=ja(c[l],e,t);f&&n.push(f)}}return n}refit(e=null){return(this.indirect?Ef:mf)(this,e)}raycast(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?kf:Sf;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?Af:_f;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?Of:bf;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=yt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?vf:pf});return yt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=yt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const T=this.resolveTriangleIndex(x);we(a,T*3,o,c)}:x=>{we(a,x*3,o,c)},u=yt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const T=e.resolveTriangleIndex(x);we(u,T*3,f,p)}:x=>{we(u,x*3,f,p)};if(s){if(!(e instanceof Vn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const x=(T,g,v,_,b,M,C,P)=>{for(let E=v,z=v+_;E<z;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=T,R=T+g;I<R;I++)if(l(I),a.needsUpdate=!0,s(a,u,I,E,b,M,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,_,b,M,C,P,E){return T(g,v,_,b,M,C,P,E)?!0:x(g,v,_,b,M,C,P,E)}}else i=x}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return xr.set(e.min,e.max,t),xr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>xr.intersectsBox(n),intersectsTriangle:n=>xr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?Uf:Pf)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return lf(this,e,t,n,i)}}const Bn={Mesh:A.Mesh.prototype.raycast,Line:A.Line.prototype.raycast,LineSegments:A.LineSegments.prototype.raycast,LineLoop:A.LineLoop.prototype.raycast,Points:A.Points.prototype.raycast,BatchedMesh:A.BatchedMesh.prototype.raycast},De=new A.Mesh,br=[];function Df(r,e){if(this.isBatchedMesh)Lf.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof A.Mesh)n=Bn.Mesh;else if(this instanceof A.LineSegments)n=Bn.LineSegments;else if(this instanceof A.LineLoop)n=Bn.LineLoop;else if(this instanceof A.Line)n=Bn.Line;else if(this instanceof A.Points)n=Bn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function Lf(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;De.material=this.material,De.geometry=this.geometry;const a=De.geometry.boundsTree,o=De.geometry.drawRange;De.geometry.boundingSphere===null&&(De.geometry.boundingSphere=new A.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(De.geometry.boundsTree=t[u],this.getMatrixAt(c,De.matrixWorld).premultiply(s),!De.geometry.boundsTree){this.getBoundingBoxAt(u,De.geometry.boundingBox),this.getBoundingSphereAt(u,De.geometry.boundingSphere);const f=i[u];De.geometry.setDrawRange(f.start,f.count)}De.raycast(r,br);for(let f=0,p=br.length;f<p;f++){const m=br[f];m.object=this,m.batchId=c,e.push(m)}br.length=0}De.geometry.boundsTree=a,De.geometry.drawRange=o,De.material=null,De.geometry=null}else Bn.BatchedMesh.call(this,r,e)}function Ff(r={}){const{type:e=Vn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const fn=new A.Vector3,dn=new A.Vector3,pn=new A.Vector3,Ha=new A.Vector4,Tr=new A.Vector3,Ns=new A.Vector3,qa=new A.Vector4,Xa=new A.Vector4,Mr=new A.Matrix4,Ya=new A.Matrix4;function ni(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function oi(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new A.BufferAttribute(new t(i*s),i,n)}function sl(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Vf(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function Za(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;qa.fromBufferAttribute(i.attributes.skinIndex,e),Xa.fromBufferAttribute(i.attributes.skinWeight,e),Mr.elements.fill(0);for(let o=0;o<4;o++){const c=Xa.getComponent(o);if(c!==0){const l=qa.getComponent(o);Ya.multiplyMatrices(s[l].matrixWorld,a[l]),Vf(Mr,Ya,c)}}return Mr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Mr),t}function Us(r,e,t,n,i){Tr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(Ns.fromBufferAttribute(c,n),t?Tr.addScaledVector(Ns,o):Tr.addScaledVector(Ns.sub(i),o))}i.add(Tr)}function Jf(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new A.BufferGeometry){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const f=r[u];let p=0;if(n!==(f.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in f.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new A.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const T=r[x],g=T.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=T.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const T in f)x+=f[T].count;t.setAttribute(u,oi(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,T=f.length;x<T;x++){const g=f[x];a[x]!==!0&&sl(g,p,m),m+=g.count}}return t}function jf(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Gf(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class $f{constructor(e){this.matrixWorld=new A.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&jf(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Wf{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new A.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new A.BufferGeometry){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new $f(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new A.BufferAttribute(new Float32Array(0),4,!1))}else Jf(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new A.BufferGeometry){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",oi(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",oi(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",oi(o.tangent)),ni(n.index,t.index),ni(o.position,c.position),s&&ni(o.normal,c.normal),a&&ni(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new A.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,b=o.position.count;_<b;_++)fn.fromBufferAttribute(l,_),u&&dn.fromBufferAttribute(u,_),f&&(Ha.fromBufferAttribute(f,_),pn.fromBufferAttribute(f,_)),g&&(p&&Us(p,g,T,_,fn),m&&Us(m,g,T,_,dn),x&&Us(x,g,T,_,pn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,fn),u&&Za(e,_,dn),f&&Za(e,_,pn)),i&&fn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,fn.x,fn.y,fn.z),u&&(i&&dn.applyNormalMatrix(v),c.normal.setXYZ(_,dn.x,dn.y,dn.z)),f&&(i&&pn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,pn.x,pn.y,pn.z,Ha.w));for(const _ in this.attributes){const b=this.attributes[_];b==="position"||b==="tangent"||b==="normal"||!(b in o)||(c[b]||t.setAttribute(b,oi(o[b])),ni(o[b],c[b]),sl(o[b],c[b]))}return e.matrixWorld.determinant()<0&&Gf(t),t}}const Hf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Yc,BVH:nl,CENTER:go,CONTAINED:Ys,ExtendedTriangle:gt,GeometryBVH:rl,MeshBVH:Vn,OrientedBox:qe,SAH:Zc,SKIP_GENERATION:$r,StaticGeometryGenerator:Wf,acceleratedRaycast:Df,computeBoundsTree:Ff,generateIndirectBuffer:il},Symbol.toStringTag,{value:"Module"}));class qf{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const mt={node:"node",material:"material",camera:"camera",light:"light"},In="KHR_animation_pointer",Xf={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear$1,STEP:A.InterpolateDiscrete$1};class Yf{constructor(e){this.name=In,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){const t=e.target,n=t.extensions&&t.extensions[In]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=mt.node,a;if(n){const c=t.extensions[In];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=mt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=mt.light:l.startsWith("/cameras/")&&(s=mt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case mt.material:const u=("/materials/"+a.toString()+"/").length,f=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=f+i;break;case mt.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":i="visible";break}l=m+i;break;case mt.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case mt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[In].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===mt.node?o=this.parser.getDependency("node",a):s===mt.material?o=this.parser.getDependency("material",a):s===mt.light?o=this.parser.getDependency("light",a):s===mt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[In]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[In].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof A.SkinnedMesh$1&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,T){try{const g=T.split(".").filter(Boolean),_=g[g.length-1].replace(/\[.*\]$/,"");return _ in x?typeof x[_]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(e,o)?(T=A.BooleanKeyframeTrack,g=!0):T=A.NumberKeyframeTrack$1;break;case 2:case 3:T=A.VectorKeyframeTrack$1;break;case 4:o.endsWith(".quaternion")?T=A.QuaternionKeyframeTrack$1:T=A.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?Xf[i.interpolation]:A.InterpolateLinear$1;let _=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(_=_.map(M=>M/Math.PI*180)),g&&(_=_.map(M=>M>0));const b=new T(o,t.array,_,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),c.push(b),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const M=new Float32Array(_.length/4);for(let P=0,E=_.length/4;P<E;P+=1)M[P]=_[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,M,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),c.push(C)}}return c}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],T=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,_=s.parameters!==void 0?s.parameters[T.output]:T.output;let b=t.loadAnimationTargetFromChannelWithAnimationPointer(x);b||(b=t.loadAnimationTargetFromChannel(x)),o.push(b),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(T),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],T=p[2],g=p[3],v=p[4],_=[];for(let b=0,M=m.length;b<M;b++){const C=m[b],P=x[b],E=T[b],z=g[b],I=v[b];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(C,P,E,z,I);if(R||(R=i._createAnimationTracks(C,P,E,z,I)),R)for(let N=0;N<R.length;N++)_.push(R[N])}return new A.AnimationClip$1(a,void 0,_)})}}const Zf=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Yf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=Fc;exports.BatchedParticleRenderer=zh;exports.Builder=ao;exports.ByteBuffer=li;exports.ConstantColor=gn;exports.ConstantValue=ee;exports.Matrix4=Et;exports.MeshBVH=Vn;exports.MotionController=Rl;exports.ParticleSystem=Lr;exports.SIZE_PREFIX_LENGTH=Qa;exports.TrailParticle=Ur;exports.Vector4=at;exports.WorkerBase=qf;exports.bundler=cu;exports.createNoise4D=Bh;exports.fetchProfile=Cl;exports.index=Vh;exports.index$1=Hf;exports.index$2=Zf;exports.md5=Mu;exports.v5=Su;
1116
+ }`;class Oh extends Hc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new A.BufferGeometry,this.indexBuffer=new A.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new A.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(A.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Dn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Xs(this.settings.material.map.channel),e.map=new A.Uniform$1(this.settings.material.map),e.mapTransform=new A.Uniform$1(new It().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new A.ShaderMaterial({uniforms:e,defines:t,vertexShader:Ah,fragmentShader:Rh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||A.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const T=c[x],g=T.uvTile%f,v=Math.floor(T.uvTile/f+.001),_=T.previous.values();let b=_.next(),M=b.value,C=M;b.done||(b=_.next());let P;b.value!==void 0?P=b.value:P=C;for(let E=0;E<T.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(T.parentMatrix?this.vector_.copy(C.position).applyMatrix4(T.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.previousBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(T.parentMatrix?this.vector_.copy(M.position).applyMatrix4(T.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(T.parentMatrix?this.vector_.copy(P.position).applyMatrix4(T.parentMatrix):this.vector_.copy(P.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else if(T.parentMatrix)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else{const z=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,C.size*z),this.widthBuffer.setX(e+1,C.size*z)}this.uvBuffer.setXY(e,(E/T.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/T.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,C.color.x,C.color.y,C.color.z,C.color.w),this.colorBuffer.setXYZW(e+1,C.color.x,C.color.y,C.color.z,C.color.w),E+1<T.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),M=C,C=P,b.done||(b=_.next(),b.value!==void 0&&(P=b.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ji{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new A.Triangle;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new A.Vector3,this._tempB=new A.Vector3,this._tempC=new A.Vector3,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ji(t.geometries[e.geometry])}clone(){return new Ji(this._geometry)}update(e,t){}}lh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ji,loadJSON:Ji.fromJSON}],behaviors:[]});class yo extends A.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(yo.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new Oh(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new kh(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const zh=yo;vh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const qc=Math.sqrt(5),Ih=(qc-1)/4,Ue=(5-qc)/20,sr=r=>Math.floor(r)|0,or=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Bh(r=Math.random){const e=Nh(r),t=new Float64Array(e).map(a=>or[a%32*4]),n=new Float64Array(e).map(a=>or[a%32*4+1]),i=new Float64Array(e).map(a=>or[a%32*4+2]),s=new Float64Array(e).map(a=>or[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,T;const g=(o+c+l+u)*Ih,v=sr(o+g),_=sr(c+g),b=sr(l+g),M=sr(u+g),C=(v+_+b+M)*Ue,P=v-C,E=_-C,z=b-C,I=M-C,R=o-P,N=c-E,O=l-z,U=u-I;let F=0,J=0,W=0,K=0;R>N?F++:J++,R>O?F++:W++,R>U?F++:K++,N>O?J++:W++,N>U?J++:K++,O>U?W++:K++;const $=F>=3?1:0,me=J>=3?1:0,ne=W>=3?1:0,ue=K>=3?1:0,re=F>=2?1:0,ge=J>=2?1:0,be=W>=2?1:0,se=K>=2?1:0,he=F>=1?1:0,oe=J>=1?1:0,Xe=W>=1?1:0,Ve=K>=1?1:0,Je=R-$+Ue,Ye=N-me+Ue,xe=O-ne+Ue,ye=U-ue+Ue,ae=R-re+2*Ue,ut=N-ge+2*Ue,ke=O-be+2*Ue,fe=U-se+2*Ue,it=R-he+3*Ue,vt=N-oe+3*Ue,St=O-Xe+3*Ue,rt=U-Ve+3*Ue,xt=R-1+4*Ue,ht=N-1+4*Ue,ft=O-1+4*Ue,_t=U-1+4*Ue,Re=v&255,Ze=_&255,ct=b&255,Ke=M&255;let Q=.6-R*R-N*N-O*O-U*U;if(Q<0)f=0;else{const le=Re+e[Ze+e[ct+e[Ke]]];Q*=Q,f=Q*Q*(t[le]*R+n[le]*N+i[le]*O+s[le]*U)}let bt=.6-Je*Je-Ye*Ye-xe*xe-ye*ye;if(bt<0)p=0;else{const le=Re+$+e[Ze+me+e[ct+ne+e[Ke+ue]]];bt*=bt,p=bt*bt*(t[le]*Je+n[le]*Ye+i[le]*xe+s[le]*ye)}let Nt=.6-ae*ae-ut*ut-ke*ke-fe*fe;if(Nt<0)m=0;else{const le=Re+re+e[Ze+ge+e[ct+be+e[Ke+se]]];Nt*=Nt,m=Nt*Nt*(t[le]*ae+n[le]*ut+i[le]*ke+s[le]*fe)}let Tt=.6-it*it-vt*vt-St*St-rt*rt;if(Tt<0)x=0;else{const le=Re+he+e[Ze+oe+e[ct+Xe+e[Ke+Ve]]];Tt*=Tt,x=Tt*Tt*(t[le]*it+n[le]*vt+i[le]*St+s[le]*rt)}let Ut=.6-xt*xt-ht*ht-ft*ft-_t*_t;if(Ut<0)T=0;else{const le=Re+1+e[Ze+1+e[ct+1+e[Ke+1]]];Ut*=Ut,T=Ut*Ut*(t[le]*xt+n[le]*ht+i[le]*ft+s[le]*_t)}return 27*(f+p+m+x+T)}}function Nh(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Uh=Object.defineProperty,Dh=(r,e,t)=>e in r?Uh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ce=(r,e,t)=>(Dh(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Ce(this,"type"),Ce(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Ce(this,"value"),Ce(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Ce(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Ce(this,"value"),Ce(this,"type"),Ce(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class T extends r{}class g extends r{}class v extends r{}class _ extends r{}class b extends r{}class M extends r{}class C extends r{}class P extends r{}class E extends r{}class z extends r{}class I{constructor(d){Ce(this,"input"),Ce(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const w=this.input.codePointAt(y);d.push(w),y+=String.fromCodePoint(w).length}return d}}function R(h){return h===10}function N(h){return R(h)||h===8192||h===32}function O(h){return h>=48&&h<=57}function U(h){return O(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return F(h)||O(h)||h===45}function W(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function K(h,d){return h===92&&!R(d)}function $(h,d,y){return h===45?F(d)||d===45||K(d,y):!!F(h)||h===92&&K(h,d)}function me(h,d,y){return h===43||h===45?O(d)||d===46&&O(y):O(h===46?d:h)}function ne(h){const d=h.consume();if(U(d)){let y=[d];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function ue(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const w=h.peek()[0];w===void 0||(R(w)?h.consume():y.value+=String.fromCodePoint(ne(h)))}else y.value+=String.fromCodePoint(S)}}function re(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!K(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ne(h))}}}function ge(h){let d=(function(y){let S="integer",w="";for([43,45].includes(y.peek()[0])&&(w+=String.fromCodePoint(y.consume()));O(...y.peek());)w+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&O(y.peek()[1]))for(w+=String.fromCodePoint(y.consume(),y.consume()),S="number";O(...y.peek());)w+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&O(y.peek()[2])?(w+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):O(y.peek()[1])&&(w+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(w),type:S}})(h);return $(...h.peek())?new p(d.value,d.type,re(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function be(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;K(...h.peek())&&ne(h)}}function se(h){const d=re(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const w=y.consume();if(w===41||w===void 0)return S;if(N(w)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(be(y),new c)}if([34,39,40].includes(w)||W(w))return be(y),new c;if(w===92){if(!K(...y.peek()))return be(y),new c;S.value+=ne(y)}else S.value+=String.fromCodePoint(w)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function he(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return ue(h,d);if(d===35){if(J(y[0])||K(...y)){const S=new i;return $(...y)&&(S.type="id"),S.value=re(h),S}return new l(String.fromCodePoint(d))}return d===39?ue(h,d):d===40?new C:d===41?new P:d===43?me(...y)?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?me(...h.peek())?(h.reconsume(d),ge(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new T):$(...h.peek())?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===46?me(...h.peek())?(h.reconsume(d),ge(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?$(...y)?new n(re(h)):new l(String.fromCodePoint(d)):d===91?new b:d===92?K(...y)?(h.reconsume(d),se(h)):new l(String.fromCodePoint(d)):d===93?new M:d===123?new E:d===125?new z:O(d)?(h.reconsume(d),ge(h)):F(d)?(h.reconsume(d),se(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function Xe(h){return oe.has(h.toLowerCase())}function Ve(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function Je(h){const d=[];let y=0;function S(){let k=0;const B=y;for(;y<h.length;){const L=h.slice(y,y+1);if(/\s/.test(L)&&k===0)break;if(L==="(")k+=1;else if(L===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(B,y)}function w(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?w():d.push(S())}return d}function Ye(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function xe(h,d){const y=[],S=[];for(const w of h)d(w)?y.push(w):S.push(w);return[y,S]}function ye(h,d={}){function y(S){return Array.from(S).map((w=>ye(w,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const w=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(w,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(ye(h.value,d));break;case"clamp":h=new CSSMathClamp(ye(h.lower,d),ye(h.value,d),ye(h.upper,d));break;case"invert":h=new CSSMathInvert(ye(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((w=>w instanceof CSSUnitValue&&w.unit!=="percent"&&Xe(w.unit)&&w.unit===S[0].unit))){const w=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(w,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[w,k]=xe(S,(L=>L instanceof CSSUnitValue&&L.unit!=="percent")),B=Array.from(Ye(w,"unit").values());if(B.some((L=>L.length>0))){const L=B.map((D=>{const V=Math[h.operator].apply(Math,D.map((({value:H})=>H)));return new CSSUnitValue(V,D[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...L,...k):new CSSMathMax(...L,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const B=k.filter((L=>L instanceof CSSUnitValue));return[...k.filter((L=>!(L instanceof CSSUnitValue))),...Array.from(Ye(B,"unit").entries()).map((([L,D])=>{const V=D.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,L)}))]},w=[];for(const k of h.values)k instanceof CSSMathSum?w.push(...k.values):w.push(k);return w=S(w),w.length===1?w[0]:new CSSMathSum(...w)}if(h instanceof CSSMathProduct){let S=[];for(const B of h.values)B instanceof CSSMathProduct?S.push(...B.values):S.push(B);const[w,k]=xe(S,(B=>B instanceof CSSUnitValue&&B.unit==="number"));if(w.length>1){const B=w.reduce(((L,{value:D})=>L*D),1);S=[new CSSUnitValue(B,"number"),...k]}if(S.length===2){let B,L;for(const D of S)D instanceof CSSUnitValue&&D.unit==="number"?B=D:D instanceof CSSMathSum&&[...D.values].every((V=>V instanceof CSSUnitValue))&&(L=D);if(B&&L)return new CSSMathSum(...[...L.values].map((D=>new CSSUnitValue(D.value*B.value,D.unit))))}if(S.every((B=>B instanceof CSSUnitValue&&Xe(B.unit)||B instanceof CSSMathInvert&&B.value instanceof CSSUnitValue&&Xe(B.value.unit)))){const B=new CSSMathProduct(...S).toSum();if(B&&B.values.length===1)return B.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,ut=["percent","length","angle","time","frequency","resolution","flex"],ke={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},fe=new Map;for(const h of Object.values(ke))if(h.compatible)for(const d of h.units)fe.set(d,h);function it(h){return fe.get(h)}function vt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function St(h){return h==="number"?{}:h==="percent"?{percent:1}:ke.absoluteLengths.units.has(h)||ke.fontRelativeLengths.units.has(h)||ke.viewportRelativeLengths.units.has(h)?{length:1}:ke.angle.units.has(h)?{angle:1}:ke.time.units.has(h)?{time:1}:ke.frequency.units.has(h)?{frequency:1}:ke.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function rt(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=it(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=rt(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[w,k]of Object.entries(y[1]))S[w]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=rt(y),w=[];if(S===ae)return ae;for(const k of d)for(const B of S)w.push([k[0]*B[0],vt(k[1],B[1])]);d=w}return d}throw new Error("Not implemented")}function xt(h,d){if(St(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=rt(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(w,k){const B=w.unit,L=w.value,D=it(B),V=it(k);return!V||D!==V?ae:new CSSUnitValue(L*V.ratios[B]/V.ratios[k],k)})(ht(y[0]),d);if(S===ae)throw new TypeError;return S}function ht(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const w=S[0];return w[1]!==1?ae:new CSSUnitValue(d,w[0])}function ft(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=rt(h).map((S=>ht(S)));if(y.some((S=>S===ae)))throw new TypeError("Type error");return new CSSMathSum(...y)}function _t(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of ut)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Re{constructor(d,y){Ce(this,"name"),Ce(this,"values"),this.name=d,this.values=y}}class Ze{constructor(d,y){Ce(this,"value"),Ce(this,"associatedToken"),this.value=d,this.associatedToken=y}}function ct(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new I(d),S=[];for(;;){const w=he(y);if(w===void 0)return S;S.push(w)}})(h);throw new TypeError("Invalid input type "+typeof h)}function Ke(h){const d=h.shift();return d instanceof E||d instanceof b||d instanceof C?(function(y,S){let w;if(S instanceof E)w=z;else if(S instanceof C)w=P;else{if(!(S instanceof b))return;w=M}const k=new Ze([],S);for(;;){const B=y.shift();if(B instanceof w||B===void 0)return k;y.unshift(B),k.value.push(Ke(y))}})(h,d):d instanceof t?(function(y,S){const w=new Re(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return w;S.unshift(k),w.values.push(Ke(S))}})(d,h):d}function Q(h){if(h instanceof C||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function bt(h){return h[h.length-1]}function Nt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",w=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...w,...k]}}function Tt(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>Tt(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>Tt(d))));if(h.type==="NEGATE")return new CSSMathNegate(Tt(h.value));if(h.type==="INVERT")return new CSSMathInvert(Tt(h.value));if(h instanceof Ze)return Ut(new Re("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return le(h)}function Ut(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((w=>!(w instanceof m||w instanceof _))).map((w=>ye(Ut(new Re("calc",w)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=Tt((function(S){const w=[],k=[];for(;S.length;){const B=S.shift();if(B instanceof u||B instanceof p||B instanceof f||B instanceof Re||B instanceof Ze||B instanceof e)k.push(B);else if(B instanceof l&&["*","/","+","-"].includes(B.value)){for(;w.length&&!(bt(w)instanceof C)&&Q(bt(w))>Q(B);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}w.push(B)}else if(B instanceof C)w.push(B);else if(B instanceof P){if(!w.length)return null;for(;!(bt(w)instanceof C);){const L=w.pop(),D=k.pop(),V=k.pop();k.push(Nt(L,V,D))}if(!(bt(w)instanceof C))return null;w.pop()}else if(!(B instanceof m))return null}for(;w.length;){if(bt(w)instanceof C)return null;const B=w.pop(),L=k.pop(),D=k.pop();k.push(Nt(B,D,L))}return k[0]})([...h.values]));let y;try{y=ye(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function le(h){return h instanceof Re&&["calc","min","max","clamp"].includes(h.name)?Ut(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function ol(h){const d=(function(y){const S=ct(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const w=Ke(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?w:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Re||new CSSStyleSheet().insertRule("error",0),d instanceof p&&St(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),le(d)}(function(){let h=new WeakMap;function d(k){const B=[];for(let D=0;D<k.length;D++)B[D]=typeof(L=k[D])=="number"?new CSSUnitValue(L,"number"):L;var L;return B}class y{static parse(B){return B instanceof y?B:ye(ol(B),{})}}class S extends y{constructor(B,L,D,V){super(),h.set(this,{values:d(B),operator:L,name:D||L,delimiter:V||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const B=h.get(this);return`${B.name}(${B.values.join(B.delimiter)})`}}const w={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,B){super(),h.set(this,{value:k,unit:B})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ft(this,...k)}type(){return St(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${(function(B){switch(B){case"percent":return"%";case"number":return"";default:return B.toLowerCase()}})(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ft(this,...k)}type(){return h.get(this).values.map((k=>k.type())).reduce(_t)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const B={};for(const L of ut)B[L]=-1*k[L];return B})(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:B=>new CSSUnitValue(B,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,B]of Object.entries(w))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:B}))throw Error(`Error installing CSSOM support for ${k}`)})();const bo="block";let je=new WeakMap,Dt=new WeakMap;const $i=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function To(h){return h===document.scrollingElement?document:h}function sn(h){Xr(h);let d=je.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Mo(h,d){if(!h)return null;const y=Dt.get(h).sourceMeasurements,S=getComputedStyle(h);let w=y.scrollTop;return Ve(d,S)==="x"&&(w=Math.abs(y.scrollLeft)),w}function qr(h,d){const y=ye(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function Xr(h){if(!(h instanceof _n))return void(function(y){const S=je.get(y);if(!S.anonymousSource)return;const w=wo(S.anonymousSource,S.anonymousTarget);xn(y,w)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void xn(h,null);xn(h,ts(d))}function Co(h){return["block","inline","x","y"].includes(h)}function Yr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function Zr(h,d){if(!h||!d)return;let y=0,S=0,w=d;const k=h.offsetParent;for(;w&&w!=k;)S+=w.offsetLeft,y+=w.offsetTop,w=w.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const B=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:B.fontSize}}function Wi(h){let d=Dt.get(h);d.sourceMeasurements=Yr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof _n&&(je.get(S).subjectMeasurements=Zr(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&sn(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function xn(h,d){const y=je.get(h),S=y.source;if(S!=d){if(S){const w=Dt.get(S);if(w){w.timelineRefs.delete(h);const k=Array.from(w.timelineRefs).filter((B=>B.deref()===void 0));for(const B of k)w.timelineRefs.delete(B);w.timelineRefs.size===0&&(w.disconnect(),Dt.delete(S))}}if(y.source=d,d){let w=Dt.get(d);if(!w){w={timelineRefs:new Set,sourceMeasurements:Yr(d)},Dt.set(d,w);const k=new ResizeObserver((D=>{for(const V of D)Wi(y.source)}));k.observe(d);for(const D of d.children)k.observe(D);const B=new MutationObserver((D=>{for(const V of D)Wi(V.target)}));B.observe(d,{attributes:!0,attributeFilter:["style","class"]});const L=()=>{w.sourceMeasurements.scrollLeft=d.scrollLeft,w.sourceMeasurements.scrollTop=d.scrollTop;for(const D of w.timelineRefs){const V=D.deref();V&&sn(V)}};To(d).addEventListener("scroll",L),w.disconnect=()=>{k.disconnect(),B.disconnect(),To(d).removeEventListener("scroll",L)}}w.timelineRefs.add(new WeakRef(h))}}}function Kr(h,d){let y=je.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Qr(h,d,y){let S=je.get(h).animations;for(let w=0;w<S.length;w++)if(S[w].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{sn(h)}))}class Qe{constructor(d){if(je.set(this,{source:null,axis:bo,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),xn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=bo){if(!Co(d.axis))throw TypeError("Invalid axis");je.get(this).axis=d.axis}sn(this)}set source(d){xn(this,d),sn(this)}get source(){return je.get(this).source}set axis(d){if(!Co(d))throw TypeError("Invalid axis");je.get(this).axis=d,sn(this)}get axis(){return je.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const w=this.axis,k=Mo(y,w),B=(function(L,D){const V=Dt.get(L).sourceMeasurements,H=getComputedStyle(L).writingMode=="horizontal-tb";return D==="block"?D=H?"y":"x":D==="inline"&&(D=H?"x":"y"),D==="y"?V.scrollHeight-V.clientHeight:D==="x"?V.scrollWidth-V.clientWidth:void 0})(y,w);return B>0?CSS.percent(100*k/B):CSS.percent(100)}get __polyfill(){return!0}}function es(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function wo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return ts(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function al(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Po(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function cl(h){return getComputedStyle(h).position!="static"||Po(h)}function ll(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return es(h,al);case"absolute":return es(h,cl);case"fixed":return es(h,Po)}}function ts(h){if(h&&h.isConnected){for(;h=ll(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function Gn(h,d){const y=je.get(h),S=y.subjectMeasurements,w=Dt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof _n?ns(d,w,S,y.axis,y.inset):null}function ns(h,d,y,S,w){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let B,L,D={fontSize:y.fontSize};Ve(S,d)==="x"?(B=y.offsetWidth,L=y.left,D.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(L+=d.scrollWidth-d.clientWidth,D.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),D.containerSize=d.clientWidth):(B=y.offsetHeight,L=y.top,D.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],D.containerSize=d.clientHeight);const V=(function(os,Zi){const _l={start:0,end:0};if(!os)return _l;const[bl,Tl]=[os.start,os.end].map(((Jo,jo)=>Jo==="auto"?Zi.scrollPadding[jo]==="auto"?0:parseFloat(Zi.scrollPadding[jo]):qr(Jo,{percentageReference:CSS.px(Zi.containerSize),fontSize:CSS.px(parseFloat(Zi.fontSize))})));return{start:bl,end:Tl}})(w,D),H=L-D.containerSize+V.end,X=L+B-V.start,Y=H+B,de=X-B,Te=Math.min(Y,de),st=Math.max(Y,de);let Mt,dt;const Vo=B>D.containerSize-V.start-V.end;switch(h){case"cover":Mt=H,dt=X;break;case"contain":Mt=Te,dt=st;break;case"entry":Mt=H,dt=Te;break;case"exit":Mt=st,dt=X;break;case"entry-crossing":Mt=H,dt=Vo?st:Te;break;case"exit-crossing":Mt=Vo?Te:st,dt=X}return{start:Mt,end:dt}}function Eo(h,d){if(h instanceof _n){const{rangeName:y,offset:S}=d;return ko(Gn(h,y),S,Gn(h,"cover"),h.subject)}if(h instanceof Qe){const{axis:y,source:S}=h,{sourceMeasurements:w}=Dt.get(S);let k;return k=Ve(y,w)==="x"?w.scrollWidth-w.clientWidth:w.scrollHeight-w.clientHeight,qr(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function ko(h,d,y,S){if(!h||!y)return 0;let w=getComputedStyle(S);return(qr(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(w.fontSize))})+h.start-y.start)/(y.end-y.start)}let _n=class extends Qe{constructor(d){super(d);const y=je.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let w;if(w=typeof S=="string"?Je(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],w.length===0||w.length>2)throw TypeError("Invalid inset");for(const k of w){if(k==="auto")continue;const B=k.type();if(B.length!==1&&B.percent!==1)throw TypeError("Invalid inset")}return{start:w[0],end:w[1]??w[0]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{Wi(y.source)})).observe(y.subject),new MutationObserver((()=>{Wi(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),Xr(this),y.subjectMeasurements=Zr(y.source,y.subject),sn(this)}get source(){return Xr(this),je.get(this).source}set source(d){throw new Error("Cannot set the source of a view timeline")}get subject(){return je.get(this).subject}get axis(){return je.get(this).axis}get currentTime(){const y=Mo(this.source,this.axis);if(y==null)return null;const S=Gn(this,"cover");if(!S)return null;const w=(y-S.start)/(S.end-S.start);return CSS.percent(100*w)}get startOffset(){return CSS.px(Gn(this,"cover").start)}get endOffset(){return CSS.px(Gn(this,"cover").end)}};const ul=document.getAnimations,hl=window.Element.prototype.getAnimations,fl=window.Element.prototype.animate,Ro=window.Animation;class bn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function $n(h){h.readyPromise=new bn,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Hi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&zo(h):Oo(h))}))}function Ao(){return new DOMException("The user aborted a request","AbortError")}function on(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Ft(h),w=S?y*d/S:0;return CSS.percent(w)}function ve(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Ft(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Oo(h){const d=ve(h,h.timeline.currentTime);if(h.holdTime!=null)kt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;kt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Lt(h,!1,!1),Vt(h),h.pendingTask=null}function zo(h){const d=ve(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),kt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Lt(h,!1,!1),Vt(h),h.pendingTask=null}function Io(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function Tn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function kt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Bo(h){if(!h.timeline)return null;const d=ve(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Lt(h,d,y){if(!h.timeline)return;let S=d?ve(h,h.proxy.currentTime):Bo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const w=Tn(h),k=Ft(h);let B=h.previousCurrentTime;w>0&&S>=k&&h.previousCurrentTime!=null?((B===null||B<k)&&(B=k),h.holdTime=d?S:B):w<0&&S<=0?((B==null||B>0)&&(B=0),h.holdTime=d?S:B):w!=0&&(d&&h.holdTime!==null&&(h.startTime=(function(L,D){if(!L.timeline)return null;const V=ve(L,L.timeline.currentTime);return V==null?null:V-D/L.animation.playbackRate})(h,h.holdTime)),h.holdTime=null)}Vt(h),h.previousCurrentTime=ve(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new bn),h.finishedPromise.state=="pending"&&(y?Io(h):Promise.resolve().then((()=>{Io(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new bn),h.animation.playState!="paused"&&h.animation.pause())}function Ft(h){const d=(function(S){const w=S.proxy.effect.getTiming();return S.normalizedTiming||w})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Vt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;is(h,(ve(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&is(h,h.holdTime)}function is(h,d){const y=h.timeline,S=h.animation.playbackRate,w=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+w}function rs(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,w=ve(h,h.proxy.currentTime);Tn(h)==0&&w==null&&(h.holdTime=0),w==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Vt(h),h.readyPromise||$n(h),h.pendingTask="play",Qr(h.timeline,h.animation,ss.bind(h.proxy)),Lt(h,!1,!1))}function ss(h){const d=q.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Hi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&zo(d):Oo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ve(d,h);is(d,(S-ve(d,this.startTime))*this.playbackRate),Lt(d,!1,!1)}}function No(h){h.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(h=>{q=new WeakMap}),!1);let Uo=new WeakMap;function Hi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const B=k.animationRange.start==="normal"?Do(k.timeline):k.animationRange.start;return Eo(k.timeline,B)})(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const B=k.animationRange.end==="normal"?Lo(k.timeline):k.animationRange.end;return 1-Eo(k.timeline,B)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const w=Tn(h);h.startTime=ve(h,w>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&No(h)}function qi(h){throw new Error("Unsupported timeline class")}function Do(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof Qe?CSS.percent(0):void qi()}function Lo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof Qe?CSS.percent(100):void qi()}function dl(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Do(h),end:Lo(h)};if(h instanceof ViewTimeline){const S=Je(d),w=[],k=[];if(S.forEach((B=>{if($i.includes(B))w.push(B);else try{k.push(CSSNumericValue.parse(B))}catch{throw TypeError(`Could not parse range "${d}"`)}})),w.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return w.length&&(y.start.rangeName=w[0],y.end.rangeName=w.length>1?w[1]:w[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof Qe){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}qi()}function Xi(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",w=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(w=d.offset);else{const k=Je(d);k.length===1?$i.includes(k[0])?S=k[0]:w=ye(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],w=ye(CSSNumericValue.parse(k[1]),{}))}if(!$i.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:w}}if(h instanceof Qe)return CSSNumericValue.parse(d);qi()}class Yi{constructor(d,y,S={}){const w=y instanceof Qe,k=d instanceof Ro?d:new Ro(d,w?void 0:y);Uo.set(k,this),q.set(this,{animation:k,timeline:w?y:void 0,playState:w?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:w?dl(y,S["animation-range"]):null,proxy:this})}get effect(){const d=q.get(this);return d.timeline?(d.effect||(d.effect=(function(y){const S=y.animation.effect,w=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=on(y,H.localTime),H.endTime=on(y,H.endTime),H.activeDuration=on(y,H.activeDuration);const Y=Ft(y),de=H.iterations?(Y-H.delay-H.endDelay)/H.iterations:0;H.duration=Y?CSS.percent(X*de/Y):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},B={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Y=Object.assign({},y.specifiedTiming);if(Y.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Y.duration===null||Y.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Y.delay=0,Y.endDelay=0,X=Y.iterations?1e5:0,Y.duration=Y.iterations?(X-Y.delay-Y.endDelay)/Y.iterations:0,Y.duration<0&&(Y.duration=0,Y.endDelay=X-Y.delay),w.apply(S,[Y])),y.normalizedTiming=Y,y.specifiedTiming}},L={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Y=X[0],de=Y.duration;if(de===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Y.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");de!==void 0&&de!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),No(y)}}},D=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return D.getComputedTiming=new Proxy(S.getComputedTiming,k),D.getTiming=new Proxy(S.getTiming,B),D.updateTiming=new Proxy(S.updateTiming,L),D})(d)),d.effect):d.animation.effect}set effect(d){const y=q.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=q.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=q.get(this),S=this.timeline;if(S==d)return;const w=this.playState,k=this.currentTime;let B,L=Ft(y);B=k===null?null:L===0?0:ve(y,k)/L;const D=S instanceof Qe,V=d instanceof Qe,H=this.pending;if(D&&Kr(y.timeline,y.animation),V)return y.timeline=d,kt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,w!=="running"&&w!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||$n(y),y.pendingTask="play",Qr(y.timeline,y.animation,ss.bind(this))),w==="paused"&&B!==null&&(y.holdTime=B*L),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||$n(y),y.pendingTask=w=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Lt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Kr(y.timeline,y.animation),y.timeline=null,D)switch(k!==null&&(y.animation.currentTime=B*Ft(y)),w){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=q.get(this);return d.timeline?on(d,d.startTime):d.animation.startTime}set startTime(d){const y=q.get(this);if(d=ve(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ve(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Vt(y));const S=ve(y,this.currentTime);kt(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1),Vt(y)}get currentTime(){const d=q.get(this);return d.timeline?d.holdTime!=null?on(d,d.holdTime):on(d,Bo(d)):d.animation.currentTime}set currentTime(d){const y=q.get(this);y.timeline?((function(S,w){if(w==null&&S.currentTime!==null)throw new TypeError;w=ve(S,w),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=w:S.startTime=ve(S,S.timeline.currentTime)-w/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,d),y.pendingTask=="pause"&&(y.holdTime=ve(y,d),kt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Lt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(d){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=q.get(this);if(!d.timeline)return d.animation.playState;const y=ve(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Ft(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=q.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof Qe&&(y.animationRange.start=Xi(y.timeline,d,"start"),Hi(y),Vt(y))}get rangeEnd(){var d;return((d=q.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof Qe&&(y.animationRange.end=Xi(y.timeline,d,"end"),Hi(y),Vt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const d=q.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=q.get(this);if(!d.timeline)return void d.animation.finish();const y=Tn(d),S=Ft(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");kt(d);const w=y<0?0:S;this.currentTime=on(d,w);const k=ve(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-w/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Lt(d,!0,!0)}play(){const d=q.get(this);d.timeline?rs(d):d.animation.play()}pause(){const d=q.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||$n(d),d.pendingTask="pause",Qr(d.timeline,d.animation,ss.bind(d.proxy))):d.animation.pause()}reverse(){const d=q.get(this),y=Tn(d),S=ve(d,this.currentTime),w=Ft(d)==1/0,k=y!=0&&(y<0||S>0||!w);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-Tn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),rs(d)}updatePlaybackRate(d){const y=q.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":kt(y);break;case"finished":const w=ve(y,y.timeline.currentTime),k=w!==null?(w-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?w:w!=null&&k!=null?(w-k)/d:null,kt(y),Lt(y,!1,!1),Vt(y);break;default:rs(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(d){q.get(this).animation.id=d}cancel(){const d=q.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,kt(y),y.readyPromise.reject(Ao()),$n(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Ao()),d.finishedPromise=new bn,d.animation.cancel()),d.startTime=null,d.holdTime=null,Kr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(d){q.get(this).animation.onfinish=d}get oncancel(){return q.get(this).animation.oncancel}set oncancel(d){q.get(this).animation.oncancel=d}get onremove(){return q.get(this).animation.onremove}set onremove(d){q.get(this).animation.onremove=d}get finished(){const d=q.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new bn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=q.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new bn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){q.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){q.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){q.get(this).animation.dispatchEvent(d)}}function pl(h,d){const y=d.timeline;y instanceof Qe&&delete d.timeline;const S=fl.apply(this,[h,d]),w=new Yi(S,y);return y instanceof Qe&&(S.pause(),q.get(w).animationRange={start:Xi(y,d.rangeStart,"start"),end:Xi(y,d.rangeEnd,"end")},w.play()),w}function Fo(h){for(let d=0;d<h.length;++d){let y=Uo.get(h[d]);y&&(h[d]=y)}return h}function ml(h){return Fo(hl.apply(this,[h]))}function yl(h){return Fo(ul.apply(this,[h]))}const Ae={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Mn=["block","inline","x","y"],gl=["nearest","root","self"],Xt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const w=this.parseQualifiedRule(S);w&&(d?this.parseKeyframesAndSaveNameMapping(w,S):this.handleScrollTimelineProps(w,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:wo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const w=this.sourceSelectorToScrollTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{source:k,...w.axis?{axis:w.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const w=this.subjectSelectorToViewTimeline[S];if(w.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,w.selector);if(k)return{subject:k,axis:w.axis,inset:w.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),w=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!w)return;let k=[],B=[],L=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(B=this.extractMatches(h.block.contents,Ae.ANIMATION_NAME)),S&&y||(w&&this.extractMatches(h.block.contents,Ae.ANIMATION).forEach((D=>{const V=this.extractAnimationName(D);V&&S&&B.push(V),S&&(this.hasDuration(D)||(this.hasAutoDuration(D)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(D," 1s "+D),L=!0))})),L&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,B)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let w=[];if(d){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE);for(const L of B){const D=this.split(L);let V={selector:h.selector,name:""};D.length==1?V.name=D[0]:D.length==2&&(Mn.includes(D[0])?(V.axis=D[0],V.name=D[1]):(V.axis=D[1],V.name=D[0])),w.push(V)}}if(y){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE_NAME);for(let L=0;L<B.length;L++)if(L<w.length)w[L].name=B[L];else{let D={selector:h.selector,name:B[L]};w.push(D)}}let k=[];if(S){const B=this.extractMatches(h.block.contents,Ae.SCROLL_TIMELINE_AXIS);if(k=B.filter((L=>Mn.includes(L))),k.length!=B.length)throw new Error("Invalid axis")}for(let B=0;B<w.length;B++)k.length&&(w[B].axis=k[B%w.length]);this.sourceSelectorToScrollTimeline.push(...w)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),w=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE);for(let V of D){const H=this.split(V);let X={selector:h.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(Mn.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_NAME);for(let V=0;V<D.length;V++)if(V<k.length)k[V].name=D[V];else{let H={selector:h.selector,name:D[V],inset:null};k.push(H)}}let B=[],L=[];if(w&&(B=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_INSET)),S){const D=this.extractMatches(h.block.contents,Ae.VIEW_TIMELINE_AXIS);if(L=D.filter((V=>Mn.includes(V))),L.length!=D.length)throw new Error("Invalid axis")}for(let D=0;D<k.length;D++)B.length&&(k[D].inset=B[D%k.length]),L.length&&(k[D].axis=L[D%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter((d=>{return y=d,Ae.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,Ae.ANIMATION_TIME_RANGE));const w=Math.max(d.length,y.length,S.length);for(let k=0;k<w;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=Ae.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map((S=>S.trim())).forEach((S=>{if((function(w){return(w.startsWith("scroll")||w.startsWith("view"))&&w.includes("(")})(S)){const w=this.saveAnonymousTimelineName(S);y.push(w)}else y.push(S)})),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=Ae.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Mn.includes(w)?S.axis=w:gl.includes(w)&&(S.source=w)})),S}parseAnonymousViewTimeline(h){const d=Ae.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((w=>{Mn.includes(w)?S.axis=w:S.inset=S.inset?`${S.inset} ${w}`:w})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){Ae.IDENTIFIER.lastIndex=h.index;const d=Ae.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,w)=>{w>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(D){return $i.some((V=>D.startsWith(V)))}const S=h.block.contents,w=(function(D){let V=0,H=-1,X=-1;const Y=[];for(let de=0;de<D.length;de++)D[de]=="{"?V++:D[de]=="}"&&V--,V==1&&D[de]!="{"&&D[de]!="}"&&H==-1&&(H=de),V==2&&D[de]=="{"&&(X=de,Y.push({start:H,end:X}),H=X=-1);return Y})(S);if(w.length==0)return new Map;const k=new Map;let B=!1;const L=[];L.push(S.substring(0,w[0].start));for(let D=0;D<w.length;D++){const V=S.substring(w[D].start,w[D].end);let H=[];V.split(",").forEach((X=>{const Y=X.split(" ").map((Te=>Te.trim())).filter((Te=>Te!="")).join(" "),de=k.size;k.set(de,Y),H.push(`${de}%`),y(Y)&&(B=!0)})),L.push(H.join(",")),D==w.length-1?L.push(S.substring(w[D].end)):L.push(S.substring(w[D].end,w[D+1].start))}return B?(h.block.contents=L.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const w=S.index-d;S.index=h+y.length+w}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){Ae.WHITE_SPACE.lastIndex=h.index;const d=Ae.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function vl(h,d,y,S,w,k){const B=Yr(d),L=Zr(d,y);return ko(ns(h,B,L,S,w),k,ns("cover",B,L,S,w),y)}function Sl(h,d,y){const S=Xt.getAnimationTimelineOptions(d,y);if(!S)return null;const w=S["animation-timeline"];if(!w)return null;let k=Xt.getScrollTimelineOptions(w,y)||Xt.getViewTimelineOptions(w,y);return k?(k.subject&&(function(B,L){const D=ts(L.subject),V=L.axis||L.axis;function H(Y,de){let Te=null;for(const[st,Mt]of Y)if(st==100*de.offset){if(Mt=="from")Te=0;else if(Mt=="to")Te=100;else{const dt=Mt.split(" ");Te=dt.length==1?parseFloat(dt[0]):100*vl(dt[0],D,L.subject,V,L.inset,CSS.percent(parseFloat(dt[1])))}break}return Te}const X=Xt.keyframeNamesSelectors.get(B.animationName);if(X&&X.size){const Y=[];B.effect.getKeyframes().forEach((Te=>{const st=H(X,Te);st!==null&&st>=0&&st<=100&&(Te.offset=st/100,Y.push(Te))}));const de=Y.sort(((Te,st)=>Te.offset<st.offset?-1:Te.affset>st.offset?1:0));B.effect.setKeyframes(de)}})(h,k),{timeline:k.source?new Qe(k):new _n(k),animOptions:S}):null}function xl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let w=Xt.transpileStyleSheet(S.innerHTML,!0);w=Xt.transpileStyleSheet(w,!1),S.innerHTML=w}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async w=>{const k=await w.text();let B=Xt.transpileStyleSheet(k,!0);if(B=Xt.transpileStyleSheet(k,!1),B!=k){const L=new Blob([B],{type:"text/css"}),D=URL.createObjectURL(L);S.setAttribute("href",D)}}))}new MutationObserver((S=>{for(const w of S)for(const k of w.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=Sl(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof Yi)y.timeline=S.timeline;else{const w=new Yi(y,S.timeline,S.animOptions);y.pause(),w.play()}}))}))}(function(){if(!xl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:Qe}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:_n}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Yi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:ml}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:yl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Lh{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class Xc{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_;this._closedByUser=!1,this.handleOpenEvent=b=>this.handleEvent(ce.open,b),this.handleErrorEvent=b=>this.handleEvent(ce.error,b),this.handleCloseEvent=b=>this.handleEvent(ce.close,b),this.handleMessageEvent=b=>this.handleEvent(ce.message,b),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(ce.retry,{detail:n});this.handleEvent(ce.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class Fh{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new Xc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,_,b,M,C,P,E,z;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(T=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&T!==void 0?T:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(C=(M=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||M===void 0?void 0:M.reconnect)!==null&&C!==void 0?C:[],[e]:[...(z=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&z!==void 0?z:[],{listener:t,options:n}]}}),this}}const Vh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Lh,Websocket:Xc,WebsocketBuilder:Fh,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),go=0,Yc=1,Zc=2,Ys=2,ws=1.25,ka=1,$e=32,Pe=$e/4,Kc=65535,kr=Math.pow(2,-24),$r=Symbol("SKIP_GENERATION"),Qc={strategy:go,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$r]:!1};function Se(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Ra(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Aa(r,e){e.set(r)}function Oa(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function ar(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function Xn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function Ee(r,e){return e[r+15]===Kc}function We(r,e){return e[r+6]}function tt(r,e){return e[r+14]}function Ie(r){return r+Pe}function Be(r,e){const t=e[r+6];return r+t*Pe}function vo(r,e){return e[r+7]}function Ps(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,T=-1/0,g=-1/0;const v=r.offset||0;for(let _=(e-v)*6,b=(e+t-v)*6;_<b;_+=6){const M=r[_+0],C=r[_+1],P=M-C,E=M+C;P<s&&(s=P),E>c&&(c=E),M<f&&(f=M),M>x&&(x=M);const z=r[_+2],I=r[_+3],R=z-I,N=z+I;R<a&&(a=R),N>l&&(l=N),z<p&&(p=z),z>T&&(T=z);const O=r[_+4],U=r[_+5],F=O-U,J=O+U;F<o&&(o=F),J>u&&(u=J),O<m&&(m=O),O>g&&(g=O)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=T,i[5]=g}const Jt=32,Jh=(r,e)=>r.candidate-e.candidate,Kt=new Array(Jt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),cr=new Float32Array(6);function jh(r,e,t,n,i,s){let a=-1,o=0;if(s===go)a=Ra(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Yc)a=Ra(r),a!==-1&&(o=Gh(t,n,i,a));else if(s===Zc){const c=Xn(r);let l=ws*i;const u=t.offset||0,f=(n-u)*6,p=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],v=(e[m+3]-x)/Jt;if(i<Jt/4){const _=[...Kt];_.length=i;let b=0;for(let C=f;C<p;C+=6,b++){const P=_[b];P.candidate=t[C+2*m],P.count=0;const{bounds:E,leftCacheBounds:z,rightCacheBounds:I}=P;for(let R=0;R<3;R++)I[R]=1/0,I[R+3]=-1/0,z[R]=1/0,z[R+3]=-1/0,E[R]=1/0,E[R+3]=-1/0;ar(C,t,E)}_.sort(Jh);let M=i;for(let C=0;C<M;C++){const P=_[C];for(;C+1<M&&_[C+1].candidate===P.candidate;)_.splice(C+1,1),M--}for(let C=f;C<p;C+=6){const P=t[C+2*m];for(let E=0;E<M;E++){const z=_[E];P>=z.candidate?ar(C,t,z.rightCacheBounds):(ar(C,t,z.leftCacheBounds),z.count++)}}for(let C=0;C<M;C++){const P=_[C],E=P.count,z=i-P.count,I=P.leftCacheBounds,R=P.rightCacheBounds;let N=0;E!==0&&(N=Xn(I)/c);let O=0;z!==0&&(O=Xn(R)/c);const U=ka+ws*(N*E+O*z);U<l&&(a=m,l=U,o=P.candidate)}}else{for(let M=0;M<Jt;M++){const C=Kt[M];C.count=0,C.candidate=x+v+M*v;const P=C.bounds;for(let E=0;E<3;E++)P[E]=1/0,P[E+3]=-1/0}for(let M=f;M<p;M+=6){let E=~~((t[M+2*m]-x)/v);E>=Jt&&(E=Jt-1);const z=Kt[E];z.count++,ar(M,t,z.bounds)}const _=Kt[Jt-1];Aa(_.bounds,_.rightCacheBounds);for(let M=Jt-2;M>=0;M--){const C=Kt[M],P=Kt[M+1];Oa(C.bounds,P.rightCacheBounds,C.rightCacheBounds)}let b=0;for(let M=0;M<Jt-1;M++){const C=Kt[M],P=C.count,E=C.bounds,I=Kt[M+1].rightCacheBounds;P!==0&&(b===0?Aa(E,cr):Oa(E,cr,cr)),b+=P;let R=0,N=0;b!==0&&(R=Xn(cr)/c);const O=i-b;O!==0&&(N=Xn(I)/c);const U=ka+ws*(R*b+N*O);U<l&&(a=m,l=U,o=C.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Gh(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class Es{constructor(){this.boundingData=new Float32Array(6)}}function $h(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let f=0;f<e;f++){let p=r[a*e+f];r[a*e+f]=r[o*e+f],r[o*e+f]=p}for(let f=0;f<6;f++){const p=a-u,m=o-u,x=t[p*6+f];t[p*6+f]=t[m*6+f],t[m*6+f]=x}a++,o--}else return a}}let el,Rr,Zs,tl;const Wh=Math.pow(2,32);function Ks(r){return"count"in r?1:1+Ks(r.left)+Ks(r.right)}function Hh(r,e,t){return el=new Float32Array(t),Rr=new Uint32Array(t),Zs=new Uint16Array(t),tl=new Uint8Array(t),Qs(r,e)}function Qs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)el[t+a]=s[a];if(i)return e.buffer?(tl.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Rr[t+6]=e.offset,Zs[n+14]=e.count,Zs[n+15]=Kc,r+$e);{const{left:a,right:o,splitAxis:c}=e,l=r+$e;let u=Qs(l,a);const f=r/$e,m=u/$e-f;if(m>Wh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Rr[t+6]=m,Rr[t+7]=c,Qs(u,o)}}function qh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,u=r.primitiveBuffer,f=r.primitiveBufferStride,p=new Float32Array(6);let m=!1;const x=new Es;return Ps(e,t,n,x.boundingData,p),g(x,t,n,p),x;function T(v){l&&l(v/n)}function g(v,_,b,M=null,C=0){if(!m&&C>=s&&(m=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),b<=o||C>=s)return T(_+b),v.offset=_,v.count=b,v;const P=jh(v.boundingData,M,e,_,b,c);if(P.axis===-1)return T(_+b),v.offset=_,v.count=b,v;const E=$h(u,f,e,_,b,P);if(E===_||E===_+b)T(_+b),v.offset=_,v.count=b;else{v.splitAxis=P.axis;const z=new Es,I=_,R=E-_;v.left=z,Ps(e,I,R,z.boundingData,p),g(z,I,R,p,C+1);const N=new Es,O=E,U=b-R;v.right=N,Ps(e,O,U,N.boundingData,p),g(N,O,U,p,C+1)}return v}}function Xh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=qh(r,o,c.offset,c.count,e),u=Ks(l),f=new t($e*u);return Hh(0,l,f),f})}class So{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Yh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const pe=new Yh;let nn,Un;const wn=[],lr=new So(()=>new A.Box3);function Zh(r,e,t,n,i,s){nn=lr.getPrimitive(),Un=lr.getPrimitive(),wn.push(nn,Un),pe.setBuffer(r._roots[e]);const a=eo(0,r.geometry,t,n,i,s);pe.clearBuffer(),lr.releasePrimitive(nn),lr.releasePrimitive(Un),wn.pop(),wn.pop();const o=wn.length;return o>0&&(Un=wn[o-1],nn=wn[o-2]),a}function eo(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=pe;let u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);return Se(r,o,nn),n(p,m,!1,a,s+r/Pe,nn)}else{let R=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Ie(O),J=O*2;return We(O,F)},N=function(O){const{uint16Array:U,uint32Array:F}=pe;let J=O*2;for(;!Ee(J,U);)O=Be(O,F),J=O*2;return We(O,F)+tt(J,U)};const p=Ie(r),m=Be(r,l);let x=p,T=m,g,v,_,b;if(i&&(_=nn,b=Un,Se(x,o,_),Se(T,o,b),g=i(_),v=i(b),v<g)){x=m,T=p;const O=g;g=v,v=O,_=b}_||(_=nn,Se(x,o,_));const M=Ee(x*2,c),C=t(_,M,g,a+1,s+x/Pe);let P;if(C===Ys){const O=R(x),F=N(x)-O;P=n(O,F,!0,a+1,s+x/Pe,_)}else P=C&&eo(x,e,t,n,i,s,a+1);if(P)return!0;b=Un,Se(T,o,b);const E=Ee(T*2,c),z=t(b,E,v,a+1,s+T/Pe);let I;if(z===Ys){const O=R(T),F=N(T)-O;I=n(O,F,!0,a+1,s+T/Pe,b)}else I=z&&eo(T,e,t,n,i,s,a+1);return!!I}}const ci=new pe.constructor,Fr=new pe.constructor,en=new So(()=>new A.Box3),Pn=new A.Box3,En=new A.Box3,ks=new A.Box3,Rs=new A.Box3;let As=!1;function Kh(r,e,t,n){if(As)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");As=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new A.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){ci.setBuffer(i[u]),c=0;const p=en.getPrimitive();Se(0,ci.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Fr.setBuffer(s[m]),a=wt(0,0,t,l,n,o,c,0,0,p),Fr.clearBuffer(),c+=s[m].byteLength/$e,!a);m++);if(en.releasePrimitive(p),ci.clearBuffer(),o+=i[u].byteLength/$e,a)break}return As=!1,a}function wt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Fr,p=ci):(f=ci,p=Fr);const m=f.float32Array,x=f.uint32Array,T=f.uint16Array,g=p.float32Array,v=p.uint32Array,_=p.uint16Array,b=r*2,M=e*2,C=Ee(b,T),P=Ee(M,_);let E=!1;if(P&&C)u?E=i(We(e,v),tt(e*2,_),We(r,x),tt(r*2,T),c,a+e/Pe,o,s+r/Pe):E=i(We(r,x),tt(r*2,T),We(e,v),tt(e*2,_),o,s+r/Pe,c,a+e/Pe);else if(P){const z=en.getPrimitive();Se(e,g,z),z.applyMatrix4(t);const I=Ie(r),R=Be(r,x);Se(I,m,Pn),Se(R,m,En);const N=z.intersectsBox(Pn),O=z.intersectsBox(En);E=N&&wt(e,I,n,t,i,a,s,c,o+1,z,!u)||O&&wt(e,R,n,t,i,a,s,c,o+1,z,!u),en.releasePrimitive(z)}else{const z=Ie(e),I=Be(e,v);Se(z,g,ks),Se(I,g,Rs);const R=l.intersectsBox(ks),N=l.intersectsBox(Rs);if(R&&N)E=wt(r,z,t,n,i,s,a,o,c+1,l,u)||wt(r,I,t,n,i,s,a,o,c+1,l,u);else if(R)if(C)E=wt(r,z,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(ks).applyMatrix4(t);const U=Ie(r),F=Be(r,x);Se(U,m,Pn),Se(F,m,En);const J=O.intersectsBox(Pn),W=O.intersectsBox(En);E=J&&wt(z,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(z,F,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}else if(N)if(C)E=wt(r,I,t,n,i,s,a,o,c+1,l,u);else{const O=en.getPrimitive();O.copy(Rs).applyMatrix4(t);const U=Ie(r),F=Be(r,x);Se(U,m,Pn),Se(F,m,En);const J=O.intersectsBox(Pn),W=O.intersectsBox(En);E=J&&wt(I,U,n,t,i,a,s,c,o+1,O,!u)||W&&wt(I,F,n,t,i,a,s,c,o+1,O,!u),en.releasePrimitive(O)}}return E}const za=new A.Box3,kn=new Float32Array(6);class nl{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Qc,...e},Xh(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0;for(let f=e,p=e+t;f<p;f++){this.writePrimitiveBounds(f,kn,0);const[m,x,T,g,v,_]=kn;m<s&&(s=m),g>c&&(c=g),x<a&&(a=x),v>l&&(l=v),T<o&&(o=T),_>u&&(u=_)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,kn,0);const[o,c,l,u,f,p]=kn,m=(o+u)/2,x=(c+f)/2,T=(l+p)/2,g=(u-o)/2,v=(f-c)/2,_=(p-l)/2,b=(s-i)*6;n[b+0]=m,n[b+1]=g+(Math.abs(m)+g)*kr,n[b+2]=x,n[b+3]=v+(Math.abs(x)+v)*kr,n[b+4]=T,n[b+5]=_+(Math.abs(T)+_)*kr}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/$e;for(let l=0;l<c;l++){const u=Pe*l,f=2*u;Ee(f,o)&&(a[u+6]+=e)}}}}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=Ee(l,s);if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=Ie(o),p=Be(o,i),m=vo(o,i);e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/$e;for(let l=c-1;l>=0;l--){const u=l*Pe,f=u*2;if(Ee(f,a)){const m=We(u,s),x=tt(f,a);this.writePrimitiveRangeBounds(m,x,kn,0),o.set(kn,u)}else{const m=Ie(u),x=Be(u,s);for(let T=0;T<3;T++){const g=o[m+T],v=o[m+T+3],_=o[x+T],b=o[x+T+3];o[u+T]=g<_?g:_,o[u+T+3]=v>b?v:b}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),za),e.union(za)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const f=i;i=(p,m,x,T,g)=>f(p,m,x,T,g)?!0:o(p,m,this,s,x,T,a)}else i||(s?i=(f,p,m,x)=>o(f,p,this,s,m,x,a):i=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=Zh(this,f,n,i,t,l),c)break;l+=m.byteLength/$e}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Kh(this,e,t,i)}}function Qh(){return typeof SharedArrayBuffer<"u"}function xo(r){return r.index?r.index.count:r.attributes.position.count}function Wr(r){return xo(r)/3}function ef(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function tf(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=ef(t,n);r.setIndex(new A.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function nf(r,e,t){const n=xo(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function rf(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function Ia(r,e,t){const n=nf(r,e,t),i=rf(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=xo(r)/t,l=[];for(const p of i){const{offset:m,count:x}=p,T=m,g=isFinite(x)?x:c-m,v=m+g;T<o&&v>a&&(l.push({pos:Math.max(a,T),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((p,m)=>p.pos!==m.pos?p.pos-m.pos:p.type==="end"?-1:1);let u=0,f=null;for(const p of l){const m=p.pos;u!==0&&m!==f&&s.push({offset:f,count:m-f}),u+=p.isStart?1:-1,f=m}return s}function il(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:u,count:f}=r[l];for(let p=0;p<f;p++)o[c+p]=u+p;c+=f}return o}class rl extends nl{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Qh())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Qc,...t},t[$r]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=Ia(t,e.range,n),s=il(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else tf(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new A.Box3))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Ia(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class qt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const c=e[s][t];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}qt.prototype.setFromBox=(function(){const r=new A.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const sf=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,_;g!==0?v=(f*p-x*m)/g:v=0,_=(f+v*p)/m,a.x=v,a.y=_}})(),_o=(function(){const r=new A.Vector2,e=new A.Vector3,t=new A.Vector3;return function(i,s,a,o){sf(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),of=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Plane,n=new A.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),af=["x","y","z"],Gt=1e-15,Ba=Gt*Gt;function pt(r){return Math.abs(r)<Gt}class gt extends A.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A.Vector3),this.satBounds=new Array(4).fill().map(()=>new qt),this.points=[this.a,this.b,this.c],this.plane=new A.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new A.Line3,this.needsUpdate=!0}intersectsSphere(e){return of(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const T=l.length(),g=f.length(),v=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,T<Gt?g<Gt||v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<Gt?v<Gt?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<Gt&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}gt.prototype.closestPointToSegment=(function(){const r=new A.Vector3,e=new A.Vector3,t=new A.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),_o(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();gt.prototype.intersectsTriangle=(function(){const r=new gt,e=new qt,t=new qt,n=new A.Vector3,i=new A.Vector3,s=new A.Vector3,a=new A.Vector3,o=new A.Line3,c=new A.Line3,l=new A.Vector3,u=new A.Vector2,f=new A.Vector2;function p(b,M,C,P){const E=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?E.copy(b.plane.normal):E.copy(M.plane.normal);const z=b.satBounds,I=b.satAxes;for(let O=1;O<4;O++){const U=z[O],F=I[O];if(e.setFromPoints(F,M.points),U.isSeparated(e)||(a.copy(E).cross(F),e.setFromPoints(a,b.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}const R=M.satBounds,N=M.satAxes;for(let O=1;O<4;O++){const U=R[O],F=N[O];if(e.setFromPoints(F,b.points),U.isSeparated(e)||(a.crossVectors(E,F),e.setFromPoints(a,b.points),t.setFromPoints(a,M.points),e.isSeparated(t)))return!1}return C&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),C.start.set(0,0,0),C.end.set(0,0,0)),!0}function m(b,M,C,P,E,z,I,R,N,O,U){let F=I/(I-R);O.x=P+(E-P)*F,U.start.subVectors(M,b).multiplyScalar(F).add(b),F=I/(I-N),O.y=P+(z-P)*F,U.end.subVectors(C,b).multiplyScalar(F).add(b)}function x(b,M,C,P,E,z,I,R,N,O,U){if(E>0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else if(z>0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(R*N>0||I!=0)m(b.a,b.b,b.c,M,C,P,I,R,N,O,U);else if(R!=0)m(b.b,b.a,b.c,C,M,P,R,I,N,O,U);else if(N!=0)m(b.c,b.a,b.b,P,M,C,N,I,R,O,U);else return!0;return!1}function T(b,M,C,P){const E=M.degenerateSegment,z=b.plane.distanceToPoint(E.start),I=b.plane.distanceToPoint(E.end);return pt(z)?pt(I)?p(b,M,C,P):(C&&(C.start.copy(E.start),C.end.copy(E.start)),b.containsPoint(E.start)):pt(I)?(C&&(C.start.copy(E.end),C.end.copy(E.end)),b.containsPoint(E.end)):b.plane.intersectLine(E,n)!=null?(C&&(C.start.copy(n),C.end.copy(n)),b.containsPoint(n)):!1}function g(b,M,C){const P=M.a;return pt(b.plane.distanceToPoint(P))&&b.containsPoint(P)?(C&&(C.start.copy(P),C.end.copy(P)),!0):!1}function v(b,M,C){const P=b.degenerateSegment,E=M.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<Ba?(C&&(C.start.copy(E),C.end.copy(E)),!0):!1}function _(b,M,C,P){if(b.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const E=b.degenerateSegment,z=M.degenerateSegment,I=i,R=s;E.delta(I),z.delta(R);const N=n.subVectors(z.start,E.start),O=I.x*R.y-I.y*R.x;if(pt(O))return!1;const U=(N.x*R.y-N.y*R.x)/O,F=-(I.x*N.y-I.y*N.x)/O;if(U<0||U>1||F<0||F>1)return!1;const J=E.start.z+I.z*U,W=z.start.z+R.z*F;return pt(J-W)?(C&&(C.start.copy(E.start).addScaledVector(I,U),C.end.copy(E.start).addScaledVector(I,U)),!0):!1}else return M.isDegenerateIntoPoint?v(b,M,C):T(M,b,C,P);else{if(b.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(b.a)<Ba?(C&&(C.start.copy(b.a),C.end.copy(b.a)),!0):!1:M.isDegenerateIntoSegment?v(M,b,C):g(M,b,C);if(M.isDegenerateIntoPoint)return g(b,M,C);if(M.isDegenerateIntoSegment)return T(b,M,C,P)}}return function(M,C=null,P=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(r.copy(M),r.update(),M=r);const E=_(this,M,C,P);if(E!==void 0)return E;const z=this.plane,I=M.plane;let R=I.distanceToPoint(this.a),N=I.distanceToPoint(this.b),O=I.distanceToPoint(this.c);pt(R)&&(R=0),pt(N)&&(N=0),pt(O)&&(O=0);const U=R*N,F=R*O;if(U>0&&F>0)return!1;let J=z.distanceToPoint(M.a),W=z.distanceToPoint(M.b),K=z.distanceToPoint(M.c);pt(J)&&(J=0),pt(W)&&(W=0),pt(K)&&(K=0);const $=J*W,me=J*K;if($>0&&me>0)return!1;i.copy(z.normal),s.copy(I.normal);const ne=i.cross(s);let ue=0,re=Math.abs(ne.x);const ge=Math.abs(ne.y);ge>re&&(re=ge,ue=1),Math.abs(ne.z)>re&&(ue=2);const se=af[ue],he=this.a[se],oe=this.b[se],Xe=this.c[se],Ve=M.a[se],Je=M.b[se],Ye=M.c[se];if(x(this,he,oe,Xe,U,F,R,N,O,u,o))return p(this,M,C,P);if(x(M,Ve,Je,Ye,$,me,J,W,K,f,c))return p(this,M,C,P);if(u.y<u.x){const xe=u.y;u.y=u.x,u.x=xe,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(f.y<f.x){const xe=f.y;f.y=f.x,f.x=xe,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<f.x||f.y<u.x?!1:(C&&(f.x>u.x?C.start.copy(c.start):C.start.copy(o.start),f.y<u.y?C.end.copy(c.end):C.end.copy(o.end)),!0)}})();gt.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();gt.prototype.distanceToTriangle=(function(){const r=new A.Vector3,e=new A.Vector3,t=["a","b","c"],n=new A.Line3,i=new A.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const T=this[m];a.closestPointToPoint(T,r),p=T.distanceToSquared(r),p<u&&(u=p,o&&o.copy(T),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const T=t[x],g=t[(x+1)%3];i.set(a[T],a[g]),_o(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();class qe{constructor(e,t,n){this.isOrientedBox=!0,this.min=new A.Vector3,this.max=new A.Vector3,this.matrix=new A.Matrix4,this.invMatrix=new A.Matrix4,this.points=new Array(8).fill().map(()=>new A.Vector3),this.satAxes=new Array(3).fill().map(()=>new A.Vector3),this.satBounds=new Array(3).fill().map(()=>new qt),this.alignedSatBounds=new Array(3).fill().map(()=>new qt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}qe.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();qe.prototype.intersectsBox=(function(){const r=new qt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(r.setFromBox(l,t),u.isSeparated(r))return!1}return!0}})();qe.prototype.intersectsTriangle=(function(){const r=new gt,e=new Array(3),t=new qt,n=new qt,i=new A.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const T=u[x];if(i.crossVectors(m,T),t.setFromPoints(i,e),n.setFromPoints(i,f),t.isSeparated(n))return!1}}return!0}})();qe.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();qe.prototype.distanceToPoint=(function(){const r=new A.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();qe.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new A.Line3),t=new Array(12).fill().map(()=>new A.Line3),n=new A.Vector3,i=new A.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const _=v.distanceToSquared(i);if(_<x&&(x=_,c&&c.copy(v),l&&l.copy(i),_<u))return Math.sqrt(_)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){const b=(g+1)%3,M=(g+2)%3,C=v<<b|_<<M,P=1<<g|v<<b|_<<M,E=m[C],z=m[P];e[T].set(E,z);const R=r[g],N=r[b],O=r[M],U=t[T],F=U.start,J=U.end;F[R]=f[R],F[N]=v?f[N]:p[N],F[O]=_?f[O]:p[N],J[R]=p[R],J[N]=v?f[N]:p[N],J[O]=_?f[O]:p[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=_?p.z:f.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<x&&(x=b,c&&c.copy(n),l&&l.copy(i),b<u))return Math.sqrt(b)}for(let g=0;g<12;g++){const v=e[g];for(let _=0;_<12;_++){const b=t[_];_o(v,b,n,i);const M=n.distanceToSquared(i);if(M<x&&(x=M,c&&c.copy(n),l&&l.copy(i),M<u))return Math.sqrt(M)}}return Math.sqrt(x)}})();class cf extends So{constructor(){super(()=>new gt)}}const yt=new cf,Yn=new A.Vector3,Os=new A.Vector3;function lf(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(Yn.copy(e).clamp(u.min,u.max),Yn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Yn);const p=e.distanceToSquared(Yn);return p<o&&(Os.copy(Yn),o=p,c=f),p<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Os):t.point=Os.clone(),t.distance=l,t.faceIndex=c,t}const ur=parseInt(A.REVISION)>=169,uf=parseInt(A.REVISION)<=161,ln=new A.Vector3,un=new A.Vector3,hn=new A.Vector3,hr=new A.Vector2,fr=new A.Vector2,dr=new A.Vector2,Na=new A.Vector3,Ua=new A.Vector3,Da=new A.Vector3,Zn=new A.Vector3;function hf(r,e,t,n,i,s,a,o){let c;if(s===A.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==A.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function La(r,e,t,n,i,s,a,o,c,l,u){ln.fromBufferAttribute(e,s),un.fromBufferAttribute(e,a),hn.fromBufferAttribute(e,o);const f=hf(r,ln,un,hn,Zn,c,l,u);if(f){if(n){hr.fromBufferAttribute(n,s),fr.fromBufferAttribute(n,a),dr.fromBufferAttribute(n,o),f.uv=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv);ur||(f.uv=m)}if(i){hr.fromBufferAttribute(i,s),fr.fromBufferAttribute(i,a),dr.fromBufferAttribute(i,o),f.uv1=new A.Vector2;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,hr,fr,dr,f.uv1);ur||(f.uv1=m),uf&&(f.uv2=f.uv1)}if(t){Na.fromBufferAttribute(t,s),Ua.fromBufferAttribute(t,a),Da.fromBufferAttribute(t,o),f.normal=new A.Vector3;const m=A.Triangle.getInterpolation(Zn,ln,un,hn,Na,Ua,Da,f.normal);f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1),ur||(f.normal=m)}const p={a:s,b:a,c:o,normal:new A.Vector3,materialIndex:0};if(A.Triangle.getNormal(ln,un,hn,p.normal),f.face=p,f.faceIndex=s,ur){const m=new A.Vector3;A.Triangle.getBarycoord(Zn,ln,un,hn,m),f.barycoord=m}}return f}function Fa(r){return r&&r.isMaterial?r.side:r}function Hr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:f,groups:p}=r;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:m,normal:x,uv:T,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let _=0,b=p.length;_<b;_++){const{start:M,count:C,materialIndex:P}=p[_];if(v>=M&&v<M+C){const E=Fa(e[P]),z=La(t,m,x,T,g,c,l,u,E,s,a);if(z)if(z.faceIndex=n,z.face.materialIndex=P,i)i.push(z);else return z}}}else{const v=Fa(e),_=La(t,m,x,T,g,c,l,u,v,s,a);if(_)if(_.faceIndex=n,_.face.materialIndex=0,i)i.push(_);else return _}return null}function we(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function ff(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Hr(c,e,t,u,s,a,o)}function df(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function pf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function mf(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=3*g,I=3*(g+v);z<I;z++){let R=n[z];const N=i.getX(R),O=i.getY(R),U=i.getZ(R);N<_&&(_=N),N>C&&(C=N),O<b&&(b=O),O>P&&(P=O),U<M&&(M=U),U>E&&(E=U)}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=F>W?F:W}return I}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],b=e[r+1],M=e[r+3+1],C=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(_-x)*f):(s=(_-x)*f,a=(v-x)*f),p>=0?(o=(b-T)*p,c=(M-T)*p):(o=(M-T)*p,c=(b-T)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(C-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(C-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function yf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Hr(c,e,t,p,s,a,o)}}function gf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Hr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function vf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),we(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function Sf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),to(0,r,t,n,i,s,a),pe.clearBuffer()}function to(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);ff(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&to(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&to(m,e,t,n,i,s,a)}}const xf=["x","y","z"];function _f(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=no(0,r,t,n,i,s);return pe.clearBuffer(),a}function no(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return df(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=xf[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?no(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?no(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const pr=new A.Box3,Rn=new gt,An=new gt,Kn=new A.Matrix4,Va=new qe,mr=new qe;function bf(r,e,t,n){pe.setBuffer(r._roots[e]);const i=io(0,r,t,n);return pe.clearBuffer(),i}function io(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Va.set(t.boundingBox.min,t.boundingBox.max,n),i=Va),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(r,o),g=tt(c,a);if(Kn.copy(n).invert(),t.boundsTree)return Se(r,s,mr),mr.matrix.copy(Kn),mr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>mr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T*3,M=(g+T)*3;b<M;b+=3)if(we(An,b,f,p),An.needsUpdate=!0,_.intersectsTriangle(An))return!0;return!1}});{const v=Wr(t);for(let _=T*3,b=(g+T)*3;_<b;_+=3){we(Rn,_,f,p),Rn.a.applyMatrix4(Kn),Rn.b.applyMatrix4(Kn),Rn.c.applyMatrix4(Kn),Rn.needsUpdate=!0;for(let M=0,C=v*3;M<C;M+=3)if(we(An,M,m,x),An.needsUpdate=!0,Rn.intersectsTriangle(An))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,pr),!!(i.intersectsBox(pr)&&io(u,e,t,n,i)||(Se(f,s,pr),i.intersectsBox(pr)&&io(f,e,t,n,i)))}}const yr=new A.Matrix4,zs=new qe,Qn=new qe,Tf=new A.Vector3,Mf=new A.Vector3,Cf=new A.Vector3,wf=new A.Vector3;function Pf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),zs.set(e.boundingBox.min,e.boundingBox.max,t),zs.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=Tf,T=Mf,g=null,v=null;i&&(g=Cf,v=wf);let _=1/0,b=null,M=null;return yr.copy(t).invert(),Qn.matrix.copy(yr),r.shapecast({boundsTraverseOrder:C=>zs.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&E<a?(P&&(Qn.min.copy(C.min),Qn.max.copy(C.max),Qn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>Qn.distanceToBox(z),intersectsBounds:(z,I,R)=>R<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){we(m,3*R,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let O=C,U=C+P;O<U;O++){we(p,3*O,l,c),p.needsUpdate=!0;const F=p.distanceToTriangle(m,x,g);if(F<_&&(T.copy(x),v&&v.copy(g),_=F,b=O,M=R),F<s)return!0}}}});{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){we(p,3*R,l,c),p.needsUpdate=!0;const O=p.distanceToTriangle(m,x,g);if(O<_&&(T.copy(x),v&&v.copy(g),_=O,b=R,M=z),O<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(yr),T.applyMatrix4(yr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function Ef(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(Ee(T,o)){const g=We(p,a),v=tt(T,o);let _=1/0,b=1/0,M=1/0,C=-1/0,P=-1/0,E=-1/0;for(let z=g,I=g+v;z<I;z++){const R=3*r.resolveTriangleIndex(z);for(let N=0;N<3;N++){let O=R+N;O=n?n[O]:O;const U=i.getX(O),F=i.getY(O),J=i.getZ(O);U<_&&(_=U),U>C&&(C=U),F<b&&(b=F),F>P&&(P=F),J<M&&(M=J),J>E&&(E=J)}}return c[p+0]!==_||c[p+1]!==b||c[p+2]!==M||c[p+3]!==C||c[p+4]!==P||c[p+5]!==E?(c[p+0]=_,c[p+1]=b,c[p+2]=M,c[p+3]=C,c[p+4]=P,c[p+5]=E,!0):!1}else{const g=Ie(p),v=Be(p,a);let _=x,b=!1,M=!1;if(e){if(!_){const R=g/Pe+m/$e,N=v/Pe+m/$e;b=e.has(R),M=e.has(N),_=!b&&!M}}else b=!0,M=!0;const C=_||b,P=_||M;let E=!1;C&&(E=f(g,m,_));let z=!1;P&&(z=f(v,m,_));const I=E||z;if(I)for(let R=0;R<3;R++){const N=g+R,O=v+R,U=c[N],F=c[N+3],J=c[O],W=c[O+3];c[p+R]=U<J?U:J,c[p+R+3]=F>W?F:W}return I}}}function kf(r,e,t,n,i,s,a){pe.setBuffer(r._roots[e]),ro(0,r,t,n,i,s,a),pe.clearBuffer()}function ro(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=pe,u=r*2;if(Ee(u,c)){const p=We(r,l),m=tt(u,c);yf(e,t,n,p,m,i,s,a)}else{const p=Ie(r);rn(p,o,n,s,a)&&ro(p,e,t,n,i,s,a);const m=Be(r,l);rn(m,o,n,s,a)&&ro(m,e,t,n,i,s,a)}}const Rf=["x","y","z"];function Af(r,e,t,n,i,s){pe.setBuffer(r._roots[e]);const a=so(0,r,t,n,i,s);return pe.clearBuffer(),a}function so(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=pe;let l=r*2;if(Ee(l,o)){const f=We(r,c),p=tt(l,o);return gf(e,t,n,f,p,i,s)}else{const f=vo(r,c),p=Rf[f],x=n.direction[p]>=0;let T,g;x?(T=Ie(r),g=Be(r,c)):(T=Be(r,c),g=Ie(r));const _=rn(T,a,n,i,s)?so(T,e,t,n,i,s):null;if(_){const C=_.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return _}const M=rn(g,a,n,i,s)?so(g,e,t,n,i,s):null;return _&&M?_.distance<=M.distance?_:M:_||M||null}}const gr=new A.Box3,On=new gt,zn=new gt,ei=new A.Matrix4,Ja=new qe,vr=new qe;function Of(r,e,t,n){pe.setBuffer(r._roots[e]);const i=oo(0,r,t,n);return pe.clearBuffer(),i}function oo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=pe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ja.set(t.boundingBox.min,t.boundingBox.max,n),i=Ja),Ee(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=We(r,o),g=tt(c,a);if(ei.copy(n).invert(),t.boundsTree)return Se(r,s,vr),vr.matrix.copy(ei),vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>vr.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(n),_.b.applyMatrix4(n),_.c.applyMatrix4(n),_.needsUpdate=!0;for(let b=T,M=g+T;b<M;b++)if(we(zn,3*e.resolveTriangleIndex(b),f,p),zn.needsUpdate=!0,_.intersectsTriangle(zn))return!0;return!1}});{const v=Wr(t);for(let _=T,b=g+T;_<b;_++){const M=e.resolveTriangleIndex(_);we(On,3*M,f,p),On.a.applyMatrix4(ei),On.b.applyMatrix4(ei),On.c.applyMatrix4(ei),On.needsUpdate=!0;for(let C=0,P=v*3;C<P;C+=3)if(we(zn,C,m,x),zn.needsUpdate=!0,On.intersectsTriangle(zn))return!0}}}else{const u=Ie(r),f=Be(r,o);return Se(u,s,gr),!!(i.intersectsBox(gr)&&oo(u,e,t,n,i)||(Se(f,s,gr),i.intersectsBox(gr)&&oo(f,e,t,n,i)))}}const Sr=new A.Matrix4,Is=new qe,ti=new qe,zf=new A.Vector3,If=new A.Vector3,Bf=new A.Vector3,Nf=new A.Vector3;function Uf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Is.set(e.boundingBox.min,e.boundingBox.max,t),Is.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=yt.getPrimitive(),m=yt.getPrimitive();let x=zf,T=If,g=null,v=null;i&&(g=Bf,v=Nf);let _=1/0,b=null,M=null;return Sr.copy(t).invert(),ti.matrix.copy(Sr),r.shapecast({boundsTraverseOrder:C=>Is.distanceToBox(C),intersectsBounds:(C,P,E)=>E<_&&E<a?(P&&(ti.min.copy(C.min),ti.max.copy(C.max),ti.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:z=>ti.distanceToBox(z),intersectsBounds:(z,I,R)=>R<_&&R<a,intersectsRange:(z,I)=>{for(let R=z,N=z+I;R<N;R++){const O=E.resolveTriangleIndex(R);we(m,3*O,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=C,F=C+P;U<F;U++){const J=r.resolveTriangleIndex(U);we(p,3*J,l,c),p.needsUpdate=!0;const W=p.distanceToTriangle(m,x,g);if(W<_&&(T.copy(x),v&&v.copy(g),_=W,b=U,M=R),W<s)return!0}}}})}else{const E=Wr(e);for(let z=0,I=E;z<I;z++){we(m,3*z,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=C,N=C+P;R<N;R++){const O=r.resolveTriangleIndex(R);we(p,3*O,l,c),p.needsUpdate=!0;const U=p.distanceToTriangle(m,x,g);if(U<_&&(T.copy(x),v&&v.copy(g),_=U,b=R,M=z),U<s)return!0}}}}}),yt.releasePrimitive(p),yt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=_,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Sr),T.applyMatrix4(Sr),i.distance=T.sub(i.point).length(),i.faceIndex=M),n)}function ja(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const xr=new qe,_r=new A.Ray,Ga=new A.Vector3,$a=new A.Matrix4,Wa=new A.Vector3,Bs=["getX","getY","getZ"];class Vn extends rl{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Vn(t,{...n,[$r]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new A.BufferAttribute(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const f=l[u],p=new Uint32Array(f),m=new Uint16Array(f);for(let x=0,T=f.byteLength/$e;x<T;x++){const g=Pe*x,v=2*g;Ee(v,m)||(p[g+6]=p[g+6]/Pe-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,l=(s?s[e]:e)*3;let u=l+0,f=l+1,p=l+2;o&&(u=o[u],f=o[f],p=o[p]);for(let m=0;m<3;m++){const x=a[Bs[m]](u),T=a[Bs[m]](f),g=a[Bs[m]](p);let v=x;T<v&&(v=T),g<v&&(v=g);let _=x;T>_&&(_=T),g>_&&(_=g),t[n+m]=v,t[n+m+3]=_}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,u=a.offset||0;let f=3;a.isInterleavedBufferAttribute&&(f=a.data.stride);const p=["getX","getY","getZ"],m=n.offset;for(let x=e,T=e+t;x<T;x++){const v=(s?s[x]:x)*3,_=(x-m)*6;let b=v+0,M=v+1,C=v+2;o&&(b=o[b],M=o[M],C=o[C]),c||(b=b*f+u,M=M*f+u,C=C*f+u);for(let P=0;P<3;P++){let E,z,I;c?(E=a[p[P]](b),z=a[p[P]](M),I=a[p[P]](C)):(E=l[b+P],z=l[M+P],I=l[C+P]);let R=E;z<R&&(R=z),I<R&&(R=I);let N=E;z>N&&(N=z),I>N&&(N=I);const O=(N-R)/2,U=P*2;n[_+U+0]=R+O,n[_+U+1]=O+(Math.abs(R)+O)*kr}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;$a.copy(e.matrixWorld).invert(),_r.copy(t.ray).applyMatrix4($a),Wa.setFromMatrixScale(e.matrixWorld),Ga.copy(_r.direction).multiply(Wa);const s=Ga.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(_r,i,a,o);c=ja(c,e,t),c&&n.push(c)}else{const c=this.raycast(_r,i,a,o);for(let l=0,u=c.length;l<u;l++){const f=ja(c[l],e,t);f&&n.push(f)}}return n}refit(e=null){return(this.indirect?Ef:mf)(this,e)}raycast(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?kf:Sf;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=A.FrontSide,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?Af:_f;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?Of:bf;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=yt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?vf:pf});return yt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=yt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const T=this.resolveTriangleIndex(x);we(a,T*3,o,c)}:x=>{we(a,x*3,o,c)},u=yt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const T=e.resolveTriangleIndex(x);we(u,T*3,f,p)}:x=>{we(u,x*3,f,p)};if(s){if(!(e instanceof Vn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const x=(T,g,v,_,b,M,C,P)=>{for(let E=v,z=v+_;E<z;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let I=T,R=T+g;I<R;I++)if(l(I),a.needsUpdate=!0,s(a,u,I,E,b,M,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,_,b,M,C,P,E){return T(g,v,_,b,M,C,P,E)?!0:x(g,v,_,b,M,C,P,E)}}else i=x}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return xr.set(e.min,e.max,t),xr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>xr.intersectsBox(n),intersectsTriangle:n=>xr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?Uf:Pf)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return lf(this,e,t,n,i)}}const Bn={Mesh:A.Mesh.prototype.raycast,Line:A.Line.prototype.raycast,LineSegments:A.LineSegments.prototype.raycast,LineLoop:A.LineLoop.prototype.raycast,Points:A.Points.prototype.raycast,BatchedMesh:A.BatchedMesh.prototype.raycast},De=new A.Mesh,br=[];function Df(r,e){if(this.isBatchedMesh)Lf.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof A.Mesh)n=Bn.Mesh;else if(this instanceof A.LineSegments)n=Bn.LineSegments;else if(this instanceof A.LineLoop)n=Bn.LineLoop;else if(this instanceof A.Line)n=Bn.Line;else if(this instanceof A.Points)n=Bn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function Lf(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;De.material=this.material,De.geometry=this.geometry;const a=De.geometry.boundsTree,o=De.geometry.drawRange;De.geometry.boundingSphere===null&&(De.geometry.boundingSphere=new A.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(De.geometry.boundsTree=t[u],this.getMatrixAt(c,De.matrixWorld).premultiply(s),!De.geometry.boundsTree){this.getBoundingBoxAt(u,De.geometry.boundingBox),this.getBoundingSphereAt(u,De.geometry.boundingSphere);const f=i[u];De.geometry.setDrawRange(f.start,f.count)}De.raycast(r,br);for(let f=0,p=br.length;f<p;f++){const m=br[f];m.object=this,m.batchId=c,e.push(m)}br.length=0}De.geometry.boundsTree=a,De.geometry.drawRange=o,De.material=null,De.geometry=null}else Bn.BatchedMesh.call(this,r,e)}function Ff(r={}){const{type:e=Vn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const fn=new A.Vector3,dn=new A.Vector3,pn=new A.Vector3,Ha=new A.Vector4,Tr=new A.Vector3,Ns=new A.Vector3,qa=new A.Vector4,Xa=new A.Vector4,Mr=new A.Matrix4,Ya=new A.Matrix4;function ni(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function oi(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new A.BufferAttribute(new t(i*s),i,n)}function sl(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Vf(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function Za(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;qa.fromBufferAttribute(i.attributes.skinIndex,e),Xa.fromBufferAttribute(i.attributes.skinWeight,e),Mr.elements.fill(0);for(let o=0;o<4;o++){const c=Xa.getComponent(o);if(c!==0){const l=qa.getComponent(o);Ya.multiplyMatrices(s[l].matrixWorld,a[l]),Vf(Mr,Ya,c)}}return Mr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Mr),t}function Us(r,e,t,n,i){Tr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(Ns.fromBufferAttribute(c,n),t?Tr.addScaledVector(Ns,o):Tr.addScaledVector(Ns.sub(i),o))}i.add(Tr)}function Jf(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new A.BufferGeometry){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const f=r[u];let p=0;if(n!==(f.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in f.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new A.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const T=r[x],g=T.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=T.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const T in f)x+=f[T].count;t.setAttribute(u,oi(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,T=f.length;x<T;x++){const g=f[x];a[x]!==!0&&sl(g,p,m),m+=g.count}}return t}function jf(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Gf(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class $f{constructor(e){this.matrixWorld=new A.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&jf(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Wf{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new A.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new A.BufferGeometry){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new $f(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new A.BufferAttribute(new Float32Array(0),4,!1))}else Jf(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new A.BufferGeometry){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",oi(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",oi(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",oi(o.tangent)),ni(n.index,t.index),ni(o.position,c.position),s&&ni(o.normal,c.normal),a&&ni(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new A.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,b=o.position.count;_<b;_++)fn.fromBufferAttribute(l,_),u&&dn.fromBufferAttribute(u,_),f&&(Ha.fromBufferAttribute(f,_),pn.fromBufferAttribute(f,_)),g&&(p&&Us(p,g,T,_,fn),m&&Us(m,g,T,_,dn),x&&Us(x,g,T,_,pn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,fn),u&&Za(e,_,dn),f&&Za(e,_,pn)),i&&fn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,fn.x,fn.y,fn.z),u&&(i&&dn.applyNormalMatrix(v),c.normal.setXYZ(_,dn.x,dn.y,dn.z)),f&&(i&&pn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,pn.x,pn.y,pn.z,Ha.w));for(const _ in this.attributes){const b=this.attributes[_];b==="position"||b==="tangent"||b==="normal"||!(b in o)||(c[b]||t.setAttribute(b,oi(o[b])),ni(o[b],c[b]),sl(o[b],c[b]))}return e.matrixWorld.determinant()<0&&Gf(t),t}}const Hf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Yc,BVH:nl,CENTER:go,CONTAINED:Ys,ExtendedTriangle:gt,GeometryBVH:rl,MeshBVH:Vn,OrientedBox:qe,SAH:Zc,SKIP_GENERATION:$r,StaticGeometryGenerator:Wf,acceleratedRaycast:Df,computeBoundsTree:Ff,generateIndirectBuffer:il},Symbol.toStringTag,{value:"Module"}));class qf{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}function Xf(r){return new Worker("/generateMeshBVH.worker-DiCnZlf3.js",{name:r?.name})}const mt={node:"node",material:"material",camera:"camera",light:"light"},In="KHR_animation_pointer",Yf={CUBICSPLINE:void 0,LINEAR:A.InterpolateLinear$1,STEP:A.InterpolateDiscrete$1};class Zf{constructor(e){this.name=In,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){const t=e.target,n=t.extensions&&t.extensions[In]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=mt.node,a;if(n){const c=t.extensions[In];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=mt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=mt.light:l.startsWith("/cameras/")&&(s=mt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case mt.material:const u=("/materials/"+a.toString()+"/").length,f=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=f+i;break;case mt.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":i="visible";break}l=m+i;break;case mt.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case mt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[In].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===mt.node?o=this.parser.getDependency("node",a):s===mt.material?o=this.parser.getDependency("material",a):s===mt.light?o=this.parser.getDependency("light",a):s===mt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[In]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[In].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof A.SkinnedMesh$1&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,T){try{const g=T.split(".").filter(Boolean),_=g[g.length-1].replace(/\[.*\]$/,"");return _ in x?typeof x[_]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(e,o)?(T=A.BooleanKeyframeTrack,g=!0):T=A.NumberKeyframeTrack$1;break;case 2:case 3:T=A.VectorKeyframeTrack$1;break;case 4:o.endsWith(".quaternion")?T=A.QuaternionKeyframeTrack$1:T=A.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?Yf[i.interpolation]:A.InterpolateLinear$1;let _=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(_=_.map(M=>M/Math.PI*180)),g&&(_=_.map(M=>M>0));const b=new T(o,t.array,_,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),c.push(b),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const M=new Float32Array(_.length/4);for(let P=0,E=_.length/4;P<E;P+=1)M[P]=_[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,M,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(b),c.push(C)}}return c}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],T=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,_=s.parameters!==void 0?s.parameters[T.output]:T.output;let b=t.loadAnimationTargetFromChannelWithAnimationPointer(x);b||(b=t.loadAnimationTargetFromChannel(x)),o.push(b),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(T),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],T=p[2],g=p[3],v=p[4],_=[];for(let b=0,M=m.length;b<M;b++){const C=m[b],P=x[b],E=T[b],z=g[b],I=v[b];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(C,P,E,z,I);if(R||(R=i._createAnimationTracks(C,P,E,z,I)),R)for(let N=0;N<R.length;N++)_.push(R[N])}return new A.AnimationClip$1(a,void 0,_)})}}const Kf=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Zf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=Fc;exports.BatchedParticleRenderer=zh;exports.Builder=ao;exports.ByteBuffer=li;exports.ConstantColor=gn;exports.ConstantValue=ee;exports.Matrix4=Et;exports.MeshBVH=Vn;exports.MotionController=Rl;exports.ParticleSystem=Lr;exports.SIZE_PREFIX_LENGTH=Qa;exports.TrailParticle=Ur;exports.Vector4=at;exports.WorkerBase=qf;exports.WorkerWrapper=Xf;exports.bundler=cu;exports.createNoise4D=Bh;exports.fetchProfile=Cl;exports.index=Vh;exports.index$1=Hf;exports.index$2=Kf;exports.md5=Mu;exports.v5=Su;