@needle-tools/engine 6.0.0-alpha.5 → 6.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/{materialx-B3qY8vPU.js → materialx-Bd9BE6LR.js} +1 -1
- package/dist/{materialx-BwYvA-4x.umd.cjs → materialx-CzRx9AGf.umd.cjs} +2 -2
- package/dist/{materialx-CTPhpPxI.min.js → materialx-x1m4IJd1.min.js} +1 -1
- package/dist/{needle-engine.bundle-_kAszB-k.min.js → needle-engine.bundle-D6mZl1dR.min.js} +9 -9
- package/dist/{needle-engine.bundle-D3nBMgfk.umd.cjs → needle-engine.bundle-DOHf03pR.umd.cjs} +9 -9
- package/dist/{needle-engine.bundle-4xlWxOTF.js → needle-engine.bundle-Hu7ZAxEI.js} +550 -555
- package/dist/needle-engine.d.ts +14 -14
- package/dist/needle-engine.js +562 -562
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{vendor-BQUQwut5.js → vendor-BatPc34p.js} +50 -41
- package/dist/{vendor-BJviq-Oq.umd.cjs → vendor-CDN1hirK.umd.cjs} +1 -1
- package/dist/{vendor-CdNldo8c.min.js → vendor-T07c_9f_.min.js} +1 -1
- package/lib/engine/api.d.ts +1 -1
- package/lib/engine/api.js +1 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_init.js +2 -2
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +73 -73
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_networking_blob.js +3 -3
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +2 -2
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +1 -1
- package/lib/engine-components/Renderer.js +2 -11
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/license.js +4 -4
- package/plugins/license/cli.js +7 -4
- package/plugins/vite/license.js +4 -4
- package/src/engine/api.ts +1 -1
- package/src/engine/engine_init.ts +2 -2
- package/src/engine/engine_license.ts +70 -70
- package/src/engine/engine_networking_blob.ts +3 -3
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
- package/src/engine/webcomponents/needle-engine.loading.ts +2 -2
- package/src/engine/webcomponents/needle-engine.ts +2 -2
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine-components/Renderer.ts +4 -13
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
|
@@ -13101,4 +13101,4 @@ void main() {\r
|
|
|
13101
13101
|
xxyyzz = vec3(cov[0][0], cov[1][1], cov[2][2]);
|
|
13102
13102
|
xyxzyz = vec3(cov[0][1], cov[0][2], cov[1][2]);
|
|
13103
13103
|
}
|
|
13104
|
-
`);new F.Vector3(-1,-3,1).normalize(),new F.Color(1,1,1),new F.Color(.5,.5,1);new F.Color(1,1,1),new F.Color(.25,.25,.5);var sa=(B=>(B.w="wrist",B.t0="thumb-metacarpal",B.t1="thumb-phalanx-proximal",B.t2="thumb-phalanx-distal",B.t3="thumb-tip",B.i0="index-finger-metacarpal",B.i1="index-finger-phalanx-proximal",B.i2="index-finger-phalanx-intermediate",B.i3="index-finger-phalanx-distal",B.i4="index-finger-tip",B.m0="middle-finger-metacarpal",B.m1="middle-finger-phalanx-proximal",B.m2="middle-finger-phalanx-intermediate",B.m3="middle-finger-phalanx-distal",B.m4="middle-finger-tip",B.r0="ring-finger-metacarpal",B.r1="ring-finger-phalanx-proximal",B.r2="ring-finger-phalanx-intermediate",B.r3="ring-finger-phalanx-distal",B.r4="ring-finger-tip",B.p0="pinky-finger-metacarpal",B.p1="pinky-finger-phalanx-proximal",B.p2="pinky-finger-phalanx-intermediate",B.p3="pinky-finger-phalanx-distal",B.p4="pinky-finger-tip",B))(sa||{});const Yy=Object.keys(sa);Yy.length;new F.Euler(0,0,0,"YXZ");var to=(B=>(B.w="wrist",B.t0="thumb-metacarpal",B.t1="thumb-phalanx-proximal",B.t2="thumb-phalanx-distal",B.t3="thumb-tip",B.i0="index-finger-metacarpal",B.i1="index-finger-phalanx-proximal",B.i2="index-finger-phalanx-intermediate",B.i3="index-finger-phalanx-distal",B.i4="index-finger-tip",B.m0="middle-finger-metacarpal",B.m1="middle-finger-phalanx-proximal",B.m2="middle-finger-phalanx-intermediate",B.m3="middle-finger-phalanx-distal",B.m4="middle-finger-tip",B.r0="ring-finger-metacarpal",B.r1="ring-finger-phalanx-proximal",B.r2="ring-finger-phalanx-intermediate",B.r3="ring-finger-phalanx-distal",B.r4="ring-finger-tip",B.p0="pinky-finger-metacarpal",B.p1="pinky-finger-phalanx-proximal",B.p2="pinky-finger-phalanx-intermediate",B.p3="pinky-finger-phalanx-distal",B.p4="pinky-finger-tip",B))(to||{});const ta=Object.keys(to);ta.length;const Ky=Object.freeze(Object.defineProperty({__proto__:null,ExtSplats:lg,JOINT_IDS:ta,JointEnum:to,LN_SCALE_MAX:dI,LN_SCALE_MIN:KI,OldSparkViewpoint:ND,OldSplatAccumulator:rE,PackedSplats:Gg,PagedSplats:uB,Readback:UC,RgbaArray:Aa,SparkRenderer:Gy,SplatAccumulator:mQ,SplatEdit:zE,SplatEditSdf:ga,SplatEdits:Ca,SplatFileType:HI,SplatGenerator:AB,SplatLoader:io,SplatMesh:Zg,SplatModifier:Ea,SplatPager:eQ,SplatTransformer:UB,floatToUint8:kB,fromHalf:ig,getSplatFileType:Da,isAndroid:dw,isIos:fE,isMobile:lE,isOculus:lw,isVisionPro:fw,setPackedSplat:GD,toHalf:Eg,unpackSplat:dE},Symbol.toStringTag,{value:"Module"})),wo=0,wa=1,aa=2,JD=2,mi=1.25,bs=1,wI=32,vA=wI/4,ea=65535,SE=Math.pow(2,-24),$E=Symbol("SKIP_GENERATION"),ca={strategy:wo,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$E]:!1};function pA(B,A,I){return I.min.x=A[B],I.min.y=A[B+1],I.min.z=A[B+2],I.max.x=A[B+3],I.max.y=A[B+4],I.max.z=A[B+5],I}function ms(B){let A=-1,I=-1/0;for(let g=0;g<3;g++){const Q=B[g+3]-B[g];Q>I&&(I=Q,A=g)}return A}function Ps(B,A){A.set(B)}function Ts(B,A,I){let g,Q;for(let C=0;C<3;C++){const E=C+3;g=B[C],Q=A[C],I[C]=g<Q?g:Q,g=B[E],Q=A[E],I[E]=g>Q?g:Q}}function jC(B,A,I){for(let g=0;g<3;g++){const Q=A[B+2*g],C=A[B+2*g+1],E=Q-C,i=Q+C;E<I[g]&&(I[g]=E),i>I[g+3]&&(I[g+3]=i)}}function wB(B){const A=B[3]-B[0],I=B[4]-B[1],g=B[5]-B[2];return 2*(A*I+I*g+g*A)}function VA(B,A){return A[B+15]===ea}function aI(B,A){return A[B+6]}function RI(B,A){return A[B+14]}function AI(B){return B+vA}function II(B,A){const I=A[B+6];return B+I*vA}function ao(B,A){return A[B+7]}function Pi(B,A,I,g,Q){let C=1/0,E=1/0,i=1/0,D=-1/0,o=-1/0,s=-1/0,t=1/0,w=1/0,a=1/0,y=-1/0,R=-1/0,n=-1/0;const h=B.offset||0;for(let G=(A-h)*6,r=(A+I-h)*6;G<r;G+=6){const M=B[G+0],k=B[G+1],J=M-k,U=M+k;J<C&&(C=J),U>D&&(D=U),M<t&&(t=M),M>y&&(y=M);const Y=B[G+2],d=B[G+3],H=Y-d,f=Y+d;H<E&&(E=H),f>o&&(o=f),Y<w&&(w=Y),Y>R&&(R=Y);const l=B[G+4],p=B[G+5],q=l-p,m=l+p;q<i&&(i=q),m>s&&(s=m),l<a&&(a=l),l>n&&(n=l)}g[0]=C,g[1]=E,g[2]=i,g[3]=D,g[4]=o,g[5]=s,Q[0]=t,Q[1]=w,Q[2]=a,Q[3]=y,Q[4]=R,Q[5]=n}const Lg=32,dy=(B,A)=>B.candidate-A.candidate,Tg=new Array(Lg).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zC=new Float32Array(6);function ly(B,A,I,g,Q,C){let E=-1,i=0;if(C===wo)E=ms(A),E!==-1&&(i=(A[E]+A[E+3])/2);else if(C===wa)E=ms(B),E!==-1&&(i=fy(I,g,Q,E));else if(C===aa){const D=wB(B);let o=mi*Q;const s=I.offset||0,t=(g-s)*6,w=(g+Q-s)*6;for(let a=0;a<3;a++){const y=A[a],h=(A[a+3]-y)/Lg;if(Q<Lg/4){const G=[...Tg];G.length=Q;let r=0;for(let k=t;k<w;k+=6,r++){const J=G[r];J.candidate=I[k+2*a],J.count=0;const{bounds:U,leftCacheBounds:Y,rightCacheBounds:d}=J;for(let H=0;H<3;H++)d[H]=1/0,d[H+3]=-1/0,Y[H]=1/0,Y[H+3]=-1/0,U[H]=1/0,U[H+3]=-1/0;jC(k,I,U)}G.sort(dy);let M=Q;for(let k=0;k<M;k++){const J=G[k];for(;k+1<M&&G[k+1].candidate===J.candidate;)G.splice(k+1,1),M--}for(let k=t;k<w;k+=6){const J=I[k+2*a];for(let U=0;U<M;U++){const Y=G[U];J>=Y.candidate?jC(k,I,Y.rightCacheBounds):(jC(k,I,Y.leftCacheBounds),Y.count++)}}for(let k=0;k<M;k++){const J=G[k],U=J.count,Y=Q-J.count,d=J.leftCacheBounds,H=J.rightCacheBounds;let f=0;U!==0&&(f=wB(d)/D);let l=0;Y!==0&&(l=wB(H)/D);const p=bs+mi*(f*U+l*Y);p<o&&(E=a,o=p,i=J.candidate)}}else{for(let M=0;M<Lg;M++){const k=Tg[M];k.count=0,k.candidate=y+h+M*h;const J=k.bounds;for(let U=0;U<3;U++)J[U]=1/0,J[U+3]=-1/0}for(let M=t;M<w;M+=6){let U=~~((I[M+2*a]-y)/h);U>=Lg&&(U=Lg-1);const Y=Tg[U];Y.count++,jC(M,I,Y.bounds)}const G=Tg[Lg-1];Ps(G.bounds,G.rightCacheBounds);for(let M=Lg-2;M>=0;M--){const k=Tg[M],J=Tg[M+1];Ts(k.bounds,J.rightCacheBounds,k.rightCacheBounds)}let r=0;for(let M=0;M<Lg-1;M++){const k=Tg[M],J=k.count,U=k.bounds,d=Tg[M+1].rightCacheBounds;J!==0&&(r===0?Ps(U,zC):Ts(U,zC,zC)),r+=J;let H=0,f=0;r!==0&&(H=wB(zC)/D);const l=Q-r;l!==0&&(f=wB(d)/D);const p=bs+mi*(H*r+f*l);p<o&&(E=a,o=p,i=k.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${C} used.`);return{axis:E,pos:i}}function fy(B,A,I,g){let Q=0;const C=B.offset;for(let E=A,i=A+I;E<i;E++)Q+=B[(E-C)*6+g*2];return Q/I}class Ti{constructor(){this.boundingData=new Float32Array(6)}}function xy(B,A,I,g,Q,C){let E=g,i=g+Q-1;const D=C.pos,o=C.axis*2,s=I.offset||0;for(;;){for(;E<=i&&I[(E-s)*6+o]<D;)E++;for(;E<=i&&I[(i-s)*6+o]>=D;)i--;if(E<i){for(let t=0;t<A;t++){let w=B[E*A+t];B[E*A+t]=B[i*A+t],B[i*A+t]=w}for(let t=0;t<6;t++){const w=E-s,a=i-s,y=I[w*6+t];I[w*6+t]=I[a*6+t],I[a*6+t]=y}E++,i--}else return E}}let na,RE,UD,ha;const py=Math.pow(2,32);function LD(B){return"count"in B?1:1+LD(B.left)+LD(B.right)}function uy(B,A,I){return na=new Float32Array(I),RE=new Uint32Array(I),UD=new Uint16Array(I),ha=new Uint8Array(I),HD(B,A)}function HD(B,A){const I=B/4,g=B/2,Q="count"in A,C=A.boundingData;for(let E=0;E<6;E++)na[I+E]=C[E];if(Q)return A.buffer?(ha.set(new Uint8Array(A.buffer),B),B+A.buffer.byteLength):(RE[I+6]=A.offset,UD[g+14]=A.count,UD[g+15]=ea,B+wI);{const{left:E,right:i,splitAxis:D}=A,o=B+wI;let s=HD(o,E);const t=B/wI,a=s/wI-t;if(a>py)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return RE[I+6]=a,RE[I+7]=D,HD(s,i)}}function qy(B,A,I,g,Q){const{maxDepth:C,verbose:E,maxLeafSize:i,strategy:D,onProgress:o}=Q,s=B.primitiveBuffer,t=B.primitiveBufferStride,w=new Float32Array(6);let a=!1;const y=new Ti;return Pi(A,I,g,y.boundingData,w),n(y,I,g,w),y;function R(h){o&&o(h/g)}function n(h,G,r,M=null,k=0){if(!a&&k>=C&&(a=!0,E&&console.warn(`BVH: Max depth of ${C} reached when generating BVH. Consider increasing maxDepth.`)),r<=i||k>=C)return R(G+r),h.offset=G,h.count=r,h;const J=ly(h.boundingData,M,A,G,r,D);if(J.axis===-1)return R(G+r),h.offset=G,h.count=r,h;const U=xy(s,t,A,G,r,J);if(U===G||U===G+r)R(G+r),h.offset=G,h.count=r;else{h.splitAxis=J.axis;const Y=new Ti,d=G,H=U-G;h.left=Y,Pi(A,d,H,Y.boundingData,w),n(Y,d,H,w,k+1);const f=new Ti,l=U,p=r-H;h.right=f,Pi(A,l,p,f.boundingData,w),n(f,l,p,w,k+1)}return h}}function by(B,A){const I=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,g=B.getRootRanges(A.range),Q=g[0],C=g[g.length-1],E={offset:Q.offset,count:C.offset+C.count-Q.offset},i=new Float32Array(6*E.count);i.offset=E.offset,B.computePrimitiveBounds(E.offset,E.count,i),B._roots=g.map(D=>{const o=qy(B,i,D.offset,D.count,A),s=LD(o),t=new I(wI*s);return uy(0,o,t),t})}class eo{constructor(A){this._getNewPrimitive=A,this._primitives=[]}getPrimitive(){const A=this._primitives;return A.length===0?this._getNewPrimitive():A.pop()}releasePrimitive(A){this._primitives.push(A)}}class my{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const A=[];let I=null;this.setBuffer=g=>{I&&A.push(I),I=g,this.float32Array=new Float32Array(g),this.uint16Array=new Uint16Array(g),this.uint32Array=new Uint32Array(g)},this.clearBuffer=()=>{I=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,A.length!==0&&this.setBuffer(A.pop())}}}const KA=new my;let Vg,XQ;const dQ=[],_C=new eo(()=>new F.Box3);function Py(B,A,I,g,Q,C){Vg=_C.getPrimitive(),XQ=_C.getPrimitive(),dQ.push(Vg,XQ),KA.setBuffer(B._roots[A]);const E=YD(0,B.geometry,I,g,Q,C);KA.clearBuffer(),_C.releasePrimitive(Vg),_C.releasePrimitive(XQ),dQ.pop(),dQ.pop();const i=dQ.length;return i>0&&(XQ=dQ[i-1],Vg=dQ[i-2]),E}function YD(B,A,I,g,Q=null,C=0,E=0){const{float32Array:i,uint16Array:D,uint32Array:o}=KA;let s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);return pA(B,i,Vg),g(w,a,!1,E,C+B/vA,Vg)}else{let H=function(l){const{uint16Array:p,uint32Array:q}=KA;let m=l*2;for(;!VA(m,p);)l=AI(l),m=l*2;return aI(l,q)},f=function(l){const{uint16Array:p,uint32Array:q}=KA;let m=l*2;for(;!VA(m,p);)l=II(l,q),m=l*2;return aI(l,q)+RI(m,p)};const w=AI(B),a=II(B,o);let y=w,R=a,n,h,G,r;if(Q&&(G=Vg,r=XQ,pA(y,i,G),pA(R,i,r),n=Q(G),h=Q(r),h<n)){y=a,R=w;const l=n;n=h,h=l,G=r}G||(G=Vg,pA(y,i,G));const M=VA(y*2,D),k=I(G,M,n,E+1,C+y/vA);let J;if(k===JD){const l=H(y),q=f(y)-l;J=g(l,q,!0,E+1,C+y/vA,G)}else J=k&&YD(y,A,I,g,Q,C,E+1);if(J)return!0;r=XQ,pA(R,i,r);const U=VA(R*2,D),Y=I(r,U,h,E+1,C+R/vA);let d;if(Y===JD){const l=H(R),q=f(R)-l;d=g(l,q,!0,E+1,C+R/vA,r)}else d=Y&&YD(R,A,I,g,Q,C,E+1);return!!d}}const qB=new KA.constructor,uE=new KA.constructor,Xg=new eo(()=>new F.Box3),lQ=new F.Box3,fQ=new F.Box3,Oi=new F.Box3,Xi=new F.Box3;let vi=!1;function Ty(B,A,I,g){if(vi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");vi=!0;const Q=B._roots,C=A._roots;let E,i=0,D=0;const o=new F.Matrix4().copy(I).invert();for(let s=0,t=Q.length;s<t;s++){qB.setBuffer(Q[s]),D=0;const w=Xg.getPrimitive();pA(0,qB.float32Array,w),w.applyMatrix4(o);for(let a=0,y=C.length;a<y&&(uE.setBuffer(C[a]),E=Cg(0,0,I,o,g,i,D,0,0,w),uE.clearBuffer(),D+=C[a].byteLength/wI,!E);a++);if(Xg.releasePrimitive(w),qB.clearBuffer(),i+=Q[s].byteLength/wI,E)break}return vi=!1,E}function Cg(B,A,I,g,Q,C=0,E=0,i=0,D=0,o=null,s=!1){let t,w;s?(t=uE,w=qB):(t=qB,w=uE);const a=t.float32Array,y=t.uint32Array,R=t.uint16Array,n=w.float32Array,h=w.uint32Array,G=w.uint16Array,r=B*2,M=A*2,k=VA(r,R),J=VA(M,G);let U=!1;if(J&&k)s?U=Q(aI(A,h),RI(A*2,G),aI(B,y),RI(B*2,R),D,E+A/vA,i,C+B/vA):U=Q(aI(B,y),RI(B*2,R),aI(A,h),RI(A*2,G),i,C+B/vA,D,E+A/vA);else if(J){const Y=Xg.getPrimitive();pA(A,n,Y),Y.applyMatrix4(I);const d=AI(B),H=II(B,y);pA(d,a,lQ),pA(H,a,fQ);const f=Y.intersectsBox(lQ),l=Y.intersectsBox(fQ);U=f&&Cg(A,d,g,I,Q,E,C,D,i+1,Y,!s)||l&&Cg(A,H,g,I,Q,E,C,D,i+1,Y,!s),Xg.releasePrimitive(Y)}else{const Y=AI(A),d=II(A,h);pA(Y,n,Oi),pA(d,n,Xi);const H=o.intersectsBox(Oi),f=o.intersectsBox(Xi);if(H&&f)U=Cg(B,Y,I,g,Q,C,E,i,D+1,o,s)||Cg(B,d,I,g,Q,C,E,i,D+1,o,s);else if(H)if(k)U=Cg(B,Y,I,g,Q,C,E,i,D+1,o,s);else{const l=Xg.getPrimitive();l.copy(Oi).applyMatrix4(I);const p=AI(B),q=II(B,y);pA(p,a,lQ),pA(q,a,fQ);const m=l.intersectsBox(lQ),T=l.intersectsBox(fQ);U=m&&Cg(Y,p,g,I,Q,E,C,D,i+1,l,!s)||T&&Cg(Y,q,g,I,Q,E,C,D,i+1,l,!s),Xg.releasePrimitive(l)}else if(f)if(k)U=Cg(B,d,I,g,Q,C,E,i,D+1,o,s);else{const l=Xg.getPrimitive();l.copy(Xi).applyMatrix4(I);const p=AI(B),q=II(B,y);pA(p,a,lQ),pA(q,a,fQ);const m=l.intersectsBox(lQ),T=l.intersectsBox(fQ);U=m&&Cg(d,p,g,I,Q,E,C,D,i+1,l,!s)||T&&Cg(d,q,g,I,Q,E,C,D,i+1,l,!s),Xg.releasePrimitive(l)}}return U}const Os=new F.Box3,xQ=new Float32Array(6);class ya{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(A){A={...ca,...A},by(this,A)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(A,I,g,Q){let C=1/0,E=1/0,i=1/0,D=-1/0,o=-1/0,s=-1/0;for(let t=A,w=A+I;t<w;t++){this.writePrimitiveBounds(t,xQ,0);const[a,y,R,n,h,G]=xQ;a<C&&(C=a),n>D&&(D=n),y<E&&(E=y),h>o&&(o=h),R<i&&(i=R),G>s&&(s=G)}return g[Q+0]=C,g[Q+1]=E,g[Q+2]=i,g[Q+3]=D,g[Q+4]=o,g[Q+5]=s,g}computePrimitiveBounds(A,I,g){const Q=g.offset||0;for(let C=A,E=A+I;C<E;C++){this.writePrimitiveBounds(C,xQ,0);const[i,D,o,s,t,w]=xQ,a=(i+s)/2,y=(D+t)/2,R=(o+w)/2,n=(s-i)/2,h=(t-D)/2,G=(w-o)/2,r=(C-Q)*6;g[r+0]=a,g[r+1]=n+(Math.abs(a)+n)*SE,g[r+2]=y,g[r+3]=h+(Math.abs(y)+h)*SE,g[r+4]=R,g[r+5]=G+(Math.abs(R)+G)*SE}return g}shiftPrimitiveOffsets(A){const I=this._indirectBuffer;if(I)for(let g=0,Q=I.length;g<Q;g++)I[g]+=A;else{const g=this._roots;for(let Q=0;Q<g.length;Q++){const C=g[Q],E=new Uint32Array(C),i=new Uint16Array(C),D=C.byteLength/wI;for(let o=0;o<D;o++){const s=vA*o,t=2*s;VA(t,i)&&(E[s+6]+=A)}}}}traverse(A,I=0){const g=this._roots[I],Q=new Uint32Array(g),C=new Uint16Array(g);E(0);function E(i,D=0){const o=i*2,s=VA(o,C);if(s){const t=Q[i+6],w=C[o+14];A(D,s,new Float32Array(g,i*4,6),t,w)}else{const t=AI(i),w=II(i,Q),a=ao(i,Q);A(D,s,new Float32Array(g,i*4,6),a)||(E(t,D+1),E(w,D+1))}}}refit(){const A=this._roots;for(let I=0,g=A.length;I<g;I++){const Q=A[I],C=new Uint32Array(Q),E=new Uint16Array(Q),i=new Float32Array(Q),D=Q.byteLength/wI;for(let o=D-1;o>=0;o--){const s=o*vA,t=s*2;if(VA(t,E)){const a=aI(s,C),y=RI(t,E);this.writePrimitiveRangeBounds(a,y,xQ,0),i.set(xQ,s)}else{const a=AI(s),y=II(s,C);for(let R=0;R<3;R++){const n=i[a+R],h=i[a+R+3],G=i[y+R],r=i[y+R+3];i[s+R]=n<G?n:G,i[s+R+3]=h>r?h:r}}}}}getBoundingBox(A){return A.makeEmpty(),this._roots.forEach(g=>{pA(0,new Float32Array(g),Os),A.union(Os)}),A}shapecast(A){let{boundsTraverseOrder:I,intersectsBounds:g,intersectsRange:Q,intersectsPrimitive:C,scratchPrimitive:E,iterate:i}=A;if(Q&&C){const t=Q;Q=(w,a,y,R,n)=>t(w,a,y,R,n)?!0:i(w,a,this,C,y,R,E)}else Q||(C?Q=(t,w,a,y)=>i(t,w,this,C,a,y,E):Q=(t,w,a)=>a);let D=!1,o=0;const s=this._roots;for(let t=0,w=s.length;t<w;t++){const a=s[t];if(D=Py(this,t,g,Q,I,o),D)break;o+=a.byteLength/wI}return D}bvhcast(A,I,g){let{intersectsRanges:Q}=g;return Ty(this,A,I,Q)}}function Oy(){return typeof SharedArrayBuffer<"u"}function co(B){return B.index?B.index.count:B.attributes.position.count}function Ai(B){return co(B)/3}function Xy(B,A=ArrayBuffer){return B>65535?new Uint32Array(new A(4*B)):new Uint16Array(new A(2*B))}function vy(B,A){if(!B.index){const I=B.attributes.position.count,g=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,Q=Xy(I,g);B.setIndex(new F.BufferAttribute(Q,1));for(let C=0;C<I;C++)Q[C]=C}}function Vy(B,A,I){const g=co(B)/I,Q=A||B.drawRange,C=Q.start/I,E=(Q.start+Q.count)/I,i=Math.max(0,C),D=Math.min(g,E)-i;return{offset:Math.floor(i),count:Math.floor(D)}}function Zy(B,A){return B.groups.map(I=>({offset:I.start/A,count:I.count/A}))}function Xs(B,A,I){const g=Vy(B,A,I),Q=Zy(B,I);if(!Q.length)return[g];const C=[],E=g.offset,i=g.offset+g.count,D=co(B)/I,o=[];for(const w of Q){const{offset:a,count:y}=w,R=a,n=isFinite(y)?y:D-a,h=a+n;R<i&&h>E&&(o.push({pos:Math.max(E,R),isStart:!0}),o.push({pos:Math.min(i,h),isStart:!1}))}o.sort((w,a)=>w.pos!==a.pos?w.pos-a.pos:w.type==="end"?-1:1);let s=0,t=null;for(const w of o){const a=w.pos;s!==0&&a!==t&&C.push({offset:t,count:a-t}),s+=w.isStart?1:-1,t=a}return C}function Ga(B,A){const I=B[B.length-1],g=I.offset+I.count>2**16,Q=B.reduce((o,s)=>o+s.count,0),C=g?4:2,E=A?new SharedArrayBuffer(Q*C):new ArrayBuffer(Q*C),i=g?new Uint32Array(E):new Uint16Array(E);let D=0;for(let o=0;o<B.length;o++){const{offset:s,count:t}=B[o];for(let w=0;w<t;w++)i[D+w]=s+w;D+=t}return i}class ra extends ya{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(A){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(A){}constructor(A,I={}){if(A.isBufferGeometry){if(A.index&&A.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(I.useSharedArrayBuffer&&!Oy())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=A,this.resolvePrimitiveIndex=I.indirect?g=>this._indirectBuffer[g]:g=>g,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,I={...ca,...I},I[$E]||this.init(I)}init(A){const{geometry:I,primitiveStride:g}=this;if(A.indirect){const Q=Xs(I,A.range,g),C=Ga(Q,A.useSharedArrayBuffer);this._indirectBuffer=C}else vy(I,A);super.init(A),!I.boundingBox&&A.setBoundingBox&&(I.boundingBox=this.getBoundingBox(new F.Box3))}getRootRanges(A){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Xs(this.geometry,A,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ug{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(A,I){let g=1/0,Q=-1/0;for(let C=0,E=A.length;C<E;C++){const D=A[C][I];g=D<g?D:g,Q=D>Q?D:Q}this.min=g,this.max=Q}setFromPoints(A,I){let g=1/0,Q=-1/0;for(let C=0,E=I.length;C<E;C++){const i=I[C],D=A.dot(i);g=D<g?D:g,Q=D>Q?D:Q}this.min=g,this.max=Q}isSeparated(A){return this.min>A.max||A.min>this.max}}ug.prototype.setFromBox=(function(){const B=new F.Vector3;return function(I,g){const Q=g.min,C=g.max;let E=1/0,i=-1/0;for(let D=0;D<=1;D++)for(let o=0;o<=1;o++)for(let s=0;s<=1;s++){B.x=Q.x*D+C.x*(1-D),B.y=Q.y*o+C.y*(1-o),B.z=Q.z*s+C.z*(1-s);const t=I.dot(B);E=Math.min(t,E),i=Math.max(t,i)}this.min=E,this.max=i}})();const Wy=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Vector3;return function(Q,C,E){const i=Q.start,D=B,o=C.start,s=A;I.subVectors(i,o),B.subVectors(Q.end,Q.start),A.subVectors(C.end,C.start);const t=I.dot(s),w=s.dot(D),a=s.dot(s),y=I.dot(D),n=D.dot(D)*a-w*w;let h,G;n!==0?h=(t*w-y*a)/n:h=0,G=(t+h*w)/a,E.x=h,E.y=G}})(),no=(function(){const B=new F.Vector2,A=new F.Vector3,I=new F.Vector3;return function(Q,C,E,i){Wy(Q,C,B);let D=B.x,o=B.y;if(D>=0&&D<=1&&o>=0&&o<=1){Q.at(D,E),C.at(o,i);return}else if(D>=0&&D<=1){o<0?C.at(0,i):C.at(1,i),Q.closestPointToPoint(i,!0,E);return}else if(o>=0&&o<=1){D<0?Q.at(0,E):Q.at(1,E),C.closestPointToPoint(E,!0,i);return}else{let s;D<0?s=Q.start:s=Q.end;let t;o<0?t=C.start:t=C.end;const w=A,a=I;if(Q.closestPointToPoint(t,!0,A),C.closestPointToPoint(s,!0,I),w.distanceToSquared(t)<=a.distanceToSquared(s)){E.copy(w),i.copy(t);return}else{E.copy(s),i.copy(a);return}}}})(),jy=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Plane,g=new F.Line3;return function(C,E){const{radius:i,center:D}=C,{a:o,b:s,c:t}=E;if(g.start=o,g.end=s,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i||(g.start=o,g.end=t,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i)||(g.start=s,g.end=t,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i))return!0;const R=E.getPlane(I);if(Math.abs(R.distanceToPoint(D))<=i){const h=R.projectPoint(D,A);if(E.containsPoint(h))return!0}return!1}})(),zy=["x","y","z"],Yg=1e-15,vs=Yg*Yg;function TI(B){return Math.abs(B)<Yg}class ZI extends F.Triangle{constructor(...A){super(...A),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new F.Vector3),this.satBounds=new Array(4).fill().map(()=>new ug),this.points=[this.a,this.b,this.c],this.plane=new F.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new F.Line3,this.needsUpdate=!0}intersectsSphere(A){return jy(A,this)}update(){const A=this.a,I=this.b,g=this.c,Q=this.points,C=this.satAxes,E=this.satBounds,i=C[0],D=E[0];this.getNormal(i),D.setFromPoints(i,Q);const o=C[1],s=E[1];o.subVectors(A,I),s.setFromPoints(o,Q);const t=C[2],w=E[2];t.subVectors(I,g),w.setFromPoints(t,Q);const a=C[3],y=E[3];a.subVectors(g,A),y.setFromPoints(a,Q);const R=o.length(),n=t.length(),h=a.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,R<Yg?n<Yg||h<Yg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(A),this.degenerateSegment.end.copy(g)):n<Yg?h<Yg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(I),this.degenerateSegment.end.copy(A)):h<Yg&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(g),this.degenerateSegment.end.copy(I)),this.plane.setFromNormalAndCoplanarPoint(i,A),this.needsUpdate=!1}}ZI.prototype.closestPointToSegment=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Line3;return function(Q,C=null,E=null){const{start:i,end:D}=Q,o=this.points;let s,t=1/0;for(let w=0;w<3;w++){const a=(w+1)%3;I.start.copy(o[w]),I.end.copy(o[a]),no(I,Q,B,A),s=B.distanceToSquared(A),s<t&&(t=s,C&&C.copy(B),E&&E.copy(A))}return this.closestPointToPoint(i,B),s=i.distanceToSquared(B),s<t&&(t=s,C&&C.copy(B),E&&E.copy(i)),this.closestPointToPoint(D,B),s=D.distanceToSquared(B),s<t&&(t=s,C&&C.copy(B),E&&E.copy(D)),Math.sqrt(t)}})();ZI.prototype.intersectsTriangle=(function(){const B=new ZI,A=new ug,I=new ug,g=new F.Vector3,Q=new F.Vector3,C=new F.Vector3,E=new F.Vector3,i=new F.Line3,D=new F.Line3,o=new F.Vector3,s=new F.Vector2,t=new F.Vector2;function w(r,M,k,J){const U=g;!r.isDegenerateIntoPoint&&!r.isDegenerateIntoSegment?U.copy(r.plane.normal):U.copy(M.plane.normal);const Y=r.satBounds,d=r.satAxes;for(let l=1;l<4;l++){const p=Y[l],q=d[l];if(A.setFromPoints(q,M.points),p.isSeparated(A)||(E.copy(U).cross(q),A.setFromPoints(E,r.points),I.setFromPoints(E,M.points),A.isSeparated(I)))return!1}const H=M.satBounds,f=M.satAxes;for(let l=1;l<4;l++){const p=H[l],q=f[l];if(A.setFromPoints(q,r.points),p.isSeparated(A)||(E.crossVectors(U,q),A.setFromPoints(E,r.points),I.setFromPoints(E,M.points),A.isSeparated(I)))return!1}return k&&(J||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),k.start.set(0,0,0),k.end.set(0,0,0)),!0}function a(r,M,k,J,U,Y,d,H,f,l,p){let q=d/(d-H);l.x=J+(U-J)*q,p.start.subVectors(M,r).multiplyScalar(q).add(r),q=d/(d-f),l.y=J+(Y-J)*q,p.end.subVectors(k,r).multiplyScalar(q).add(r)}function y(r,M,k,J,U,Y,d,H,f,l,p){if(U>0)a(r.c,r.a,r.b,J,M,k,f,d,H,l,p);else if(Y>0)a(r.b,r.a,r.c,k,M,J,H,d,f,l,p);else if(H*f>0||d!=0)a(r.a,r.b,r.c,M,k,J,d,H,f,l,p);else if(H!=0)a(r.b,r.a,r.c,k,M,J,H,d,f,l,p);else if(f!=0)a(r.c,r.a,r.b,J,M,k,f,d,H,l,p);else return!0;return!1}function R(r,M,k,J){const U=M.degenerateSegment,Y=r.plane.distanceToPoint(U.start),d=r.plane.distanceToPoint(U.end);return TI(Y)?TI(d)?w(r,M,k,J):(k&&(k.start.copy(U.start),k.end.copy(U.start)),r.containsPoint(U.start)):TI(d)?(k&&(k.start.copy(U.end),k.end.copy(U.end)),r.containsPoint(U.end)):r.plane.intersectLine(U,g)!=null?(k&&(k.start.copy(g),k.end.copy(g)),r.containsPoint(g)):!1}function n(r,M,k){const J=M.a;return TI(r.plane.distanceToPoint(J))&&r.containsPoint(J)?(k&&(k.start.copy(J),k.end.copy(J)),!0):!1}function h(r,M,k){const J=r.degenerateSegment,U=M.a;return J.closestPointToPoint(U,!0,g),U.distanceToSquared(g)<vs?(k&&(k.start.copy(U),k.end.copy(U)),!0):!1}function G(r,M,k,J){if(r.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const U=r.degenerateSegment,Y=M.degenerateSegment,d=Q,H=C;U.delta(d),Y.delta(H);const f=g.subVectors(Y.start,U.start),l=d.x*H.y-d.y*H.x;if(TI(l))return!1;const p=(f.x*H.y-f.y*H.x)/l,q=-(d.x*f.y-d.y*f.x)/l;if(p<0||p>1||q<0||q>1)return!1;const m=U.start.z+d.z*p,T=Y.start.z+H.z*q;return TI(m-T)?(k&&(k.start.copy(U.start).addScaledVector(d,p),k.end.copy(U.start).addScaledVector(d,p)),!0):!1}else return M.isDegenerateIntoPoint?h(r,M,k):R(M,r,k,J);else{if(r.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(r.a)<vs?(k&&(k.start.copy(r.a),k.end.copy(r.a)),!0):!1:M.isDegenerateIntoSegment?h(M,r,k):n(M,r,k);if(M.isDegenerateIntoPoint)return n(r,M,k);if(M.isDegenerateIntoSegment)return R(r,M,k,J)}}return function(M,k=null,J=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(B.copy(M),B.update(),M=B);const U=G(this,M,k,J);if(U!==void 0)return U;const Y=this.plane,d=M.plane;let H=d.distanceToPoint(this.a),f=d.distanceToPoint(this.b),l=d.distanceToPoint(this.c);TI(H)&&(H=0),TI(f)&&(f=0),TI(l)&&(l=0);const p=H*f,q=H*l;if(p>0&&q>0)return!1;let m=Y.distanceToPoint(M.a),T=Y.distanceToPoint(M.b),Z=Y.distanceToPoint(M.c);TI(m)&&(m=0),TI(T)&&(T=0),TI(Z)&&(Z=0);const O=m*T,j=m*Z;if(O>0&&j>0)return!1;Q.copy(Y.normal),C.copy(d.normal);const gA=Q.cross(C);let QA=0,CA=Math.abs(gA.x);const EA=Math.abs(gA.y);EA>CA&&(CA=EA,QA=1),Math.abs(gA.z)>CA&&(QA=2);const W=zy[QA],$=this.a[W],z=this.b[W],MA=this.c[W],kA=M.a[W],NA=M.b[W],JA=M.c[W];if(y(this,$,z,MA,p,q,H,f,l,s,i))return w(this,M,k,J);if(y(M,kA,NA,JA,O,j,m,T,Z,t,D))return w(this,M,k,J);if(s.y<s.x){const iA=s.y;s.y=s.x,s.x=iA,o.copy(i.start),i.start.copy(i.end),i.end.copy(o)}if(t.y<t.x){const iA=t.y;t.y=t.x,t.x=iA,o.copy(D.start),D.start.copy(D.end),D.end.copy(o)}return s.y<t.x||t.y<s.x?!1:(k&&(t.x>s.x?k.start.copy(D.start):k.start.copy(i.start),t.y<s.y?k.end.copy(D.end):k.end.copy(i.end)),!0)}})();ZI.prototype.distanceToPoint=(function(){const B=new F.Vector3;return function(I){return this.closestPointToPoint(I,B),I.distanceTo(B)}})();ZI.prototype.distanceToTriangle=(function(){const B=new F.Vector3,A=new F.Vector3,I=["a","b","c"],g=new F.Line3,Q=new F.Line3;return function(E,i=null,D=null){const o=i||D?g:null;if(this.intersectsTriangle(E,o))return(i||D)&&(i&&o.getCenter(i),D&&o.getCenter(D)),0;let s=1/0;for(let t=0;t<3;t++){let w;const a=I[t],y=E[a];this.closestPointToPoint(y,B),w=y.distanceToSquared(B),w<s&&(s=w,i&&i.copy(B),D&&D.copy(y));const R=this[a];E.closestPointToPoint(R,B),w=R.distanceToSquared(B),w<s&&(s=w,i&&i.copy(R),D&&D.copy(B))}for(let t=0;t<3;t++){const w=I[t],a=I[(t+1)%3];g.set(this[w],this[a]);for(let y=0;y<3;y++){const R=I[y],n=I[(y+1)%3];Q.set(E[R],E[n]),no(g,Q,B,A);const h=B.distanceToSquared(A);h<s&&(s=h,i&&i.copy(B),D&&D.copy(A))}}return Math.sqrt(s)}})();class cI{constructor(A,I,g){this.isOrientedBox=!0,this.min=new F.Vector3,this.max=new F.Vector3,this.matrix=new F.Matrix4,this.invMatrix=new F.Matrix4,this.points=new Array(8).fill().map(()=>new F.Vector3),this.satAxes=new Array(3).fill().map(()=>new F.Vector3),this.satBounds=new Array(3).fill().map(()=>new ug),this.alignedSatBounds=new Array(3).fill().map(()=>new ug),this.needsUpdate=!1,A&&this.min.copy(A),I&&this.max.copy(I),g&&this.matrix.copy(g)}set(A,I,g){this.min.copy(A),this.max.copy(I),this.matrix.copy(g),this.needsUpdate=!0}copy(A){this.min.copy(A.min),this.max.copy(A.max),this.matrix.copy(A.matrix),this.needsUpdate=!0}}cI.prototype.update=(function(){return function(){const A=this.matrix,I=this.min,g=this.max,Q=this.points;for(let o=0;o<=1;o++)for(let s=0;s<=1;s++)for(let t=0;t<=1;t++){const w=1*o|2*s|4*t,a=Q[w];a.x=o?g.x:I.x,a.y=s?g.y:I.y,a.z=t?g.z:I.z,a.applyMatrix4(A)}const C=this.satBounds,E=this.satAxes,i=Q[0];for(let o=0;o<3;o++){const s=E[o],t=C[o],w=1<<o,a=Q[w];s.subVectors(i,a),t.setFromPoints(s,Q)}const D=this.alignedSatBounds;D[0].setFromPointsField(Q,"x"),D[1].setFromPointsField(Q,"y"),D[2].setFromPointsField(Q,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();cI.prototype.intersectsBox=(function(){const B=new ug;return function(I){this.needsUpdate&&this.update();const g=I.min,Q=I.max,C=this.satBounds,E=this.satAxes,i=this.alignedSatBounds;if(B.min=g.x,B.max=Q.x,i[0].isSeparated(B)||(B.min=g.y,B.max=Q.y,i[1].isSeparated(B))||(B.min=g.z,B.max=Q.z,i[2].isSeparated(B)))return!1;for(let D=0;D<3;D++){const o=E[D],s=C[D];if(B.setFromBox(o,I),s.isSeparated(B))return!1}return!0}})();cI.prototype.intersectsTriangle=(function(){const B=new ZI,A=new Array(3),I=new ug,g=new ug,Q=new F.Vector3;return function(E){this.needsUpdate&&this.update(),E.isExtendedTriangle?E.needsUpdate&&E.update():(B.copy(E),B.update(),E=B);const i=this.satBounds,D=this.satAxes;A[0]=E.a,A[1]=E.b,A[2]=E.c;for(let w=0;w<3;w++){const a=i[w],y=D[w];if(I.setFromPoints(y,A),a.isSeparated(I))return!1}const o=E.satBounds,s=E.satAxes,t=this.points;for(let w=0;w<3;w++){const a=o[w],y=s[w];if(I.setFromPoints(y,t),a.isSeparated(I))return!1}for(let w=0;w<3;w++){const a=D[w];for(let y=0;y<4;y++){const R=s[y];if(Q.crossVectors(a,R),I.setFromPoints(Q,A),g.setFromPoints(Q,t),I.isSeparated(g))return!1}}return!0}})();cI.prototype.closestPointToPoint=(function(){return function(A,I){return this.needsUpdate&&this.update(),I.copy(A).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),I}})();cI.prototype.distanceToPoint=(function(){const B=new F.Vector3;return function(I){return this.closestPointToPoint(I,B),I.distanceTo(B)}})();cI.prototype.distanceToBox=(function(){const B=["x","y","z"],A=new Array(12).fill().map(()=>new F.Line3),I=new Array(12).fill().map(()=>new F.Line3),g=new F.Vector3,Q=new F.Vector3;return function(E,i=0,D=null,o=null){if(this.needsUpdate&&this.update(),this.intersectsBox(E))return(D||o)&&(E.getCenter(Q),this.closestPointToPoint(Q,g),E.closestPointToPoint(g,Q),D&&D.copy(g),o&&o.copy(Q)),0;const s=i*i,t=E.min,w=E.max,a=this.points;let y=1/0;for(let n=0;n<8;n++){const h=a[n];Q.copy(h).clamp(t,w);const G=h.distanceToSquared(Q);if(G<y&&(y=G,D&&D.copy(h),o&&o.copy(Q),G<s))return Math.sqrt(G)}let R=0;for(let n=0;n<3;n++)for(let h=0;h<=1;h++)for(let G=0;G<=1;G++){const r=(n+1)%3,M=(n+2)%3,k=h<<r|G<<M,J=1<<n|h<<r|G<<M,U=a[k],Y=a[J];A[R].set(U,Y);const H=B[n],f=B[r],l=B[M],p=I[R],q=p.start,m=p.end;q[H]=t[H],q[f]=h?t[f]:w[f],q[l]=G?t[l]:w[f],m[H]=w[H],m[f]=h?t[f]:w[f],m[l]=G?t[l]:w[f],R++}for(let n=0;n<=1;n++)for(let h=0;h<=1;h++)for(let G=0;G<=1;G++){Q.x=n?w.x:t.x,Q.y=h?w.y:t.y,Q.z=G?w.z:t.z,this.closestPointToPoint(Q,g);const r=Q.distanceToSquared(g);if(r<y&&(y=r,D&&D.copy(g),o&&o.copy(Q),r<s))return Math.sqrt(r)}for(let n=0;n<12;n++){const h=A[n];for(let G=0;G<12;G++){const r=I[G];no(h,r,g,Q);const M=g.distanceToSquared(Q);if(M<y&&(y=M,D&&D.copy(g),o&&o.copy(Q),M<s))return Math.sqrt(M)}}return Math.sqrt(y)}})();class _y extends eo{constructor(){super(()=>new ZI)}}const vI=new _y,aB=new F.Vector3,Vi=new F.Vector3;function $y(B,A,I={},g=0,Q=1/0){const C=g*g,E=Q*Q;let i=1/0,D=null;if(B.shapecast({boundsTraverseOrder:s=>(aB.copy(A).clamp(s.min,s.max),aB.distanceToSquared(A)),intersectsBounds:(s,t,w)=>w<i&&w<E,intersectsTriangle:(s,t)=>{s.closestPointToPoint(A,aB);const w=A.distanceToSquared(aB);return w<i&&(Vi.copy(aB),i=w,D=t),w<C}}),i===1/0)return null;const o=Math.sqrt(i);return I.point?I.point.copy(Vi):I.point=Vi.clone(),I.distance=o,I.faceIndex=D,I}const $C=parseInt(F.REVISION)>=169,AG=parseInt(F.REVISION)<=161,AQ=new F.Vector3,IQ=new F.Vector3,gQ=new F.Vector3,AE=new F.Vector2,IE=new F.Vector2,gE=new F.Vector2,Vs=new F.Vector3,Zs=new F.Vector3,Ws=new F.Vector3,eB=new F.Vector3;function IG(B,A,I,g,Q,C,E,i){let D;if(C===F.BackSide?D=B.intersectTriangle(g,I,A,!0,Q):D=B.intersectTriangle(A,I,g,C!==F.DoubleSide,Q),D===null)return null;const o=B.origin.distanceTo(Q);return o<E||o>i?null:{distance:o,point:Q.clone()}}function js(B,A,I,g,Q,C,E,i,D,o,s){AQ.fromBufferAttribute(A,C),IQ.fromBufferAttribute(A,E),gQ.fromBufferAttribute(A,i);const t=IG(B,AQ,IQ,gQ,eB,D,o,s);if(t){if(g){AE.fromBufferAttribute(g,C),IE.fromBufferAttribute(g,E),gE.fromBufferAttribute(g,i),t.uv=new F.Vector2;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,AE,IE,gE,t.uv);$C||(t.uv=a)}if(Q){AE.fromBufferAttribute(Q,C),IE.fromBufferAttribute(Q,E),gE.fromBufferAttribute(Q,i),t.uv1=new F.Vector2;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,AE,IE,gE,t.uv1);$C||(t.uv1=a),AG&&(t.uv2=t.uv1)}if(I){Vs.fromBufferAttribute(I,C),Zs.fromBufferAttribute(I,E),Ws.fromBufferAttribute(I,i),t.normal=new F.Vector3;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,Vs,Zs,Ws,t.normal);t.normal.dot(B.direction)>0&&t.normal.multiplyScalar(-1),$C||(t.normal=a)}const w={a:C,b:E,c:i,normal:new F.Vector3,materialIndex:0};if(F.Triangle.getNormal(AQ,IQ,gQ,w.normal),t.face=w,t.faceIndex=C,$C){const a=new F.Vector3;F.Triangle.getBarycoord(eB,AQ,IQ,gQ,a),t.barycoord=a}}return t}function zs(B){return B&&B.isMaterial?B.side:B}function Ii(B,A,I,g,Q,C,E){const i=g*3;let D=i+0,o=i+1,s=i+2;const{index:t,groups:w}=B;B.index&&(D=t.getX(D),o=t.getX(o),s=t.getX(s));const{position:a,normal:y,uv:R,uv1:n}=B.attributes;if(Array.isArray(A)){const h=g*3;for(let G=0,r=w.length;G<r;G++){const{start:M,count:k,materialIndex:J}=w[G];if(h>=M&&h<M+k){const U=zs(A[J]),Y=js(I,a,y,R,n,D,o,s,U,C,E);if(Y)if(Y.faceIndex=g,Y.face.materialIndex=J,Q)Q.push(Y);else return Y}}}else{const h=zs(A),G=js(I,a,y,R,n,D,o,s,h,C,E);if(G)if(G.faceIndex=g,G.face.materialIndex=0,Q)Q.push(G);else return G}return null}function TA(B,A,I,g){const Q=B.a,C=B.b,E=B.c;let i=A,D=A+1,o=A+2;I&&(i=I.getX(i),D=I.getX(D),o=I.getX(o)),Q.x=g.getX(i),Q.y=g.getY(i),Q.z=g.getZ(i),C.x=g.getX(D),C.y=g.getY(D),C.z=g.getZ(D),E.x=g.getX(o),E.y=g.getY(o),E.z=g.getZ(o)}function gG(B,A,I,g,Q,C,E,i){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++)Ii(D,A,I,s,C,E,i)}function QG(B,A,I,g,Q,C,E){const{geometry:i,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=Ii(i,A,I,t,null,C,E),a&&a.distance<o&&(s=a,o=a.distance)}return s}function BG(B,A,I,g,Q,C,E){const{geometry:i}=I,{index:D}=i,o=i.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=s,TA(E,w*3,D,o),E.needsUpdate=!0,g(E,w,Q,C))return!0}return!1}function CG(B,A=null){A&&Array.isArray(A)&&(A=new Set(A));const I=B.geometry,g=I.index?I.index.array:null,Q=I.attributes.position;let C,E,i,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],E=new Uint32Array(C),i=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,y=!1){const R=w*2;if(VA(R,i)){const n=aI(w,E),h=RI(R,i);let G=1/0,r=1/0,M=1/0,k=-1/0,J=-1/0,U=-1/0;for(let Y=3*n,d=3*(n+h);Y<d;Y++){let H=g[Y];const f=Q.getX(H),l=Q.getY(H),p=Q.getZ(H);f<G&&(G=f),f>k&&(k=f),l<r&&(r=l),l>J&&(J=l),p<M&&(M=p),p>U&&(U=p)}return D[w+0]!==G||D[w+1]!==r||D[w+2]!==M||D[w+3]!==k||D[w+4]!==J||D[w+5]!==U?(D[w+0]=G,D[w+1]=r,D[w+2]=M,D[w+3]=k,D[w+4]=J,D[w+5]=U,!0):!1}else{const n=AI(w),h=II(w,E);let G=y,r=!1,M=!1;if(A){if(!G){const H=n/vA+a/wI,f=h/vA+a/wI;r=A.has(H),M=A.has(f),G=!r&&!M}}else r=!0,M=!0;const k=G||r,J=G||M;let U=!1;k&&(U=t(n,a,G));let Y=!1;J&&(Y=t(h,a,G));const d=U||Y;if(d)for(let H=0;H<3;H++){const f=n+H,l=h+H,p=D[f],q=D[f+3],m=D[l],T=D[l+3];D[w+H]=p<m?p:m,D[w+H+3]=q>T?q:T}return d}}}function Wg(B,A,I,g,Q){let C,E,i,D,o,s;const t=1/I.direction.x,w=1/I.direction.y,a=1/I.direction.z,y=I.origin.x,R=I.origin.y,n=I.origin.z;let h=A[B],G=A[B+3],r=A[B+1],M=A[B+3+1],k=A[B+2],J=A[B+3+2];return t>=0?(C=(h-y)*t,E=(G-y)*t):(C=(G-y)*t,E=(h-y)*t),w>=0?(i=(r-R)*w,D=(M-R)*w):(i=(M-R)*w,D=(r-R)*w),C>D||i>E||((i>C||isNaN(C))&&(C=i),(D<E||isNaN(E))&&(E=D),a>=0?(o=(k-n)*a,s=(J-n)*a):(o=(J-n)*a,s=(k-n)*a),C>s||o>E)?!1:((o>C||C!==C)&&(C=o),(s<E||E!==E)&&(E=s),C<=Q&&E>=g)}function EG(B,A,I,g,Q,C,E,i){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++){let w=o?o[s]:s;Ii(D,A,I,w,C,E,i)}}function iG(B,A,I,g,Q,C,E){const{geometry:i,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=Ii(i,A,I,D?D[t]:t,null,C,E),a&&a.distance<o&&(s=a,o=a.distance)}return s}function DG(B,A,I,g,Q,C,E){const{geometry:i}=I,{index:D}=i,o=i.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=I.resolveTriangleIndex(s),TA(E,w*3,D,o),E.needsUpdate=!0,g(E,w,Q,C))return!0}return!1}function oG(B,A,I,g,Q,C,E){KA.setBuffer(B._roots[A]),KD(0,B,I,g,Q,C,E),KA.clearBuffer()}function KD(B,A,I,g,Q,C,E){const{float32Array:i,uint16Array:D,uint32Array:o}=KA,s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);gG(A,I,g,w,a,Q,C,E)}else{const w=AI(B);Wg(w,i,g,C,E)&&KD(w,A,I,g,Q,C,E);const a=II(B,o);Wg(a,i,g,C,E)&&KD(a,A,I,g,Q,C,E)}}const sG=["x","y","z"];function tG(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const E=dD(0,B,I,g,Q,C);return KA.clearBuffer(),E}function dD(B,A,I,g,Q,C){const{float32Array:E,uint16Array:i,uint32Array:D}=KA;let o=B*2;if(VA(o,i)){const t=aI(B,D),w=RI(o,i);return QG(A,I,g,t,w,Q,C)}else{const t=ao(B,D),w=sG[t],y=g.direction[w]>=0;let R,n;y?(R=AI(B),n=II(B,D)):(R=II(B,D),n=AI(B));const G=Wg(R,E,g,Q,C)?dD(R,A,I,g,Q,C):null;if(G){const k=G.point[w];if(y?k<=E[n+t]:k>=E[n+t+3])return G}const M=Wg(n,E,g,Q,C)?dD(n,A,I,g,Q,C):null;return G&&M?G.distance<=M.distance?G:M:G||M||null}}const QE=new F.Box3,pQ=new ZI,uQ=new ZI,cB=new F.Matrix4,_s=new cI,BE=new cI;function wG(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=lD(0,B,I,g);return KA.clearBuffer(),Q}function lD(B,A,I,g,Q=null){const{float32Array:C,uint16Array:E,uint32Array:i}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),_s.set(I.boundingBox.min,I.boundingBox.max,g),Q=_s),VA(D,E)){const s=A.geometry,t=s.index,w=s.attributes.position,a=I.index,y=I.attributes.position,R=aI(B,i),n=RI(D,E);if(cB.copy(g).invert(),I.boundsTree)return pA(B,C,BE),BE.matrix.copy(cB),BE.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:G=>BE.intersectsBox(G),intersectsTriangle:G=>{G.a.applyMatrix4(g),G.b.applyMatrix4(g),G.c.applyMatrix4(g),G.needsUpdate=!0;for(let r=R*3,M=(n+R)*3;r<M;r+=3)if(TA(uQ,r,t,w),uQ.needsUpdate=!0,G.intersectsTriangle(uQ))return!0;return!1}});{const h=Ai(I);for(let G=R*3,r=(n+R)*3;G<r;G+=3){TA(pQ,G,t,w),pQ.a.applyMatrix4(cB),pQ.b.applyMatrix4(cB),pQ.c.applyMatrix4(cB),pQ.needsUpdate=!0;for(let M=0,k=h*3;M<k;M+=3)if(TA(uQ,M,a,y),uQ.needsUpdate=!0,pQ.intersectsTriangle(uQ))return!0}}}else{const s=AI(B),t=II(B,i);return pA(s,C,QE),!!(Q.intersectsBox(QE)&&lD(s,A,I,g,Q)||(pA(t,C,QE),Q.intersectsBox(QE)&&lD(t,A,I,g,Q)))}}const CE=new F.Matrix4,Zi=new cI,nB=new cI,aG=new F.Vector3,eG=new F.Vector3,cG=new F.Vector3,nG=new F.Vector3;function hG(B,A,I,g={},Q={},C=0,E=1/0){A.boundingBox||A.computeBoundingBox(),Zi.set(A.boundingBox.min,A.boundingBox.max,I),Zi.needsUpdate=!0;const i=B.geometry,D=i.attributes.position,o=i.index,s=A.attributes.position,t=A.index,w=vI.getPrimitive(),a=vI.getPrimitive();let y=aG,R=eG,n=null,h=null;Q&&(n=cG,h=nG);let G=1/0,r=null,M=null;return CE.copy(I).invert(),nB.matrix.copy(CE),B.shapecast({boundsTraverseOrder:k=>Zi.distanceToBox(k),intersectsBounds:(k,J,U)=>U<G&&U<E?(J&&(nB.min.copy(k.min),nB.max.copy(k.max),nB.needsUpdate=!0),!0):!1,intersectsRange:(k,J)=>{if(A.boundsTree)return A.boundsTree.shapecast({boundsTraverseOrder:Y=>nB.distanceToBox(Y),intersectsBounds:(Y,d,H)=>H<G&&H<E,intersectsRange:(Y,d)=>{for(let H=Y,f=Y+d;H<f;H++){TA(a,3*H,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let l=k,p=k+J;l<p;l++){TA(w,3*l,o,D),w.needsUpdate=!0;const q=w.distanceToTriangle(a,y,n);if(q<G&&(R.copy(y),h&&h.copy(n),G=q,r=l,M=H),q<C)return!0}}}});{const U=Ai(A);for(let Y=0,d=U;Y<d;Y++){TA(a,3*Y,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let H=k,f=k+J;H<f;H++){TA(w,3*H,o,D),w.needsUpdate=!0;const l=w.distanceToTriangle(a,y,n);if(l<G&&(R.copy(y),h&&h.copy(n),G=l,r=H,M=Y),l<C)return!0}}}}}),vI.releasePrimitive(w),vI.releasePrimitive(a),G===1/0?null:(g.point?g.point.copy(R):g.point=R.clone(),g.distance=G,g.faceIndex=r,Q&&(Q.point?Q.point.copy(h):Q.point=h.clone(),Q.point.applyMatrix4(CE),R.applyMatrix4(CE),Q.distance=R.sub(Q.point).length(),Q.faceIndex=M),g)}function yG(B,A=null){A&&Array.isArray(A)&&(A=new Set(A));const I=B.geometry,g=I.index?I.index.array:null,Q=I.attributes.position;let C,E,i,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],E=new Uint32Array(C),i=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,y=!1){const R=w*2;if(VA(R,i)){const n=aI(w,E),h=RI(R,i);let G=1/0,r=1/0,M=1/0,k=-1/0,J=-1/0,U=-1/0;for(let Y=n,d=n+h;Y<d;Y++){const H=3*B.resolveTriangleIndex(Y);for(let f=0;f<3;f++){let l=H+f;l=g?g[l]:l;const p=Q.getX(l),q=Q.getY(l),m=Q.getZ(l);p<G&&(G=p),p>k&&(k=p),q<r&&(r=q),q>J&&(J=q),m<M&&(M=m),m>U&&(U=m)}}return D[w+0]!==G||D[w+1]!==r||D[w+2]!==M||D[w+3]!==k||D[w+4]!==J||D[w+5]!==U?(D[w+0]=G,D[w+1]=r,D[w+2]=M,D[w+3]=k,D[w+4]=J,D[w+5]=U,!0):!1}else{const n=AI(w),h=II(w,E);let G=y,r=!1,M=!1;if(A){if(!G){const H=n/vA+a/wI,f=h/vA+a/wI;r=A.has(H),M=A.has(f),G=!r&&!M}}else r=!0,M=!0;const k=G||r,J=G||M;let U=!1;k&&(U=t(n,a,G));let Y=!1;J&&(Y=t(h,a,G));const d=U||Y;if(d)for(let H=0;H<3;H++){const f=n+H,l=h+H,p=D[f],q=D[f+3],m=D[l],T=D[l+3];D[w+H]=p<m?p:m,D[w+H+3]=q>T?q:T}return d}}}function GG(B,A,I,g,Q,C,E){KA.setBuffer(B._roots[A]),fD(0,B,I,g,Q,C,E),KA.clearBuffer()}function fD(B,A,I,g,Q,C,E){const{float32Array:i,uint16Array:D,uint32Array:o}=KA,s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);EG(A,I,g,w,a,Q,C,E)}else{const w=AI(B);Wg(w,i,g,C,E)&&fD(w,A,I,g,Q,C,E);const a=II(B,o);Wg(a,i,g,C,E)&&fD(a,A,I,g,Q,C,E)}}const rG=["x","y","z"];function SG(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const E=xD(0,B,I,g,Q,C);return KA.clearBuffer(),E}function xD(B,A,I,g,Q,C){const{float32Array:E,uint16Array:i,uint32Array:D}=KA;let o=B*2;if(VA(o,i)){const t=aI(B,D),w=RI(o,i);return iG(A,I,g,t,w,Q,C)}else{const t=ao(B,D),w=rG[t],y=g.direction[w]>=0;let R,n;y?(R=AI(B),n=II(B,D)):(R=II(B,D),n=AI(B));const G=Wg(R,E,g,Q,C)?xD(R,A,I,g,Q,C):null;if(G){const k=G.point[w];if(y?k<=E[n+t]:k>=E[n+t+3])return G}const M=Wg(n,E,g,Q,C)?xD(n,A,I,g,Q,C):null;return G&&M?G.distance<=M.distance?G:M:G||M||null}}const EE=new F.Box3,qQ=new ZI,bQ=new ZI,hB=new F.Matrix4,$s=new cI,iE=new cI;function RG(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=pD(0,B,I,g);return KA.clearBuffer(),Q}function pD(B,A,I,g,Q=null){const{float32Array:C,uint16Array:E,uint32Array:i}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),$s.set(I.boundingBox.min,I.boundingBox.max,g),Q=$s),VA(D,E)){const s=A.geometry,t=s.index,w=s.attributes.position,a=I.index,y=I.attributes.position,R=aI(B,i),n=RI(D,E);if(hB.copy(g).invert(),I.boundsTree)return pA(B,C,iE),iE.matrix.copy(hB),iE.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:G=>iE.intersectsBox(G),intersectsTriangle:G=>{G.a.applyMatrix4(g),G.b.applyMatrix4(g),G.c.applyMatrix4(g),G.needsUpdate=!0;for(let r=R,M=n+R;r<M;r++)if(TA(bQ,3*A.resolveTriangleIndex(r),t,w),bQ.needsUpdate=!0,G.intersectsTriangle(bQ))return!0;return!1}});{const h=Ai(I);for(let G=R,r=n+R;G<r;G++){const M=A.resolveTriangleIndex(G);TA(qQ,3*M,t,w),qQ.a.applyMatrix4(hB),qQ.b.applyMatrix4(hB),qQ.c.applyMatrix4(hB),qQ.needsUpdate=!0;for(let k=0,J=h*3;k<J;k+=3)if(TA(bQ,k,a,y),bQ.needsUpdate=!0,qQ.intersectsTriangle(bQ))return!0}}}else{const s=AI(B),t=II(B,i);return pA(s,C,EE),!!(Q.intersectsBox(EE)&&pD(s,A,I,g,Q)||(pA(t,C,EE),Q.intersectsBox(EE)&&pD(t,A,I,g,Q)))}}const DE=new F.Matrix4,Wi=new cI,yB=new cI,FG=new F.Vector3,kG=new F.Vector3,MG=new F.Vector3,NG=new F.Vector3;function JG(B,A,I,g={},Q={},C=0,E=1/0){A.boundingBox||A.computeBoundingBox(),Wi.set(A.boundingBox.min,A.boundingBox.max,I),Wi.needsUpdate=!0;const i=B.geometry,D=i.attributes.position,o=i.index,s=A.attributes.position,t=A.index,w=vI.getPrimitive(),a=vI.getPrimitive();let y=FG,R=kG,n=null,h=null;Q&&(n=MG,h=NG);let G=1/0,r=null,M=null;return DE.copy(I).invert(),yB.matrix.copy(DE),B.shapecast({boundsTraverseOrder:k=>Wi.distanceToBox(k),intersectsBounds:(k,J,U)=>U<G&&U<E?(J&&(yB.min.copy(k.min),yB.max.copy(k.max),yB.needsUpdate=!0),!0):!1,intersectsRange:(k,J)=>{if(A.boundsTree){const U=A.boundsTree;return U.shapecast({boundsTraverseOrder:Y=>yB.distanceToBox(Y),intersectsBounds:(Y,d,H)=>H<G&&H<E,intersectsRange:(Y,d)=>{for(let H=Y,f=Y+d;H<f;H++){const l=U.resolveTriangleIndex(H);TA(a,3*l,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let p=k,q=k+J;p<q;p++){const m=B.resolveTriangleIndex(p);TA(w,3*m,o,D),w.needsUpdate=!0;const T=w.distanceToTriangle(a,y,n);if(T<G&&(R.copy(y),h&&h.copy(n),G=T,r=p,M=H),T<C)return!0}}}})}else{const U=Ai(A);for(let Y=0,d=U;Y<d;Y++){TA(a,3*Y,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let H=k,f=k+J;H<f;H++){const l=B.resolveTriangleIndex(H);TA(w,3*l,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,y,n);if(p<G&&(R.copy(y),h&&h.copy(n),G=p,r=H,M=Y),p<C)return!0}}}}}),vI.releasePrimitive(w),vI.releasePrimitive(a),G===1/0?null:(g.point?g.point.copy(R):g.point=R.clone(),g.distance=G,g.faceIndex=r,Q&&(Q.point?Q.point.copy(h):Q.point=h.clone(),Q.point.applyMatrix4(DE),R.applyMatrix4(DE),Q.distance=R.sub(Q.point).length(),Q.faceIndex=M),g)}function At(B,A,I){return B===null?null:(B.point.applyMatrix4(A.matrixWorld),B.distance=B.point.distanceTo(I.ray.origin),B.object=A,B)}const oE=new cI,sE=new F.Ray,It=new F.Vector3,gt=new F.Matrix4,Qt=new F.Vector3,ji=["getX","getY","getZ"];class gB extends ra{static serialize(A,I={}){I={cloneBuffers:!0,...I};const g=A.geometry,Q=A._roots,C=A._indirectBuffer,E=g.getIndex(),i={version:1,roots:null,index:null,indirectBuffer:null};return I.cloneBuffers?(i.roots=Q.map(D=>D.slice()),i.index=E?E.array.slice():null,i.indirectBuffer=C?C.slice():null):(i.roots=Q,i.index=E?E.array:null,i.indirectBuffer=C),i}static deserialize(A,I,g={}){g={setIndex:!0,indirect:!!A.indirectBuffer,...g};const{index:Q,roots:C,indirectBuffer:E}=A;A.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),D(C));const i=new gB(I,{...g,[$E]:!0});if(i._roots=C,i._indirectBuffer=E||null,g.setIndex){const o=I.getIndex();if(o===null){const s=new F.BufferAttribute(A.index,1,!1);I.setIndex(s)}else o.array!==Q&&(o.array.set(Q),o.needsUpdate=!0)}return i;function D(o){for(let s=0;s<o.length;s++){const t=o[s],w=new Uint32Array(t),a=new Uint16Array(t);for(let y=0,R=t.byteLength/wI;y<R;y++){const n=vA*y,h=2*n;VA(h,a)||(w[n+6]=w[n+6]/vA-y)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(A,I={}){I.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),I={...I,maxLeafSize:I.maxLeafTris}),super(A,I)}shiftTriangleOffsets(A){return super.shiftPrimitiveOffsets(A)}writePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,E=Q.attributes.position,i=Q.index?Q.index.array:null,o=(C?C[A]:A)*3;let s=o+0,t=o+1,w=o+2;i&&(s=i[s],t=i[t],w=i[w]);for(let a=0;a<3;a++){const y=E[ji[a]](s),R=E[ji[a]](t),n=E[ji[a]](w);let h=y;R<h&&(h=R),n<h&&(h=n);let G=y;R>G&&(G=R),n>G&&(G=n),I[g+a]=h,I[g+a+3]=G}return I}computePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,E=Q.attributes.position,i=Q.index?Q.index.array:null,D=E.normalized;if(A<0||I+A-g.offset>g.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const o=E.array,s=E.offset||0;let t=3;E.isInterleavedBufferAttribute&&(t=E.data.stride);const w=["getX","getY","getZ"],a=g.offset;for(let y=A,R=A+I;y<R;y++){const h=(C?C[y]:y)*3,G=(y-a)*6;let r=h+0,M=h+1,k=h+2;i&&(r=i[r],M=i[M],k=i[k]),D||(r=r*t+s,M=M*t+s,k=k*t+s);for(let J=0;J<3;J++){let U,Y,d;D?(U=E[w[J]](r),Y=E[w[J]](M),d=E[w[J]](k)):(U=o[r+J],Y=o[M+J],d=o[k+J]);let H=U;Y<H&&(H=Y),d<H&&(H=d);let f=U;Y>f&&(f=Y),d>f&&(f=d);const l=(f-H)/2,p=J*2;g[G+p+0]=H+l,g[G+p+1]=l+(Math.abs(H)+l)*SE}}return g}raycastObject3D(A,I,g=[]){const{material:Q}=A;if(Q===void 0)return;gt.copy(A.matrixWorld).invert(),sE.copy(I.ray).applyMatrix4(gt),Qt.setFromMatrixScale(A.matrixWorld),It.copy(sE.direction).multiply(Qt);const C=It.length(),E=I.near/C,i=I.far/C;if(I.firstHitOnly===!0){let D=this.raycastFirst(sE,Q,E,i);D=At(D,A,I),D&&g.push(D)}else{const D=this.raycast(sE,Q,E,i);for(let o=0,s=D.length;o<s;o++){const t=At(D[o],A,I);t&&g.push(t)}}return g}refit(A=null){return(this.indirect?yG:CG)(this,A)}raycast(A,I=F.FrontSide,g=0,Q=1/0){const C=this._roots,E=[],i=this.indirect?GG:oG;for(let D=0,o=C.length;D<o;D++)i(this,D,I,A,E,g,Q);return E}raycastFirst(A,I=F.FrontSide,g=0,Q=1/0){const C=this._roots;let E=null;const i=this.indirect?SG:tG;for(let D=0,o=C.length;D<o;D++){const s=i(this,D,I,A,g,Q);s!=null&&(E==null||s.distance<E.distance)&&(E=s)}return E}intersectsGeometry(A,I){let g=!1;const Q=this._roots,C=this.indirect?RG:wG;for(let E=0,i=Q.length;E<i&&(g=C(this,E,A,I),!g);E++);return g}shapecast(A){const I=vI.getPrimitive(),g=super.shapecast({...A,intersectsPrimitive:A.intersectsTriangle,scratchPrimitive:I,iterate:this.indirect?DG:BG});return vI.releasePrimitive(I),g}bvhcast(A,I,g){let{intersectsRanges:Q,intersectsTriangles:C}=g;const E=vI.getPrimitive(),i=this.geometry.index,D=this.geometry.attributes.position,o=this.indirect?y=>{const R=this.resolveTriangleIndex(y);TA(E,R*3,i,D)}:y=>{TA(E,y*3,i,D)},s=vI.getPrimitive(),t=A.geometry.index,w=A.geometry.attributes.position,a=A.indirect?y=>{const R=A.resolveTriangleIndex(y);TA(s,R*3,t,w)}:y=>{TA(s,y*3,t,w)};if(C){if(!(A instanceof gB))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const y=(R,n,h,G,r,M,k,J)=>{for(let U=h,Y=h+G;U<Y;U++){a(U),s.a.applyMatrix4(I),s.b.applyMatrix4(I),s.c.applyMatrix4(I),s.needsUpdate=!0;for(let d=R,H=R+n;d<H;d++)if(o(d),E.needsUpdate=!0,C(E,s,d,U,r,M,k,J))return!0}return!1};if(Q){const R=Q;Q=function(n,h,G,r,M,k,J,U){return R(n,h,G,r,M,k,J,U)?!0:y(n,h,G,r,M,k,J,U)}}else Q=y}return super.bvhcast(A,I,{intersectsRanges:Q})}intersectsBox(A,I){return oE.set(A.min,A.max,I),oE.needsUpdate=!0,this.shapecast({intersectsBounds:g=>oE.intersectsBox(g),intersectsTriangle:g=>oE.intersectsTriangle(g)})}intersectsSphere(A){return this.shapecast({intersectsBounds:I=>A.intersectsBox(I),intersectsTriangle:I=>I.intersectsSphere(A)})}closestPointToGeometry(A,I,g={},Q={},C=0,E=1/0){return(this.indirect?JG:hG)(this,A,I,g,Q,C,E)}closestPointToPoint(A,I={},g=0,Q=1/0){return $y(this,A,I,g,Q)}}const PQ={Mesh:F.Mesh.prototype.raycast,Line:F.Line.prototype.raycast,LineSegments:F.LineSegments.prototype.raycast,LineLoop:F.LineLoop.prototype.raycast,Points:F.Points.prototype.raycast,BatchedMesh:F.BatchedMesh.prototype.raycast},CI=new F.Mesh,tE=[];function UG(B,A){if(this.isBatchedMesh)LG.call(this,B,A);else{const{geometry:I}=this;if(I.boundsTree)I.boundsTree.raycastObject3D(this,B,A);else{let g;if(this instanceof F.Mesh)g=PQ.Mesh;else if(this instanceof F.LineSegments)g=PQ.LineSegments;else if(this instanceof F.LineLoop)g=PQ.LineLoop;else if(this instanceof F.Line)g=PQ.Line;else if(this instanceof F.Points)g=PQ.Points;else throw new Error("BVH: Fallback raycast function not found.");g.call(this,B,A)}}}function LG(B,A){if(this.boundsTrees){const I=this.boundsTrees,g=this._drawInfo||this._instanceInfo,Q=this._drawRanges||this._geometryInfo,C=this.matrixWorld;CI.material=this.material,CI.geometry=this.geometry;const E=CI.geometry.boundsTree,i=CI.geometry.drawRange;CI.geometry.boundingSphere===null&&(CI.geometry.boundingSphere=new F.Sphere);for(let D=0,o=g.length;D<o;D++){if(!this.getVisibleAt(D))continue;const s=g[D].geometryIndex;if(CI.geometry.boundsTree=I[s],this.getMatrixAt(D,CI.matrixWorld).premultiply(C),!CI.geometry.boundsTree){this.getBoundingBoxAt(s,CI.geometry.boundingBox),this.getBoundingSphereAt(s,CI.geometry.boundingSphere);const t=Q[s];CI.geometry.setDrawRange(t.start,t.count)}CI.raycast(B,tE);for(let t=0,w=tE.length;t<w;t++){const a=tE[t];a.object=this,a.batchId=D,A.push(a)}tE.length=0}CI.geometry.boundsTree=E,CI.geometry.drawRange=i,CI.material=null,CI.geometry=null}else PQ.BatchedMesh.call(this,B,A)}function HG(B={}){const{type:A=gB}=B;return this.boundsTree=new A(this,B),this.boundsTree}const QQ=new F.Vector3,BQ=new F.Vector3,CQ=new F.Vector3,Bt=new F.Vector4,wE=new F.Vector3,zi=new F.Vector3,Ct=new F.Vector4,Et=new F.Vector4,aE=new F.Matrix4,it=new F.Matrix4;function GB(B,A){if(!B&&!A)return;const I=B.count===A.count,g=B.normalized===A.normalized,Q=B.array.constructor===A.array.constructor,C=B.itemSize===A.itemSize;if(!I||!g||!Q||!C)throw new Error}function YB(B,A=null){const I=B.array.constructor,g=B.normalized,Q=B.itemSize,C=A===null?B.count:A;return new F.BufferAttribute(new I(Q*C),Q,g)}function Sa(B,A,I=0){if(B.isInterleavedBufferAttribute){const g=B.itemSize;for(let Q=0,C=B.count;Q<C;Q++){const E=Q+I;A.setX(E,B.getX(Q)),g>=2&&A.setY(E,B.getY(Q)),g>=3&&A.setZ(E,B.getZ(Q)),g>=4&&A.setW(E,B.getW(Q))}}else{const g=A.array,Q=g.constructor,C=g.BYTES_PER_ELEMENT*B.itemSize*I;new Q(g.buffer,C,B.array.length).set(B.array)}}function YG(B,A,I){const g=B.elements,Q=A.elements;for(let C=0,E=Q.length;C<E;C++)g[C]+=Q[C]*I}function Dt(B,A,I){const g=B.skeleton,Q=B.geometry,C=g.bones,E=g.boneInverses;Ct.fromBufferAttribute(Q.attributes.skinIndex,A),Et.fromBufferAttribute(Q.attributes.skinWeight,A),aE.elements.fill(0);for(let i=0;i<4;i++){const D=Et.getComponent(i);if(D!==0){const o=Ct.getComponent(i);it.multiplyMatrices(C[o].matrixWorld,E[o]),YG(aE,it,D)}}return aE.multiply(B.bindMatrix).premultiply(B.bindMatrixInverse),I.transformDirection(aE),I}function _i(B,A,I,g,Q){wE.set(0,0,0);for(let C=0,E=B.length;C<E;C++){const i=A[C],D=B[C];i!==0&&(zi.fromBufferAttribute(D,g),I?wE.addScaledVector(zi,i):wE.addScaledVector(zi.sub(Q),i))}Q.add(wE)}function KG(B,A={useGroups:!1,updateIndex:!1,skipAttributes:[]},I=new F.BufferGeometry){const g=B[0].index!==null,{useGroups:Q=!1,updateIndex:C=!1,skipAttributes:E=[]}=A,i=new Set(Object.keys(B[0].attributes)),D={};let o=0;I.clearGroups();for(let s=0;s<B.length;++s){const t=B[s];let w=0;if(g!==(t.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 a in t.attributes){if(!i.has(a))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+a+'" attribute exists among all geometries, or in none of them.');D[a]===void 0&&(D[a]=[]),D[a].push(t.attributes[a]),w++}if(w!==i.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(Q){let a;if(g)a=t.index.count;else if(t.attributes.position!==void 0)a=t.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");I.addGroup(o,a,s),o+=a}}if(g){let s=!1;if(!I.index){let t=0;for(let w=0;w<B.length;++w)t+=B[w].index.count;I.setIndex(new F.BufferAttribute(new Uint32Array(t),1,!1)),s=!0}if(C||s){const t=I.index;let w=0,a=0;for(let y=0;y<B.length;++y){const R=B[y],n=R.index;if(E[y]!==!0)for(let h=0;h<n.count;++h)t.setX(w,n.getX(h)+a),w++;a+=R.attributes.position.count}}}for(const s in D){const t=D[s];if(!(s in I.attributes)){let y=0;for(const R in t)y+=t[R].count;I.setAttribute(s,YB(D[s][0],y))}const w=I.attributes[s];let a=0;for(let y=0,R=t.length;y<R;y++){const n=t[y];E[y]!==!0&&Sa(n,w,a),a+=n.count}}return I}function dG(B,A){if(B===null||A===null)return B===A;if(B.length!==A.length)return!1;for(let I=0,g=B.length;I<g;I++)if(B[I]!==A[I])return!1;return!0}function lG(B){const{index:A,attributes:I}=B;if(A)for(let g=0,Q=A.count;g<Q;g+=3){const C=A.getX(g),E=A.getX(g+2);A.setX(g,E),A.setX(g+2,C)}else for(const g in I){const Q=I[g],C=Q.itemSize;for(let E=0,i=Q.count;E<i;E+=3)for(let D=0;D<C;D++){const o=Q.getComponent(E,D),s=Q.getComponent(E+2,D);Q.setComponent(E,D,s),Q.setComponent(E+2,D,o)}}return B}class fG{constructor(A){this.matrixWorld=new F.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=A,this.update()}update(){const A=this.mesh,I=A.geometry,g=A.skeleton,Q=(I.index?I.index.count:I.attributes.position.count)/3;if(this.matrixWorld.copy(A.matrixWorld),this.geometryHash=I.attributes.position.version,this.primitiveCount=Q,g){g.boneTexture||g.computeBoneTexture(),g.update();const C=g.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==C.length?this.boneMatrices=C.slice():this.boneMatrices.set(C)}else this.boneMatrices=null}didChange(){const A=this.mesh,I=A.geometry,g=(I.index?I.index.count:I.attributes.position.count)/3;return!(this.matrixWorld.equals(A.matrixWorld)&&this.geometryHash===I.attributes.position.version&&dG(A.skeleton&&A.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===g)}}class xG{constructor(A){Array.isArray(A)||(A=[A]);const I=[];A.forEach(g=>{g.traverseVisible(Q=>{Q.isMesh&&I.push(Q)})}),this.meshes=I,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(I.length).fill().map(()=>new F.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const A=[];return this.meshes.forEach(I=>{Array.isArray(I.material)?A.push(...I.material):A.push(I.material)}),A}generate(A=new F.BufferGeometry){let I=[];const{meshes:g,useGroups:Q,_intermediateGeometry:C,_diffMap:E}=this;for(let i=0,D=g.length;i<D;i++){const o=g[i],s=C[i],t=E.get(o);!t||t.didChange(o)?(this._convertToStaticGeometry(o,s),I.push(!1),t?t.update():E.set(o,new fG(o))):I.push(!0)}if(C.length===0){A.setIndex(null);const i=A.attributes;for(const D in i)A.deleteAttribute(D);for(const D in this.attributes)A.setAttribute(this.attributes[D],new F.BufferAttribute(new Float32Array(0),4,!1))}else KG(C,{useGroups:Q,skipAttributes:I},A);for(const i in A.attributes)A.attributes[i].needsUpdate=!0;return A}_convertToStaticGeometry(A,I=new F.BufferGeometry){const g=A.geometry,Q=this.applyWorldTransforms,C=this.attributes.includes("normal"),E=this.attributes.includes("tangent"),i=g.attributes,D=I.attributes;!I.index&&g.index&&(I.index=g.index.clone()),D.position||I.setAttribute("position",YB(i.position)),C&&!D.normal&&i.normal&&I.setAttribute("normal",YB(i.normal)),E&&!D.tangent&&i.tangent&&I.setAttribute("tangent",YB(i.tangent)),GB(g.index,I.index),GB(i.position,D.position),C&&GB(i.normal,D.normal),E&&GB(i.tangent,D.tangent);const o=i.position,s=C?i.normal:null,t=E?i.tangent:null,w=g.morphAttributes.position,a=g.morphAttributes.normal,y=g.morphAttributes.tangent,R=g.morphTargetsRelative,n=A.morphTargetInfluences,h=new F.Matrix3;h.getNormalMatrix(A.matrixWorld),g.index&&I.index.array.set(g.index.array);for(let G=0,r=i.position.count;G<r;G++)QQ.fromBufferAttribute(o,G),s&&BQ.fromBufferAttribute(s,G),t&&(Bt.fromBufferAttribute(t,G),CQ.fromBufferAttribute(t,G)),n&&(w&&_i(w,n,R,G,QQ),a&&_i(a,n,R,G,BQ),y&&_i(y,n,R,G,CQ)),A.isSkinnedMesh&&(A.applyBoneTransform(G,QQ),s&&Dt(A,G,BQ),t&&Dt(A,G,CQ)),Q&&QQ.applyMatrix4(A.matrixWorld),D.position.setXYZ(G,QQ.x,QQ.y,QQ.z),s&&(Q&&BQ.applyNormalMatrix(h),D.normal.setXYZ(G,BQ.x,BQ.y,BQ.z)),t&&(Q&&CQ.transformDirection(A.matrixWorld),D.tangent.setXYZW(G,CQ.x,CQ.y,CQ.z,Bt.w));for(const G in this.attributes){const r=this.attributes[G];r==="position"||r==="tangent"||r==="normal"||!(r in i)||(D[r]||I.setAttribute(r,YB(i[r])),GB(i[r],D[r]),Sa(i[r],D[r]))}return A.matrixWorld.determinant()<0&&lG(I),I}}const pG=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:wa,BVH:ya,CENTER:wo,CONTAINED:JD,ExtendedTriangle:ZI,GeometryBVH:ra,MeshBVH:gB,OrientedBox:cI,SAH:aa,SKIP_GENERATION:$E,StaticGeometryGenerator:xG,acceleratedRaycast:UG,computeBoundsTree:HG,generateIndirectBuffer:Ga},Symbol.toStringTag,{value:"Module"}));class uG{constructor(A){this.name="WorkerBase",this.running=!1,this.worker=A,this.worker.onerror=I=>{throw I.message?new Error(`${this.name}: Could not create Web Worker with error "${I.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...A){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 I=this.runTask(this.worker,...A);return I.finally(()=>{this.running=!1}),I}dispose(){this.worker.terminate(),this.worker=null}}const OI={node:"node",material:"material",camera:"camera",light:"light"},DQ="KHR_animation_pointer",qG={CUBICSPLINE:void 0,LINEAR:F.InterpolateLinear,STEP:F.InterpolateDiscrete};class bG{constructor(A){this.name=DQ,this.parser=A,this.animationPointerResolver=null,this.pointerPathMap=new Map}setAnimationPointerResolver(A){return this.animationPointerResolver=A,this}loadAnimationTargetFromChannel(A){const I=A.target,g=I.node!==void 0?I.node:I.id;return this.parser.getDependency("node",g)}loadAnimationTargetFromChannelWithAnimationPointer(A){PG();const I=A.target,g=I.extensions&&I.extensions[DQ]&&I.path&&I.path==="pointer";if(!g)return null;let Q,C=OI.node,E;if(g){const D=I.extensions[DQ];let o=D.pointer;if(!o){console.warn("Invalid path",D,I);return}if(o.startsWith("/materials/")?C=OI.material:o.startsWith("/extensions/KHR_lights_punctual/lights/")?C=OI.light:o.startsWith("/cameras/")&&(C=OI.camera),E=this._tryResolveTargetId(o,C),E===null||isNaN(E)){console.warn("Failed resolving animation node id: "+E,o);return}switch(C){case OI.material:const t=("/materials/"+E.toString()+"/").length,w=o.substring(0,t);switch(Q=o.substring(t),Q){case"pbrMetallicRoughness/baseColorFactor":Q="color";break;case"pbrMetallicRoughness/roughnessFactor":Q="roughness";break;case"pbrMetallicRoughness/metallicFactor":Q="metalness";break;case"emissiveFactor":Q="emissive";break;case"alphaCutoff":Q="alphaTest";break;case"occlusionTexture/strength":Q="aoMapIntensity";break;case"normalTexture/scale":Q="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":Q="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":Q="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":Q="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":Q="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":Q="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":Q="transmission";break;case"extensions/KHR_materials_ior/ior":Q="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":Q="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":Q="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":Q="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":Q="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":Q="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":Q="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":Q="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":Q="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":Q="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":Q="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":Q="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":Q="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":Q="specularColor";break}o=w+Q;break;case OI.node:const a=("/nodes/"+E.toString()+"/").length,y=o.substring(0,a);if(Q=o.substring(a),Q.startsWith("weights/")){const G=Q.substring(8);/^\d+$/.test(G)?Q="morphTargetInfluences["+G+"]":console.warn(DQ+": invalid weight index",Q,o)}else switch(Q){case"translation":Q="position";break;case"rotation":Q="quaternion";break;case"scale":Q="scale";break;case"weights":Q="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":Q="visible";break}o=y+Q;break;case OI.light:const R=("/extensions/KHR_lights_punctual/lights/"+E.toString()+"/").length;switch(Q=o.substring(R),Q){case"color":break;case"intensity":break;case"spot/innerConeAngle":Q="penumbra";break;case"spot/outerConeAngle":Q="angle";break;case"range":Q="distance";break}o="/lights/"+E.toString()+"/"+Q;break;case OI.camera:const n=("/cameras/"+E.toString()+"/").length,h=o.substring(0,n);switch(Q=o.substring(n),Q){case"perspective/yfov":Q="fov";break;case"perspective/znear":case"orthographic/znear":Q="near";break;case"perspective/zfar":case"orthographic/zfar":Q="far";break;case"perspective/aspect":Q="aspect";break;case"orthographic/xmag":Q="zoom";break;case"orthographic/ymag":Q="zoom";break}o=h+Q;break}this.animationPointerResolver?.resolvePath&&(o=this.animationPointerResolver.resolvePath(o));const s=D.pointer;this.pointerPathMap.set(s,o)}if(E==null||isNaN(E)){console.warn("Failed resolving animation node id: "+E,I);return}let i;return C===OI.node?i=this.parser.getDependency("node",E):C===OI.material?i=this.parser.getDependency("material",E):C===OI.light?i=this.parser.getDependency("light",E):C===OI.camera?i=this.parser.getDependency("camera",E):console.error("Unhandled type",C),i}createAnimationTracksWithAnimationPointer(A,I,g,Q,C){if(!(C.extensions&&C.extensions[DQ]&&C.path&&C.path==="pointer"))return null;const i=C.extensions[DQ].pointer;let D=this.pointerPathMap.get(i);if(!D)return null;const o=[];D=D.replaceAll("/",".");const s=D.split(".");var w=A.name!==void 0&&A.name!==null?A.name:A.uuid;if(s[2]=w,s[3]?.startsWith("morphTargetInfluences")){const R=s[3];if(A.type==="Group"){for(const n of A.children)n.morphTargetInfluences&&(s[3]=n.name,s[4]=R,y(this.parser));return o}}y(this.parser);function a(R,n){try{const h=n.split(".").filter(Boolean),r=h[h.length-1].replace(/\[.*\]$/,"");return r in R?typeof R[r]=="boolean":!1}catch{return!1}}function y(R){D=s.join(".");let n,h=!1;switch(g.itemSize){case 1:Object.prototype.toString.call(g.array)==="[object Uint8Array]"&&a(A,D)?(n=F.BooleanKeyframeTrack,h=!0):n=F.NumberKeyframeTrack;break;case 2:case 3:n=F.VectorKeyframeTrack;break;case 4:D.endsWith(".quaternion")?n=F.QuaternionKeyframeTrack:n=F.ColorKeyframeTrack;break}if(!n){console.warn("Unsupported output accessor format",g);return}const G=Q.interpolation!==void 0?qG[Q.interpolation]:F.InterpolateLinear;let r=R._getArrayFromAccessor(g);D.endsWith(".fov")&&(r=r.map(k=>k/Math.PI*180)),h&&(r=r.map(k=>k>0));const M=new n(D,I.array,r,G);if(G==="CUBICSPLINE"&&R._createCubicSplineTrackInterpolant(M),o.push(M),D&&g.itemSize===4&&D.startsWith(".materials.")&&D.endsWith(".color")){const k=new Float32Array(r.length/4);for(let U=0,Y=r.length/4;U<Y;U+=1)k[U]=r[U*4+3];const J=new n(D.replace(".color",".opacity"),I.array,k,G);G==="CUBICSPLINE"&&R._createCubicSplineTrackInterpolant(M),o.push(J)}}return o}_tryResolveTargetId(A,I){let g="";return I==="node"?g=A.substring(7):I==="material"?g=A.substring(11):I==="light"?g=A.substring(39):I==="camera"&&(g=A.substring(9)),g=g.substring(0,g.indexOf("/")),Number.parseInt(g)}loadAnimation(A){const I=this,g=this.parser.json,Q=this.parser,C=g.animations[A],E=C.name?C.name:"animation_"+A,i=[],D=[],o=[],s=[],t=[];for(let w=0,a=C.channels.length;w<a;w++){const y=C.channels[w],R=C.samplers[y.sampler],n=y.target,h=C.parameters!==void 0?C.parameters[R.input]:R.input,G=C.parameters!==void 0?C.parameters[R.output]:R.output;let r=I.loadAnimationTargetFromChannelWithAnimationPointer(y);r||(r=I.loadAnimationTargetFromChannel(y)),i.push(r),D.push(Q.getDependency("accessor",h)),o.push(Q.getDependency("accessor",G)),s.push(R),t.push(n)}return Promise.all([Promise.all(i),Promise.all(D),Promise.all(o),Promise.all(s),Promise.all(t)]).then(function(w){const a=w[0],y=w[1],R=w[2],n=w[3],h=w[4],G=[];for(let r=0,M=a.length;r<M;r++){const k=a[r],J=y[r],U=R[r],Y=n[r],d=h[r];if(k===void 0)continue;k.updateMatrix&&(k.updateMatrix(),k.matrixAutoUpdate=!0);let H=I.createAnimationTracksWithAnimationPointer(k,J,U,Y,d);if(H||(H=Q._createAnimationTracks(k,J,U,Y,d)),H)for(let f=0;f<H.length;f++)G.push(H[f])}return new F.AnimationClip(E,void 0,G)})}}let ot=!1,mG=null;function PG(){if(ot)return;ot=!0;const B=mG||=F.PropertyBinding.findNode;F.PropertyBinding.findNode=function(A,I){if(!I)return B(A,I);if(I.startsWith(".materials.")){const g=I.substring(11).substring(I.indexOf(".")),Q=g.indexOf("."),C=Q<0?g:g.substring(0,Q);let E=null;return A.traverse(i=>{E!==null||i.type!=="Mesh"&&i.type!=="SkinnedMesh"||i.material&&(i.material.uuid===C||i.material.name===C)&&(E=i.material,E!==null&&(g.endsWith(".map")?E=E.map:g.endsWith(".emissiveMap")&&(E=E.emissiveMap)))}),E}else if(I.startsWith(".nodes.")||I.startsWith(".lights.")||I.startsWith(".cameras.")){const g=I.split(".");let Q;for(let C=1;C<g.length;C++){const E=g[C];if(E.length==36)Q=A.getObjectByProperty("uuid",E);else if(Q&&Q[E]){const D=Number.parseInt(E);let o=E;D>=0&&(o=D),Q=Q[o]}else{const D=A.getObjectByName(E);D&&(Q=D)}}if(!Q){const C=B(A,g[2]);return C||console.warn(DQ+": Property binding not found",I,A,A.name,g),C}return Q}return B(A,I)}}const TG=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:bG},Symbol.toStringTag,{value:"Module"}));var OG=Object.defineProperty,XG=(B,A,I)=>A in B?OG(B,A,{enumerable:!0,configurable:!0,writable:!0,value:I}):B[A]=I,PA=(B,A,I)=>(XG(B,typeof A!="symbol"?A+"":A,I),I);(function(){class B{}class A extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class I extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class g extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class Q extends B{constructor(c,S="unrestricted"){super(),PA(this,"type"),PA(this,"value"),this.value=c,this.type=S}}class C extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class E extends B{}class i extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class D extends B{}class o extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class s extends B{constructor(c,S="integer"){super(),PA(this,"value"),PA(this,"type"),this.value=c,this.type=S}}class t extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class w extends B{constructor(c,S,N){super(),PA(this,"value"),PA(this,"type"),PA(this,"unit"),this.value=c,this.type=S,this.unit=N}}class a extends B{}class y extends B{}class R extends B{}class n extends B{}class h extends B{}class G extends B{}class r extends B{}class M extends B{}class k extends B{}class J extends B{}class U extends B{}class Y extends B{}class d{constructor(c){PA(this,"input"),PA(this,"index",0),this.input=c}consume(){const c=this.input.codePointAt(this.index);return c!==void 0&&(this.index+=String.fromCodePoint(c).length),c}reconsume(c){c!==void 0&&(this.index-=String.fromCodePoint(c).length)}peek(){const c=[];let S=this.index;for(let N=0;N<3&&S<this.input.length;N++){const L=this.input.codePointAt(S);c.push(L),S+=String.fromCodePoint(L).length}return c}}function H(e){return e===10}function f(e){return H(e)||e===8192||e===32}function l(e){return e>=48&&e<=57}function p(e){return l(e)||e>=65&&e<=70||e>=97&&e<=102}function q(e){return(function(c){return(function(S){return S>=65&&S<=90})(c)||(function(S){return S>=97&&S<=122})(c)})(e)||(function(c){return c>=128})(e)||e===95}function m(e){return q(e)||l(e)||e===45}function T(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function Z(e,c){return e===92&&!H(c)}function O(e,c,S){return e===45?q(c)||c===45||Z(c,S):!!q(e)||e===92&&Z(e,c)}function j(e,c,S){return e===43||e===45?l(c)||c===46&&l(S):l(e===46?c:e)}function gA(e){const c=e.consume();if(p(c)){let S=[c];for(;p(...e.peek())&&S.length<5;)S.push(e.consume());f(...e.peek())&&e.consume();const N=parseInt(String.fromCodePoint(...S),16);return N===0||N>1114111?65533:N}return c===void 0?65533:c}function QA(e,c){const S=new C("");for(;;){const N=e.consume();if(N===c||N===void 0)return S;if(N===10)return e.reconsume(N),new E;if(N===92){const L=e.peek()[0];L===void 0||(H(L)?e.consume():S.value+=String.fromCodePoint(gA(e)))}else S.value+=String.fromCodePoint(N)}}function CA(e){let c="";for(;;){const S=e.consume();if(m(S))c+=String.fromCodePoint(S);else{if(!Z(...e.peek()))return e.reconsume(S),c;c+=String.fromCodePoint(gA(e))}}}function EA(e){let c=(function(S){let N="integer",L="";for([43,45].includes(S.peek()[0])&&(L+=String.fromCodePoint(S.consume()));l(...S.peek());)L+=String.fromCodePoint(S.consume());if(S.peek()[0]===46&&l(S.peek()[1]))for(L+=String.fromCodePoint(S.consume(),S.consume()),N="number";l(...S.peek());)L+=String.fromCodePoint(S.consume());return[69,101].includes(S.peek()[0])&&([45,43].includes(S.peek()[1])&&l(S.peek()[2])?(L+=String.fromCodePoint(S.consume(),S.consume(),S.consume()),N="number"):l(S.peek()[1])&&(L+=String.fromCodePoint(S.consume(),S.consume()),N="number")),{value:parseFloat(L),type:N}})(e);return O(...e.peek())?new w(c.value,c.type,CA(e)):e.peek()[0]===37?(e.consume(),new t(c.value)):new s(c.value,c.type)}function BA(e){for(;;){const c=e.consume();if(c===41||c===void 0)return;Z(...e.peek())&&gA(e)}}function W(e){const c=CA(e);if(c.match(/url/i)&&e.peek()[0]===40){for(e.consume();f(e.peek()[0])&&f(e.peek()[1]);)e.consume();return[34,39].includes(e.peek()[0])||f(e.peek()[0])&&[34,39].includes(e.peek()[1])?new I(c):(function(S){const N=new i("");for(;f(...S.peek());)S.consume();for(;;){const L=S.consume();if(L===41||L===void 0)return N;if(f(L)){for(;f(...S.peek());)S.consume();return S.peek()[0]===41||S.peek()[0]===void 0?(S.consume(),N):(BA(S),new D)}if([34,39,40].includes(L)||T(L))return BA(S),new D;if(L===92){if(!Z(...S.peek()))return BA(S),new D;N.value+=gA(S)}else N.value+=String.fromCodePoint(L)}})(e)}return e.peek()[0]===40?(e.consume(),new I(c)):new A(c)}function $(e){const c=e.consume(),S=e.peek();if(f(c)){for(;f(...e.peek());)e.consume();return new a}if(c===34)return QA(e,c);if(c===35){if(m(S[0])||Z(...S)){const N=new Q;return O(...S)&&(N.type="id"),N.value=CA(e),N}return new o(String.fromCodePoint(c))}return c===39?QA(e,c):c===40?new k:c===41?new J:c===43?j(...S)?(e.reconsume(c),EA(e)):new o(String.fromCodePoint(c)):c===44?new G:c===45?j(...e.peek())?(e.reconsume(c),EA(e)):e.peek()[0]===45&&e.peek()[1]===62?(e.consume(),e.consume(),new R):O(...e.peek())?(e.reconsume(c),W(e)):new o(String.fromCodePoint(c)):c===46?j(...e.peek())?(e.reconsume(c),EA(e)):new o(String.fromCodePoint(c)):c===58?new n:c===59?new h:c===60?S[0]===33&&S[1]===45&&S[2]===45?(e.consume(),e.consume(),e.consume(),new y):new o(String.fromCodePoint(c)):c===64?O(...S)?new g(CA(e)):new o(String.fromCodePoint(c)):c===91?new r:c===92?Z(...S)?(e.reconsume(c),W(e)):new o(String.fromCodePoint(c)):c===93?new M:c===123?new U:c===125?new Y:l(c)?(e.reconsume(c),EA(e)):q(c)?(e.reconsume(c),W(e)):c===void 0?void 0:new o(String.fromCodePoint(c))}const z=new Set(["px","deg","s","hz","dppx","number","fr"]);function MA(e){return z.has(e.toLowerCase())}function kA(e,c){if(["x","y"].includes(e))return e;if(!c)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const S=c.writingMode=="horizontal-tb";if(e==="block")e=S?"y":"x";else{if(e!=="inline")throw new TypeError(`Invalid axis “${e}”`);e=S?"x":"y"}return e}function NA(e){const c=[];let S=0;function N(){let K=0;const x=S;for(;S<e.length;){const b=e.slice(S,S+1);if(/\s/.test(b)&&K===0)break;if(b==="(")K+=1;else if(b===")"&&(K-=1,K===0)){S++;break}S++}return e.slice(x,S)}function L(){for(;/\s/.test(e.slice(S,S+1));)S++}for(;S<e.length;){const K=e.slice(S,S+1);/\s/.test(K)?L():c.push(N())}return c}function JA(e,c){return e.reduce(((S,N)=>(S.has(N[c])?S.get(N[c]).push(N):S.set(N[c],[N]),S)),new Map)}function iA(e,c){const S=[],N=[];for(const L of e)c(L)?S.push(L):N.push(L);return[S,N]}function oA(e,c={}){function S(N){return Array.from(N).map((L=>oA(L,c)))}if(e instanceof CSSUnitValue){if(e.unit==="percent"&&c.percentageReference){const L=e.value/100*c.percentageReference.value,K=c.percentageReference.unit;return new CSSUnitValue(L,K)}const N=e.toSum();if(N&&N.values.length===1&&(e=N.values[0]),e instanceof CSSUnitValue&&e.unit==="em"&&c.fontSize&&(e=new CSSUnitValue(e.value*c.fontSize.value,c.fontSize.unit)),e instanceof CSSKeywordValue){if(e.value==="e")return new CSSUnitValue(Math.E,"number");if(e.value==="pi")return new CSSUnitValue(Math.PI,"number")}return e}if(!e.operator)return e;switch(e.operator){case"sum":e=new CSSMathSum(...S(e.values));break;case"product":e=new CSSMathProduct(...S(e.values));break;case"negate":e=new CSSMathNegate(oA(e.value,c));break;case"clamp":e=new CSSMathClamp(oA(e.lower,c),oA(e.value,c),oA(e.upper,c));break;case"invert":e=new CSSMathInvert(oA(e.value,c));break;case"min":e=new CSSMathMin(...S(e.values));break;case"max":e=new CSSMathMax(...S(e.values))}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const N=Array.from(e.values);if(N.every((L=>L instanceof CSSUnitValue&&L.unit!=="percent"&&MA(L.unit)&&L.unit===N[0].unit))){const L=Math[e.operator].apply(Math,N.map((({value:K})=>K)));return new CSSUnitValue(L,N[0].unit)}}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const N=Array.from(e.values),[L,K]=iA(N,(b=>b instanceof CSSUnitValue&&b.unit!=="percent")),x=Array.from(JA(L,"unit").values());if(x.some((b=>b.length>0))){const b=x.map((u=>{const P=Math[e.operator].apply(Math,u.map((({value:V})=>V)));return new CSSUnitValue(P,u[0].unit)}));e=e instanceof CSSMathMin?new CSSMathMin(...b,...K):new CSSMathMax(...b,...K)}return N.length===1?N[0]:e}if(e instanceof CSSMathNegate)return e.value instanceof CSSUnitValue?new CSSUnitValue(0-e.value.value,e.value.unit):e.value instanceof CSSMathNegate?e.value.value:e;if(e instanceof CSSMathInvert)return e.value instanceof CSSMathInvert?e.value.value:e;if(e instanceof CSSMathSum){let N=function(K){const x=K.filter((b=>b instanceof CSSUnitValue));return[...K.filter((b=>!(b instanceof CSSUnitValue))),...Array.from(JA(x,"unit").entries()).map((([b,u])=>{const P=u.reduce(((V,{value:IA})=>V+IA),0);return new CSSUnitValue(P,b)}))]},L=[];for(const K of e.values)K instanceof CSSMathSum?L.push(...K.values):L.push(K);return L=N(L),L.length===1?L[0]:new CSSMathSum(...L)}if(e instanceof CSSMathProduct){let N=[];for(const x of e.values)x instanceof CSSMathProduct?N.push(...x.values):N.push(x);const[L,K]=iA(N,(x=>x instanceof CSSUnitValue&&x.unit==="number"));if(L.length>1){const x=L.reduce(((b,{value:u})=>b*u),1);N=[new CSSUnitValue(x,"number"),...K]}if(N.length===2){let x,b;for(const u of N)u instanceof CSSUnitValue&&u.unit==="number"?x=u:u instanceof CSSMathSum&&[...u.values].every((P=>P instanceof CSSUnitValue))&&(b=u);if(x&&b)return new CSSMathSum(...[...b.values].map((u=>new CSSUnitValue(u.value*x.value,u.unit))))}if(N.every((x=>x instanceof CSSUnitValue&&MA(x.unit)||x instanceof CSSMathInvert&&x.value instanceof CSSUnitValue&&MA(x.value.unit)))){const x=new CSSMathProduct(...N).toSum();if(x&&x.values.length===1)return x.values[0]}return new CSSMathProduct(...N)}return e}const rA=null,qI=["percent","length","angle","time","frequency","resolution","flex"],ZA={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}}},UA=new Map;for(const e of Object.values(ZA))if(e.compatible)for(const c of e.units)UA.set(c,e);function MI(e){return UA.get(e)}function WI(e,c){const S={...e};for(const N of Object.keys(c))S[N]?S[N]+=c[N]:S[N]=c[N];return S}function jI(e){return e==="number"?{}:e==="percent"?{percent:1}:ZA.absoluteLengths.units.has(e)||ZA.fontRelativeLengths.units.has(e)||ZA.viewportRelativeLengths.units.has(e)?{length:1}:ZA.angle.units.has(e)?{angle:1}:ZA.time.units.has(e)?{time:1}:ZA.frequency.units.has(e)?{frequency:1}:ZA.resolution.units.has(e)?{resolution:1}:e==="fr"?{flex:1}:rA}function NI(e){if(e instanceof CSSUnitValue){let{unit:c,value:S}=e;const N=MI(e.unit);return N&&c!==N.canonicalUnit&&(S*=N.ratios[c],c=N.canonicalUnit),c==="number"?[[S,{}]]:[[S,{[c]:1}]]}if(e instanceof CSSMathInvert){if(!(e.value instanceof CSSUnitValue))throw new Error("Not implemented");const c=NI(e.value);if(c===rA||c.length>1)return rA;const S=c[0],N={};for(const[L,K]of Object.entries(S[1]))N[L]=-1*K;return c[0]=[1/S[0],N],c}if(e instanceof CSSMathProduct){let c=[[1,{}]];for(const S of e.values){const N=NI(S),L=[];if(N===rA)return rA;for(const K of c)for(const x of N)L.push([K[0]*x[0],WI(K[1],x[1])]);c=L}return c}throw new Error("Not implemented")}function zI(e,c){if(jI(c)===rA)throw new SyntaxError("The string did not match the expected pattern.");const S=NI(e);if(!S)throw new TypeError;if(S.length>1)throw new TypeError("Sum has more than one item");const N=(function(L,K){const x=L.unit,b=L.value,u=MI(x),P=MI(K);return!P||u!==P?rA:new CSSUnitValue(b*P.ratios[x]/P.ratios[K],K)})(bI(S[0]),c);if(N===rA)throw new TypeError;return N}function bI(e){const[c,S]=e,N=Object.entries(S);if(N.length>1)return rA;if(N.length===0)return new CSSUnitValue(c,"number");const L=N[0];return L[1]!==1?rA:new CSSUnitValue(c,L[0])}function mI(e,...c){if(c&&c.length)throw new Error("Not implemented");const S=NI(e).map((N=>bI(N)));if(S.some((N=>N===rA)))throw new TypeError("Type error");return new CSSMathSum(...S)}function _I(e,c){if(e.percentHint&&c.percentHint&&e.percentHint!==c.percentHint)return rA;const S={...e,percentHint:e.percentHint??c.percentHint};for(const N of qI)c[N]&&(S[N]??(S[N]=0),S[N]+=c[N]);return S}class WA{constructor(c,S){PA(this,"name"),PA(this,"values"),this.name=c,this.values=S}}class nI{constructor(c,S){PA(this,"value"),PA(this,"associatedToken"),this.value=c,this.associatedToken=S}}function fI(e){if(Array.isArray(e))return e;if(typeof e=="string")return(function(c){const S=new d(c),N=[];for(;;){const L=$(S);if(L===void 0)return N;N.push(L)}})(e);throw new TypeError("Invalid input type "+typeof e)}function hI(e){const c=e.shift();return c instanceof U||c instanceof r||c instanceof k?(function(S,N){let L;if(N instanceof U)L=Y;else if(N instanceof k)L=J;else{if(!(N instanceof r))return;L=M}const K=new nI([],N);for(;;){const x=S.shift();if(x instanceof L||x===void 0)return K;S.unshift(x),K.value.push(hI(S))}})(e,c):c instanceof I?(function(S,N){const L=new WA(S.value,[]);for(;;){const K=N.shift();if(K instanceof J||K===void 0)return L;N.unshift(K),L.values.push(hI(N))}})(c,e):c}function wA(e){if(e instanceof k||e instanceof J)return 6;if(e instanceof o)switch(e.value){case"*":case"/":return 4;case"+":case"-":return 2}}function $I(e){return e[e.length-1]}function Sg(e,c,S){const N=["+","-"].includes(e.value)?"ADDITION":"MULTIPLICATION",L=c.type===N?c.values:[c],K=S.type===N?S.values:[S];return e.value==="-"?K[0]={type:"NEGATE",value:K[0]}:e.value==="/"&&(K[0]={type:"INVERT",value:K[0]}),{type:N,values:[...L,...K]}}function Ag(e){if(e.type==="ADDITION")return new CSSMathSum(...e.values.map((c=>Ag(c))));if(e.type==="MULTIPLICATION")return new CSSMathProduct(...e.values.map((c=>Ag(c))));if(e.type==="NEGATE")return new CSSMathNegate(Ag(e.value));if(e.type==="INVERT")return new CSSMathInvert(Ag(e.value));if(e instanceof nI)return Rg(new WA("calc",e.value));if(e instanceof A){if(e.value==="e")return new CSSUnitValue(Math.E,"number");if(e.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return RA(e)}function Rg(e){if(e.name==="min"||e.name==="max"){const N=e.values.filter((L=>!(L instanceof a||L instanceof G))).map((L=>oA(Rg(new WA("calc",L)))));return e.name==="min"?new CSSMathMin(...N):new CSSMathMax(...N)}if(e.name!=="calc")return null;const c=Ag((function(N){const L=[],K=[];for(;N.length;){const x=N.shift();if(x instanceof s||x instanceof w||x instanceof t||x instanceof WA||x instanceof nI||x instanceof A)K.push(x);else if(x instanceof o&&["*","/","+","-"].includes(x.value)){for(;L.length&&!($I(L)instanceof k)&&wA($I(L))>wA(x);){const b=L.pop(),u=K.pop(),P=K.pop();K.push(Sg(b,P,u))}L.push(x)}else if(x instanceof k)L.push(x);else if(x instanceof J){if(!L.length)return null;for(;!($I(L)instanceof k);){const b=L.pop(),u=K.pop(),P=K.pop();K.push(Sg(b,P,u))}if(!($I(L)instanceof k))return null;L.pop()}else if(!(x instanceof a))return null}for(;L.length;){if($I(L)instanceof k)return null;const x=L.pop(),b=K.pop(),u=K.pop();K.push(Sg(x,u,b))}return K[0]})([...e.values]));let S;try{S=oA(c)}catch{new CSSStyleSheet().insertRule("error",0)}return S instanceof CSSUnitValue?new CSSMathSum(S):S}function RA(e){return e instanceof WA&&["calc","min","max","clamp"].includes(e.name)?Rg(e):e instanceof s&&e.value===0&&!e.unit?new CSSUnitValue(0,"px"):e instanceof s?new CSSUnitValue(e.value,"number"):e instanceof t?new CSSUnitValue(e.value,"percent"):e instanceof w?new CSSUnitValue(e.value,e.unit):void 0}function Ra(e){const c=(function(S){const N=fI(S);for(;N[0]instanceof a;)N.shift();if(N[0]===void 0)return null;const L=hI(N);for(;N[0]instanceof a;)N.shift();return N[0]===void 0?L:null})(e);return c===null&&new CSSStyleSheet().insertRule("error",0),c instanceof s||c instanceof t||c instanceof w||c instanceof WA||new CSSStyleSheet().insertRule("error",0),c instanceof w&&jI(c.unit)===null&&new CSSStyleSheet().insertRule("error",0),RA(c)}(function(){let e=new WeakMap;function c(K){const x=[];for(let u=0;u<K.length;u++)x[u]=typeof(b=K[u])=="number"?new CSSUnitValue(b,"number"):b;var b;return x}class S{static parse(x){return x instanceof S?x:oA(Ra(x),{})}}class N extends S{constructor(x,b,u,P){super(),e.set(this,{values:c(x),operator:b,name:u||b,delimiter:P||", "})}get operator(){return e.get(this).operator}get values(){return e.get(this).values}toString(){const x=e.get(this);return`${x.name}(${x.values.join(x.delimiter)})`}}const L={CSSNumericValue:S,CSSMathValue:N,CSSUnitValue:class extends S{constructor(K,x){super(),e.set(this,{value:K,unit:x})}get value(){return e.get(this).value}set value(K){e.get(this).value=K}get unit(){return e.get(this).unit}to(K){return zI(this,K)}toSum(...K){return mI(this,...K)}type(){return jI(e.get(this).unit)}toString(){const K=e.get(this);return`${K.value}${(function(x){switch(x){case"percent":return"%";case"number":return"";default:return x.toLowerCase()}})(K.unit)}`}},CSSKeywordValue:class{constructor(K){this.value=K}toString(){return this.value.toString()}},CSSMathSum:class extends N{constructor(K){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends N{constructor(K){super(arguments,"product","calc"," * ")}toSum(...K){return mI(this,...K)}type(){return e.get(this).values.map((K=>K.type())).reduce(_I)}},CSSMathNegate:class extends N{constructor(K){super([arguments[0]],"negate","-")}get value(){return e.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends N{constructor(K){super([1,arguments[0]],"invert","calc"," / ")}get value(){return e.get(this).values[1]}type(){return(function(K){const x={};for(const b of qI)x[b]=-1*K[b];return x})(e.get(this).values[1].type())}},CSSMathMax:class extends N{constructor(){super(arguments,"max")}},CSSMathMin:class extends N{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:x=>new CSSUnitValue(x,K)}))throw Error(`Error installing CSS.${K}`)}));for(let[K,x]of Object.entries(L))if(!(K in window)&&!Reflect.defineProperty(window,K,{value:x}))throw Error(`Error installing CSSOM support for ${K}`)})();const ho="block";let oI=new WeakMap,Fg=new WeakMap;const LC=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function yo(e){return e===document.scrollingElement?document:e}function jg(e){Qi(e);let c=oI.get(e).animations;if(c.length===0)return;let S=e.currentTime;for(let N=0;N<c.length;N++)c[N].tickAnimation(S)}function Go(e,c){if(!e)return null;const S=Fg.get(e).sourceMeasurements,N=getComputedStyle(e);let L=S.scrollTop;return kA(c,N)==="x"&&(L=Math.abs(S.scrollLeft)),L}function gi(e,c){const S=oA(e,c);if(S instanceof CSSUnitValue){if(S.unit==="px")return S.value;throw TypeError("Unhandled unit type "+S.unit)}throw TypeError("Unsupported value type: "+typeof e)}function Qi(e){if(!(e instanceof kQ))return void(function(S){const N=oI.get(S);if(!N.anonymousSource)return;const L=So(N.anonymousSource,N.anonymousTarget);FQ(S,L)})(e);const c=e.subject;if(!c||getComputedStyle(c).display=="none")return void FQ(e,null);FQ(e,oi(c))}function ro(e){return["block","inline","x","y"].includes(e)}function Bi(e){const c=getComputedStyle(e);return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight,clientWidth:e.clientWidth,clientHeight:e.clientHeight,writingMode:c.writingMode,direction:c.direction,scrollPaddingTop:c.scrollPaddingTop,scrollPaddingBottom:c.scrollPaddingBottom,scrollPaddingLeft:c.scrollPaddingLeft,scrollPaddingRight:c.scrollPaddingRight}}function Ci(e,c){if(!e||!c)return;let S=0,N=0,L=c;const K=e.offsetParent;for(;L&&L!=K;)N+=L.offsetLeft,S+=L.offsetTop,L=L.offsetParent;N-=e.offsetLeft+e.clientLeft,S-=e.offsetTop+e.clientTop;const x=getComputedStyle(c);return{top:S,left:N,offsetWidth:c.offsetWidth,offsetHeight:c.offsetHeight,fontSize:x.fontSize}}function HC(e){let c=Fg.get(e);c.sourceMeasurements=Bi(e);for(const S of c.timelineRefs){const N=S.deref();N instanceof kQ&&(oI.get(N).subjectMeasurements=Ci(e,N.subject))}c.updateScheduled||(setTimeout((()=>{for(const S of c.timelineRefs){const N=S.deref();N&&jg(N)}c.updateScheduled=!1})),c.updateScheduled=!0)}function FQ(e,c){const S=oI.get(e),N=S.source;if(N!=c){if(N){const L=Fg.get(N);if(L){L.timelineRefs.delete(e);const K=Array.from(L.timelineRefs).filter((x=>x.deref()===void 0));for(const x of K)L.timelineRefs.delete(x);L.timelineRefs.size===0&&(L.disconnect(),Fg.delete(N))}}if(S.source=c,c){let L=Fg.get(c);if(!L){L={timelineRefs:new Set,sourceMeasurements:Bi(c)},Fg.set(c,L);const K=new ResizeObserver((u=>{for(const P of u)HC(S.source)}));K.observe(c);for(const u of c.children)K.observe(u);const x=new MutationObserver((u=>{for(const P of u)HC(P.target)}));x.observe(c,{attributes:!0,attributeFilter:["style","class"]});const b=()=>{L.sourceMeasurements.scrollLeft=c.scrollLeft,L.sourceMeasurements.scrollTop=c.scrollTop;for(const u of L.timelineRefs){const P=u.deref();P&&jg(P)}};yo(c).addEventListener("scroll",b),L.disconnect=()=>{K.disconnect(),x.disconnect(),yo(c).removeEventListener("scroll",b)}}L.timelineRefs.add(new WeakRef(e))}}}function Ei(e,c){let S=oI.get(e).animations;for(let N=0;N<S.length;N++)S[N].animation==c&&S.splice(N,1)}function ii(e,c,S){let N=oI.get(e).animations;for(let L=0;L<N.length;L++)if(N[L].animation==c)return;N.push({animation:c,tickAnimation:S}),queueMicrotask((()=>{jg(e)}))}class yI{constructor(c){if(oI.set(this,{source:null,axis:ho,anonymousSource:c?c.anonymousSource:null,anonymousTarget:c?c.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),FQ(this,c&&c.source!==void 0?c.source:document.scrollingElement),c&&c.axis!==void 0&&c.axis!=ho){if(!ro(c.axis))throw TypeError("Invalid axis");oI.get(this).axis=c.axis}jg(this)}set source(c){FQ(this,c),jg(this)}get source(){return oI.get(this).source}set axis(c){if(!ro(c))throw TypeError("Invalid axis");oI.get(this).axis=c,jg(this)}get axis(){return oI.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const c=this.source;if(!c)return"inactive";let S=getComputedStyle(c);return S.display=="none"?"inactive":c==document.scrollingElement||S.overflow!="visible"&&S.overflow!="clip"?"active":"inactive"}get currentTime(){const S=this.source;if(!S||!S.isConnected||this.phase=="inactive")return null;const N=getComputedStyle(S);if(N.display==="inline"||N.display==="none")return null;const L=this.axis,K=Go(S,L),x=(function(b,u){const P=Fg.get(b).sourceMeasurements,V=getComputedStyle(b).writingMode=="horizontal-tb";return u==="block"?u=V?"y":"x":u==="inline"&&(u=V?"x":"y"),u==="y"?P.scrollHeight-P.clientHeight:u==="x"?P.scrollWidth-P.clientWidth:void 0})(S,L);return x>0?CSS.percent(100*K/x):CSS.percent(100)}get __polyfill(){return!0}}function Di(e,c){let S=e.parentElement;for(;S!=null;){if(c(S))return S;S=S.parentElement}}function So(e,c){switch(e){case"root":return document.scrollingElement;case"nearest":return oi(c);case"self":return c;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Fa(e){switch(getComputedStyle(e).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 Ro(e){const c=getComputedStyle(e);return c.transform!="none"||c.perspective!="none"||c.willChange=="transform"||c.willChange=="perspective"||c.filter!="none"||c.willChange=="filter"||c.backdropFilter!="none"}function ka(e){return getComputedStyle(e).position!="static"||Ro(e)}function Ma(e){switch(getComputedStyle(e).position){case"static":case"relative":case"sticky":return Di(e,Fa);case"absolute":return Di(e,ka);case"fixed":return Di(e,Ro)}}function oi(e){if(e&&e.isConnected){for(;e=Ma(e);)switch(getComputedStyle(e)["overflow-x"]){case"auto":case"scroll":case"hidden":return e==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:e}return document.scrollingElement}}function iB(e,c){const S=oI.get(e),N=S.subjectMeasurements,L=Fg.get(S.source).sourceMeasurements;return e.phase==="inactive"?null:e instanceof kQ?si(c,L,N,S.axis,S.inset):null}function si(e,c,S,N,L){const K=c.direction=="rtl"||c.writingMode=="vertical-rl";let x,b,u={fontSize:S.fontSize};kA(N,c)==="x"?(x=S.offsetWidth,b=S.left,u.scrollPadding=[c.scrollPaddingLeft,c.scrollPaddingRight],K&&(b+=c.scrollWidth-c.clientWidth,u.scrollPadding=[c.scrollPaddingRight,c.scrollPaddingLeft]),u.containerSize=c.clientWidth):(x=S.offsetHeight,b=S.top,u.scrollPadding=[c.scrollPaddingTop,c.scrollPaddingBottom],u.containerSize=c.clientHeight);const P=(function(ei,fC){const pa={start:0,end:0};if(!ei)return pa;const[ua,qa]=[ei.start,ei.end].map(((uo,qo)=>uo==="auto"?fC.scrollPadding[qo]==="auto"?0:parseFloat(fC.scrollPadding[qo]):gi(uo,{percentageReference:CSS.px(fC.containerSize),fontSize:CSS.px(parseFloat(fC.fontSize))})));return{start:ua,end:qa}})(L,u),V=b-u.containerSize+P.end,IA=b+x-P.start,DA=V+x,LA=IA-x,bA=Math.min(DA,LA),JI=Math.max(DA,LA);let Ig,PI;const po=x>u.containerSize-P.start-P.end;switch(e){case"cover":Ig=V,PI=IA;break;case"contain":Ig=bA,PI=JI;break;case"entry":Ig=V,PI=bA;break;case"exit":Ig=JI,PI=IA;break;case"entry-crossing":Ig=V,PI=po?JI:bA;break;case"exit-crossing":Ig=po?bA:JI,PI=IA}return{start:Ig,end:PI}}function Fo(e,c){if(e instanceof kQ){const{rangeName:S,offset:N}=c;return ko(iB(e,S),N,iB(e,"cover"),e.subject)}if(e instanceof yI){const{axis:S,source:N}=e,{sourceMeasurements:L}=Fg.get(N);let K;return K=kA(S,L)==="x"?L.scrollWidth-L.clientWidth:L.scrollHeight-L.clientHeight,gi(c,{percentageReference:CSS.px(K)})/K}unsupportedTimeline(e)}function ko(e,c,S,N){if(!e||!S)return 0;let L=getComputedStyle(N);return(gi(c,{percentageReference:CSS.px(e.end-e.start),fontSize:CSS.px(parseFloat(L.fontSize))})+e.start-S.start)/(S.end-S.start)}let kQ=class extends yI{constructor(c){super(c);const S=oI.get(this);S.subject=c&&c.subject?c.subject:void 0,c&&c.inset&&(S.inset=(function(N){if(!N)return{start:0,end:0};let L;if(L=typeof N=="string"?NA(N).map((K=>{if(K==="auto")return"auto";try{return CSSNumericValue.parse(K)}catch{throw TypeError(`Could not parse inset "${N}"`)}})):Array.isArray(N)?N:[N],L.length===0||L.length>2)throw TypeError("Invalid inset");for(const K of L){if(K==="auto")continue;const x=K.type();if(x.length!==1&&x.percent!==1)throw TypeError("Invalid inset")}return{start:L[0],end:L[1]??L[0]}})(c.inset)),S.subject&&(new ResizeObserver((()=>{HC(S.source)})).observe(S.subject),new MutationObserver((()=>{HC(S.source)})).observe(S.subject,{attributes:!0,attributeFilter:["class","style"]})),Qi(this),S.subjectMeasurements=Ci(S.source,S.subject),jg(this)}get source(){return Qi(this),oI.get(this).source}set source(c){throw new Error("Cannot set the source of a view timeline")}get subject(){return oI.get(this).subject}get axis(){return oI.get(this).axis}get currentTime(){const S=Go(this.source,this.axis);if(S==null)return null;const N=iB(this,"cover");if(!N)return null;const L=(S-N.start)/(N.end-N.start);return CSS.percent(100*L)}get startOffset(){return CSS.px(iB(this,"cover").start)}get endOffset(){return CSS.px(iB(this,"cover").end)}};const Na=document.getAnimations,Ja=window.Element.prototype.getAnimations,Ua=window.Element.prototype.animate,Mo=window.Animation;class MQ{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((c,S)=>{this.nativeResolve=c,this.nativeReject=S}))}resolve(c){this.state="resolved",this.nativeResolve(c)}reject(c){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(c)}}function DB(e){e.readyPromise=new MQ,requestAnimationFrame((()=>{var c;(((c=e.timeline)==null?void 0:c.currentTime)??null)!==null&&(YC(e),e.pendingTask!=="play"||e.startTime===null&&e.holdTime===null?e.pendingTask==="pause"&&Uo(e):Jo(e))}))}function No(){return new DOMException("The user aborted a request","AbortError")}function zg(e,c){if(c===null)return c;if(typeof c!="number")throw new DOMException(`Unexpected value: ${c}. Cannot convert to CssNumberish`,"InvalidStateError");const S=e.rangeDuration??100,N=Mg(e),L=N?S*c/N:0;return CSS.percent(L)}function fA(e,c){if(e.timeline){if(c===null)return c;if(c.unit==="percent"){const S=e.rangeDuration??100,N=Mg(e);return c.value*N/S}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(c==null||typeof c=="number")return c;const S=c.to("ms");if(S)return S.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Jo(e){const c=fA(e,e.timeline.currentTime);if(e.holdTime!=null)wg(e),e.animation.playbackRate==0?e.startTime=c:(e.startTime=c-e.holdTime/e.animation.playbackRate,e.holdTime=null);else if(e.startTime!==null&&e.pendingPlaybackRate!==null){const S=(c-e.startTime)*e.animation.playbackRate;wg(e);const N=e.animation.playbackRate;N==0?(e.holdTime=null,e.startTime=c):e.startTime=c-S/N}e.readyPromise&&e.readyPromise.state=="pending"&&e.readyPromise.resolve(e.proxy),kg(e,!1,!1),Ng(e),e.pendingTask=null}function Uo(e){const c=fA(e,e.timeline.currentTime);e.startTime!=null&&e.holdTime==null&&(e.holdTime=(c-e.startTime)*e.animation.playbackRate),wg(e),e.startTime=null,e.readyPromise.resolve(e.proxy),kg(e,!1,!1),Ng(e),e.pendingTask=null}function Lo(e){if(!e.finishedPromise||e.finishedPromise.state!="pending"||e.proxy.playState!="finished")return;e.finishedPromise.resolve(e.proxy),e.animation.pause();const c=new CustomEvent("finish",{detail:{currentTime:e.proxy.currentTime,timelineTime:e.proxy.timeline.currentTime}});Object.defineProperty(c,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(c,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{e.animation.dispatchEvent(c)}))}))}function NQ(e){return e.pendingPlaybackRate!==null?e.pendingPlaybackRate:e.animation.playbackRate}function wg(e){e.pendingPlaybackRate!==null&&(e.animation.playbackRate=e.pendingPlaybackRate,e.pendingPlaybackRate=null)}function Ho(e){if(!e.timeline)return null;const c=fA(e,e.timeline.currentTime);if(c===null||e.startTime===null)return null;let S=(c-e.startTime)*e.animation.playbackRate;return S==-0&&(S=0),S}function kg(e,c,S){if(!e.timeline)return;let N=c?fA(e,e.proxy.currentTime):Ho(e);if(N&&e.startTime!=null&&!e.proxy.pending){const L=NQ(e),K=Mg(e);let x=e.previousCurrentTime;L>0&&N>=K&&e.previousCurrentTime!=null?((x===null||x<K)&&(x=K),e.holdTime=c?N:x):L<0&&N<=0?((x==null||x>0)&&(x=0),e.holdTime=c?N:x):L!=0&&(c&&e.holdTime!==null&&(e.startTime=(function(b,u){if(!b.timeline)return null;const P=fA(b,b.timeline.currentTime);return P==null?null:P-u/b.animation.playbackRate})(e,e.holdTime)),e.holdTime=null)}Ng(e),e.previousCurrentTime=fA(e,e.proxy.currentTime),e.proxy.playState=="finished"?(e.finishedPromise||(e.finishedPromise=new MQ),e.finishedPromise.state=="pending"&&(S?Lo(e):Promise.resolve().then((()=>{Lo(e)})))):(e.finishedPromise&&e.finishedPromise.state=="resolved"&&(e.finishedPromise=new MQ),e.animation.playState!="paused"&&e.animation.pause())}function Mg(e){const c=(function(N){const L=N.proxy.effect.getTiming();return N.normalizedTiming||L})(e),S=c.delay+c.endDelay+c.iterations*c.duration;return Math.max(0,S)}function Ng(e){if(e.timeline)if(e.startTime!==null){const c=e.timeline.currentTime;if(c==null)return;ti(e,(fA(e,c)-e.startTime)*e.animation.playbackRate)}else e.holdTime!==null&&ti(e,e.holdTime)}function ti(e,c){const S=e.timeline,N=e.animation.playbackRate,L=S.currentTime&&S.currentTime.value==(N<0?0:100)?N<0?.001:-.001:0;e.animation.currentTime=c+L}function wi(e,c){if(!e.timeline)return;const S=e.proxy.playState=="paused"&&e.proxy.pending;let N=!1,L=fA(e,e.proxy.currentTime);NQ(e)==0&&L==null&&(e.holdTime=0),L==null&&(e.autoAlignStartTime=!0),(e.proxy.playState==="finished"||S)&&(e.holdTime=null,e.startTime=null,e.autoAlignStartTime=!0),e.holdTime&&(e.startTime=null),e.pendingTask&&(e.pendingTask=null,N=!0),(e.holdTime!==null||e.autoAlignStartTime||S||e.pendingPlaybackRate!==null)&&(e.readyPromise&&!N&&(e.readyPromise=null),Ng(e),e.readyPromise||DB(e),e.pendingTask="play",ii(e.timeline,e.animation,ai.bind(e.proxy)),kg(e,!1,!1))}function ai(e){const c=AA.get(this);if(!c)return;if(e==null)return void(c.proxy.playState!=="paused"&&c.animation.playState!="idle"&&c.animation.cancel());YC(c),c.pendingTask&&requestAnimationFrame((()=>{c.pendingTask!=="play"||c.startTime===null&&c.holdTime===null?c.pendingTask==="pause"&&Uo(c):Jo(c)}));const S=this.playState;if(S=="running"||S=="finished"){const N=fA(c,e);ti(c,(N-fA(c,this.startTime))*this.playbackRate),kg(c,!1,!1)}}function Yo(e){e.specifiedTiming=null}let AA=new WeakMap;window.addEventListener("pagehide",(e=>{AA=new WeakMap}),!1);let Ko=new WeakMap;function YC(e){if(!e.autoAlignStartTime||!e.timeline||!e.timeline.currentTime||e.proxy.playState==="idle"||e.proxy.playState==="paused"&&e.holdTime!==null)return;const c=e.rangeDuration;let S,N;try{S=CSS.percent(100*(function(K){if(!K.animationRange)return 0;const x=K.animationRange.start==="normal"?lo(K.timeline):K.animationRange.start;return Fo(K.timeline,x)})(e))}catch(K){S=CSS.percent(0),e.animationRange.start="normal",console.warn("Exception when calculating start offset",K)}try{N=CSS.percent(100*(1-(function(K){if(!K.animationRange)return 0;const x=K.animationRange.end==="normal"?fo(K.timeline):K.animationRange.end;return 1-Fo(K.timeline,x)})(e)))}catch(K){N=CSS.percent(100),e.animationRange.end="normal",console.warn("Exception when calculating end offset",K)}e.rangeDuration=N.value-S.value;const L=NQ(e);e.startTime=fA(e,L>=0?S:N),e.holdTime=null,e.rangeDuration!==c&&Yo(e)}function KC(e){throw new Error("Unsupported timeline class")}function lo(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:e instanceof yI?CSS.percent(0):void KC()}function fo(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:e instanceof yI?CSS.percent(100):void KC()}function La(e,c){if(!c)return{start:"normal",end:"normal"};const S={start:lo(e),end:fo(e)};if(e instanceof ViewTimeline){const N=NA(c),L=[],K=[];if(N.forEach((x=>{if(LC.includes(x))L.push(x);else try{K.push(CSSNumericValue.parse(x))}catch{throw TypeError(`Could not parse range "${c}"`)}})),L.length>2||K.length>2||K.length==1)throw TypeError("Invalid time range or unsupported time range format.");return L.length&&(S.start.rangeName=L[0],S.end.rangeName=L.length>1?L[1]:L[0]),K.length>1&&(S.start.offset=K[0],S.end.offset=K[1]),S}if(e instanceof yI){const N=c.split(" ");if(N.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return S.start=CSSNumericValue.parse(N[0]),S.end=CSSNumericValue.parse(N[1]),S}KC()}function dC(e,c,S){if(!c||c==="normal")return"normal";if(e instanceof ViewTimeline){let N="cover",L=S==="start"?CSS.percent(0):CSS.percent(100);if(c instanceof Object)c.rangeName!==void 0&&(N=c.rangeName),c.offset!==void 0&&(L=c.offset);else{const K=NA(c);K.length===1?LC.includes(K[0])?N=K[0]:L=oA(CSSNumericValue.parse(K[0]),{}):K.length===2&&(N=K[0],L=oA(CSSNumericValue.parse(K[1]),{}))}if(!LC.includes(N))throw TypeError("Invalid range name");return{rangeName:N,offset:L}}if(e instanceof yI)return CSSNumericValue.parse(c);KC()}class lC{constructor(c,S,N={}){const L=S instanceof yI,K=c instanceof Mo?c:new Mo(c,L?void 0:S);Ko.set(K,this),AA.set(this,{animation:K,timeline:L?S:void 0,playState:L?"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:L?La(S,N["animation-range"]):null,proxy:this})}get effect(){const c=AA.get(this);return c.timeline?(c.effect||(c.effect=(function(S){const N=S.animation.effect,L=N.updateTiming,K={apply:function(P){N.getTiming();const V=P.apply(N);if(S.timeline){const IA=S.duration??100;V.localTime=zg(S,V.localTime),V.endTime=zg(S,V.endTime),V.activeDuration=zg(S,V.activeDuration);const DA=Mg(S),LA=V.iterations?(DA-V.delay-V.endDelay)/V.iterations:0;V.duration=DA?CSS.percent(IA*LA/DA):CSS.percent(0),S.timeline.currentTime===void 0&&(V.localTime=null)}return V}},x={apply:function(P,V){if(S.specifiedTiming)return S.specifiedTiming;S.specifiedTiming=P.apply(N);let IA,DA=Object.assign({},S.specifiedTiming);if(DA.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(DA.duration===null||DA.duration==="auto"||S.autoDurationEffect)&&S.timeline&&(S.autoDurationEffect=!0,DA.delay=0,DA.endDelay=0,IA=DA.iterations?1e5:0,DA.duration=DA.iterations?(IA-DA.delay-DA.endDelay)/DA.iterations:0,DA.duration<0&&(DA.duration=0,DA.endDelay=IA-DA.delay),L.apply(N,[DA])),S.normalizedTiming=DA,S.specifiedTiming}},b={apply:function(P,V,IA){if(IA&&IA.length){if(S.timeline&&IA[0]){const DA=IA[0],LA=DA.duration;if(LA===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(DA.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");LA!==void 0&&LA!=="auto"&&(S.autoDurationEffect=null)}S.specifiedTiming&&P.apply(N,[S.specifiedTiming]),P.apply(N,IA),Yo(S)}}},u=new Proxy(N,{get:function(P,V){const IA=P[V];return typeof IA=="function"?IA.bind(N):IA},set:function(P,V,IA){return P[V]=IA,!0}});return u.getComputedTiming=new Proxy(N.getComputedTiming,K),u.getTiming=new Proxy(N.getTiming,x),u.updateTiming=new Proxy(N.updateTiming,b),u})(c)),c.effect):c.animation.effect}set effect(c){const S=AA.get(this);S.animation.effect=c,S.effect=null,S.autoDurationEffect=null}get timeline(){const c=AA.get(this);return c.timeline||c.animation.timeline}set timeline(c){const S=AA.get(this),N=this.timeline;if(N==c)return;const L=this.playState,K=this.currentTime;let x,b=Mg(S);x=K===null?null:b===0?0:fA(S,K)/b;const u=N instanceof yI,P=c instanceof yI,V=this.pending;if(u&&Ei(S.timeline,S.animation),P)return S.timeline=c,wg(S),S.autoAlignStartTime=!0,S.startTime=null,S.holdTime=null,L!=="running"&&L!=="finished"||(S.readyPromise&&S.readyPromise.state!=="resolved"||DB(S),S.pendingTask="play",ii(S.timeline,S.animation,ai.bind(this))),L==="paused"&&x!==null&&(S.holdTime=x*b),V&&(S.readyPromise&&S.readyPromise.state!="resolved"||DB(S),S.pendingTask=L=="paused"?"pause":"play"),S.startTime!==null&&(S.holdTime=null),void kg(S,!1,!1);if(S.animation.timeline!=c)throw TypeError("Unsupported timeline: "+c);if(Ei(S.timeline,S.animation),S.timeline=null,u)switch(K!==null&&(S.animation.currentTime=x*Mg(S)),L){case"paused":S.animation.pause();break;case"running":case"finished":S.animation.play()}}get startTime(){const c=AA.get(this);return c.timeline?zg(c,c.startTime):c.animation.startTime}set startTime(c){const S=AA.get(this);if(c=fA(S,c),!S.timeline)return void(S.animation.startTime=c);S.autoAlignStartTime=!1,fA(S,S.timeline.currentTime)==null&&S.startTime!=null&&(S.holdTime=null,Ng(S));const N=fA(S,this.currentTime);wg(S),S.startTime=c,S.startTime!==null&&S.animation.playbackRate!=0?S.holdTime=null:S.holdTime=N,S.pendingTask&&(S.pendingTask=null,S.readyPromise.resolve(this)),kg(S,!0,!1),Ng(S)}get currentTime(){const c=AA.get(this);return c.timeline?c.holdTime!=null?zg(c,c.holdTime):zg(c,Ho(c)):c.animation.currentTime}set currentTime(c){const S=AA.get(this);S.timeline?((function(N,L){if(L==null&&N.currentTime!==null)throw new TypeError;L=fA(N,L),N.autoAlignStartTime=!1,N.holdTime!==null||N.startTime===null||N.timeline.phase==="inactive"||N.animation.playbackRate===0?N.holdTime=L:N.startTime=fA(N,N.timeline.currentTime)-L/N.animation.playbackRate,N.timeline.phase==="inactive"&&(N.startTime=null),N.previousCurrentTime=null})(S,c),S.pendingTask=="pause"&&(S.holdTime=fA(S,c),wg(S),S.startTime=null,S.pendingTask=null,S.readyPromise.resolve(this)),kg(S,!0,!1)):S.animation.currentTime=c}get playbackRate(){return AA.get(this).animation.playbackRate}set playbackRate(c){const S=AA.get(this);if(!S.timeline)return void(S.animation.playbackRate=c);S.pendingPlaybackRate=null;const N=this.currentTime;S.animation.playbackRate=c,N!==null&&(this.currentTime=N)}get playState(){const c=AA.get(this);if(!c.timeline)return c.animation.playState;const S=fA(c,this.currentTime);return S===null&&c.startTime===null&&c.pendingTask==null?"idle":c.pendingTask=="pause"||c.startTime===null&&c.pendingTask!="play"?"paused":S!=null&&(c.animation.playbackRate>0&&S>=Mg(c)||c.animation.playbackRate<0&&S<=0)?"finished":"running"}get rangeStart(){var c;return((c=AA.get(this).animationRange)==null?void 0:c.start)??"normal"}set rangeStart(c){const S=AA.get(this);if(!S.timeline)return S.animation.rangeStart=c;S.timeline instanceof yI&&(S.animationRange.start=dC(S.timeline,c,"start"),YC(S),Ng(S))}get rangeEnd(){var c;return((c=AA.get(this).animationRange)==null?void 0:c.end)??"normal"}set rangeEnd(c){const S=AA.get(this);if(!S.timeline)return S.animation.rangeEnd=c;S.timeline instanceof yI&&(S.animationRange.end=dC(S.timeline,c,"end"),YC(S),Ng(S))}get replaceState(){return AA.get(this).animation.pending}get pending(){const c=AA.get(this);return c.timeline?!!c.readyPromise&&c.readyPromise.state=="pending":c.animation.pending}finish(){const c=AA.get(this);if(!c.timeline)return void c.animation.finish();const S=NQ(c),N=Mg(c);if(S==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(S>0&&N==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");wg(c);const L=S<0?0:N;this.currentTime=zg(c,L);const K=fA(c,c.timeline.currentTime);c.startTime===null&&K!==null&&(c.startTime=K-L/c.animation.playbackRate),c.pendingTask=="pause"&&c.startTime!==null&&(c.holdTime=null,c.pendingTask=null,c.readyPromise.resolve(this)),c.pendingTask=="play"&&c.startTime!==null&&(c.pendingTask=null,c.readyPromise.resolve(this)),kg(c,!0,!0)}play(){const c=AA.get(this);c.timeline?wi(c):c.animation.play()}pause(){const c=AA.get(this);c.timeline?this.playState!="paused"&&(c.animation.currentTime===null&&(c.autoAlignStartTime=!0),c.pendingTask=="play"?c.pendingTask=null:c.readyPromise=null,c.readyPromise||DB(c),c.pendingTask="pause",ii(c.timeline,c.animation,ai.bind(c.proxy))):c.animation.pause()}reverse(){const c=AA.get(this),S=NQ(c),N=fA(c,this.currentTime),L=Mg(c)==1/0,K=S!=0&&(S<0||N>0||!L);if(!c.timeline||!K)return K&&(c.pendingPlaybackRate=-NQ(c)),void c.animation.reverse();if(c.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-S),wi(c)}updatePlaybackRate(c){const S=AA.get(this);if(S.pendingPlaybackRate=c,!S.timeline)return void S.animation.updatePlaybackRate(c);const N=this.playState;if(!S.readyPromise||S.readyPromise.state!="pending")switch(N){case"idle":case"paused":wg(S);break;case"finished":const L=fA(S,S.timeline.currentTime),K=L!==null?(L-S.startTime)*S.animation.playbackRate:null;S.startTime=c==0?L:L!=null&&K!=null?(L-K)/c:null,wg(S),kg(S,!1,!1),Ng(S);break;default:wi(S)}}persist(){AA.get(this).animation.persist()}get id(){return AA.get(this).animation.id}set id(c){AA.get(this).animation.id=c}cancel(){const c=AA.get(this);c.timeline?(this.playState!="idle"&&((function(S){S.pendingTask&&(S.pendingTask=null,wg(S),S.readyPromise.reject(No()),DB(S),S.readyPromise.resolve(S.proxy))})(c),c.finishedPromise&&c.finishedPromise.state=="pending"&&c.finishedPromise.reject(No()),c.finishedPromise=new MQ,c.animation.cancel()),c.startTime=null,c.holdTime=null,Ei(c.timeline,c.animation)):c.animation.cancel()}get onfinish(){return AA.get(this).animation.onfinish}set onfinish(c){AA.get(this).animation.onfinish=c}get oncancel(){return AA.get(this).animation.oncancel}set oncancel(c){AA.get(this).animation.oncancel=c}get onremove(){return AA.get(this).animation.onremove}set onremove(c){AA.get(this).animation.onremove=c}get finished(){const c=AA.get(this);return c.timeline?(c.finishedPromise||(c.finishedPromise=new MQ),c.finishedPromise.promise):c.animation.finished}get ready(){const c=AA.get(this);return c.timeline?(c.readyPromise||(c.readyPromise=new MQ,c.readyPromise.resolve(this)),c.readyPromise.promise):c.animation.ready}addEventListener(c,S,N){AA.get(this).animation.addEventListener(c,S,N)}removeEventListener(c,S,N){AA.get(this).animation.removeEventListener(c,S,N)}dispatchEvent(c){AA.get(this).animation.dispatchEvent(c)}}function Ha(e,c){const S=c.timeline;S instanceof yI&&delete c.timeline;const N=Ua.apply(this,[e,c]),L=new lC(N,S);return S instanceof yI&&(N.pause(),AA.get(L).animationRange={start:dC(S,c.rangeStart,"start"),end:dC(S,c.rangeEnd,"end")},L.play()),L}function xo(e){for(let c=0;c<e.length;++c){let S=Ko.get(e[c]);S&&(e[c]=S)}return e}function Ya(e){return xo(Ja.apply(this,[e]))}function Ka(e){return xo(Na.apply(this,[e]))}const jA={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\(([^)]*)\)/},JQ=["block","inline","x","y"],da=["nearest","root","self"],qg=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(e,c,S){const N={sheetSrc:e,index:0,name:S};for(;N.index<N.sheetSrc.length&&(this.eatWhitespace(N),!(N.index>=N.sheetSrc.length));){if(this.lookAhead("/*",N)){for(;this.lookAhead("/*",N);)this.eatComment(N),this.eatWhitespace(N);continue}const L=this.parseQualifiedRule(N);L&&(c?this.parseKeyframesAndSaveNameMapping(L,N):this.handleScrollTimelineProps(L,N))}return N.sheetSrc}getAnimationTimelineOptions(e,c){for(let S=this.cssRulesWithTimelineName.length-1;S>=0;S--){const N=this.cssRulesWithTimelineName[S];try{if(c.matches(N.selector)&&(!N["animation-name"]||N["animation-name"]==e))return{"animation-timeline":N["animation-timeline"],"animation-range":N["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(e,c){const S=this.anonymousScrollTimelineOptions.get(e);return S?{anonymousSource:S.source,anonymousTarget:c,source:So(S.source??"nearest",c),axis:S.axis?S.axis:"block"}:null}getScrollTimelineOptions(e,c){const S=this.getAnonymousScrollTimelineOptions(e,c);if(S)return S;for(let N=this.sourceSelectorToScrollTimeline.length-1;N>=0;N--){const L=this.sourceSelectorToScrollTimeline[N];if(L.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(c,L.selector);if(K)return{source:K,...L.axis?{axis:L.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(e,c){let S=e;for(;S;){if(S.matches(c))return S;S=S.previousElementSibling||S.parentElement}return null}getAnonymousViewTimelineOptions(e,c){const S=this.anonymousViewTimelineOptions.get(e);return S?{subject:c,axis:S.axis?S.axis:"block",inset:S.inset?S.inset:"auto"}:null}getViewTimelineOptions(e,c){const S=this.getAnonymousViewTimelineOptions(e,c);if(S)return S;for(let N=this.subjectSelectorToViewTimeline.length-1;N>=0;N--){const L=this.subjectSelectorToViewTimeline[N];if(L.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(c,L.selector);if(K)return{subject:K,axis:L.axis,inset:L.inset}}}return null}handleScrollTimelineProps(e,c){if(e.selector.includes("@keyframes"))return;const S=e.block.contents.includes("animation-name:"),N=e.block.contents.includes("animation-timeline:"),L=e.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(e),this.saveSubjectSelectorToViewTimeline(e),!N&&!S&&!L)return;let K=[],x=[],b=!1;N&&(K=this.extractScrollTimelineNames(e.block.contents)),S&&(x=this.extractMatches(e.block.contents,jA.ANIMATION_NAME)),N&&S||(L&&this.extractMatches(e.block.contents,jA.ANIMATION).forEach((u=>{const P=this.extractAnimationName(u);P&&N&&x.push(P),N&&(this.hasDuration(u)||(this.hasAutoDuration(u)&&(e.block.contents=e.block.contents.replace("auto"," ")),e.block.contents=e.block.contents.replace(u," 1s "+u),b=!0))})),b&&this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,c)),this.saveRelationInList(e,K,x)}saveSourceSelectorToScrollTimeline(e){const c=e.block.contents.includes("scroll-timeline:"),S=e.block.contents.includes("scroll-timeline-name:"),N=e.block.contents.includes("scroll-timeline-axis:");if(!c&&!S)return;let L=[];if(c){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE);for(const b of x){const u=this.split(b);let P={selector:e.selector,name:""};u.length==1?P.name=u[0]:u.length==2&&(JQ.includes(u[0])?(P.axis=u[0],P.name=u[1]):(P.axis=u[1],P.name=u[0])),L.push(P)}}if(S){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE_NAME);for(let b=0;b<x.length;b++)if(b<L.length)L[b].name=x[b];else{let u={selector:e.selector,name:x[b]};L.push(u)}}let K=[];if(N){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE_AXIS);if(K=x.filter((b=>JQ.includes(b))),K.length!=x.length)throw new Error("Invalid axis")}for(let x=0;x<L.length;x++)K.length&&(L[x].axis=K[x%L.length]);this.sourceSelectorToScrollTimeline.push(...L)}saveSubjectSelectorToViewTimeline(e){const c=e.block.contents.includes("view-timeline:"),S=e.block.contents.includes("view-timeline-name:"),N=e.block.contents.includes("view-timeline-axis:"),L=e.block.contents.includes("view-timeline-inset:");if(!c&&!S)return;let K=[];if(c){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE);for(let P of u){const V=this.split(P);let IA={selector:e.selector,name:"",inset:null};V.length==1?IA.name=V[0]:V.length==2&&(JQ.includes(V[0])?(IA.axis=V[0],IA.name=V[1]):(IA.axis=V[1],IA.name=V[0])),K.push(IA)}}if(S){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_NAME);for(let P=0;P<u.length;P++)if(P<K.length)K[P].name=u[P];else{let V={selector:e.selector,name:u[P],inset:null};K.push(V)}}let x=[],b=[];if(L&&(x=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_INSET)),N){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_AXIS);if(b=u.filter((P=>JQ.includes(P))),b.length!=u.length)throw new Error("Invalid axis")}for(let u=0;u<K.length;u++)x.length&&(K[u].inset=x[u%K.length]),b.length&&(K[u].axis=b[u%K.length]);this.subjectSelectorToViewTimeline.push(...K)}hasDuration(e){return e.split(" ").filter((c=>{return S=c,jA.TIME.exec(S);var S})).length>=1}hasAutoDuration(e){return e.split(" ").filter((c=>c==="auto")).length>=1}saveRelationInList(e,c,S){let N=[];e.block.contents.includes("animation-range:")&&(N=this.extractMatches(e.block.contents,jA.ANIMATION_TIME_RANGE));const L=Math.max(c.length,S.length,N.length);for(let K=0;K<L;K++)this.cssRulesWithTimelineName.push({selector:e.selector,"animation-timeline":c[K%c.length],...S.length?{"animation-name":S[K%S.length]}:{},...N.length?{"animation-range":N[K%N.length]}:{}})}extractScrollTimelineNames(e){const c=jA.ANIMATION_TIMELINE.exec(e)[1].trim(),S=[];return c.split(",").map((N=>N.trim())).forEach((N=>{if((function(L){return(L.startsWith("scroll")||L.startsWith("view"))&&L.includes("(")})(N)){const L=this.saveAnonymousTimelineName(N);S.push(L)}else S.push(N)})),S}saveAnonymousTimelineName(e){const c=":t"+this.nextAnonymousTimelineNameIndex++;return e.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(c,this.parseAnonymousScrollTimeline(e)):this.anonymousViewTimelineOptions.set(c,this.parseAnonymousViewTimeline(e)),c}parseAnonymousScrollTimeline(e){const c=jA.ANONYMOUS_SCROLL_TIMELINE.exec(e);if(!c)return null;const S=c[1],N={};return S.split(" ").forEach((L=>{JQ.includes(L)?N.axis=L:da.includes(L)&&(N.source=L)})),N}parseAnonymousViewTimeline(e){const c=jA.ANONYMOUS_VIEW_TIMELINE.exec(e);if(!c)return null;const S=c[1],N={};return S.split(" ").forEach((L=>{JQ.includes(L)?N.axis=L:N.inset=N.inset?`${N.inset} ${L}`:L})),N}extractAnimationName(e){return this.findMatchingEntryInContainer(e,this.keyframeNamesSelectors)}findMatchingEntryInContainer(e,c){const S=e.split(" ").filter((N=>c.has(N)));return S?S[0]:null}parseIdentifier(e){jA.IDENTIFIER.lastIndex=e.index;const c=jA.IDENTIFIER.exec(e.sheetSrc);if(!c)throw this.parseError(e,"Expected an identifier");return e.index+=c[0].length,c[0]}parseKeyframesAndSaveNameMapping(e,c){if(e.selector.startsWith("@keyframes")){const S=this.replaceKeyframesAndGetMapping(e,c);e.selector.split(" ").forEach(((N,L)=>{L>0&&this.keyframeNamesSelectors.set(N,S)}))}}replaceKeyframesAndGetMapping(e,c){function S(u){return LC.some((P=>u.startsWith(P)))}const N=e.block.contents,L=(function(u){let P=0,V=-1,IA=-1;const DA=[];for(let LA=0;LA<u.length;LA++)u[LA]=="{"?P++:u[LA]=="}"&&P--,P==1&&u[LA]!="{"&&u[LA]!="}"&&V==-1&&(V=LA),P==2&&u[LA]=="{"&&(IA=LA,DA.push({start:V,end:IA}),V=IA=-1);return DA})(N);if(L.length==0)return new Map;const K=new Map;let x=!1;const b=[];b.push(N.substring(0,L[0].start));for(let u=0;u<L.length;u++){const P=N.substring(L[u].start,L[u].end);let V=[];P.split(",").forEach((IA=>{const DA=IA.split(" ").map((bA=>bA.trim())).filter((bA=>bA!="")).join(" "),LA=K.size;K.set(LA,DA),V.push(`${LA}%`),S(DA)&&(x=!0)})),b.push(V.join(",")),u==L.length-1?b.push(N.substring(L[u].end)):b.push(N.substring(L[u].end,L[u+1].start))}return x?(e.block.contents=b.join(""),this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,c),K):new Map}parseQualifiedRule(e){const c=e.index,S=this.parseSelector(e).trim();if(S)return{selector:S,block:this.eatBlock(e),startIndex:c,endIndex:e.index}}removeEnclosingDoubleQuotes(e){let c=e[0]=='"'?1:0,S=e[e.length-1]=='"'?e.length-1:e.length;return e.substring(c,S)}assertString(e,c){if(e.sheetSrc.substr(e.index,c.length)!=c)throw this.parseError(e,`Did not find expected sequence ${c}`);e.index+=c.length}replacePart(e,c,S,N){if(N.sheetSrc=N.sheetSrc.slice(0,e)+S+N.sheetSrc.slice(c),N.index>=c){const L=N.index-c;N.index=e+S.length+L}}eatComment(e){this.assertString(e,"/*"),this.eatUntil("*/",e,!0),this.assertString(e,"*/")}eatBlock(e){const c=e.index;this.assertString(e,"{");let S=1;for(;S!=0;)this.lookAhead("/*",e)?this.eatComment(e):(e.sheetSrc[e.index]==="{"?S++:e.sheetSrc[e.index]==="}"&&S--,this.advance(e));const N=e.index;return{startIndex:c,endIndex:N,contents:e.sheetSrc.slice(c,N)}}advance(e){if(e.index++,e.index>e.sheetSrc.length)throw this.parseError(e,"Advanced beyond the end")}parseError(e,c){return Error(`(${e.name?e.name:"<anonymous file>"}): ${c}`)}eatUntil(e,c,S=!1){const N=c.index;for(;!this.lookAhead(e,c);)this.advance(c);return S&&(c.sheetSrc=c.sheetSrc.slice(0,N)+" ".repeat(c.index-N)+c.sheetSrc.slice(c.index)),c.sheetSrc.slice(N,c.index)}parseSelector(e){let c=e.index;if(this.eatUntil("{",e),c===e.index)throw Error("Empty selector");return e.sheetSrc.slice(c,e.index)}eatWhitespace(e){jA.WHITE_SPACE.lastIndex=e.index;const c=jA.WHITE_SPACE.exec(e.sheetSrc);c&&(e.index+=c[0].length)}lookAhead(e,c){return c.sheetSrc.substr(c.index,e.length)==e}peek(e){return e.sheetSrc[e.index]}extractMatches(e,c,S=","){return c.exec(e)[1].trim().split(S).map((N=>N.trim()))}split(e){return e.split(" ").map((c=>c.trim())).filter((c=>c!=""))}};function la(e,c,S,N,L,K){const x=Bi(c),b=Ci(c,S);return ko(si(e,x,b,N,L),K,si("cover",x,b,N,L),S)}function fa(e,c,S){const N=qg.getAnimationTimelineOptions(c,S);if(!N)return null;const L=N["animation-timeline"];if(!L)return null;let K=qg.getScrollTimelineOptions(L,S)||qg.getViewTimelineOptions(L,S);return K?(K.subject&&(function(x,b){const u=oi(b.subject),P=b.axis||b.axis;function V(DA,LA){let bA=null;for(const[JI,Ig]of DA)if(JI==100*LA.offset){if(Ig=="from")bA=0;else if(Ig=="to")bA=100;else{const PI=Ig.split(" ");bA=PI.length==1?parseFloat(PI[0]):100*la(PI[0],u,b.subject,P,b.inset,CSS.percent(parseFloat(PI[1])))}break}return bA}const IA=qg.keyframeNamesSelectors.get(x.animationName);if(IA&&IA.size){const DA=[];x.effect.getKeyframes().forEach((bA=>{const JI=V(IA,bA);JI!==null&&JI>=0&&JI<=100&&(bA.offset=JI/100,DA.push(bA))}));const LA=DA.sort(((bA,JI)=>bA.offset<JI.offset?-1:bA.affset>JI.offset?1:0));x.effect.setKeyframes(LA)}})(e,K),{timeline:K.source?new yI(K):new kQ(K),animOptions:N}):null}function xa(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function c(N){if(N.innerHTML.trim().length===0||"aphrodite"in N.dataset)return;let L=qg.transpileStyleSheet(N.innerHTML,!0);L=qg.transpileStyleSheet(L,!1),N.innerHTML=L}function S(N){N.type!="text/css"&&N.rel!="stylesheet"||!N.href||new URL(N.href,document.baseURI).origin==location.origin&&fetch(N.getAttribute("href")).then((async L=>{const K=await L.text();let x=qg.transpileStyleSheet(K,!0);if(x=qg.transpileStyleSheet(K,!1),x!=K){const b=new Blob([x],{type:"text/css"}),u=URL.createObjectURL(b);N.setAttribute("href",u)}}))}new MutationObserver((N=>{for(const L of N)for(const K of L.addedNodes)K instanceof HTMLStyleElement&&c(K),K instanceof HTMLLinkElement&&S(K)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((N=>c(N))),document.querySelectorAll("link").forEach((N=>S(N)))})();const e=CSS.supports;CSS.supports=c=>(c=c.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),e(c)),window.addEventListener("animationstart",(c=>{c.target.getAnimations().filter((S=>S.animationName===c.animationName)).forEach((S=>{const N=fa(S,S.animationName,c.target);if(N)if(!N.timeline||S instanceof lC)S.timeline=N.timeline;else{const L=new lC(S,N.timeline,N.animOptions);S.pause(),L.play()}}))}))}(function(){if(!xa()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:yI}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:kQ}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Ha}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:lC}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Ya}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Ka}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const vG=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),VG=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BatchedParticleRenderer=Y0;exports.Builder=bD;exports.ByteBuffer=mB;exports.ConstantColor=hQ;exports.ConstantValue=nA;exports.Matrix4=tg;exports.MeshBVH=gB;exports.MotionController=Re;exports.PROJECT_DOCUMENT_KEY=XD;exports.ParticleSystem=LE;exports.SIZE_PREFIX_LENGTH=ct;exports.TrailParticle=JE;exports.Vector4=YI;exports.WorkerBase=uG;exports.__viteBrowserExternal=VG;exports.applyDef=Ut;exports.applyOver=Ht;exports.attachNeedleIdsToLoadedGltf=et;exports.bundler=xc;exports.createNoise4D=d0;exports.createOverApplyState=Lt;exports.deriveInstanceId=Ee;exports.enableProjectDocumentInspection=p0;exports.evaluateProjectDocument=P0;exports.fetchProfile=he;exports.getProjectDocumentInspection=q0;exports.index=Qc;exports.index$1=pG;exports.index$2=TG;exports.isProjectDocument=Mt;exports.reportProjectIssues=f0;exports.resolveDocumentRemoteSrc=rB;exports.resolveMaterialEntity=Yt;exports.scrollTimeline=vG;exports.spark_module=Ky;exports.splitPath=vD;exports.v5=ja;
|
|
13104
|
+
`);new F.Vector3(-1,-3,1).normalize(),new F.Color(1,1,1),new F.Color(.5,.5,1);new F.Color(1,1,1),new F.Color(.25,.25,.5);var sa=(B=>(B.w="wrist",B.t0="thumb-metacarpal",B.t1="thumb-phalanx-proximal",B.t2="thumb-phalanx-distal",B.t3="thumb-tip",B.i0="index-finger-metacarpal",B.i1="index-finger-phalanx-proximal",B.i2="index-finger-phalanx-intermediate",B.i3="index-finger-phalanx-distal",B.i4="index-finger-tip",B.m0="middle-finger-metacarpal",B.m1="middle-finger-phalanx-proximal",B.m2="middle-finger-phalanx-intermediate",B.m3="middle-finger-phalanx-distal",B.m4="middle-finger-tip",B.r0="ring-finger-metacarpal",B.r1="ring-finger-phalanx-proximal",B.r2="ring-finger-phalanx-intermediate",B.r3="ring-finger-phalanx-distal",B.r4="ring-finger-tip",B.p0="pinky-finger-metacarpal",B.p1="pinky-finger-phalanx-proximal",B.p2="pinky-finger-phalanx-intermediate",B.p3="pinky-finger-phalanx-distal",B.p4="pinky-finger-tip",B))(sa||{});const Yy=Object.keys(sa);Yy.length;new F.Euler(0,0,0,"YXZ");var to=(B=>(B.w="wrist",B.t0="thumb-metacarpal",B.t1="thumb-phalanx-proximal",B.t2="thumb-phalanx-distal",B.t3="thumb-tip",B.i0="index-finger-metacarpal",B.i1="index-finger-phalanx-proximal",B.i2="index-finger-phalanx-intermediate",B.i3="index-finger-phalanx-distal",B.i4="index-finger-tip",B.m0="middle-finger-metacarpal",B.m1="middle-finger-phalanx-proximal",B.m2="middle-finger-phalanx-intermediate",B.m3="middle-finger-phalanx-distal",B.m4="middle-finger-tip",B.r0="ring-finger-metacarpal",B.r1="ring-finger-phalanx-proximal",B.r2="ring-finger-phalanx-intermediate",B.r3="ring-finger-phalanx-distal",B.r4="ring-finger-tip",B.p0="pinky-finger-metacarpal",B.p1="pinky-finger-phalanx-proximal",B.p2="pinky-finger-phalanx-intermediate",B.p3="pinky-finger-phalanx-distal",B.p4="pinky-finger-tip",B))(to||{});const ta=Object.keys(to);ta.length;const Ky=Object.freeze(Object.defineProperty({__proto__:null,ExtSplats:lg,JOINT_IDS:ta,JointEnum:to,LN_SCALE_MAX:dI,LN_SCALE_MIN:KI,OldSparkViewpoint:ND,OldSplatAccumulator:rE,PackedSplats:Gg,PagedSplats:uB,Readback:UC,RgbaArray:Aa,SparkRenderer:Gy,SplatAccumulator:mQ,SplatEdit:zE,SplatEditSdf:ga,SplatEdits:Ca,SplatFileType:HI,SplatGenerator:AB,SplatLoader:io,SplatMesh:Zg,SplatModifier:Ea,SplatPager:eQ,SplatTransformer:UB,floatToUint8:kB,fromHalf:ig,getSplatFileType:Da,isAndroid:dw,isIos:fE,isMobile:lE,isOculus:lw,isVisionPro:fw,setPackedSplat:GD,toHalf:Eg,unpackSplat:dE},Symbol.toStringTag,{value:"Module"})),wo=0,wa=1,aa=2,JD=2,mi=1.25,bs=1,wI=32,vA=wI/4,ea=65535,SE=Math.pow(2,-24),$E=Symbol("SKIP_GENERATION"),ca={strategy:wo,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[$E]:!1};function pA(B,A,I){return I.min.x=A[B],I.min.y=A[B+1],I.min.z=A[B+2],I.max.x=A[B+3],I.max.y=A[B+4],I.max.z=A[B+5],I}function ms(B){let A=-1,I=-1/0;for(let g=0;g<3;g++){const Q=B[g+3]-B[g];Q>I&&(I=Q,A=g)}return A}function Ps(B,A){A.set(B)}function Ts(B,A,I){let g,Q;for(let C=0;C<3;C++){const E=C+3;g=B[C],Q=A[C],I[C]=g<Q?g:Q,g=B[E],Q=A[E],I[E]=g>Q?g:Q}}function jC(B,A,I){for(let g=0;g<3;g++){const Q=A[B+2*g],C=A[B+2*g+1],E=Q-C,i=Q+C;E<I[g]&&(I[g]=E),i>I[g+3]&&(I[g+3]=i)}}function wB(B){const A=B[3]-B[0],I=B[4]-B[1],g=B[5]-B[2];return 2*(A*I+I*g+g*A)}function VA(B,A){return A[B+15]===ea}function aI(B,A){return A[B+6]}function RI(B,A){return A[B+14]}function AI(B){return B+vA}function II(B,A){const I=A[B+6];return B+I*vA}function ao(B,A){return A[B+7]}function Pi(B,A,I,g,Q){let C=1/0,E=1/0,i=1/0,D=-1/0,o=-1/0,s=-1/0,t=1/0,w=1/0,a=1/0,y=-1/0,R=-1/0,n=-1/0;const h=B.offset||0;for(let G=(A-h)*6,r=(A+I-h)*6;G<r;G+=6){const M=B[G+0],k=B[G+1],J=M-k,U=M+k;J<C&&(C=J),U>D&&(D=U),M<t&&(t=M),M>y&&(y=M);const Y=B[G+2],d=B[G+3],H=Y-d,f=Y+d;H<E&&(E=H),f>o&&(o=f),Y<w&&(w=Y),Y>R&&(R=Y);const l=B[G+4],p=B[G+5],q=l-p,m=l+p;q<i&&(i=q),m>s&&(s=m),l<a&&(a=l),l>n&&(n=l)}g[0]=C,g[1]=E,g[2]=i,g[3]=D,g[4]=o,g[5]=s,Q[0]=t,Q[1]=w,Q[2]=a,Q[3]=y,Q[4]=R,Q[5]=n}const Lg=32,dy=(B,A)=>B.candidate-A.candidate,Tg=new Array(Lg).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zC=new Float32Array(6);function ly(B,A,I,g,Q,C){let E=-1,i=0;if(C===wo)E=ms(A),E!==-1&&(i=(A[E]+A[E+3])/2);else if(C===wa)E=ms(B),E!==-1&&(i=fy(I,g,Q,E));else if(C===aa){const D=wB(B);let o=mi*Q;const s=I.offset||0,t=(g-s)*6,w=(g+Q-s)*6;for(let a=0;a<3;a++){const y=A[a],h=(A[a+3]-y)/Lg;if(Q<Lg/4){const G=[...Tg];G.length=Q;let r=0;for(let k=t;k<w;k+=6,r++){const J=G[r];J.candidate=I[k+2*a],J.count=0;const{bounds:U,leftCacheBounds:Y,rightCacheBounds:d}=J;for(let H=0;H<3;H++)d[H]=1/0,d[H+3]=-1/0,Y[H]=1/0,Y[H+3]=-1/0,U[H]=1/0,U[H+3]=-1/0;jC(k,I,U)}G.sort(dy);let M=Q;for(let k=0;k<M;k++){const J=G[k];for(;k+1<M&&G[k+1].candidate===J.candidate;)G.splice(k+1,1),M--}for(let k=t;k<w;k+=6){const J=I[k+2*a];for(let U=0;U<M;U++){const Y=G[U];J>=Y.candidate?jC(k,I,Y.rightCacheBounds):(jC(k,I,Y.leftCacheBounds),Y.count++)}}for(let k=0;k<M;k++){const J=G[k],U=J.count,Y=Q-J.count,d=J.leftCacheBounds,H=J.rightCacheBounds;let f=0;U!==0&&(f=wB(d)/D);let l=0;Y!==0&&(l=wB(H)/D);const p=bs+mi*(f*U+l*Y);p<o&&(E=a,o=p,i=J.candidate)}}else{for(let M=0;M<Lg;M++){const k=Tg[M];k.count=0,k.candidate=y+h+M*h;const J=k.bounds;for(let U=0;U<3;U++)J[U]=1/0,J[U+3]=-1/0}for(let M=t;M<w;M+=6){let U=~~((I[M+2*a]-y)/h);U>=Lg&&(U=Lg-1);const Y=Tg[U];Y.count++,jC(M,I,Y.bounds)}const G=Tg[Lg-1];Ps(G.bounds,G.rightCacheBounds);for(let M=Lg-2;M>=0;M--){const k=Tg[M],J=Tg[M+1];Ts(k.bounds,J.rightCacheBounds,k.rightCacheBounds)}let r=0;for(let M=0;M<Lg-1;M++){const k=Tg[M],J=k.count,U=k.bounds,d=Tg[M+1].rightCacheBounds;J!==0&&(r===0?Ps(U,zC):Ts(U,zC,zC)),r+=J;let H=0,f=0;r!==0&&(H=wB(zC)/D);const l=Q-r;l!==0&&(f=wB(d)/D);const p=bs+mi*(H*r+f*l);p<o&&(E=a,o=p,i=k.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${C} used.`);return{axis:E,pos:i}}function fy(B,A,I,g){let Q=0;const C=B.offset;for(let E=A,i=A+I;E<i;E++)Q+=B[(E-C)*6+g*2];return Q/I}class Ti{constructor(){this.boundingData=new Float32Array(6)}}function xy(B,A,I,g,Q,C){let E=g,i=g+Q-1;const D=C.pos,o=C.axis*2,s=I.offset||0;for(;;){for(;E<=i&&I[(E-s)*6+o]<D;)E++;for(;E<=i&&I[(i-s)*6+o]>=D;)i--;if(E<i){for(let t=0;t<A;t++){let w=B[E*A+t];B[E*A+t]=B[i*A+t],B[i*A+t]=w}for(let t=0;t<6;t++){const w=E-s,a=i-s,y=I[w*6+t];I[w*6+t]=I[a*6+t],I[a*6+t]=y}E++,i--}else return E}}let na,RE,UD,ha;const py=Math.pow(2,32);function LD(B){return"count"in B?1:1+LD(B.left)+LD(B.right)}function uy(B,A,I){return na=new Float32Array(I),RE=new Uint32Array(I),UD=new Uint16Array(I),ha=new Uint8Array(I),HD(B,A)}function HD(B,A){const I=B/4,g=B/2,Q="count"in A,C=A.boundingData;for(let E=0;E<6;E++)na[I+E]=C[E];if(Q)return A.buffer?(ha.set(new Uint8Array(A.buffer),B),B+A.buffer.byteLength):(RE[I+6]=A.offset,UD[g+14]=A.count,UD[g+15]=ea,B+wI);{const{left:E,right:i,splitAxis:D}=A,o=B+wI;let s=HD(o,E);const t=B/wI,a=s/wI-t;if(a>py)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return RE[I+6]=a,RE[I+7]=D,HD(s,i)}}function qy(B,A,I,g,Q){const{maxDepth:C,verbose:E,maxLeafSize:i,strategy:D,onProgress:o}=Q,s=B.primitiveBuffer,t=B.primitiveBufferStride,w=new Float32Array(6);let a=!1;const y=new Ti;return Pi(A,I,g,y.boundingData,w),n(y,I,g,w),y;function R(h){o&&o(h/g)}function n(h,G,r,M=null,k=0){if(!a&&k>=C&&(a=!0,E&&console.warn(`BVH: Max depth of ${C} reached when generating BVH. Consider increasing maxDepth.`)),r<=i||k>=C)return R(G+r),h.offset=G,h.count=r,h;const J=ly(h.boundingData,M,A,G,r,D);if(J.axis===-1)return R(G+r),h.offset=G,h.count=r,h;const U=xy(s,t,A,G,r,J);if(U===G||U===G+r)R(G+r),h.offset=G,h.count=r;else{h.splitAxis=J.axis;const Y=new Ti,d=G,H=U-G;h.left=Y,Pi(A,d,H,Y.boundingData,w),n(Y,d,H,w,k+1);const f=new Ti,l=U,p=r-H;h.right=f,Pi(A,l,p,f.boundingData,w),n(f,l,p,w,k+1)}return h}}function by(B,A){const I=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,g=B.getRootRanges(A.range),Q=g[0],C=g[g.length-1],E={offset:Q.offset,count:C.offset+C.count-Q.offset},i=new Float32Array(6*E.count);i.offset=E.offset,B.computePrimitiveBounds(E.offset,E.count,i),B._roots=g.map(D=>{const o=qy(B,i,D.offset,D.count,A),s=LD(o),t=new I(wI*s);return uy(0,o,t),t})}class eo{constructor(A){this._getNewPrimitive=A,this._primitives=[]}getPrimitive(){const A=this._primitives;return A.length===0?this._getNewPrimitive():A.pop()}releasePrimitive(A){this._primitives.push(A)}}class my{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const A=[];let I=null;this.setBuffer=g=>{I&&A.push(I),I=g,this.float32Array=new Float32Array(g),this.uint16Array=new Uint16Array(g),this.uint32Array=new Uint32Array(g)},this.clearBuffer=()=>{I=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,A.length!==0&&this.setBuffer(A.pop())}}}const KA=new my;let Vg,XQ;const dQ=[],_C=new eo(()=>new F.Box3);function Py(B,A,I,g,Q,C){Vg=_C.getPrimitive(),XQ=_C.getPrimitive(),dQ.push(Vg,XQ),KA.setBuffer(B._roots[A]);const E=YD(0,B.geometry,I,g,Q,C);KA.clearBuffer(),_C.releasePrimitive(Vg),_C.releasePrimitive(XQ),dQ.pop(),dQ.pop();const i=dQ.length;return i>0&&(XQ=dQ[i-1],Vg=dQ[i-2]),E}function YD(B,A,I,g,Q=null,C=0,E=0){const{float32Array:i,uint16Array:D,uint32Array:o}=KA;let s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);return pA(B,i,Vg),g(w,a,!1,E,C+B/vA,Vg)}else{let H=function(l){const{uint16Array:p,uint32Array:q}=KA;let m=l*2;for(;!VA(m,p);)l=AI(l),m=l*2;return aI(l,q)},f=function(l){const{uint16Array:p,uint32Array:q}=KA;let m=l*2;for(;!VA(m,p);)l=II(l,q),m=l*2;return aI(l,q)+RI(m,p)};const w=AI(B),a=II(B,o);let y=w,R=a,n,h,G,r;if(Q&&(G=Vg,r=XQ,pA(y,i,G),pA(R,i,r),n=Q(G),h=Q(r),h<n)){y=a,R=w;const l=n;n=h,h=l,G=r}G||(G=Vg,pA(y,i,G));const M=VA(y*2,D),k=I(G,M,n,E+1,C+y/vA);let J;if(k===JD){const l=H(y),q=f(y)-l;J=g(l,q,!0,E+1,C+y/vA,G)}else J=k&&YD(y,A,I,g,Q,C,E+1);if(J)return!0;r=XQ,pA(R,i,r);const U=VA(R*2,D),Y=I(r,U,h,E+1,C+R/vA);let d;if(Y===JD){const l=H(R),q=f(R)-l;d=g(l,q,!0,E+1,C+R/vA,r)}else d=Y&&YD(R,A,I,g,Q,C,E+1);return!!d}}const qB=new KA.constructor,uE=new KA.constructor,Xg=new eo(()=>new F.Box3),lQ=new F.Box3,fQ=new F.Box3,Oi=new F.Box3,Xi=new F.Box3;let vi=!1;function Ty(B,A,I,g){if(vi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");vi=!0;const Q=B._roots,C=A._roots;let E,i=0,D=0;const o=new F.Matrix4().copy(I).invert();for(let s=0,t=Q.length;s<t;s++){qB.setBuffer(Q[s]),D=0;const w=Xg.getPrimitive();pA(0,qB.float32Array,w),w.applyMatrix4(o);for(let a=0,y=C.length;a<y&&(uE.setBuffer(C[a]),E=Cg(0,0,I,o,g,i,D,0,0,w),uE.clearBuffer(),D+=C[a].byteLength/wI,!E);a++);if(Xg.releasePrimitive(w),qB.clearBuffer(),i+=Q[s].byteLength/wI,E)break}return vi=!1,E}function Cg(B,A,I,g,Q,C=0,E=0,i=0,D=0,o=null,s=!1){let t,w;s?(t=uE,w=qB):(t=qB,w=uE);const a=t.float32Array,y=t.uint32Array,R=t.uint16Array,n=w.float32Array,h=w.uint32Array,G=w.uint16Array,r=B*2,M=A*2,k=VA(r,R),J=VA(M,G);let U=!1;if(J&&k)s?U=Q(aI(A,h),RI(A*2,G),aI(B,y),RI(B*2,R),D,E+A/vA,i,C+B/vA):U=Q(aI(B,y),RI(B*2,R),aI(A,h),RI(A*2,G),i,C+B/vA,D,E+A/vA);else if(J){const Y=Xg.getPrimitive();pA(A,n,Y),Y.applyMatrix4(I);const d=AI(B),H=II(B,y);pA(d,a,lQ),pA(H,a,fQ);const f=Y.intersectsBox(lQ),l=Y.intersectsBox(fQ);U=f&&Cg(A,d,g,I,Q,E,C,D,i+1,Y,!s)||l&&Cg(A,H,g,I,Q,E,C,D,i+1,Y,!s),Xg.releasePrimitive(Y)}else{const Y=AI(A),d=II(A,h);pA(Y,n,Oi),pA(d,n,Xi);const H=o.intersectsBox(Oi),f=o.intersectsBox(Xi);if(H&&f)U=Cg(B,Y,I,g,Q,C,E,i,D+1,o,s)||Cg(B,d,I,g,Q,C,E,i,D+1,o,s);else if(H)if(k)U=Cg(B,Y,I,g,Q,C,E,i,D+1,o,s);else{const l=Xg.getPrimitive();l.copy(Oi).applyMatrix4(I);const p=AI(B),q=II(B,y);pA(p,a,lQ),pA(q,a,fQ);const m=l.intersectsBox(lQ),T=l.intersectsBox(fQ);U=m&&Cg(Y,p,g,I,Q,E,C,D,i+1,l,!s)||T&&Cg(Y,q,g,I,Q,E,C,D,i+1,l,!s),Xg.releasePrimitive(l)}else if(f)if(k)U=Cg(B,d,I,g,Q,C,E,i,D+1,o,s);else{const l=Xg.getPrimitive();l.copy(Xi).applyMatrix4(I);const p=AI(B),q=II(B,y);pA(p,a,lQ),pA(q,a,fQ);const m=l.intersectsBox(lQ),T=l.intersectsBox(fQ);U=m&&Cg(d,p,g,I,Q,E,C,D,i+1,l,!s)||T&&Cg(d,q,g,I,Q,E,C,D,i+1,l,!s),Xg.releasePrimitive(l)}}return U}const Os=new F.Box3,xQ=new Float32Array(6);class ya{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(A){A={...ca,...A},by(this,A)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(A,I,g,Q){let C=1/0,E=1/0,i=1/0,D=-1/0,o=-1/0,s=-1/0;for(let t=A,w=A+I;t<w;t++){this.writePrimitiveBounds(t,xQ,0);const[a,y,R,n,h,G]=xQ;a<C&&(C=a),n>D&&(D=n),y<E&&(E=y),h>o&&(o=h),R<i&&(i=R),G>s&&(s=G)}return g[Q+0]=C,g[Q+1]=E,g[Q+2]=i,g[Q+3]=D,g[Q+4]=o,g[Q+5]=s,g}computePrimitiveBounds(A,I,g){const Q=g.offset||0;for(let C=A,E=A+I;C<E;C++){this.writePrimitiveBounds(C,xQ,0);const[i,D,o,s,t,w]=xQ,a=(i+s)/2,y=(D+t)/2,R=(o+w)/2,n=(s-i)/2,h=(t-D)/2,G=(w-o)/2,r=(C-Q)*6;g[r+0]=a,g[r+1]=n+(Math.abs(a)+n)*SE,g[r+2]=y,g[r+3]=h+(Math.abs(y)+h)*SE,g[r+4]=R,g[r+5]=G+(Math.abs(R)+G)*SE}return g}shiftPrimitiveOffsets(A){const I=this._indirectBuffer;if(I)for(let g=0,Q=I.length;g<Q;g++)I[g]+=A;else{const g=this._roots;for(let Q=0;Q<g.length;Q++){const C=g[Q],E=new Uint32Array(C),i=new Uint16Array(C),D=C.byteLength/wI;for(let o=0;o<D;o++){const s=vA*o,t=2*s;VA(t,i)&&(E[s+6]+=A)}}}}traverse(A,I=0){const g=this._roots[I],Q=new Uint32Array(g),C=new Uint16Array(g);E(0);function E(i,D=0){const o=i*2,s=VA(o,C);if(s){const t=Q[i+6],w=C[o+14];A(D,s,new Float32Array(g,i*4,6),t,w)}else{const t=AI(i),w=II(i,Q),a=ao(i,Q);A(D,s,new Float32Array(g,i*4,6),a)||(E(t,D+1),E(w,D+1))}}}refit(){const A=this._roots;for(let I=0,g=A.length;I<g;I++){const Q=A[I],C=new Uint32Array(Q),E=new Uint16Array(Q),i=new Float32Array(Q),D=Q.byteLength/wI;for(let o=D-1;o>=0;o--){const s=o*vA,t=s*2;if(VA(t,E)){const a=aI(s,C),y=RI(t,E);this.writePrimitiveRangeBounds(a,y,xQ,0),i.set(xQ,s)}else{const a=AI(s),y=II(s,C);for(let R=0;R<3;R++){const n=i[a+R],h=i[a+R+3],G=i[y+R],r=i[y+R+3];i[s+R]=n<G?n:G,i[s+R+3]=h>r?h:r}}}}}getBoundingBox(A){return A.makeEmpty(),this._roots.forEach(g=>{pA(0,new Float32Array(g),Os),A.union(Os)}),A}shapecast(A){let{boundsTraverseOrder:I,intersectsBounds:g,intersectsRange:Q,intersectsPrimitive:C,scratchPrimitive:E,iterate:i}=A;if(Q&&C){const t=Q;Q=(w,a,y,R,n)=>t(w,a,y,R,n)?!0:i(w,a,this,C,y,R,E)}else Q||(C?Q=(t,w,a,y)=>i(t,w,this,C,a,y,E):Q=(t,w,a)=>a);let D=!1,o=0;const s=this._roots;for(let t=0,w=s.length;t<w;t++){const a=s[t];if(D=Py(this,t,g,Q,I,o),D)break;o+=a.byteLength/wI}return D}bvhcast(A,I,g){let{intersectsRanges:Q}=g;return Ty(this,A,I,Q)}}function Oy(){return typeof SharedArrayBuffer<"u"}function co(B){return B.index?B.index.count:B.attributes.position.count}function Ai(B){return co(B)/3}function Xy(B,A=ArrayBuffer){return B>65535?new Uint32Array(new A(4*B)):new Uint16Array(new A(2*B))}function vy(B,A){if(!B.index){const I=B.attributes.position.count,g=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,Q=Xy(I,g);B.setIndex(new F.BufferAttribute(Q,1));for(let C=0;C<I;C++)Q[C]=C}}function Vy(B,A,I){const g=co(B)/I,Q=A||B.drawRange,C=Q.start/I,E=(Q.start+Q.count)/I,i=Math.max(0,C),D=Math.min(g,E)-i;return{offset:Math.floor(i),count:Math.floor(D)}}function Zy(B,A){return B.groups.map(I=>({offset:I.start/A,count:I.count/A}))}function Xs(B,A,I){const g=Vy(B,A,I),Q=Zy(B,I);if(!Q.length)return[g];const C=[],E=g.offset,i=g.offset+g.count,D=co(B)/I,o=[];for(const w of Q){const{offset:a,count:y}=w,R=a,n=isFinite(y)?y:D-a,h=a+n;R<i&&h>E&&(o.push({pos:Math.max(E,R),isStart:!0}),o.push({pos:Math.min(i,h),isStart:!1}))}o.sort((w,a)=>w.pos!==a.pos?w.pos-a.pos:w.type==="end"?-1:1);let s=0,t=null;for(const w of o){const a=w.pos;s!==0&&a!==t&&C.push({offset:t,count:a-t}),s+=w.isStart?1:-1,t=a}return C}function Ga(B,A){const I=B[B.length-1],g=I.offset+I.count>2**16,Q=B.reduce((o,s)=>o+s.count,0),C=g?4:2,E=A?new SharedArrayBuffer(Q*C):new ArrayBuffer(Q*C),i=g?new Uint32Array(E):new Uint16Array(E);let D=0;for(let o=0;o<B.length;o++){const{offset:s,count:t}=B[o];for(let w=0;w<t;w++)i[D+w]=s+w;D+=t}return i}class ra extends ya{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(A){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(A){}constructor(A,I={}){if(A.isBufferGeometry){if(A.index&&A.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(I.useSharedArrayBuffer&&!Oy())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=A,this.resolvePrimitiveIndex=I.indirect?g=>this._indirectBuffer[g]:g=>g,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,I={...ca,...I},I[$E]||this.init(I)}init(A){const{geometry:I,primitiveStride:g}=this;if(A.indirect){const Q=Xs(I,A.range,g),C=Ga(Q,A.useSharedArrayBuffer);this._indirectBuffer=C}else vy(I,A);super.init(A),!I.boundingBox&&A.setBoundingBox&&(I.boundingBox=this.getBoundingBox(new F.Box3))}getRootRanges(A){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Xs(this.geometry,A,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ug{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(A,I){let g=1/0,Q=-1/0;for(let C=0,E=A.length;C<E;C++){const D=A[C][I];g=D<g?D:g,Q=D>Q?D:Q}this.min=g,this.max=Q}setFromPoints(A,I){let g=1/0,Q=-1/0;for(let C=0,E=I.length;C<E;C++){const i=I[C],D=A.dot(i);g=D<g?D:g,Q=D>Q?D:Q}this.min=g,this.max=Q}isSeparated(A){return this.min>A.max||A.min>this.max}}ug.prototype.setFromBox=(function(){const B=new F.Vector3;return function(I,g){const Q=g.min,C=g.max;let E=1/0,i=-1/0;for(let D=0;D<=1;D++)for(let o=0;o<=1;o++)for(let s=0;s<=1;s++){B.x=Q.x*D+C.x*(1-D),B.y=Q.y*o+C.y*(1-o),B.z=Q.z*s+C.z*(1-s);const t=I.dot(B);E=Math.min(t,E),i=Math.max(t,i)}this.min=E,this.max=i}})();const Wy=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Vector3;return function(Q,C,E){const i=Q.start,D=B,o=C.start,s=A;I.subVectors(i,o),B.subVectors(Q.end,Q.start),A.subVectors(C.end,C.start);const t=I.dot(s),w=s.dot(D),a=s.dot(s),y=I.dot(D),n=D.dot(D)*a-w*w;let h,G;n!==0?h=(t*w-y*a)/n:h=0,G=(t+h*w)/a,E.x=h,E.y=G}})(),no=(function(){const B=new F.Vector2,A=new F.Vector3,I=new F.Vector3;return function(Q,C,E,i){Wy(Q,C,B);let D=B.x,o=B.y;if(D>=0&&D<=1&&o>=0&&o<=1){Q.at(D,E),C.at(o,i);return}else if(D>=0&&D<=1){o<0?C.at(0,i):C.at(1,i),Q.closestPointToPoint(i,!0,E);return}else if(o>=0&&o<=1){D<0?Q.at(0,E):Q.at(1,E),C.closestPointToPoint(E,!0,i);return}else{let s;D<0?s=Q.start:s=Q.end;let t;o<0?t=C.start:t=C.end;const w=A,a=I;if(Q.closestPointToPoint(t,!0,A),C.closestPointToPoint(s,!0,I),w.distanceToSquared(t)<=a.distanceToSquared(s)){E.copy(w),i.copy(t);return}else{E.copy(s),i.copy(a);return}}}})(),jy=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Plane,g=new F.Line3;return function(C,E){const{radius:i,center:D}=C,{a:o,b:s,c:t}=E;if(g.start=o,g.end=s,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i||(g.start=o,g.end=t,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i)||(g.start=s,g.end=t,g.closestPointToPoint(D,!0,B).distanceTo(D)<=i))return!0;const R=E.getPlane(I);if(Math.abs(R.distanceToPoint(D))<=i){const h=R.projectPoint(D,A);if(E.containsPoint(h))return!0}return!1}})(),zy=["x","y","z"],Yg=1e-15,vs=Yg*Yg;function TI(B){return Math.abs(B)<Yg}class ZI extends F.Triangle{constructor(...A){super(...A),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new F.Vector3),this.satBounds=new Array(4).fill().map(()=>new ug),this.points=[this.a,this.b,this.c],this.plane=new F.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new F.Line3,this.needsUpdate=!0}intersectsSphere(A){return jy(A,this)}update(){const A=this.a,I=this.b,g=this.c,Q=this.points,C=this.satAxes,E=this.satBounds,i=C[0],D=E[0];this.getNormal(i),D.setFromPoints(i,Q);const o=C[1],s=E[1];o.subVectors(A,I),s.setFromPoints(o,Q);const t=C[2],w=E[2];t.subVectors(I,g),w.setFromPoints(t,Q);const a=C[3],y=E[3];a.subVectors(g,A),y.setFromPoints(a,Q);const R=o.length(),n=t.length(),h=a.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,R<Yg?n<Yg||h<Yg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(A),this.degenerateSegment.end.copy(g)):n<Yg?h<Yg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(I),this.degenerateSegment.end.copy(A)):h<Yg&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(g),this.degenerateSegment.end.copy(I)),this.plane.setFromNormalAndCoplanarPoint(i,A),this.needsUpdate=!1}}ZI.prototype.closestPointToSegment=(function(){const B=new F.Vector3,A=new F.Vector3,I=new F.Line3;return function(Q,C=null,E=null){const{start:i,end:D}=Q,o=this.points;let s,t=1/0;for(let w=0;w<3;w++){const a=(w+1)%3;I.start.copy(o[w]),I.end.copy(o[a]),no(I,Q,B,A),s=B.distanceToSquared(A),s<t&&(t=s,C&&C.copy(B),E&&E.copy(A))}return this.closestPointToPoint(i,B),s=i.distanceToSquared(B),s<t&&(t=s,C&&C.copy(B),E&&E.copy(i)),this.closestPointToPoint(D,B),s=D.distanceToSquared(B),s<t&&(t=s,C&&C.copy(B),E&&E.copy(D)),Math.sqrt(t)}})();ZI.prototype.intersectsTriangle=(function(){const B=new ZI,A=new ug,I=new ug,g=new F.Vector3,Q=new F.Vector3,C=new F.Vector3,E=new F.Vector3,i=new F.Line3,D=new F.Line3,o=new F.Vector3,s=new F.Vector2,t=new F.Vector2;function w(r,M,k,J){const U=g;!r.isDegenerateIntoPoint&&!r.isDegenerateIntoSegment?U.copy(r.plane.normal):U.copy(M.plane.normal);const Y=r.satBounds,d=r.satAxes;for(let l=1;l<4;l++){const p=Y[l],q=d[l];if(A.setFromPoints(q,M.points),p.isSeparated(A)||(E.copy(U).cross(q),A.setFromPoints(E,r.points),I.setFromPoints(E,M.points),A.isSeparated(I)))return!1}const H=M.satBounds,f=M.satAxes;for(let l=1;l<4;l++){const p=H[l],q=f[l];if(A.setFromPoints(q,r.points),p.isSeparated(A)||(E.crossVectors(U,q),A.setFromPoints(E,r.points),I.setFromPoints(E,M.points),A.isSeparated(I)))return!1}return k&&(J||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),k.start.set(0,0,0),k.end.set(0,0,0)),!0}function a(r,M,k,J,U,Y,d,H,f,l,p){let q=d/(d-H);l.x=J+(U-J)*q,p.start.subVectors(M,r).multiplyScalar(q).add(r),q=d/(d-f),l.y=J+(Y-J)*q,p.end.subVectors(k,r).multiplyScalar(q).add(r)}function y(r,M,k,J,U,Y,d,H,f,l,p){if(U>0)a(r.c,r.a,r.b,J,M,k,f,d,H,l,p);else if(Y>0)a(r.b,r.a,r.c,k,M,J,H,d,f,l,p);else if(H*f>0||d!=0)a(r.a,r.b,r.c,M,k,J,d,H,f,l,p);else if(H!=0)a(r.b,r.a,r.c,k,M,J,H,d,f,l,p);else if(f!=0)a(r.c,r.a,r.b,J,M,k,f,d,H,l,p);else return!0;return!1}function R(r,M,k,J){const U=M.degenerateSegment,Y=r.plane.distanceToPoint(U.start),d=r.plane.distanceToPoint(U.end);return TI(Y)?TI(d)?w(r,M,k,J):(k&&(k.start.copy(U.start),k.end.copy(U.start)),r.containsPoint(U.start)):TI(d)?(k&&(k.start.copy(U.end),k.end.copy(U.end)),r.containsPoint(U.end)):r.plane.intersectLine(U,g)!=null?(k&&(k.start.copy(g),k.end.copy(g)),r.containsPoint(g)):!1}function n(r,M,k){const J=M.a;return TI(r.plane.distanceToPoint(J))&&r.containsPoint(J)?(k&&(k.start.copy(J),k.end.copy(J)),!0):!1}function h(r,M,k){const J=r.degenerateSegment,U=M.a;return J.closestPointToPoint(U,!0,g),U.distanceToSquared(g)<vs?(k&&(k.start.copy(U),k.end.copy(U)),!0):!1}function G(r,M,k,J){if(r.isDegenerateIntoSegment)if(M.isDegenerateIntoSegment){const U=r.degenerateSegment,Y=M.degenerateSegment,d=Q,H=C;U.delta(d),Y.delta(H);const f=g.subVectors(Y.start,U.start),l=d.x*H.y-d.y*H.x;if(TI(l))return!1;const p=(f.x*H.y-f.y*H.x)/l,q=-(d.x*f.y-d.y*f.x)/l;if(p<0||p>1||q<0||q>1)return!1;const m=U.start.z+d.z*p,T=Y.start.z+H.z*q;return TI(m-T)?(k&&(k.start.copy(U.start).addScaledVector(d,p),k.end.copy(U.start).addScaledVector(d,p)),!0):!1}else return M.isDegenerateIntoPoint?h(r,M,k):R(M,r,k,J);else{if(r.isDegenerateIntoPoint)return M.isDegenerateIntoPoint?M.a.distanceToSquared(r.a)<vs?(k&&(k.start.copy(r.a),k.end.copy(r.a)),!0):!1:M.isDegenerateIntoSegment?h(M,r,k):n(M,r,k);if(M.isDegenerateIntoPoint)return n(r,M,k);if(M.isDegenerateIntoSegment)return R(r,M,k,J)}}return function(M,k=null,J=!1){this.needsUpdate&&this.update(),M.isExtendedTriangle?M.needsUpdate&&M.update():(B.copy(M),B.update(),M=B);const U=G(this,M,k,J);if(U!==void 0)return U;const Y=this.plane,d=M.plane;let H=d.distanceToPoint(this.a),f=d.distanceToPoint(this.b),l=d.distanceToPoint(this.c);TI(H)&&(H=0),TI(f)&&(f=0),TI(l)&&(l=0);const p=H*f,q=H*l;if(p>0&&q>0)return!1;let m=Y.distanceToPoint(M.a),T=Y.distanceToPoint(M.b),Z=Y.distanceToPoint(M.c);TI(m)&&(m=0),TI(T)&&(T=0),TI(Z)&&(Z=0);const O=m*T,j=m*Z;if(O>0&&j>0)return!1;Q.copy(Y.normal),C.copy(d.normal);const gA=Q.cross(C);let QA=0,CA=Math.abs(gA.x);const EA=Math.abs(gA.y);EA>CA&&(CA=EA,QA=1),Math.abs(gA.z)>CA&&(QA=2);const W=zy[QA],$=this.a[W],z=this.b[W],MA=this.c[W],kA=M.a[W],NA=M.b[W],JA=M.c[W];if(y(this,$,z,MA,p,q,H,f,l,s,i))return w(this,M,k,J);if(y(M,kA,NA,JA,O,j,m,T,Z,t,D))return w(this,M,k,J);if(s.y<s.x){const iA=s.y;s.y=s.x,s.x=iA,o.copy(i.start),i.start.copy(i.end),i.end.copy(o)}if(t.y<t.x){const iA=t.y;t.y=t.x,t.x=iA,o.copy(D.start),D.start.copy(D.end),D.end.copy(o)}return s.y<t.x||t.y<s.x?!1:(k&&(t.x>s.x?k.start.copy(D.start):k.start.copy(i.start),t.y<s.y?k.end.copy(D.end):k.end.copy(i.end)),!0)}})();ZI.prototype.distanceToPoint=(function(){const B=new F.Vector3;return function(I){return this.closestPointToPoint(I,B),I.distanceTo(B)}})();ZI.prototype.distanceToTriangle=(function(){const B=new F.Vector3,A=new F.Vector3,I=["a","b","c"],g=new F.Line3,Q=new F.Line3;return function(E,i=null,D=null){const o=i||D?g:null;if(this.intersectsTriangle(E,o))return(i||D)&&(i&&o.getCenter(i),D&&o.getCenter(D)),0;let s=1/0;for(let t=0;t<3;t++){let w;const a=I[t],y=E[a];this.closestPointToPoint(y,B),w=y.distanceToSquared(B),w<s&&(s=w,i&&i.copy(B),D&&D.copy(y));const R=this[a];E.closestPointToPoint(R,B),w=R.distanceToSquared(B),w<s&&(s=w,i&&i.copy(R),D&&D.copy(B))}for(let t=0;t<3;t++){const w=I[t],a=I[(t+1)%3];g.set(this[w],this[a]);for(let y=0;y<3;y++){const R=I[y],n=I[(y+1)%3];Q.set(E[R],E[n]),no(g,Q,B,A);const h=B.distanceToSquared(A);h<s&&(s=h,i&&i.copy(B),D&&D.copy(A))}}return Math.sqrt(s)}})();class cI{constructor(A,I,g){this.isOrientedBox=!0,this.min=new F.Vector3,this.max=new F.Vector3,this.matrix=new F.Matrix4,this.invMatrix=new F.Matrix4,this.points=new Array(8).fill().map(()=>new F.Vector3),this.satAxes=new Array(3).fill().map(()=>new F.Vector3),this.satBounds=new Array(3).fill().map(()=>new ug),this.alignedSatBounds=new Array(3).fill().map(()=>new ug),this.needsUpdate=!1,A&&this.min.copy(A),I&&this.max.copy(I),g&&this.matrix.copy(g)}set(A,I,g){this.min.copy(A),this.max.copy(I),this.matrix.copy(g),this.needsUpdate=!0}copy(A){this.min.copy(A.min),this.max.copy(A.max),this.matrix.copy(A.matrix),this.needsUpdate=!0}}cI.prototype.update=(function(){return function(){const A=this.matrix,I=this.min,g=this.max,Q=this.points;for(let o=0;o<=1;o++)for(let s=0;s<=1;s++)for(let t=0;t<=1;t++){const w=1*o|2*s|4*t,a=Q[w];a.x=o?g.x:I.x,a.y=s?g.y:I.y,a.z=t?g.z:I.z,a.applyMatrix4(A)}const C=this.satBounds,E=this.satAxes,i=Q[0];for(let o=0;o<3;o++){const s=E[o],t=C[o],w=1<<o,a=Q[w];s.subVectors(i,a),t.setFromPoints(s,Q)}const D=this.alignedSatBounds;D[0].setFromPointsField(Q,"x"),D[1].setFromPointsField(Q,"y"),D[2].setFromPointsField(Q,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();cI.prototype.intersectsBox=(function(){const B=new ug;return function(I){this.needsUpdate&&this.update();const g=I.min,Q=I.max,C=this.satBounds,E=this.satAxes,i=this.alignedSatBounds;if(B.min=g.x,B.max=Q.x,i[0].isSeparated(B)||(B.min=g.y,B.max=Q.y,i[1].isSeparated(B))||(B.min=g.z,B.max=Q.z,i[2].isSeparated(B)))return!1;for(let D=0;D<3;D++){const o=E[D],s=C[D];if(B.setFromBox(o,I),s.isSeparated(B))return!1}return!0}})();cI.prototype.intersectsTriangle=(function(){const B=new ZI,A=new Array(3),I=new ug,g=new ug,Q=new F.Vector3;return function(E){this.needsUpdate&&this.update(),E.isExtendedTriangle?E.needsUpdate&&E.update():(B.copy(E),B.update(),E=B);const i=this.satBounds,D=this.satAxes;A[0]=E.a,A[1]=E.b,A[2]=E.c;for(let w=0;w<3;w++){const a=i[w],y=D[w];if(I.setFromPoints(y,A),a.isSeparated(I))return!1}const o=E.satBounds,s=E.satAxes,t=this.points;for(let w=0;w<3;w++){const a=o[w],y=s[w];if(I.setFromPoints(y,t),a.isSeparated(I))return!1}for(let w=0;w<3;w++){const a=D[w];for(let y=0;y<4;y++){const R=s[y];if(Q.crossVectors(a,R),I.setFromPoints(Q,A),g.setFromPoints(Q,t),I.isSeparated(g))return!1}}return!0}})();cI.prototype.closestPointToPoint=(function(){return function(A,I){return this.needsUpdate&&this.update(),I.copy(A).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),I}})();cI.prototype.distanceToPoint=(function(){const B=new F.Vector3;return function(I){return this.closestPointToPoint(I,B),I.distanceTo(B)}})();cI.prototype.distanceToBox=(function(){const B=["x","y","z"],A=new Array(12).fill().map(()=>new F.Line3),I=new Array(12).fill().map(()=>new F.Line3),g=new F.Vector3,Q=new F.Vector3;return function(E,i=0,D=null,o=null){if(this.needsUpdate&&this.update(),this.intersectsBox(E))return(D||o)&&(E.getCenter(Q),this.closestPointToPoint(Q,g),E.closestPointToPoint(g,Q),D&&D.copy(g),o&&o.copy(Q)),0;const s=i*i,t=E.min,w=E.max,a=this.points;let y=1/0;for(let n=0;n<8;n++){const h=a[n];Q.copy(h).clamp(t,w);const G=h.distanceToSquared(Q);if(G<y&&(y=G,D&&D.copy(h),o&&o.copy(Q),G<s))return Math.sqrt(G)}let R=0;for(let n=0;n<3;n++)for(let h=0;h<=1;h++)for(let G=0;G<=1;G++){const r=(n+1)%3,M=(n+2)%3,k=h<<r|G<<M,J=1<<n|h<<r|G<<M,U=a[k],Y=a[J];A[R].set(U,Y);const H=B[n],f=B[r],l=B[M],p=I[R],q=p.start,m=p.end;q[H]=t[H],q[f]=h?t[f]:w[f],q[l]=G?t[l]:w[f],m[H]=w[H],m[f]=h?t[f]:w[f],m[l]=G?t[l]:w[f],R++}for(let n=0;n<=1;n++)for(let h=0;h<=1;h++)for(let G=0;G<=1;G++){Q.x=n?w.x:t.x,Q.y=h?w.y:t.y,Q.z=G?w.z:t.z,this.closestPointToPoint(Q,g);const r=Q.distanceToSquared(g);if(r<y&&(y=r,D&&D.copy(g),o&&o.copy(Q),r<s))return Math.sqrt(r)}for(let n=0;n<12;n++){const h=A[n];for(let G=0;G<12;G++){const r=I[G];no(h,r,g,Q);const M=g.distanceToSquared(Q);if(M<y&&(y=M,D&&D.copy(g),o&&o.copy(Q),M<s))return Math.sqrt(M)}}return Math.sqrt(y)}})();class _y extends eo{constructor(){super(()=>new ZI)}}const vI=new _y,aB=new F.Vector3,Vi=new F.Vector3;function $y(B,A,I={},g=0,Q=1/0){const C=g*g,E=Q*Q;let i=1/0,D=null;if(B.shapecast({boundsTraverseOrder:s=>(aB.copy(A).clamp(s.min,s.max),aB.distanceToSquared(A)),intersectsBounds:(s,t,w)=>w<i&&w<E,intersectsTriangle:(s,t)=>{s.closestPointToPoint(A,aB);const w=A.distanceToSquared(aB);return w<i&&(Vi.copy(aB),i=w,D=t),w<C}}),i===1/0)return null;const o=Math.sqrt(i);return I.point?I.point.copy(Vi):I.point=Vi.clone(),I.distance=o,I.faceIndex=D,I}const $C=parseInt(F.REVISION)>=169,AG=parseInt(F.REVISION)<=161,AQ=new F.Vector3,IQ=new F.Vector3,gQ=new F.Vector3,AE=new F.Vector2,IE=new F.Vector2,gE=new F.Vector2,Vs=new F.Vector3,Zs=new F.Vector3,Ws=new F.Vector3,eB=new F.Vector3;function IG(B,A,I,g,Q,C,E,i){let D;if(C===F.BackSide?D=B.intersectTriangle(g,I,A,!0,Q):D=B.intersectTriangle(A,I,g,C!==F.DoubleSide,Q),D===null)return null;const o=B.origin.distanceTo(Q);return o<E||o>i?null:{distance:o,point:Q.clone()}}function js(B,A,I,g,Q,C,E,i,D,o,s){AQ.fromBufferAttribute(A,C),IQ.fromBufferAttribute(A,E),gQ.fromBufferAttribute(A,i);const t=IG(B,AQ,IQ,gQ,eB,D,o,s);if(t){if(g){AE.fromBufferAttribute(g,C),IE.fromBufferAttribute(g,E),gE.fromBufferAttribute(g,i),t.uv=new F.Vector2;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,AE,IE,gE,t.uv);$C||(t.uv=a)}if(Q){AE.fromBufferAttribute(Q,C),IE.fromBufferAttribute(Q,E),gE.fromBufferAttribute(Q,i),t.uv1=new F.Vector2;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,AE,IE,gE,t.uv1);$C||(t.uv1=a),AG&&(t.uv2=t.uv1)}if(I){Vs.fromBufferAttribute(I,C),Zs.fromBufferAttribute(I,E),Ws.fromBufferAttribute(I,i),t.normal=new F.Vector3;const a=F.Triangle.getInterpolation(eB,AQ,IQ,gQ,Vs,Zs,Ws,t.normal);t.normal.dot(B.direction)>0&&t.normal.multiplyScalar(-1),$C||(t.normal=a)}const w={a:C,b:E,c:i,normal:new F.Vector3,materialIndex:0};if(F.Triangle.getNormal(AQ,IQ,gQ,w.normal),t.face=w,t.faceIndex=C,$C){const a=new F.Vector3;F.Triangle.getBarycoord(eB,AQ,IQ,gQ,a),t.barycoord=a}}return t}function zs(B){return B&&B.isMaterial?B.side:B}function Ii(B,A,I,g,Q,C,E){const i=g*3;let D=i+0,o=i+1,s=i+2;const{index:t,groups:w}=B;B.index&&(D=t.getX(D),o=t.getX(o),s=t.getX(s));const{position:a,normal:y,uv:R,uv1:n}=B.attributes;if(Array.isArray(A)){const h=g*3;for(let G=0,r=w.length;G<r;G++){const{start:M,count:k,materialIndex:J}=w[G];if(h>=M&&h<M+k){const U=zs(A[J]),Y=js(I,a,y,R,n,D,o,s,U,C,E);if(Y)if(Y.faceIndex=g,Y.face.materialIndex=J,Q)Q.push(Y);else return Y}}}else{const h=zs(A),G=js(I,a,y,R,n,D,o,s,h,C,E);if(G)if(G.faceIndex=g,G.face.materialIndex=0,Q)Q.push(G);else return G}return null}function TA(B,A,I,g){const Q=B.a,C=B.b,E=B.c;let i=A,D=A+1,o=A+2;I&&(i=I.getX(i),D=I.getX(D),o=I.getX(o)),Q.x=g.getX(i),Q.y=g.getY(i),Q.z=g.getZ(i),C.x=g.getX(D),C.y=g.getY(D),C.z=g.getZ(D),E.x=g.getX(o),E.y=g.getY(o),E.z=g.getZ(o)}function gG(B,A,I,g,Q,C,E,i){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++)Ii(D,A,I,s,C,E,i)}function QG(B,A,I,g,Q,C,E){const{geometry:i,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=Ii(i,A,I,t,null,C,E),a&&a.distance<o&&(s=a,o=a.distance)}return s}function BG(B,A,I,g,Q,C,E){const{geometry:i}=I,{index:D}=i,o=i.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=s,TA(E,w*3,D,o),E.needsUpdate=!0,g(E,w,Q,C))return!0}return!1}function CG(B,A=null){A&&Array.isArray(A)&&(A=new Set(A));const I=B.geometry,g=I.index?I.index.array:null,Q=I.attributes.position;let C,E,i,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],E=new Uint32Array(C),i=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,y=!1){const R=w*2;if(VA(R,i)){const n=aI(w,E),h=RI(R,i);let G=1/0,r=1/0,M=1/0,k=-1/0,J=-1/0,U=-1/0;for(let Y=3*n,d=3*(n+h);Y<d;Y++){let H=g[Y];const f=Q.getX(H),l=Q.getY(H),p=Q.getZ(H);f<G&&(G=f),f>k&&(k=f),l<r&&(r=l),l>J&&(J=l),p<M&&(M=p),p>U&&(U=p)}return D[w+0]!==G||D[w+1]!==r||D[w+2]!==M||D[w+3]!==k||D[w+4]!==J||D[w+5]!==U?(D[w+0]=G,D[w+1]=r,D[w+2]=M,D[w+3]=k,D[w+4]=J,D[w+5]=U,!0):!1}else{const n=AI(w),h=II(w,E);let G=y,r=!1,M=!1;if(A){if(!G){const H=n/vA+a/wI,f=h/vA+a/wI;r=A.has(H),M=A.has(f),G=!r&&!M}}else r=!0,M=!0;const k=G||r,J=G||M;let U=!1;k&&(U=t(n,a,G));let Y=!1;J&&(Y=t(h,a,G));const d=U||Y;if(d)for(let H=0;H<3;H++){const f=n+H,l=h+H,p=D[f],q=D[f+3],m=D[l],T=D[l+3];D[w+H]=p<m?p:m,D[w+H+3]=q>T?q:T}return d}}}function Wg(B,A,I,g,Q){let C,E,i,D,o,s;const t=1/I.direction.x,w=1/I.direction.y,a=1/I.direction.z,y=I.origin.x,R=I.origin.y,n=I.origin.z;let h=A[B],G=A[B+3],r=A[B+1],M=A[B+3+1],k=A[B+2],J=A[B+3+2];return t>=0?(C=(h-y)*t,E=(G-y)*t):(C=(G-y)*t,E=(h-y)*t),w>=0?(i=(r-R)*w,D=(M-R)*w):(i=(M-R)*w,D=(r-R)*w),C>D||i>E||((i>C||isNaN(C))&&(C=i),(D<E||isNaN(E))&&(E=D),a>=0?(o=(k-n)*a,s=(J-n)*a):(o=(J-n)*a,s=(k-n)*a),C>s||o>E)?!1:((o>C||C!==C)&&(C=o),(s<E||E!==E)&&(E=s),C<=Q&&E>=g)}function EG(B,A,I,g,Q,C,E,i){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++){let w=o?o[s]:s;Ii(D,A,I,w,C,E,i)}}function iG(B,A,I,g,Q,C,E){const{geometry:i,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=Ii(i,A,I,D?D[t]:t,null,C,E),a&&a.distance<o&&(s=a,o=a.distance)}return s}function DG(B,A,I,g,Q,C,E){const{geometry:i}=I,{index:D}=i,o=i.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=I.resolveTriangleIndex(s),TA(E,w*3,D,o),E.needsUpdate=!0,g(E,w,Q,C))return!0}return!1}function oG(B,A,I,g,Q,C,E){KA.setBuffer(B._roots[A]),KD(0,B,I,g,Q,C,E),KA.clearBuffer()}function KD(B,A,I,g,Q,C,E){const{float32Array:i,uint16Array:D,uint32Array:o}=KA,s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);gG(A,I,g,w,a,Q,C,E)}else{const w=AI(B);Wg(w,i,g,C,E)&&KD(w,A,I,g,Q,C,E);const a=II(B,o);Wg(a,i,g,C,E)&&KD(a,A,I,g,Q,C,E)}}const sG=["x","y","z"];function tG(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const E=dD(0,B,I,g,Q,C);return KA.clearBuffer(),E}function dD(B,A,I,g,Q,C){const{float32Array:E,uint16Array:i,uint32Array:D}=KA;let o=B*2;if(VA(o,i)){const t=aI(B,D),w=RI(o,i);return QG(A,I,g,t,w,Q,C)}else{const t=ao(B,D),w=sG[t],y=g.direction[w]>=0;let R,n;y?(R=AI(B),n=II(B,D)):(R=II(B,D),n=AI(B));const G=Wg(R,E,g,Q,C)?dD(R,A,I,g,Q,C):null;if(G){const k=G.point[w];if(y?k<=E[n+t]:k>=E[n+t+3])return G}const M=Wg(n,E,g,Q,C)?dD(n,A,I,g,Q,C):null;return G&&M?G.distance<=M.distance?G:M:G||M||null}}const QE=new F.Box3,pQ=new ZI,uQ=new ZI,cB=new F.Matrix4,_s=new cI,BE=new cI;function wG(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=lD(0,B,I,g);return KA.clearBuffer(),Q}function lD(B,A,I,g,Q=null){const{float32Array:C,uint16Array:E,uint32Array:i}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),_s.set(I.boundingBox.min,I.boundingBox.max,g),Q=_s),VA(D,E)){const s=A.geometry,t=s.index,w=s.attributes.position,a=I.index,y=I.attributes.position,R=aI(B,i),n=RI(D,E);if(cB.copy(g).invert(),I.boundsTree)return pA(B,C,BE),BE.matrix.copy(cB),BE.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:G=>BE.intersectsBox(G),intersectsTriangle:G=>{G.a.applyMatrix4(g),G.b.applyMatrix4(g),G.c.applyMatrix4(g),G.needsUpdate=!0;for(let r=R*3,M=(n+R)*3;r<M;r+=3)if(TA(uQ,r,t,w),uQ.needsUpdate=!0,G.intersectsTriangle(uQ))return!0;return!1}});{const h=Ai(I);for(let G=R*3,r=(n+R)*3;G<r;G+=3){TA(pQ,G,t,w),pQ.a.applyMatrix4(cB),pQ.b.applyMatrix4(cB),pQ.c.applyMatrix4(cB),pQ.needsUpdate=!0;for(let M=0,k=h*3;M<k;M+=3)if(TA(uQ,M,a,y),uQ.needsUpdate=!0,pQ.intersectsTriangle(uQ))return!0}}}else{const s=AI(B),t=II(B,i);return pA(s,C,QE),!!(Q.intersectsBox(QE)&&lD(s,A,I,g,Q)||(pA(t,C,QE),Q.intersectsBox(QE)&&lD(t,A,I,g,Q)))}}const CE=new F.Matrix4,Zi=new cI,nB=new cI,aG=new F.Vector3,eG=new F.Vector3,cG=new F.Vector3,nG=new F.Vector3;function hG(B,A,I,g={},Q={},C=0,E=1/0){A.boundingBox||A.computeBoundingBox(),Zi.set(A.boundingBox.min,A.boundingBox.max,I),Zi.needsUpdate=!0;const i=B.geometry,D=i.attributes.position,o=i.index,s=A.attributes.position,t=A.index,w=vI.getPrimitive(),a=vI.getPrimitive();let y=aG,R=eG,n=null,h=null;Q&&(n=cG,h=nG);let G=1/0,r=null,M=null;return CE.copy(I).invert(),nB.matrix.copy(CE),B.shapecast({boundsTraverseOrder:k=>Zi.distanceToBox(k),intersectsBounds:(k,J,U)=>U<G&&U<E?(J&&(nB.min.copy(k.min),nB.max.copy(k.max),nB.needsUpdate=!0),!0):!1,intersectsRange:(k,J)=>{if(A.boundsTree)return A.boundsTree.shapecast({boundsTraverseOrder:Y=>nB.distanceToBox(Y),intersectsBounds:(Y,d,H)=>H<G&&H<E,intersectsRange:(Y,d)=>{for(let H=Y,f=Y+d;H<f;H++){TA(a,3*H,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let l=k,p=k+J;l<p;l++){TA(w,3*l,o,D),w.needsUpdate=!0;const q=w.distanceToTriangle(a,y,n);if(q<G&&(R.copy(y),h&&h.copy(n),G=q,r=l,M=H),q<C)return!0}}}});{const U=Ai(A);for(let Y=0,d=U;Y<d;Y++){TA(a,3*Y,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let H=k,f=k+J;H<f;H++){TA(w,3*H,o,D),w.needsUpdate=!0;const l=w.distanceToTriangle(a,y,n);if(l<G&&(R.copy(y),h&&h.copy(n),G=l,r=H,M=Y),l<C)return!0}}}}}),vI.releasePrimitive(w),vI.releasePrimitive(a),G===1/0?null:(g.point?g.point.copy(R):g.point=R.clone(),g.distance=G,g.faceIndex=r,Q&&(Q.point?Q.point.copy(h):Q.point=h.clone(),Q.point.applyMatrix4(CE),R.applyMatrix4(CE),Q.distance=R.sub(Q.point).length(),Q.faceIndex=M),g)}function yG(B,A=null){A&&Array.isArray(A)&&(A=new Set(A));const I=B.geometry,g=I.index?I.index.array:null,Q=I.attributes.position;let C,E,i,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],E=new Uint32Array(C),i=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,y=!1){const R=w*2;if(VA(R,i)){const n=aI(w,E),h=RI(R,i);let G=1/0,r=1/0,M=1/0,k=-1/0,J=-1/0,U=-1/0;for(let Y=n,d=n+h;Y<d;Y++){const H=3*B.resolveTriangleIndex(Y);for(let f=0;f<3;f++){let l=H+f;l=g?g[l]:l;const p=Q.getX(l),q=Q.getY(l),m=Q.getZ(l);p<G&&(G=p),p>k&&(k=p),q<r&&(r=q),q>J&&(J=q),m<M&&(M=m),m>U&&(U=m)}}return D[w+0]!==G||D[w+1]!==r||D[w+2]!==M||D[w+3]!==k||D[w+4]!==J||D[w+5]!==U?(D[w+0]=G,D[w+1]=r,D[w+2]=M,D[w+3]=k,D[w+4]=J,D[w+5]=U,!0):!1}else{const n=AI(w),h=II(w,E);let G=y,r=!1,M=!1;if(A){if(!G){const H=n/vA+a/wI,f=h/vA+a/wI;r=A.has(H),M=A.has(f),G=!r&&!M}}else r=!0,M=!0;const k=G||r,J=G||M;let U=!1;k&&(U=t(n,a,G));let Y=!1;J&&(Y=t(h,a,G));const d=U||Y;if(d)for(let H=0;H<3;H++){const f=n+H,l=h+H,p=D[f],q=D[f+3],m=D[l],T=D[l+3];D[w+H]=p<m?p:m,D[w+H+3]=q>T?q:T}return d}}}function GG(B,A,I,g,Q,C,E){KA.setBuffer(B._roots[A]),fD(0,B,I,g,Q,C,E),KA.clearBuffer()}function fD(B,A,I,g,Q,C,E){const{float32Array:i,uint16Array:D,uint32Array:o}=KA,s=B*2;if(VA(s,D)){const w=aI(B,o),a=RI(s,D);EG(A,I,g,w,a,Q,C,E)}else{const w=AI(B);Wg(w,i,g,C,E)&&fD(w,A,I,g,Q,C,E);const a=II(B,o);Wg(a,i,g,C,E)&&fD(a,A,I,g,Q,C,E)}}const rG=["x","y","z"];function SG(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const E=xD(0,B,I,g,Q,C);return KA.clearBuffer(),E}function xD(B,A,I,g,Q,C){const{float32Array:E,uint16Array:i,uint32Array:D}=KA;let o=B*2;if(VA(o,i)){const t=aI(B,D),w=RI(o,i);return iG(A,I,g,t,w,Q,C)}else{const t=ao(B,D),w=rG[t],y=g.direction[w]>=0;let R,n;y?(R=AI(B),n=II(B,D)):(R=II(B,D),n=AI(B));const G=Wg(R,E,g,Q,C)?xD(R,A,I,g,Q,C):null;if(G){const k=G.point[w];if(y?k<=E[n+t]:k>=E[n+t+3])return G}const M=Wg(n,E,g,Q,C)?xD(n,A,I,g,Q,C):null;return G&&M?G.distance<=M.distance?G:M:G||M||null}}const EE=new F.Box3,qQ=new ZI,bQ=new ZI,hB=new F.Matrix4,$s=new cI,iE=new cI;function RG(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=pD(0,B,I,g);return KA.clearBuffer(),Q}function pD(B,A,I,g,Q=null){const{float32Array:C,uint16Array:E,uint32Array:i}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),$s.set(I.boundingBox.min,I.boundingBox.max,g),Q=$s),VA(D,E)){const s=A.geometry,t=s.index,w=s.attributes.position,a=I.index,y=I.attributes.position,R=aI(B,i),n=RI(D,E);if(hB.copy(g).invert(),I.boundsTree)return pA(B,C,iE),iE.matrix.copy(hB),iE.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:G=>iE.intersectsBox(G),intersectsTriangle:G=>{G.a.applyMatrix4(g),G.b.applyMatrix4(g),G.c.applyMatrix4(g),G.needsUpdate=!0;for(let r=R,M=n+R;r<M;r++)if(TA(bQ,3*A.resolveTriangleIndex(r),t,w),bQ.needsUpdate=!0,G.intersectsTriangle(bQ))return!0;return!1}});{const h=Ai(I);for(let G=R,r=n+R;G<r;G++){const M=A.resolveTriangleIndex(G);TA(qQ,3*M,t,w),qQ.a.applyMatrix4(hB),qQ.b.applyMatrix4(hB),qQ.c.applyMatrix4(hB),qQ.needsUpdate=!0;for(let k=0,J=h*3;k<J;k+=3)if(TA(bQ,k,a,y),bQ.needsUpdate=!0,qQ.intersectsTriangle(bQ))return!0}}}else{const s=AI(B),t=II(B,i);return pA(s,C,EE),!!(Q.intersectsBox(EE)&&pD(s,A,I,g,Q)||(pA(t,C,EE),Q.intersectsBox(EE)&&pD(t,A,I,g,Q)))}}const DE=new F.Matrix4,Wi=new cI,yB=new cI,FG=new F.Vector3,kG=new F.Vector3,MG=new F.Vector3,NG=new F.Vector3;function JG(B,A,I,g={},Q={},C=0,E=1/0){A.boundingBox||A.computeBoundingBox(),Wi.set(A.boundingBox.min,A.boundingBox.max,I),Wi.needsUpdate=!0;const i=B.geometry,D=i.attributes.position,o=i.index,s=A.attributes.position,t=A.index,w=vI.getPrimitive(),a=vI.getPrimitive();let y=FG,R=kG,n=null,h=null;Q&&(n=MG,h=NG);let G=1/0,r=null,M=null;return DE.copy(I).invert(),yB.matrix.copy(DE),B.shapecast({boundsTraverseOrder:k=>Wi.distanceToBox(k),intersectsBounds:(k,J,U)=>U<G&&U<E?(J&&(yB.min.copy(k.min),yB.max.copy(k.max),yB.needsUpdate=!0),!0):!1,intersectsRange:(k,J)=>{if(A.boundsTree){const U=A.boundsTree;return U.shapecast({boundsTraverseOrder:Y=>yB.distanceToBox(Y),intersectsBounds:(Y,d,H)=>H<G&&H<E,intersectsRange:(Y,d)=>{for(let H=Y,f=Y+d;H<f;H++){const l=U.resolveTriangleIndex(H);TA(a,3*l,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let p=k,q=k+J;p<q;p++){const m=B.resolveTriangleIndex(p);TA(w,3*m,o,D),w.needsUpdate=!0;const T=w.distanceToTriangle(a,y,n);if(T<G&&(R.copy(y),h&&h.copy(n),G=T,r=p,M=H),T<C)return!0}}}})}else{const U=Ai(A);for(let Y=0,d=U;Y<d;Y++){TA(a,3*Y,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let H=k,f=k+J;H<f;H++){const l=B.resolveTriangleIndex(H);TA(w,3*l,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,y,n);if(p<G&&(R.copy(y),h&&h.copy(n),G=p,r=H,M=Y),p<C)return!0}}}}}),vI.releasePrimitive(w),vI.releasePrimitive(a),G===1/0?null:(g.point?g.point.copy(R):g.point=R.clone(),g.distance=G,g.faceIndex=r,Q&&(Q.point?Q.point.copy(h):Q.point=h.clone(),Q.point.applyMatrix4(DE),R.applyMatrix4(DE),Q.distance=R.sub(Q.point).length(),Q.faceIndex=M),g)}function At(B,A,I){return B===null?null:(B.point.applyMatrix4(A.matrixWorld),B.distance=B.point.distanceTo(I.ray.origin),B.object=A,B)}const oE=new cI,sE=new F.Ray,It=new F.Vector3,gt=new F.Matrix4,Qt=new F.Vector3,ji=["getX","getY","getZ"];class gB extends ra{static serialize(A,I={}){I={cloneBuffers:!0,...I};const g=A.geometry,Q=A._roots,C=A._indirectBuffer,E=g.getIndex(),i={version:1,roots:null,index:null,indirectBuffer:null};return I.cloneBuffers?(i.roots=Q.map(D=>D.slice()),i.index=E?E.array.slice():null,i.indirectBuffer=C?C.slice():null):(i.roots=Q,i.index=E?E.array:null,i.indirectBuffer=C),i}static deserialize(A,I,g={}){g={setIndex:!0,indirect:!!A.indirectBuffer,...g};const{index:Q,roots:C,indirectBuffer:E}=A;A.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),D(C));const i=new gB(I,{...g,[$E]:!0});if(i._roots=C,i._indirectBuffer=E||null,g.setIndex){const o=I.getIndex();if(o===null){const s=new F.BufferAttribute(A.index,1,!1);I.setIndex(s)}else o.array!==Q&&(o.array.set(Q),o.needsUpdate=!0)}return i;function D(o){for(let s=0;s<o.length;s++){const t=o[s],w=new Uint32Array(t),a=new Uint16Array(t);for(let y=0,R=t.byteLength/wI;y<R;y++){const n=vA*y,h=2*n;VA(h,a)||(w[n+6]=w[n+6]/vA-y)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(A,I={}){I.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),I={...I,maxLeafSize:I.maxLeafTris}),super(A,I)}shiftTriangleOffsets(A){return super.shiftPrimitiveOffsets(A)}writePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,E=Q.attributes.position,i=Q.index?Q.index.array:null,o=(C?C[A]:A)*3;let s=o+0,t=o+1,w=o+2;i&&(s=i[s],t=i[t],w=i[w]);for(let a=0;a<3;a++){const y=E[ji[a]](s),R=E[ji[a]](t),n=E[ji[a]](w);let h=y;R<h&&(h=R),n<h&&(h=n);let G=y;R>G&&(G=R),n>G&&(G=n),I[g+a]=h,I[g+a+3]=G}return I}computePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,E=Q.attributes.position,i=Q.index?Q.index.array:null,D=E.normalized;if(A<0||I+A-g.offset>g.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const o=E.array,s=E.offset||0;let t=3;E.isInterleavedBufferAttribute&&(t=E.data.stride);const w=["getX","getY","getZ"],a=g.offset;for(let y=A,R=A+I;y<R;y++){const h=(C?C[y]:y)*3,G=(y-a)*6;let r=h+0,M=h+1,k=h+2;i&&(r=i[r],M=i[M],k=i[k]),D||(r=r*t+s,M=M*t+s,k=k*t+s);for(let J=0;J<3;J++){let U,Y,d;D?(U=E[w[J]](r),Y=E[w[J]](M),d=E[w[J]](k)):(U=o[r+J],Y=o[M+J],d=o[k+J]);let H=U;Y<H&&(H=Y),d<H&&(H=d);let f=U;Y>f&&(f=Y),d>f&&(f=d);const l=(f-H)/2,p=J*2;g[G+p+0]=H+l,g[G+p+1]=l+(Math.abs(H)+l)*SE}}return g}raycastObject3D(A,I,g=[]){const{material:Q}=A;if(Q===void 0)return;gt.copy(A.matrixWorld).invert(),sE.copy(I.ray).applyMatrix4(gt),Qt.setFromMatrixScale(A.matrixWorld),It.copy(sE.direction).multiply(Qt);const C=It.length(),E=I.near/C,i=I.far/C;if(I.firstHitOnly===!0){let D=this.raycastFirst(sE,Q,E,i);D=At(D,A,I),D&&g.push(D)}else{const D=this.raycast(sE,Q,E,i);for(let o=0,s=D.length;o<s;o++){const t=At(D[o],A,I);t&&g.push(t)}}return g}refit(A=null){return(this.indirect?yG:CG)(this,A)}raycast(A,I=F.FrontSide,g=0,Q=1/0){const C=this._roots,E=[],i=this.indirect?GG:oG;for(let D=0,o=C.length;D<o;D++)i(this,D,I,A,E,g,Q);return E}raycastFirst(A,I=F.FrontSide,g=0,Q=1/0){const C=this._roots;let E=null;const i=this.indirect?SG:tG;for(let D=0,o=C.length;D<o;D++){const s=i(this,D,I,A,g,Q);s!=null&&(E==null||s.distance<E.distance)&&(E=s)}return E}intersectsGeometry(A,I){let g=!1;const Q=this._roots,C=this.indirect?RG:wG;for(let E=0,i=Q.length;E<i&&(g=C(this,E,A,I),!g);E++);return g}shapecast(A){const I=vI.getPrimitive(),g=super.shapecast({...A,intersectsPrimitive:A.intersectsTriangle,scratchPrimitive:I,iterate:this.indirect?DG:BG});return vI.releasePrimitive(I),g}bvhcast(A,I,g){let{intersectsRanges:Q,intersectsTriangles:C}=g;const E=vI.getPrimitive(),i=this.geometry.index,D=this.geometry.attributes.position,o=this.indirect?y=>{const R=this.resolveTriangleIndex(y);TA(E,R*3,i,D)}:y=>{TA(E,y*3,i,D)},s=vI.getPrimitive(),t=A.geometry.index,w=A.geometry.attributes.position,a=A.indirect?y=>{const R=A.resolveTriangleIndex(y);TA(s,R*3,t,w)}:y=>{TA(s,y*3,t,w)};if(C){if(!(A instanceof gB))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const y=(R,n,h,G,r,M,k,J)=>{for(let U=h,Y=h+G;U<Y;U++){a(U),s.a.applyMatrix4(I),s.b.applyMatrix4(I),s.c.applyMatrix4(I),s.needsUpdate=!0;for(let d=R,H=R+n;d<H;d++)if(o(d),E.needsUpdate=!0,C(E,s,d,U,r,M,k,J))return!0}return!1};if(Q){const R=Q;Q=function(n,h,G,r,M,k,J,U){return R(n,h,G,r,M,k,J,U)?!0:y(n,h,G,r,M,k,J,U)}}else Q=y}return super.bvhcast(A,I,{intersectsRanges:Q})}intersectsBox(A,I){return oE.set(A.min,A.max,I),oE.needsUpdate=!0,this.shapecast({intersectsBounds:g=>oE.intersectsBox(g),intersectsTriangle:g=>oE.intersectsTriangle(g)})}intersectsSphere(A){return this.shapecast({intersectsBounds:I=>A.intersectsBox(I),intersectsTriangle:I=>I.intersectsSphere(A)})}closestPointToGeometry(A,I,g={},Q={},C=0,E=1/0){return(this.indirect?JG:hG)(this,A,I,g,Q,C,E)}closestPointToPoint(A,I={},g=0,Q=1/0){return $y(this,A,I,g,Q)}}const PQ={Mesh:F.Mesh.prototype.raycast,Line:F.Line.prototype.raycast,LineSegments:F.LineSegments.prototype.raycast,LineLoop:F.LineLoop.prototype.raycast,Points:F.Points.prototype.raycast,BatchedMesh:F.BatchedMesh.prototype.raycast},CI=new F.Mesh,tE=[];function UG(B,A){if(this.isBatchedMesh)LG.call(this,B,A);else{const{geometry:I}=this;if(I.boundsTree)I.boundsTree.raycastObject3D(this,B,A);else{let g;if(this instanceof F.Mesh)g=PQ.Mesh;else if(this instanceof F.LineSegments)g=PQ.LineSegments;else if(this instanceof F.LineLoop)g=PQ.LineLoop;else if(this instanceof F.Line)g=PQ.Line;else if(this instanceof F.Points)g=PQ.Points;else throw new Error("BVH: Fallback raycast function not found.");g.call(this,B,A)}}}function LG(B,A){if(this.boundsTrees){const I=this.boundsTrees,g=this._drawInfo||this._instanceInfo,Q=this._drawRanges||this._geometryInfo,C=this.matrixWorld;CI.material=this.material,CI.geometry=this.geometry;const E=CI.geometry.boundsTree,i=CI.geometry.drawRange;CI.geometry.boundingSphere===null&&(CI.geometry.boundingSphere=new F.Sphere);for(let D=0,o=g.length;D<o;D++){if(!this.getVisibleAt(D))continue;const s=g[D].geometryIndex;if(CI.geometry.boundsTree=I[s],this.getMatrixAt(D,CI.matrixWorld).premultiply(C),!CI.geometry.boundsTree){this.getBoundingBoxAt(s,CI.geometry.boundingBox),this.getBoundingSphereAt(s,CI.geometry.boundingSphere);const t=Q[s];CI.geometry.setDrawRange(t.start,t.count)}CI.raycast(B,tE);for(let t=0,w=tE.length;t<w;t++){const a=tE[t];a.object=this,a.batchId=D,A.push(a)}tE.length=0}CI.geometry.boundsTree=E,CI.geometry.drawRange=i,CI.material=null,CI.geometry=null}else PQ.BatchedMesh.call(this,B,A)}function HG(B={}){const{type:A=gB}=B;return this.boundsTree=new A(this,B),this.boundsTree}const QQ=new F.Vector3,BQ=new F.Vector3,CQ=new F.Vector3,Bt=new F.Vector4,wE=new F.Vector3,zi=new F.Vector3,Ct=new F.Vector4,Et=new F.Vector4,aE=new F.Matrix4,it=new F.Matrix4;function GB(B,A){if(!B&&!A)return;const I=B.count===A.count,g=B.normalized===A.normalized,Q=B.array.constructor===A.array.constructor,C=B.itemSize===A.itemSize;if(!I||!g||!Q||!C)throw new Error}function YB(B,A=null){const I=B.array.constructor,g=B.normalized,Q=B.itemSize,C=A===null?B.count:A;return new F.BufferAttribute(new I(Q*C),Q,g)}function Sa(B,A,I=0){if(B.isInterleavedBufferAttribute){const g=B.itemSize;for(let Q=0,C=B.count;Q<C;Q++){const E=Q+I;A.setX(E,B.getX(Q)),g>=2&&A.setY(E,B.getY(Q)),g>=3&&A.setZ(E,B.getZ(Q)),g>=4&&A.setW(E,B.getW(Q))}}else{const g=A.array,Q=g.constructor,C=g.BYTES_PER_ELEMENT*B.itemSize*I;new Q(g.buffer,C,B.array.length).set(B.array)}}function YG(B,A,I){const g=B.elements,Q=A.elements;for(let C=0,E=Q.length;C<E;C++)g[C]+=Q[C]*I}function Dt(B,A,I){const g=B.skeleton,Q=B.geometry,C=g.bones,E=g.boneInverses;Ct.fromBufferAttribute(Q.attributes.skinIndex,A),Et.fromBufferAttribute(Q.attributes.skinWeight,A),aE.elements.fill(0);for(let i=0;i<4;i++){const D=Et.getComponent(i);if(D!==0){const o=Ct.getComponent(i);it.multiplyMatrices(C[o].matrixWorld,E[o]),YG(aE,it,D)}}return aE.multiply(B.bindMatrix).premultiply(B.bindMatrixInverse),I.transformDirection(aE),I}function _i(B,A,I,g,Q){wE.set(0,0,0);for(let C=0,E=B.length;C<E;C++){const i=A[C],D=B[C];i!==0&&(zi.fromBufferAttribute(D,g),I?wE.addScaledVector(zi,i):wE.addScaledVector(zi.sub(Q),i))}Q.add(wE)}function KG(B,A={useGroups:!1,updateIndex:!1,skipAttributes:[]},I=new F.BufferGeometry){const g=B[0].index!==null,{useGroups:Q=!1,updateIndex:C=!1,skipAttributes:E=[]}=A,i=new Set(Object.keys(B[0].attributes)),D={};let o=0;I.clearGroups();for(let s=0;s<B.length;++s){const t=B[s];let w=0;if(g!==(t.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 a in t.attributes){if(!i.has(a))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+a+'" attribute exists among all geometries, or in none of them.');D[a]===void 0&&(D[a]=[]),D[a].push(t.attributes[a]),w++}if(w!==i.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(Q){let a;if(g)a=t.index.count;else if(t.attributes.position!==void 0)a=t.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");I.addGroup(o,a,s),o+=a}}if(g){let s=!1;if(!I.index){let t=0;for(let w=0;w<B.length;++w)t+=B[w].index.count;I.setIndex(new F.BufferAttribute(new Uint32Array(t),1,!1)),s=!0}if(C||s){const t=I.index;let w=0,a=0;for(let y=0;y<B.length;++y){const R=B[y],n=R.index;if(E[y]!==!0)for(let h=0;h<n.count;++h)t.setX(w,n.getX(h)+a),w++;a+=R.attributes.position.count}}}for(const s in D){const t=D[s];if(!(s in I.attributes)){let y=0;for(const R in t)y+=t[R].count;I.setAttribute(s,YB(D[s][0],y))}const w=I.attributes[s];let a=0;for(let y=0,R=t.length;y<R;y++){const n=t[y];E[y]!==!0&&Sa(n,w,a),a+=n.count}}return I}function dG(B,A){if(B===null||A===null)return B===A;if(B.length!==A.length)return!1;for(let I=0,g=B.length;I<g;I++)if(B[I]!==A[I])return!1;return!0}function lG(B){const{index:A,attributes:I}=B;if(A)for(let g=0,Q=A.count;g<Q;g+=3){const C=A.getX(g),E=A.getX(g+2);A.setX(g,E),A.setX(g+2,C)}else for(const g in I){const Q=I[g],C=Q.itemSize;for(let E=0,i=Q.count;E<i;E+=3)for(let D=0;D<C;D++){const o=Q.getComponent(E,D),s=Q.getComponent(E+2,D);Q.setComponent(E,D,s),Q.setComponent(E+2,D,o)}}return B}class fG{constructor(A){this.matrixWorld=new F.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=A,this.update()}update(){const A=this.mesh,I=A.geometry,g=A.skeleton,Q=(I.index?I.index.count:I.attributes.position.count)/3;if(this.matrixWorld.copy(A.matrixWorld),this.geometryHash=I.attributes.position.version,this.primitiveCount=Q,g){g.boneTexture||g.computeBoneTexture(),g.update();const C=g.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==C.length?this.boneMatrices=C.slice():this.boneMatrices.set(C)}else this.boneMatrices=null}didChange(){const A=this.mesh,I=A.geometry,g=(I.index?I.index.count:I.attributes.position.count)/3;return!(this.matrixWorld.equals(A.matrixWorld)&&this.geometryHash===I.attributes.position.version&&dG(A.skeleton&&A.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===g)}}class xG{constructor(A){Array.isArray(A)||(A=[A]);const I=[];A.forEach(g=>{g.traverseVisible(Q=>{Q.isMesh&&I.push(Q)})}),this.meshes=I,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(I.length).fill().map(()=>new F.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const A=[];return this.meshes.forEach(I=>{Array.isArray(I.material)?A.push(...I.material):A.push(I.material)}),A}generate(A=new F.BufferGeometry){let I=[];const{meshes:g,useGroups:Q,_intermediateGeometry:C,_diffMap:E}=this;for(let i=0,D=g.length;i<D;i++){const o=g[i],s=C[i],t=E.get(o);!t||t.didChange(o)?(this._convertToStaticGeometry(o,s),I.push(!1),t?t.update():E.set(o,new fG(o))):I.push(!0)}if(C.length===0){A.setIndex(null);const i=A.attributes;for(const D in i)A.deleteAttribute(D);for(const D in this.attributes)A.setAttribute(this.attributes[D],new F.BufferAttribute(new Float32Array(0),4,!1))}else KG(C,{useGroups:Q,skipAttributes:I},A);for(const i in A.attributes)A.attributes[i].needsUpdate=!0;return A}_convertToStaticGeometry(A,I=new F.BufferGeometry){const g=A.geometry,Q=this.applyWorldTransforms,C=this.attributes.includes("normal"),E=this.attributes.includes("tangent"),i=g.attributes,D=I.attributes;!I.index&&g.index&&(I.index=g.index.clone()),D.position||I.setAttribute("position",YB(i.position)),C&&!D.normal&&i.normal&&I.setAttribute("normal",YB(i.normal)),E&&!D.tangent&&i.tangent&&I.setAttribute("tangent",YB(i.tangent)),GB(g.index,I.index),GB(i.position,D.position),C&&GB(i.normal,D.normal),E&&GB(i.tangent,D.tangent);const o=i.position,s=C?i.normal:null,t=E?i.tangent:null,w=g.morphAttributes.position,a=g.morphAttributes.normal,y=g.morphAttributes.tangent,R=g.morphTargetsRelative,n=A.morphTargetInfluences,h=new F.Matrix3;h.getNormalMatrix(A.matrixWorld),g.index&&I.index.array.set(g.index.array);for(let G=0,r=i.position.count;G<r;G++)QQ.fromBufferAttribute(o,G),s&&BQ.fromBufferAttribute(s,G),t&&(Bt.fromBufferAttribute(t,G),CQ.fromBufferAttribute(t,G)),n&&(w&&_i(w,n,R,G,QQ),a&&_i(a,n,R,G,BQ),y&&_i(y,n,R,G,CQ)),A.isSkinnedMesh&&(A.applyBoneTransform(G,QQ),s&&Dt(A,G,BQ),t&&Dt(A,G,CQ)),Q&&QQ.applyMatrix4(A.matrixWorld),D.position.setXYZ(G,QQ.x,QQ.y,QQ.z),s&&(Q&&BQ.applyNormalMatrix(h),D.normal.setXYZ(G,BQ.x,BQ.y,BQ.z)),t&&(Q&&CQ.transformDirection(A.matrixWorld),D.tangent.setXYZW(G,CQ.x,CQ.y,CQ.z,Bt.w));for(const G in this.attributes){const r=this.attributes[G];r==="position"||r==="tangent"||r==="normal"||!(r in i)||(D[r]||I.setAttribute(r,YB(i[r])),GB(i[r],D[r]),Sa(i[r],D[r]))}return A.matrixWorld.determinant()<0&&lG(I),I}}const pG=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:wa,BVH:ya,CENTER:wo,CONTAINED:JD,ExtendedTriangle:ZI,GeometryBVH:ra,MeshBVH:gB,OrientedBox:cI,SAH:aa,SKIP_GENERATION:$E,StaticGeometryGenerator:xG,acceleratedRaycast:UG,computeBoundsTree:HG,generateIndirectBuffer:Ga},Symbol.toStringTag,{value:"Module"}));class uG{constructor(A){this.name="WorkerBase",this.running=!1,this.worker=A,this.worker.onerror=I=>{throw I.message?new Error(`${this.name}: Could not create Web Worker with error "${I.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...A){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 I=this.runTask(this.worker,...A);return I.finally(()=>{this.running=!1}),I}dispose(){this.worker.terminate(),this.worker=null}}const OI={node:"node",material:"material",camera:"camera",light:"light"},DQ="KHR_animation_pointer",qG={CUBICSPLINE:void 0,LINEAR:F.InterpolateLinear,STEP:F.InterpolateDiscrete};class bG{constructor(A){this.name=DQ,this.parser=A,this.animationPointerResolver=null,this.pointerPathMap=new Map}setAnimationPointerResolver(A){return this.animationPointerResolver=A,this}loadAnimationTargetFromChannel(A){const I=A.target,g=I.node!==void 0?I.node:I.id;return this.parser.getDependency("node",g)}loadAnimationTargetFromChannelWithAnimationPointer(A){TG();const I=A.target,g=I.extensions&&I.extensions[DQ]&&I.path&&I.path==="pointer";if(!g)return null;let Q,C=OI.node,E;if(g){const D=I.extensions[DQ];let o=D.pointer;if(!o){console.warn("Invalid path",D,I);return}if(o.startsWith("/materials/")?C=OI.material:o.startsWith("/extensions/KHR_lights_punctual/lights/")?C=OI.light:o.startsWith("/cameras/")&&(C=OI.camera),E=this._tryResolveTargetId(o,C),E===null||isNaN(E)){console.warn("Failed resolving animation node id: "+E,o);return}switch(C){case OI.material:const t=("/materials/"+E.toString()+"/").length,w=o.substring(0,t);switch(Q=o.substring(t),Q){case"pbrMetallicRoughness/baseColorFactor":Q="color";break;case"pbrMetallicRoughness/roughnessFactor":Q="roughness";break;case"pbrMetallicRoughness/metallicFactor":Q="metalness";break;case"emissiveFactor":Q="emissive";break;case"alphaCutoff":Q="alphaTest";break;case"occlusionTexture/strength":Q="aoMapIntensity";break;case"normalTexture/scale":Q="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":Q="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":Q="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":Q="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":Q="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":Q="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":Q="transmission";break;case"extensions/KHR_materials_ior/ior":Q="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":Q="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":Q="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":Q="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":Q="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":Q="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":Q="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":Q="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":Q="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":Q="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":Q="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":Q="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":Q="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":Q="specularColor";break}o=w+Q;break;case OI.node:const a=("/nodes/"+E.toString()+"/").length,y=o.substring(0,a);if(Q=o.substring(a),Q.startsWith("weights/")){const G=Q.substring(8);/^\d+$/.test(G)?Q="morphTargetInfluences["+G+"]":console.warn(DQ+": invalid weight index",Q,o)}else switch(Q){case"translation":Q="position";break;case"rotation":Q="quaternion";break;case"scale":Q="scale";break;case"weights":Q="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":Q="visible";break}o=y+Q;break;case OI.light:const R=("/extensions/KHR_lights_punctual/lights/"+E.toString()+"/").length;switch(Q=o.substring(R),Q){case"color":break;case"intensity":break;case"spot/innerConeAngle":Q="penumbra";break;case"spot/outerConeAngle":Q="angle";break;case"range":Q="distance";break}o="/lights/"+E.toString()+"/"+Q;break;case OI.camera:const n=("/cameras/"+E.toString()+"/").length,h=o.substring(0,n);switch(Q=o.substring(n),Q){case"perspective/yfov":Q="fov";break;case"perspective/znear":case"orthographic/znear":Q="near";break;case"perspective/zfar":case"orthographic/zfar":Q="far";break;case"perspective/aspect":Q="aspect";break;case"orthographic/xmag":Q="zoom";break;case"orthographic/ymag":Q="zoom";break}o=h+Q;break}this.animationPointerResolver?.resolvePath&&(o=this.animationPointerResolver.resolvePath(o));const s=D.pointer;this.pointerPathMap.set(s,o)}if(E==null||isNaN(E)){console.warn("Failed resolving animation node id: "+E,I);return}let i;return C===OI.node?i=this.parser.getDependency("node",E):C===OI.material?i=this.parser.getDependency("material",E):C===OI.light?i=this.parser.getDependency("light",E):C===OI.camera?i=this.parser.getDependency("camera",E):console.error("Unhandled type",C),i}createAnimationTracksWithAnimationPointer(A,I,g,Q,C){if(!(C.extensions&&C.extensions[DQ]&&C.path&&C.path==="pointer"))return null;const i=C.extensions[DQ].pointer;let D=this.pointerPathMap.get(i);if(!D)return null;const o=[];D=D.replaceAll("/",".");const s=D.split(".");var w=A.name!==void 0&&A.name!==null?A.name:A.uuid;if(s[2]=w,s[3]?.startsWith("morphTargetInfluences")){const R=s[3];if(A.type==="Group"){for(const n of A.children)n.morphTargetInfluences&&(s[3]=n.name,s[4]=R,y(this.parser));return o}}y(this.parser);function a(R,n){try{const h=n.split(".").filter(Boolean),r=h[h.length-1].replace(/\[.*\]$/,"");return r in R?typeof R[r]=="boolean":!1}catch{return!1}}function y(R){D=s.join(".");let n,h=!1;switch(g.itemSize){case 1:Object.prototype.toString.call(g.array)==="[object Uint8Array]"&&a(A,D)?(n=F.BooleanKeyframeTrack,h=!0):n=F.NumberKeyframeTrack;break;case 2:case 3:n=F.VectorKeyframeTrack;break;case 4:D.endsWith(".quaternion")?n=F.QuaternionKeyframeTrack:n=F.ColorKeyframeTrack;break}if(!n){console.warn("Unsupported output accessor format",g);return}const G=Q.interpolation!==void 0?qG[Q.interpolation]:F.InterpolateLinear;let r=R._getArrayFromAccessor(g);D.endsWith(".fov")&&(r=r.map(k=>k/Math.PI*180)),h&&(r=r.map(k=>k>0));const M=new n(D,I.array,r,G);if(G==="CUBICSPLINE"&&R._createCubicSplineTrackInterpolant(M),o.push(M),D&&g.itemSize===4&&D.startsWith(".materials.")&&D.endsWith(".color")){const k=new Float32Array(r.length/4);for(let U=0,Y=r.length/4;U<Y;U+=1)k[U]=r[U*4+3];const J=new n(D.replace(".color",".opacity"),I.array,k,G);G==="CUBICSPLINE"&&R._createCubicSplineTrackInterpolant(M),o.push(J)}}return o}_tryResolveTargetId(A,I){let g="";return I==="node"?g=A.substring(7):I==="material"?g=A.substring(11):I==="light"?g=A.substring(39):I==="camera"&&(g=A.substring(9)),g=g.substring(0,g.indexOf("/")),Number.parseInt(g)}loadAnimation(A){const I=this,g=this.parser.json,Q=this.parser,C=g.animations[A],E=C.name?C.name:"animation_"+A,i=[],D=[],o=[],s=[],t=[];for(let w=0,a=C.channels.length;w<a;w++){const y=C.channels[w],R=C.samplers[y.sampler],n=y.target,h=C.parameters!==void 0?C.parameters[R.input]:R.input,G=C.parameters!==void 0?C.parameters[R.output]:R.output;let r=I.loadAnimationTargetFromChannelWithAnimationPointer(y);r||(r=I.loadAnimationTargetFromChannel(y)),i.push(r),D.push(Q.getDependency("accessor",h)),o.push(Q.getDependency("accessor",G)),s.push(R),t.push(n)}return Promise.all([Promise.all(i),Promise.all(D),Promise.all(o),Promise.all(s),Promise.all(t)]).then(function(w){const a=w[0],y=w[1],R=w[2],n=w[3],h=w[4],G=[];for(let r=0,M=a.length;r<M;r++){const k=a[r],J=y[r],U=R[r],Y=n[r],d=h[r];if(k===void 0)continue;k.updateMatrix&&(k.updateMatrix(),k.matrixAutoUpdate=!0);let H=I.createAnimationTracksWithAnimationPointer(k,J,U,Y,d);if(H||(H=Q._createAnimationTracks(k,J,U,Y,d)),H)for(let f=0;f<H.length;f++)G.push(H[f])}return new F.AnimationClip(E,void 0,G)})}}function mG(B,A){for(const I of B.children){const g=I.getObjectByName(A);if(g)return g}}let ot=!1,PG=null;function TG(){if(ot)return;ot=!0;const B=PG||=F.PropertyBinding.findNode;F.PropertyBinding.findNode=function(A,I){if(!I)return B(A,I);if(I.startsWith(".materials.")){const g=I.substring(11).substring(I.indexOf(".")),Q=g.indexOf("."),C=Q<0?g:g.substring(0,Q);let E=null;return A.traverse(i=>{E!==null||i.type!=="Mesh"&&i.type!=="SkinnedMesh"||i.material&&(i.material.uuid===C||i.material.name===C)&&(E=i.material,E!==null&&(g.endsWith(".map")?E=E.map:g.endsWith(".emissiveMap")&&(E=E.emissiveMap)))}),E}else if(I.startsWith(".nodes.")||I.startsWith(".lights.")||I.startsWith(".cameras.")){const g=I.split(".");let Q;for(let C=1;C<g.length;C++){const E=g[C];if(E.length==36)Q=A.getObjectByProperty("uuid",E);else if(Q&&Q[E]){const D=Number.parseInt(E);let o=E;D>=0&&(o=D),Q=Q[o]}else if(Q&&Q.isObject3D){const D=mG(Q,E);D&&(Q=D)}else{const D=A.getObjectByName(E);D&&(Q=D)}}if(!Q){const C=B(A,g[2]);return C||console.warn(DQ+": Property binding not found",I,A,A.name,g),C}return Q}return B(A,I)}}const OG=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:bG},Symbol.toStringTag,{value:"Module"}));var XG=Object.defineProperty,vG=(B,A,I)=>A in B?XG(B,A,{enumerable:!0,configurable:!0,writable:!0,value:I}):B[A]=I,PA=(B,A,I)=>(vG(B,typeof A!="symbol"?A+"":A,I),I);(function(){class B{}class A extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class I extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class g extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class Q extends B{constructor(c,S="unrestricted"){super(),PA(this,"type"),PA(this,"value"),this.value=c,this.type=S}}class C extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class E extends B{}class i extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class D extends B{}class o extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class s extends B{constructor(c,S="integer"){super(),PA(this,"value"),PA(this,"type"),this.value=c,this.type=S}}class t extends B{constructor(c){super(),PA(this,"value"),this.value=c}}class w extends B{constructor(c,S,N){super(),PA(this,"value"),PA(this,"type"),PA(this,"unit"),this.value=c,this.type=S,this.unit=N}}class a extends B{}class y extends B{}class R extends B{}class n extends B{}class h extends B{}class G extends B{}class r extends B{}class M extends B{}class k extends B{}class J extends B{}class U extends B{}class Y extends B{}class d{constructor(c){PA(this,"input"),PA(this,"index",0),this.input=c}consume(){const c=this.input.codePointAt(this.index);return c!==void 0&&(this.index+=String.fromCodePoint(c).length),c}reconsume(c){c!==void 0&&(this.index-=String.fromCodePoint(c).length)}peek(){const c=[];let S=this.index;for(let N=0;N<3&&S<this.input.length;N++){const L=this.input.codePointAt(S);c.push(L),S+=String.fromCodePoint(L).length}return c}}function H(e){return e===10}function f(e){return H(e)||e===8192||e===32}function l(e){return e>=48&&e<=57}function p(e){return l(e)||e>=65&&e<=70||e>=97&&e<=102}function q(e){return(function(c){return(function(S){return S>=65&&S<=90})(c)||(function(S){return S>=97&&S<=122})(c)})(e)||(function(c){return c>=128})(e)||e===95}function m(e){return q(e)||l(e)||e===45}function T(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function Z(e,c){return e===92&&!H(c)}function O(e,c,S){return e===45?q(c)||c===45||Z(c,S):!!q(e)||e===92&&Z(e,c)}function j(e,c,S){return e===43||e===45?l(c)||c===46&&l(S):l(e===46?c:e)}function gA(e){const c=e.consume();if(p(c)){let S=[c];for(;p(...e.peek())&&S.length<5;)S.push(e.consume());f(...e.peek())&&e.consume();const N=parseInt(String.fromCodePoint(...S),16);return N===0||N>1114111?65533:N}return c===void 0?65533:c}function QA(e,c){const S=new C("");for(;;){const N=e.consume();if(N===c||N===void 0)return S;if(N===10)return e.reconsume(N),new E;if(N===92){const L=e.peek()[0];L===void 0||(H(L)?e.consume():S.value+=String.fromCodePoint(gA(e)))}else S.value+=String.fromCodePoint(N)}}function CA(e){let c="";for(;;){const S=e.consume();if(m(S))c+=String.fromCodePoint(S);else{if(!Z(...e.peek()))return e.reconsume(S),c;c+=String.fromCodePoint(gA(e))}}}function EA(e){let c=(function(S){let N="integer",L="";for([43,45].includes(S.peek()[0])&&(L+=String.fromCodePoint(S.consume()));l(...S.peek());)L+=String.fromCodePoint(S.consume());if(S.peek()[0]===46&&l(S.peek()[1]))for(L+=String.fromCodePoint(S.consume(),S.consume()),N="number";l(...S.peek());)L+=String.fromCodePoint(S.consume());return[69,101].includes(S.peek()[0])&&([45,43].includes(S.peek()[1])&&l(S.peek()[2])?(L+=String.fromCodePoint(S.consume(),S.consume(),S.consume()),N="number"):l(S.peek()[1])&&(L+=String.fromCodePoint(S.consume(),S.consume()),N="number")),{value:parseFloat(L),type:N}})(e);return O(...e.peek())?new w(c.value,c.type,CA(e)):e.peek()[0]===37?(e.consume(),new t(c.value)):new s(c.value,c.type)}function BA(e){for(;;){const c=e.consume();if(c===41||c===void 0)return;Z(...e.peek())&&gA(e)}}function W(e){const c=CA(e);if(c.match(/url/i)&&e.peek()[0]===40){for(e.consume();f(e.peek()[0])&&f(e.peek()[1]);)e.consume();return[34,39].includes(e.peek()[0])||f(e.peek()[0])&&[34,39].includes(e.peek()[1])?new I(c):(function(S){const N=new i("");for(;f(...S.peek());)S.consume();for(;;){const L=S.consume();if(L===41||L===void 0)return N;if(f(L)){for(;f(...S.peek());)S.consume();return S.peek()[0]===41||S.peek()[0]===void 0?(S.consume(),N):(BA(S),new D)}if([34,39,40].includes(L)||T(L))return BA(S),new D;if(L===92){if(!Z(...S.peek()))return BA(S),new D;N.value+=gA(S)}else N.value+=String.fromCodePoint(L)}})(e)}return e.peek()[0]===40?(e.consume(),new I(c)):new A(c)}function $(e){const c=e.consume(),S=e.peek();if(f(c)){for(;f(...e.peek());)e.consume();return new a}if(c===34)return QA(e,c);if(c===35){if(m(S[0])||Z(...S)){const N=new Q;return O(...S)&&(N.type="id"),N.value=CA(e),N}return new o(String.fromCodePoint(c))}return c===39?QA(e,c):c===40?new k:c===41?new J:c===43?j(...S)?(e.reconsume(c),EA(e)):new o(String.fromCodePoint(c)):c===44?new G:c===45?j(...e.peek())?(e.reconsume(c),EA(e)):e.peek()[0]===45&&e.peek()[1]===62?(e.consume(),e.consume(),new R):O(...e.peek())?(e.reconsume(c),W(e)):new o(String.fromCodePoint(c)):c===46?j(...e.peek())?(e.reconsume(c),EA(e)):new o(String.fromCodePoint(c)):c===58?new n:c===59?new h:c===60?S[0]===33&&S[1]===45&&S[2]===45?(e.consume(),e.consume(),e.consume(),new y):new o(String.fromCodePoint(c)):c===64?O(...S)?new g(CA(e)):new o(String.fromCodePoint(c)):c===91?new r:c===92?Z(...S)?(e.reconsume(c),W(e)):new o(String.fromCodePoint(c)):c===93?new M:c===123?new U:c===125?new Y:l(c)?(e.reconsume(c),EA(e)):q(c)?(e.reconsume(c),W(e)):c===void 0?void 0:new o(String.fromCodePoint(c))}const z=new Set(["px","deg","s","hz","dppx","number","fr"]);function MA(e){return z.has(e.toLowerCase())}function kA(e,c){if(["x","y"].includes(e))return e;if(!c)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const S=c.writingMode=="horizontal-tb";if(e==="block")e=S?"y":"x";else{if(e!=="inline")throw new TypeError(`Invalid axis “${e}”`);e=S?"x":"y"}return e}function NA(e){const c=[];let S=0;function N(){let K=0;const x=S;for(;S<e.length;){const b=e.slice(S,S+1);if(/\s/.test(b)&&K===0)break;if(b==="(")K+=1;else if(b===")"&&(K-=1,K===0)){S++;break}S++}return e.slice(x,S)}function L(){for(;/\s/.test(e.slice(S,S+1));)S++}for(;S<e.length;){const K=e.slice(S,S+1);/\s/.test(K)?L():c.push(N())}return c}function JA(e,c){return e.reduce(((S,N)=>(S.has(N[c])?S.get(N[c]).push(N):S.set(N[c],[N]),S)),new Map)}function iA(e,c){const S=[],N=[];for(const L of e)c(L)?S.push(L):N.push(L);return[S,N]}function oA(e,c={}){function S(N){return Array.from(N).map((L=>oA(L,c)))}if(e instanceof CSSUnitValue){if(e.unit==="percent"&&c.percentageReference){const L=e.value/100*c.percentageReference.value,K=c.percentageReference.unit;return new CSSUnitValue(L,K)}const N=e.toSum();if(N&&N.values.length===1&&(e=N.values[0]),e instanceof CSSUnitValue&&e.unit==="em"&&c.fontSize&&(e=new CSSUnitValue(e.value*c.fontSize.value,c.fontSize.unit)),e instanceof CSSKeywordValue){if(e.value==="e")return new CSSUnitValue(Math.E,"number");if(e.value==="pi")return new CSSUnitValue(Math.PI,"number")}return e}if(!e.operator)return e;switch(e.operator){case"sum":e=new CSSMathSum(...S(e.values));break;case"product":e=new CSSMathProduct(...S(e.values));break;case"negate":e=new CSSMathNegate(oA(e.value,c));break;case"clamp":e=new CSSMathClamp(oA(e.lower,c),oA(e.value,c),oA(e.upper,c));break;case"invert":e=new CSSMathInvert(oA(e.value,c));break;case"min":e=new CSSMathMin(...S(e.values));break;case"max":e=new CSSMathMax(...S(e.values))}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const N=Array.from(e.values);if(N.every((L=>L instanceof CSSUnitValue&&L.unit!=="percent"&&MA(L.unit)&&L.unit===N[0].unit))){const L=Math[e.operator].apply(Math,N.map((({value:K})=>K)));return new CSSUnitValue(L,N[0].unit)}}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const N=Array.from(e.values),[L,K]=iA(N,(b=>b instanceof CSSUnitValue&&b.unit!=="percent")),x=Array.from(JA(L,"unit").values());if(x.some((b=>b.length>0))){const b=x.map((u=>{const P=Math[e.operator].apply(Math,u.map((({value:V})=>V)));return new CSSUnitValue(P,u[0].unit)}));e=e instanceof CSSMathMin?new CSSMathMin(...b,...K):new CSSMathMax(...b,...K)}return N.length===1?N[0]:e}if(e instanceof CSSMathNegate)return e.value instanceof CSSUnitValue?new CSSUnitValue(0-e.value.value,e.value.unit):e.value instanceof CSSMathNegate?e.value.value:e;if(e instanceof CSSMathInvert)return e.value instanceof CSSMathInvert?e.value.value:e;if(e instanceof CSSMathSum){let N=function(K){const x=K.filter((b=>b instanceof CSSUnitValue));return[...K.filter((b=>!(b instanceof CSSUnitValue))),...Array.from(JA(x,"unit").entries()).map((([b,u])=>{const P=u.reduce(((V,{value:IA})=>V+IA),0);return new CSSUnitValue(P,b)}))]},L=[];for(const K of e.values)K instanceof CSSMathSum?L.push(...K.values):L.push(K);return L=N(L),L.length===1?L[0]:new CSSMathSum(...L)}if(e instanceof CSSMathProduct){let N=[];for(const x of e.values)x instanceof CSSMathProduct?N.push(...x.values):N.push(x);const[L,K]=iA(N,(x=>x instanceof CSSUnitValue&&x.unit==="number"));if(L.length>1){const x=L.reduce(((b,{value:u})=>b*u),1);N=[new CSSUnitValue(x,"number"),...K]}if(N.length===2){let x,b;for(const u of N)u instanceof CSSUnitValue&&u.unit==="number"?x=u:u instanceof CSSMathSum&&[...u.values].every((P=>P instanceof CSSUnitValue))&&(b=u);if(x&&b)return new CSSMathSum(...[...b.values].map((u=>new CSSUnitValue(u.value*x.value,u.unit))))}if(N.every((x=>x instanceof CSSUnitValue&&MA(x.unit)||x instanceof CSSMathInvert&&x.value instanceof CSSUnitValue&&MA(x.value.unit)))){const x=new CSSMathProduct(...N).toSum();if(x&&x.values.length===1)return x.values[0]}return new CSSMathProduct(...N)}return e}const rA=null,qI=["percent","length","angle","time","frequency","resolution","flex"],ZA={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}}},UA=new Map;for(const e of Object.values(ZA))if(e.compatible)for(const c of e.units)UA.set(c,e);function MI(e){return UA.get(e)}function WI(e,c){const S={...e};for(const N of Object.keys(c))S[N]?S[N]+=c[N]:S[N]=c[N];return S}function jI(e){return e==="number"?{}:e==="percent"?{percent:1}:ZA.absoluteLengths.units.has(e)||ZA.fontRelativeLengths.units.has(e)||ZA.viewportRelativeLengths.units.has(e)?{length:1}:ZA.angle.units.has(e)?{angle:1}:ZA.time.units.has(e)?{time:1}:ZA.frequency.units.has(e)?{frequency:1}:ZA.resolution.units.has(e)?{resolution:1}:e==="fr"?{flex:1}:rA}function NI(e){if(e instanceof CSSUnitValue){let{unit:c,value:S}=e;const N=MI(e.unit);return N&&c!==N.canonicalUnit&&(S*=N.ratios[c],c=N.canonicalUnit),c==="number"?[[S,{}]]:[[S,{[c]:1}]]}if(e instanceof CSSMathInvert){if(!(e.value instanceof CSSUnitValue))throw new Error("Not implemented");const c=NI(e.value);if(c===rA||c.length>1)return rA;const S=c[0],N={};for(const[L,K]of Object.entries(S[1]))N[L]=-1*K;return c[0]=[1/S[0],N],c}if(e instanceof CSSMathProduct){let c=[[1,{}]];for(const S of e.values){const N=NI(S),L=[];if(N===rA)return rA;for(const K of c)for(const x of N)L.push([K[0]*x[0],WI(K[1],x[1])]);c=L}return c}throw new Error("Not implemented")}function zI(e,c){if(jI(c)===rA)throw new SyntaxError("The string did not match the expected pattern.");const S=NI(e);if(!S)throw new TypeError;if(S.length>1)throw new TypeError("Sum has more than one item");const N=(function(L,K){const x=L.unit,b=L.value,u=MI(x),P=MI(K);return!P||u!==P?rA:new CSSUnitValue(b*P.ratios[x]/P.ratios[K],K)})(bI(S[0]),c);if(N===rA)throw new TypeError;return N}function bI(e){const[c,S]=e,N=Object.entries(S);if(N.length>1)return rA;if(N.length===0)return new CSSUnitValue(c,"number");const L=N[0];return L[1]!==1?rA:new CSSUnitValue(c,L[0])}function mI(e,...c){if(c&&c.length)throw new Error("Not implemented");const S=NI(e).map((N=>bI(N)));if(S.some((N=>N===rA)))throw new TypeError("Type error");return new CSSMathSum(...S)}function _I(e,c){if(e.percentHint&&c.percentHint&&e.percentHint!==c.percentHint)return rA;const S={...e,percentHint:e.percentHint??c.percentHint};for(const N of qI)c[N]&&(S[N]??(S[N]=0),S[N]+=c[N]);return S}class WA{constructor(c,S){PA(this,"name"),PA(this,"values"),this.name=c,this.values=S}}class nI{constructor(c,S){PA(this,"value"),PA(this,"associatedToken"),this.value=c,this.associatedToken=S}}function fI(e){if(Array.isArray(e))return e;if(typeof e=="string")return(function(c){const S=new d(c),N=[];for(;;){const L=$(S);if(L===void 0)return N;N.push(L)}})(e);throw new TypeError("Invalid input type "+typeof e)}function hI(e){const c=e.shift();return c instanceof U||c instanceof r||c instanceof k?(function(S,N){let L;if(N instanceof U)L=Y;else if(N instanceof k)L=J;else{if(!(N instanceof r))return;L=M}const K=new nI([],N);for(;;){const x=S.shift();if(x instanceof L||x===void 0)return K;S.unshift(x),K.value.push(hI(S))}})(e,c):c instanceof I?(function(S,N){const L=new WA(S.value,[]);for(;;){const K=N.shift();if(K instanceof J||K===void 0)return L;N.unshift(K),L.values.push(hI(N))}})(c,e):c}function wA(e){if(e instanceof k||e instanceof J)return 6;if(e instanceof o)switch(e.value){case"*":case"/":return 4;case"+":case"-":return 2}}function $I(e){return e[e.length-1]}function Sg(e,c,S){const N=["+","-"].includes(e.value)?"ADDITION":"MULTIPLICATION",L=c.type===N?c.values:[c],K=S.type===N?S.values:[S];return e.value==="-"?K[0]={type:"NEGATE",value:K[0]}:e.value==="/"&&(K[0]={type:"INVERT",value:K[0]}),{type:N,values:[...L,...K]}}function Ag(e){if(e.type==="ADDITION")return new CSSMathSum(...e.values.map((c=>Ag(c))));if(e.type==="MULTIPLICATION")return new CSSMathProduct(...e.values.map((c=>Ag(c))));if(e.type==="NEGATE")return new CSSMathNegate(Ag(e.value));if(e.type==="INVERT")return new CSSMathInvert(Ag(e.value));if(e instanceof nI)return Rg(new WA("calc",e.value));if(e instanceof A){if(e.value==="e")return new CSSUnitValue(Math.E,"number");if(e.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return RA(e)}function Rg(e){if(e.name==="min"||e.name==="max"){const N=e.values.filter((L=>!(L instanceof a||L instanceof G))).map((L=>oA(Rg(new WA("calc",L)))));return e.name==="min"?new CSSMathMin(...N):new CSSMathMax(...N)}if(e.name!=="calc")return null;const c=Ag((function(N){const L=[],K=[];for(;N.length;){const x=N.shift();if(x instanceof s||x instanceof w||x instanceof t||x instanceof WA||x instanceof nI||x instanceof A)K.push(x);else if(x instanceof o&&["*","/","+","-"].includes(x.value)){for(;L.length&&!($I(L)instanceof k)&&wA($I(L))>wA(x);){const b=L.pop(),u=K.pop(),P=K.pop();K.push(Sg(b,P,u))}L.push(x)}else if(x instanceof k)L.push(x);else if(x instanceof J){if(!L.length)return null;for(;!($I(L)instanceof k);){const b=L.pop(),u=K.pop(),P=K.pop();K.push(Sg(b,P,u))}if(!($I(L)instanceof k))return null;L.pop()}else if(!(x instanceof a))return null}for(;L.length;){if($I(L)instanceof k)return null;const x=L.pop(),b=K.pop(),u=K.pop();K.push(Sg(x,u,b))}return K[0]})([...e.values]));let S;try{S=oA(c)}catch{new CSSStyleSheet().insertRule("error",0)}return S instanceof CSSUnitValue?new CSSMathSum(S):S}function RA(e){return e instanceof WA&&["calc","min","max","clamp"].includes(e.name)?Rg(e):e instanceof s&&e.value===0&&!e.unit?new CSSUnitValue(0,"px"):e instanceof s?new CSSUnitValue(e.value,"number"):e instanceof t?new CSSUnitValue(e.value,"percent"):e instanceof w?new CSSUnitValue(e.value,e.unit):void 0}function Ra(e){const c=(function(S){const N=fI(S);for(;N[0]instanceof a;)N.shift();if(N[0]===void 0)return null;const L=hI(N);for(;N[0]instanceof a;)N.shift();return N[0]===void 0?L:null})(e);return c===null&&new CSSStyleSheet().insertRule("error",0),c instanceof s||c instanceof t||c instanceof w||c instanceof WA||new CSSStyleSheet().insertRule("error",0),c instanceof w&&jI(c.unit)===null&&new CSSStyleSheet().insertRule("error",0),RA(c)}(function(){let e=new WeakMap;function c(K){const x=[];for(let u=0;u<K.length;u++)x[u]=typeof(b=K[u])=="number"?new CSSUnitValue(b,"number"):b;var b;return x}class S{static parse(x){return x instanceof S?x:oA(Ra(x),{})}}class N extends S{constructor(x,b,u,P){super(),e.set(this,{values:c(x),operator:b,name:u||b,delimiter:P||", "})}get operator(){return e.get(this).operator}get values(){return e.get(this).values}toString(){const x=e.get(this);return`${x.name}(${x.values.join(x.delimiter)})`}}const L={CSSNumericValue:S,CSSMathValue:N,CSSUnitValue:class extends S{constructor(K,x){super(),e.set(this,{value:K,unit:x})}get value(){return e.get(this).value}set value(K){e.get(this).value=K}get unit(){return e.get(this).unit}to(K){return zI(this,K)}toSum(...K){return mI(this,...K)}type(){return jI(e.get(this).unit)}toString(){const K=e.get(this);return`${K.value}${(function(x){switch(x){case"percent":return"%";case"number":return"";default:return x.toLowerCase()}})(K.unit)}`}},CSSKeywordValue:class{constructor(K){this.value=K}toString(){return this.value.toString()}},CSSMathSum:class extends N{constructor(K){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends N{constructor(K){super(arguments,"product","calc"," * ")}toSum(...K){return mI(this,...K)}type(){return e.get(this).values.map((K=>K.type())).reduce(_I)}},CSSMathNegate:class extends N{constructor(K){super([arguments[0]],"negate","-")}get value(){return e.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends N{constructor(K){super([1,arguments[0]],"invert","calc"," / ")}get value(){return e.get(this).values[1]}type(){return(function(K){const x={};for(const b of qI)x[b]=-1*K[b];return x})(e.get(this).values[1].type())}},CSSMathMax:class extends N{constructor(){super(arguments,"max")}},CSSMathMin:class extends N{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:x=>new CSSUnitValue(x,K)}))throw Error(`Error installing CSS.${K}`)}));for(let[K,x]of Object.entries(L))if(!(K in window)&&!Reflect.defineProperty(window,K,{value:x}))throw Error(`Error installing CSSOM support for ${K}`)})();const ho="block";let oI=new WeakMap,Fg=new WeakMap;const LC=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function yo(e){return e===document.scrollingElement?document:e}function jg(e){Qi(e);let c=oI.get(e).animations;if(c.length===0)return;let S=e.currentTime;for(let N=0;N<c.length;N++)c[N].tickAnimation(S)}function Go(e,c){if(!e)return null;const S=Fg.get(e).sourceMeasurements,N=getComputedStyle(e);let L=S.scrollTop;return kA(c,N)==="x"&&(L=Math.abs(S.scrollLeft)),L}function gi(e,c){const S=oA(e,c);if(S instanceof CSSUnitValue){if(S.unit==="px")return S.value;throw TypeError("Unhandled unit type "+S.unit)}throw TypeError("Unsupported value type: "+typeof e)}function Qi(e){if(!(e instanceof kQ))return void(function(S){const N=oI.get(S);if(!N.anonymousSource)return;const L=So(N.anonymousSource,N.anonymousTarget);FQ(S,L)})(e);const c=e.subject;if(!c||getComputedStyle(c).display=="none")return void FQ(e,null);FQ(e,oi(c))}function ro(e){return["block","inline","x","y"].includes(e)}function Bi(e){const c=getComputedStyle(e);return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight,clientWidth:e.clientWidth,clientHeight:e.clientHeight,writingMode:c.writingMode,direction:c.direction,scrollPaddingTop:c.scrollPaddingTop,scrollPaddingBottom:c.scrollPaddingBottom,scrollPaddingLeft:c.scrollPaddingLeft,scrollPaddingRight:c.scrollPaddingRight}}function Ci(e,c){if(!e||!c)return;let S=0,N=0,L=c;const K=e.offsetParent;for(;L&&L!=K;)N+=L.offsetLeft,S+=L.offsetTop,L=L.offsetParent;N-=e.offsetLeft+e.clientLeft,S-=e.offsetTop+e.clientTop;const x=getComputedStyle(c);return{top:S,left:N,offsetWidth:c.offsetWidth,offsetHeight:c.offsetHeight,fontSize:x.fontSize}}function HC(e){let c=Fg.get(e);c.sourceMeasurements=Bi(e);for(const S of c.timelineRefs){const N=S.deref();N instanceof kQ&&(oI.get(N).subjectMeasurements=Ci(e,N.subject))}c.updateScheduled||(setTimeout((()=>{for(const S of c.timelineRefs){const N=S.deref();N&&jg(N)}c.updateScheduled=!1})),c.updateScheduled=!0)}function FQ(e,c){const S=oI.get(e),N=S.source;if(N!=c){if(N){const L=Fg.get(N);if(L){L.timelineRefs.delete(e);const K=Array.from(L.timelineRefs).filter((x=>x.deref()===void 0));for(const x of K)L.timelineRefs.delete(x);L.timelineRefs.size===0&&(L.disconnect(),Fg.delete(N))}}if(S.source=c,c){let L=Fg.get(c);if(!L){L={timelineRefs:new Set,sourceMeasurements:Bi(c)},Fg.set(c,L);const K=new ResizeObserver((u=>{for(const P of u)HC(S.source)}));K.observe(c);for(const u of c.children)K.observe(u);const x=new MutationObserver((u=>{for(const P of u)HC(P.target)}));x.observe(c,{attributes:!0,attributeFilter:["style","class"]});const b=()=>{L.sourceMeasurements.scrollLeft=c.scrollLeft,L.sourceMeasurements.scrollTop=c.scrollTop;for(const u of L.timelineRefs){const P=u.deref();P&&jg(P)}};yo(c).addEventListener("scroll",b),L.disconnect=()=>{K.disconnect(),x.disconnect(),yo(c).removeEventListener("scroll",b)}}L.timelineRefs.add(new WeakRef(e))}}}function Ei(e,c){let S=oI.get(e).animations;for(let N=0;N<S.length;N++)S[N].animation==c&&S.splice(N,1)}function ii(e,c,S){let N=oI.get(e).animations;for(let L=0;L<N.length;L++)if(N[L].animation==c)return;N.push({animation:c,tickAnimation:S}),queueMicrotask((()=>{jg(e)}))}class yI{constructor(c){if(oI.set(this,{source:null,axis:ho,anonymousSource:c?c.anonymousSource:null,anonymousTarget:c?c.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),FQ(this,c&&c.source!==void 0?c.source:document.scrollingElement),c&&c.axis!==void 0&&c.axis!=ho){if(!ro(c.axis))throw TypeError("Invalid axis");oI.get(this).axis=c.axis}jg(this)}set source(c){FQ(this,c),jg(this)}get source(){return oI.get(this).source}set axis(c){if(!ro(c))throw TypeError("Invalid axis");oI.get(this).axis=c,jg(this)}get axis(){return oI.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const c=this.source;if(!c)return"inactive";let S=getComputedStyle(c);return S.display=="none"?"inactive":c==document.scrollingElement||S.overflow!="visible"&&S.overflow!="clip"?"active":"inactive"}get currentTime(){const S=this.source;if(!S||!S.isConnected||this.phase=="inactive")return null;const N=getComputedStyle(S);if(N.display==="inline"||N.display==="none")return null;const L=this.axis,K=Go(S,L),x=(function(b,u){const P=Fg.get(b).sourceMeasurements,V=getComputedStyle(b).writingMode=="horizontal-tb";return u==="block"?u=V?"y":"x":u==="inline"&&(u=V?"x":"y"),u==="y"?P.scrollHeight-P.clientHeight:u==="x"?P.scrollWidth-P.clientWidth:void 0})(S,L);return x>0?CSS.percent(100*K/x):CSS.percent(100)}get __polyfill(){return!0}}function Di(e,c){let S=e.parentElement;for(;S!=null;){if(c(S))return S;S=S.parentElement}}function So(e,c){switch(e){case"root":return document.scrollingElement;case"nearest":return oi(c);case"self":return c;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Fa(e){switch(getComputedStyle(e).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 Ro(e){const c=getComputedStyle(e);return c.transform!="none"||c.perspective!="none"||c.willChange=="transform"||c.willChange=="perspective"||c.filter!="none"||c.willChange=="filter"||c.backdropFilter!="none"}function ka(e){return getComputedStyle(e).position!="static"||Ro(e)}function Ma(e){switch(getComputedStyle(e).position){case"static":case"relative":case"sticky":return Di(e,Fa);case"absolute":return Di(e,ka);case"fixed":return Di(e,Ro)}}function oi(e){if(e&&e.isConnected){for(;e=Ma(e);)switch(getComputedStyle(e)["overflow-x"]){case"auto":case"scroll":case"hidden":return e==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:e}return document.scrollingElement}}function iB(e,c){const S=oI.get(e),N=S.subjectMeasurements,L=Fg.get(S.source).sourceMeasurements;return e.phase==="inactive"?null:e instanceof kQ?si(c,L,N,S.axis,S.inset):null}function si(e,c,S,N,L){const K=c.direction=="rtl"||c.writingMode=="vertical-rl";let x,b,u={fontSize:S.fontSize};kA(N,c)==="x"?(x=S.offsetWidth,b=S.left,u.scrollPadding=[c.scrollPaddingLeft,c.scrollPaddingRight],K&&(b+=c.scrollWidth-c.clientWidth,u.scrollPadding=[c.scrollPaddingRight,c.scrollPaddingLeft]),u.containerSize=c.clientWidth):(x=S.offsetHeight,b=S.top,u.scrollPadding=[c.scrollPaddingTop,c.scrollPaddingBottom],u.containerSize=c.clientHeight);const P=(function(ei,fC){const pa={start:0,end:0};if(!ei)return pa;const[ua,qa]=[ei.start,ei.end].map(((uo,qo)=>uo==="auto"?fC.scrollPadding[qo]==="auto"?0:parseFloat(fC.scrollPadding[qo]):gi(uo,{percentageReference:CSS.px(fC.containerSize),fontSize:CSS.px(parseFloat(fC.fontSize))})));return{start:ua,end:qa}})(L,u),V=b-u.containerSize+P.end,IA=b+x-P.start,DA=V+x,LA=IA-x,bA=Math.min(DA,LA),JI=Math.max(DA,LA);let Ig,PI;const po=x>u.containerSize-P.start-P.end;switch(e){case"cover":Ig=V,PI=IA;break;case"contain":Ig=bA,PI=JI;break;case"entry":Ig=V,PI=bA;break;case"exit":Ig=JI,PI=IA;break;case"entry-crossing":Ig=V,PI=po?JI:bA;break;case"exit-crossing":Ig=po?bA:JI,PI=IA}return{start:Ig,end:PI}}function Fo(e,c){if(e instanceof kQ){const{rangeName:S,offset:N}=c;return ko(iB(e,S),N,iB(e,"cover"),e.subject)}if(e instanceof yI){const{axis:S,source:N}=e,{sourceMeasurements:L}=Fg.get(N);let K;return K=kA(S,L)==="x"?L.scrollWidth-L.clientWidth:L.scrollHeight-L.clientHeight,gi(c,{percentageReference:CSS.px(K)})/K}unsupportedTimeline(e)}function ko(e,c,S,N){if(!e||!S)return 0;let L=getComputedStyle(N);return(gi(c,{percentageReference:CSS.px(e.end-e.start),fontSize:CSS.px(parseFloat(L.fontSize))})+e.start-S.start)/(S.end-S.start)}let kQ=class extends yI{constructor(c){super(c);const S=oI.get(this);S.subject=c&&c.subject?c.subject:void 0,c&&c.inset&&(S.inset=(function(N){if(!N)return{start:0,end:0};let L;if(L=typeof N=="string"?NA(N).map((K=>{if(K==="auto")return"auto";try{return CSSNumericValue.parse(K)}catch{throw TypeError(`Could not parse inset "${N}"`)}})):Array.isArray(N)?N:[N],L.length===0||L.length>2)throw TypeError("Invalid inset");for(const K of L){if(K==="auto")continue;const x=K.type();if(x.length!==1&&x.percent!==1)throw TypeError("Invalid inset")}return{start:L[0],end:L[1]??L[0]}})(c.inset)),S.subject&&(new ResizeObserver((()=>{HC(S.source)})).observe(S.subject),new MutationObserver((()=>{HC(S.source)})).observe(S.subject,{attributes:!0,attributeFilter:["class","style"]})),Qi(this),S.subjectMeasurements=Ci(S.source,S.subject),jg(this)}get source(){return Qi(this),oI.get(this).source}set source(c){throw new Error("Cannot set the source of a view timeline")}get subject(){return oI.get(this).subject}get axis(){return oI.get(this).axis}get currentTime(){const S=Go(this.source,this.axis);if(S==null)return null;const N=iB(this,"cover");if(!N)return null;const L=(S-N.start)/(N.end-N.start);return CSS.percent(100*L)}get startOffset(){return CSS.px(iB(this,"cover").start)}get endOffset(){return CSS.px(iB(this,"cover").end)}};const Na=document.getAnimations,Ja=window.Element.prototype.getAnimations,Ua=window.Element.prototype.animate,Mo=window.Animation;class MQ{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((c,S)=>{this.nativeResolve=c,this.nativeReject=S}))}resolve(c){this.state="resolved",this.nativeResolve(c)}reject(c){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(c)}}function DB(e){e.readyPromise=new MQ,requestAnimationFrame((()=>{var c;(((c=e.timeline)==null?void 0:c.currentTime)??null)!==null&&(YC(e),e.pendingTask!=="play"||e.startTime===null&&e.holdTime===null?e.pendingTask==="pause"&&Uo(e):Jo(e))}))}function No(){return new DOMException("The user aborted a request","AbortError")}function zg(e,c){if(c===null)return c;if(typeof c!="number")throw new DOMException(`Unexpected value: ${c}. Cannot convert to CssNumberish`,"InvalidStateError");const S=e.rangeDuration??100,N=Mg(e),L=N?S*c/N:0;return CSS.percent(L)}function fA(e,c){if(e.timeline){if(c===null)return c;if(c.unit==="percent"){const S=e.rangeDuration??100,N=Mg(e);return c.value*N/S}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(c==null||typeof c=="number")return c;const S=c.to("ms");if(S)return S.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Jo(e){const c=fA(e,e.timeline.currentTime);if(e.holdTime!=null)wg(e),e.animation.playbackRate==0?e.startTime=c:(e.startTime=c-e.holdTime/e.animation.playbackRate,e.holdTime=null);else if(e.startTime!==null&&e.pendingPlaybackRate!==null){const S=(c-e.startTime)*e.animation.playbackRate;wg(e);const N=e.animation.playbackRate;N==0?(e.holdTime=null,e.startTime=c):e.startTime=c-S/N}e.readyPromise&&e.readyPromise.state=="pending"&&e.readyPromise.resolve(e.proxy),kg(e,!1,!1),Ng(e),e.pendingTask=null}function Uo(e){const c=fA(e,e.timeline.currentTime);e.startTime!=null&&e.holdTime==null&&(e.holdTime=(c-e.startTime)*e.animation.playbackRate),wg(e),e.startTime=null,e.readyPromise.resolve(e.proxy),kg(e,!1,!1),Ng(e),e.pendingTask=null}function Lo(e){if(!e.finishedPromise||e.finishedPromise.state!="pending"||e.proxy.playState!="finished")return;e.finishedPromise.resolve(e.proxy),e.animation.pause();const c=new CustomEvent("finish",{detail:{currentTime:e.proxy.currentTime,timelineTime:e.proxy.timeline.currentTime}});Object.defineProperty(c,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(c,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{e.animation.dispatchEvent(c)}))}))}function NQ(e){return e.pendingPlaybackRate!==null?e.pendingPlaybackRate:e.animation.playbackRate}function wg(e){e.pendingPlaybackRate!==null&&(e.animation.playbackRate=e.pendingPlaybackRate,e.pendingPlaybackRate=null)}function Ho(e){if(!e.timeline)return null;const c=fA(e,e.timeline.currentTime);if(c===null||e.startTime===null)return null;let S=(c-e.startTime)*e.animation.playbackRate;return S==-0&&(S=0),S}function kg(e,c,S){if(!e.timeline)return;let N=c?fA(e,e.proxy.currentTime):Ho(e);if(N&&e.startTime!=null&&!e.proxy.pending){const L=NQ(e),K=Mg(e);let x=e.previousCurrentTime;L>0&&N>=K&&e.previousCurrentTime!=null?((x===null||x<K)&&(x=K),e.holdTime=c?N:x):L<0&&N<=0?((x==null||x>0)&&(x=0),e.holdTime=c?N:x):L!=0&&(c&&e.holdTime!==null&&(e.startTime=(function(b,u){if(!b.timeline)return null;const P=fA(b,b.timeline.currentTime);return P==null?null:P-u/b.animation.playbackRate})(e,e.holdTime)),e.holdTime=null)}Ng(e),e.previousCurrentTime=fA(e,e.proxy.currentTime),e.proxy.playState=="finished"?(e.finishedPromise||(e.finishedPromise=new MQ),e.finishedPromise.state=="pending"&&(S?Lo(e):Promise.resolve().then((()=>{Lo(e)})))):(e.finishedPromise&&e.finishedPromise.state=="resolved"&&(e.finishedPromise=new MQ),e.animation.playState!="paused"&&e.animation.pause())}function Mg(e){const c=(function(N){const L=N.proxy.effect.getTiming();return N.normalizedTiming||L})(e),S=c.delay+c.endDelay+c.iterations*c.duration;return Math.max(0,S)}function Ng(e){if(e.timeline)if(e.startTime!==null){const c=e.timeline.currentTime;if(c==null)return;ti(e,(fA(e,c)-e.startTime)*e.animation.playbackRate)}else e.holdTime!==null&&ti(e,e.holdTime)}function ti(e,c){const S=e.timeline,N=e.animation.playbackRate,L=S.currentTime&&S.currentTime.value==(N<0?0:100)?N<0?.001:-.001:0;e.animation.currentTime=c+L}function wi(e,c){if(!e.timeline)return;const S=e.proxy.playState=="paused"&&e.proxy.pending;let N=!1,L=fA(e,e.proxy.currentTime);NQ(e)==0&&L==null&&(e.holdTime=0),L==null&&(e.autoAlignStartTime=!0),(e.proxy.playState==="finished"||S)&&(e.holdTime=null,e.startTime=null,e.autoAlignStartTime=!0),e.holdTime&&(e.startTime=null),e.pendingTask&&(e.pendingTask=null,N=!0),(e.holdTime!==null||e.autoAlignStartTime||S||e.pendingPlaybackRate!==null)&&(e.readyPromise&&!N&&(e.readyPromise=null),Ng(e),e.readyPromise||DB(e),e.pendingTask="play",ii(e.timeline,e.animation,ai.bind(e.proxy)),kg(e,!1,!1))}function ai(e){const c=AA.get(this);if(!c)return;if(e==null)return void(c.proxy.playState!=="paused"&&c.animation.playState!="idle"&&c.animation.cancel());YC(c),c.pendingTask&&requestAnimationFrame((()=>{c.pendingTask!=="play"||c.startTime===null&&c.holdTime===null?c.pendingTask==="pause"&&Uo(c):Jo(c)}));const S=this.playState;if(S=="running"||S=="finished"){const N=fA(c,e);ti(c,(N-fA(c,this.startTime))*this.playbackRate),kg(c,!1,!1)}}function Yo(e){e.specifiedTiming=null}let AA=new WeakMap;window.addEventListener("pagehide",(e=>{AA=new WeakMap}),!1);let Ko=new WeakMap;function YC(e){if(!e.autoAlignStartTime||!e.timeline||!e.timeline.currentTime||e.proxy.playState==="idle"||e.proxy.playState==="paused"&&e.holdTime!==null)return;const c=e.rangeDuration;let S,N;try{S=CSS.percent(100*(function(K){if(!K.animationRange)return 0;const x=K.animationRange.start==="normal"?lo(K.timeline):K.animationRange.start;return Fo(K.timeline,x)})(e))}catch(K){S=CSS.percent(0),e.animationRange.start="normal",console.warn("Exception when calculating start offset",K)}try{N=CSS.percent(100*(1-(function(K){if(!K.animationRange)return 0;const x=K.animationRange.end==="normal"?fo(K.timeline):K.animationRange.end;return 1-Fo(K.timeline,x)})(e)))}catch(K){N=CSS.percent(100),e.animationRange.end="normal",console.warn("Exception when calculating end offset",K)}e.rangeDuration=N.value-S.value;const L=NQ(e);e.startTime=fA(e,L>=0?S:N),e.holdTime=null,e.rangeDuration!==c&&Yo(e)}function KC(e){throw new Error("Unsupported timeline class")}function lo(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:e instanceof yI?CSS.percent(0):void KC()}function fo(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:e instanceof yI?CSS.percent(100):void KC()}function La(e,c){if(!c)return{start:"normal",end:"normal"};const S={start:lo(e),end:fo(e)};if(e instanceof ViewTimeline){const N=NA(c),L=[],K=[];if(N.forEach((x=>{if(LC.includes(x))L.push(x);else try{K.push(CSSNumericValue.parse(x))}catch{throw TypeError(`Could not parse range "${c}"`)}})),L.length>2||K.length>2||K.length==1)throw TypeError("Invalid time range or unsupported time range format.");return L.length&&(S.start.rangeName=L[0],S.end.rangeName=L.length>1?L[1]:L[0]),K.length>1&&(S.start.offset=K[0],S.end.offset=K[1]),S}if(e instanceof yI){const N=c.split(" ");if(N.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return S.start=CSSNumericValue.parse(N[0]),S.end=CSSNumericValue.parse(N[1]),S}KC()}function dC(e,c,S){if(!c||c==="normal")return"normal";if(e instanceof ViewTimeline){let N="cover",L=S==="start"?CSS.percent(0):CSS.percent(100);if(c instanceof Object)c.rangeName!==void 0&&(N=c.rangeName),c.offset!==void 0&&(L=c.offset);else{const K=NA(c);K.length===1?LC.includes(K[0])?N=K[0]:L=oA(CSSNumericValue.parse(K[0]),{}):K.length===2&&(N=K[0],L=oA(CSSNumericValue.parse(K[1]),{}))}if(!LC.includes(N))throw TypeError("Invalid range name");return{rangeName:N,offset:L}}if(e instanceof yI)return CSSNumericValue.parse(c);KC()}class lC{constructor(c,S,N={}){const L=S instanceof yI,K=c instanceof Mo?c:new Mo(c,L?void 0:S);Ko.set(K,this),AA.set(this,{animation:K,timeline:L?S:void 0,playState:L?"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:L?La(S,N["animation-range"]):null,proxy:this})}get effect(){const c=AA.get(this);return c.timeline?(c.effect||(c.effect=(function(S){const N=S.animation.effect,L=N.updateTiming,K={apply:function(P){N.getTiming();const V=P.apply(N);if(S.timeline){const IA=S.duration??100;V.localTime=zg(S,V.localTime),V.endTime=zg(S,V.endTime),V.activeDuration=zg(S,V.activeDuration);const DA=Mg(S),LA=V.iterations?(DA-V.delay-V.endDelay)/V.iterations:0;V.duration=DA?CSS.percent(IA*LA/DA):CSS.percent(0),S.timeline.currentTime===void 0&&(V.localTime=null)}return V}},x={apply:function(P,V){if(S.specifiedTiming)return S.specifiedTiming;S.specifiedTiming=P.apply(N);let IA,DA=Object.assign({},S.specifiedTiming);if(DA.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(DA.duration===null||DA.duration==="auto"||S.autoDurationEffect)&&S.timeline&&(S.autoDurationEffect=!0,DA.delay=0,DA.endDelay=0,IA=DA.iterations?1e5:0,DA.duration=DA.iterations?(IA-DA.delay-DA.endDelay)/DA.iterations:0,DA.duration<0&&(DA.duration=0,DA.endDelay=IA-DA.delay),L.apply(N,[DA])),S.normalizedTiming=DA,S.specifiedTiming}},b={apply:function(P,V,IA){if(IA&&IA.length){if(S.timeline&&IA[0]){const DA=IA[0],LA=DA.duration;if(LA===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(DA.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");LA!==void 0&&LA!=="auto"&&(S.autoDurationEffect=null)}S.specifiedTiming&&P.apply(N,[S.specifiedTiming]),P.apply(N,IA),Yo(S)}}},u=new Proxy(N,{get:function(P,V){const IA=P[V];return typeof IA=="function"?IA.bind(N):IA},set:function(P,V,IA){return P[V]=IA,!0}});return u.getComputedTiming=new Proxy(N.getComputedTiming,K),u.getTiming=new Proxy(N.getTiming,x),u.updateTiming=new Proxy(N.updateTiming,b),u})(c)),c.effect):c.animation.effect}set effect(c){const S=AA.get(this);S.animation.effect=c,S.effect=null,S.autoDurationEffect=null}get timeline(){const c=AA.get(this);return c.timeline||c.animation.timeline}set timeline(c){const S=AA.get(this),N=this.timeline;if(N==c)return;const L=this.playState,K=this.currentTime;let x,b=Mg(S);x=K===null?null:b===0?0:fA(S,K)/b;const u=N instanceof yI,P=c instanceof yI,V=this.pending;if(u&&Ei(S.timeline,S.animation),P)return S.timeline=c,wg(S),S.autoAlignStartTime=!0,S.startTime=null,S.holdTime=null,L!=="running"&&L!=="finished"||(S.readyPromise&&S.readyPromise.state!=="resolved"||DB(S),S.pendingTask="play",ii(S.timeline,S.animation,ai.bind(this))),L==="paused"&&x!==null&&(S.holdTime=x*b),V&&(S.readyPromise&&S.readyPromise.state!="resolved"||DB(S),S.pendingTask=L=="paused"?"pause":"play"),S.startTime!==null&&(S.holdTime=null),void kg(S,!1,!1);if(S.animation.timeline!=c)throw TypeError("Unsupported timeline: "+c);if(Ei(S.timeline,S.animation),S.timeline=null,u)switch(K!==null&&(S.animation.currentTime=x*Mg(S)),L){case"paused":S.animation.pause();break;case"running":case"finished":S.animation.play()}}get startTime(){const c=AA.get(this);return c.timeline?zg(c,c.startTime):c.animation.startTime}set startTime(c){const S=AA.get(this);if(c=fA(S,c),!S.timeline)return void(S.animation.startTime=c);S.autoAlignStartTime=!1,fA(S,S.timeline.currentTime)==null&&S.startTime!=null&&(S.holdTime=null,Ng(S));const N=fA(S,this.currentTime);wg(S),S.startTime=c,S.startTime!==null&&S.animation.playbackRate!=0?S.holdTime=null:S.holdTime=N,S.pendingTask&&(S.pendingTask=null,S.readyPromise.resolve(this)),kg(S,!0,!1),Ng(S)}get currentTime(){const c=AA.get(this);return c.timeline?c.holdTime!=null?zg(c,c.holdTime):zg(c,Ho(c)):c.animation.currentTime}set currentTime(c){const S=AA.get(this);S.timeline?((function(N,L){if(L==null&&N.currentTime!==null)throw new TypeError;L=fA(N,L),N.autoAlignStartTime=!1,N.holdTime!==null||N.startTime===null||N.timeline.phase==="inactive"||N.animation.playbackRate===0?N.holdTime=L:N.startTime=fA(N,N.timeline.currentTime)-L/N.animation.playbackRate,N.timeline.phase==="inactive"&&(N.startTime=null),N.previousCurrentTime=null})(S,c),S.pendingTask=="pause"&&(S.holdTime=fA(S,c),wg(S),S.startTime=null,S.pendingTask=null,S.readyPromise.resolve(this)),kg(S,!0,!1)):S.animation.currentTime=c}get playbackRate(){return AA.get(this).animation.playbackRate}set playbackRate(c){const S=AA.get(this);if(!S.timeline)return void(S.animation.playbackRate=c);S.pendingPlaybackRate=null;const N=this.currentTime;S.animation.playbackRate=c,N!==null&&(this.currentTime=N)}get playState(){const c=AA.get(this);if(!c.timeline)return c.animation.playState;const S=fA(c,this.currentTime);return S===null&&c.startTime===null&&c.pendingTask==null?"idle":c.pendingTask=="pause"||c.startTime===null&&c.pendingTask!="play"?"paused":S!=null&&(c.animation.playbackRate>0&&S>=Mg(c)||c.animation.playbackRate<0&&S<=0)?"finished":"running"}get rangeStart(){var c;return((c=AA.get(this).animationRange)==null?void 0:c.start)??"normal"}set rangeStart(c){const S=AA.get(this);if(!S.timeline)return S.animation.rangeStart=c;S.timeline instanceof yI&&(S.animationRange.start=dC(S.timeline,c,"start"),YC(S),Ng(S))}get rangeEnd(){var c;return((c=AA.get(this).animationRange)==null?void 0:c.end)??"normal"}set rangeEnd(c){const S=AA.get(this);if(!S.timeline)return S.animation.rangeEnd=c;S.timeline instanceof yI&&(S.animationRange.end=dC(S.timeline,c,"end"),YC(S),Ng(S))}get replaceState(){return AA.get(this).animation.pending}get pending(){const c=AA.get(this);return c.timeline?!!c.readyPromise&&c.readyPromise.state=="pending":c.animation.pending}finish(){const c=AA.get(this);if(!c.timeline)return void c.animation.finish();const S=NQ(c),N=Mg(c);if(S==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(S>0&&N==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");wg(c);const L=S<0?0:N;this.currentTime=zg(c,L);const K=fA(c,c.timeline.currentTime);c.startTime===null&&K!==null&&(c.startTime=K-L/c.animation.playbackRate),c.pendingTask=="pause"&&c.startTime!==null&&(c.holdTime=null,c.pendingTask=null,c.readyPromise.resolve(this)),c.pendingTask=="play"&&c.startTime!==null&&(c.pendingTask=null,c.readyPromise.resolve(this)),kg(c,!0,!0)}play(){const c=AA.get(this);c.timeline?wi(c):c.animation.play()}pause(){const c=AA.get(this);c.timeline?this.playState!="paused"&&(c.animation.currentTime===null&&(c.autoAlignStartTime=!0),c.pendingTask=="play"?c.pendingTask=null:c.readyPromise=null,c.readyPromise||DB(c),c.pendingTask="pause",ii(c.timeline,c.animation,ai.bind(c.proxy))):c.animation.pause()}reverse(){const c=AA.get(this),S=NQ(c),N=fA(c,this.currentTime),L=Mg(c)==1/0,K=S!=0&&(S<0||N>0||!L);if(!c.timeline||!K)return K&&(c.pendingPlaybackRate=-NQ(c)),void c.animation.reverse();if(c.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-S),wi(c)}updatePlaybackRate(c){const S=AA.get(this);if(S.pendingPlaybackRate=c,!S.timeline)return void S.animation.updatePlaybackRate(c);const N=this.playState;if(!S.readyPromise||S.readyPromise.state!="pending")switch(N){case"idle":case"paused":wg(S);break;case"finished":const L=fA(S,S.timeline.currentTime),K=L!==null?(L-S.startTime)*S.animation.playbackRate:null;S.startTime=c==0?L:L!=null&&K!=null?(L-K)/c:null,wg(S),kg(S,!1,!1),Ng(S);break;default:wi(S)}}persist(){AA.get(this).animation.persist()}get id(){return AA.get(this).animation.id}set id(c){AA.get(this).animation.id=c}cancel(){const c=AA.get(this);c.timeline?(this.playState!="idle"&&((function(S){S.pendingTask&&(S.pendingTask=null,wg(S),S.readyPromise.reject(No()),DB(S),S.readyPromise.resolve(S.proxy))})(c),c.finishedPromise&&c.finishedPromise.state=="pending"&&c.finishedPromise.reject(No()),c.finishedPromise=new MQ,c.animation.cancel()),c.startTime=null,c.holdTime=null,Ei(c.timeline,c.animation)):c.animation.cancel()}get onfinish(){return AA.get(this).animation.onfinish}set onfinish(c){AA.get(this).animation.onfinish=c}get oncancel(){return AA.get(this).animation.oncancel}set oncancel(c){AA.get(this).animation.oncancel=c}get onremove(){return AA.get(this).animation.onremove}set onremove(c){AA.get(this).animation.onremove=c}get finished(){const c=AA.get(this);return c.timeline?(c.finishedPromise||(c.finishedPromise=new MQ),c.finishedPromise.promise):c.animation.finished}get ready(){const c=AA.get(this);return c.timeline?(c.readyPromise||(c.readyPromise=new MQ,c.readyPromise.resolve(this)),c.readyPromise.promise):c.animation.ready}addEventListener(c,S,N){AA.get(this).animation.addEventListener(c,S,N)}removeEventListener(c,S,N){AA.get(this).animation.removeEventListener(c,S,N)}dispatchEvent(c){AA.get(this).animation.dispatchEvent(c)}}function Ha(e,c){const S=c.timeline;S instanceof yI&&delete c.timeline;const N=Ua.apply(this,[e,c]),L=new lC(N,S);return S instanceof yI&&(N.pause(),AA.get(L).animationRange={start:dC(S,c.rangeStart,"start"),end:dC(S,c.rangeEnd,"end")},L.play()),L}function xo(e){for(let c=0;c<e.length;++c){let S=Ko.get(e[c]);S&&(e[c]=S)}return e}function Ya(e){return xo(Ja.apply(this,[e]))}function Ka(e){return xo(Na.apply(this,[e]))}const jA={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\(([^)]*)\)/},JQ=["block","inline","x","y"],da=["nearest","root","self"],qg=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(e,c,S){const N={sheetSrc:e,index:0,name:S};for(;N.index<N.sheetSrc.length&&(this.eatWhitespace(N),!(N.index>=N.sheetSrc.length));){if(this.lookAhead("/*",N)){for(;this.lookAhead("/*",N);)this.eatComment(N),this.eatWhitespace(N);continue}const L=this.parseQualifiedRule(N);L&&(c?this.parseKeyframesAndSaveNameMapping(L,N):this.handleScrollTimelineProps(L,N))}return N.sheetSrc}getAnimationTimelineOptions(e,c){for(let S=this.cssRulesWithTimelineName.length-1;S>=0;S--){const N=this.cssRulesWithTimelineName[S];try{if(c.matches(N.selector)&&(!N["animation-name"]||N["animation-name"]==e))return{"animation-timeline":N["animation-timeline"],"animation-range":N["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(e,c){const S=this.anonymousScrollTimelineOptions.get(e);return S?{anonymousSource:S.source,anonymousTarget:c,source:So(S.source??"nearest",c),axis:S.axis?S.axis:"block"}:null}getScrollTimelineOptions(e,c){const S=this.getAnonymousScrollTimelineOptions(e,c);if(S)return S;for(let N=this.sourceSelectorToScrollTimeline.length-1;N>=0;N--){const L=this.sourceSelectorToScrollTimeline[N];if(L.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(c,L.selector);if(K)return{source:K,...L.axis?{axis:L.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(e,c){let S=e;for(;S;){if(S.matches(c))return S;S=S.previousElementSibling||S.parentElement}return null}getAnonymousViewTimelineOptions(e,c){const S=this.anonymousViewTimelineOptions.get(e);return S?{subject:c,axis:S.axis?S.axis:"block",inset:S.inset?S.inset:"auto"}:null}getViewTimelineOptions(e,c){const S=this.getAnonymousViewTimelineOptions(e,c);if(S)return S;for(let N=this.subjectSelectorToViewTimeline.length-1;N>=0;N--){const L=this.subjectSelectorToViewTimeline[N];if(L.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(c,L.selector);if(K)return{subject:K,axis:L.axis,inset:L.inset}}}return null}handleScrollTimelineProps(e,c){if(e.selector.includes("@keyframes"))return;const S=e.block.contents.includes("animation-name:"),N=e.block.contents.includes("animation-timeline:"),L=e.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(e),this.saveSubjectSelectorToViewTimeline(e),!N&&!S&&!L)return;let K=[],x=[],b=!1;N&&(K=this.extractScrollTimelineNames(e.block.contents)),S&&(x=this.extractMatches(e.block.contents,jA.ANIMATION_NAME)),N&&S||(L&&this.extractMatches(e.block.contents,jA.ANIMATION).forEach((u=>{const P=this.extractAnimationName(u);P&&N&&x.push(P),N&&(this.hasDuration(u)||(this.hasAutoDuration(u)&&(e.block.contents=e.block.contents.replace("auto"," ")),e.block.contents=e.block.contents.replace(u," 1s "+u),b=!0))})),b&&this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,c)),this.saveRelationInList(e,K,x)}saveSourceSelectorToScrollTimeline(e){const c=e.block.contents.includes("scroll-timeline:"),S=e.block.contents.includes("scroll-timeline-name:"),N=e.block.contents.includes("scroll-timeline-axis:");if(!c&&!S)return;let L=[];if(c){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE);for(const b of x){const u=this.split(b);let P={selector:e.selector,name:""};u.length==1?P.name=u[0]:u.length==2&&(JQ.includes(u[0])?(P.axis=u[0],P.name=u[1]):(P.axis=u[1],P.name=u[0])),L.push(P)}}if(S){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE_NAME);for(let b=0;b<x.length;b++)if(b<L.length)L[b].name=x[b];else{let u={selector:e.selector,name:x[b]};L.push(u)}}let K=[];if(N){const x=this.extractMatches(e.block.contents,jA.SCROLL_TIMELINE_AXIS);if(K=x.filter((b=>JQ.includes(b))),K.length!=x.length)throw new Error("Invalid axis")}for(let x=0;x<L.length;x++)K.length&&(L[x].axis=K[x%L.length]);this.sourceSelectorToScrollTimeline.push(...L)}saveSubjectSelectorToViewTimeline(e){const c=e.block.contents.includes("view-timeline:"),S=e.block.contents.includes("view-timeline-name:"),N=e.block.contents.includes("view-timeline-axis:"),L=e.block.contents.includes("view-timeline-inset:");if(!c&&!S)return;let K=[];if(c){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE);for(let P of u){const V=this.split(P);let IA={selector:e.selector,name:"",inset:null};V.length==1?IA.name=V[0]:V.length==2&&(JQ.includes(V[0])?(IA.axis=V[0],IA.name=V[1]):(IA.axis=V[1],IA.name=V[0])),K.push(IA)}}if(S){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_NAME);for(let P=0;P<u.length;P++)if(P<K.length)K[P].name=u[P];else{let V={selector:e.selector,name:u[P],inset:null};K.push(V)}}let x=[],b=[];if(L&&(x=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_INSET)),N){const u=this.extractMatches(e.block.contents,jA.VIEW_TIMELINE_AXIS);if(b=u.filter((P=>JQ.includes(P))),b.length!=u.length)throw new Error("Invalid axis")}for(let u=0;u<K.length;u++)x.length&&(K[u].inset=x[u%K.length]),b.length&&(K[u].axis=b[u%K.length]);this.subjectSelectorToViewTimeline.push(...K)}hasDuration(e){return e.split(" ").filter((c=>{return S=c,jA.TIME.exec(S);var S})).length>=1}hasAutoDuration(e){return e.split(" ").filter((c=>c==="auto")).length>=1}saveRelationInList(e,c,S){let N=[];e.block.contents.includes("animation-range:")&&(N=this.extractMatches(e.block.contents,jA.ANIMATION_TIME_RANGE));const L=Math.max(c.length,S.length,N.length);for(let K=0;K<L;K++)this.cssRulesWithTimelineName.push({selector:e.selector,"animation-timeline":c[K%c.length],...S.length?{"animation-name":S[K%S.length]}:{},...N.length?{"animation-range":N[K%N.length]}:{}})}extractScrollTimelineNames(e){const c=jA.ANIMATION_TIMELINE.exec(e)[1].trim(),S=[];return c.split(",").map((N=>N.trim())).forEach((N=>{if((function(L){return(L.startsWith("scroll")||L.startsWith("view"))&&L.includes("(")})(N)){const L=this.saveAnonymousTimelineName(N);S.push(L)}else S.push(N)})),S}saveAnonymousTimelineName(e){const c=":t"+this.nextAnonymousTimelineNameIndex++;return e.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(c,this.parseAnonymousScrollTimeline(e)):this.anonymousViewTimelineOptions.set(c,this.parseAnonymousViewTimeline(e)),c}parseAnonymousScrollTimeline(e){const c=jA.ANONYMOUS_SCROLL_TIMELINE.exec(e);if(!c)return null;const S=c[1],N={};return S.split(" ").forEach((L=>{JQ.includes(L)?N.axis=L:da.includes(L)&&(N.source=L)})),N}parseAnonymousViewTimeline(e){const c=jA.ANONYMOUS_VIEW_TIMELINE.exec(e);if(!c)return null;const S=c[1],N={};return S.split(" ").forEach((L=>{JQ.includes(L)?N.axis=L:N.inset=N.inset?`${N.inset} ${L}`:L})),N}extractAnimationName(e){return this.findMatchingEntryInContainer(e,this.keyframeNamesSelectors)}findMatchingEntryInContainer(e,c){const S=e.split(" ").filter((N=>c.has(N)));return S?S[0]:null}parseIdentifier(e){jA.IDENTIFIER.lastIndex=e.index;const c=jA.IDENTIFIER.exec(e.sheetSrc);if(!c)throw this.parseError(e,"Expected an identifier");return e.index+=c[0].length,c[0]}parseKeyframesAndSaveNameMapping(e,c){if(e.selector.startsWith("@keyframes")){const S=this.replaceKeyframesAndGetMapping(e,c);e.selector.split(" ").forEach(((N,L)=>{L>0&&this.keyframeNamesSelectors.set(N,S)}))}}replaceKeyframesAndGetMapping(e,c){function S(u){return LC.some((P=>u.startsWith(P)))}const N=e.block.contents,L=(function(u){let P=0,V=-1,IA=-1;const DA=[];for(let LA=0;LA<u.length;LA++)u[LA]=="{"?P++:u[LA]=="}"&&P--,P==1&&u[LA]!="{"&&u[LA]!="}"&&V==-1&&(V=LA),P==2&&u[LA]=="{"&&(IA=LA,DA.push({start:V,end:IA}),V=IA=-1);return DA})(N);if(L.length==0)return new Map;const K=new Map;let x=!1;const b=[];b.push(N.substring(0,L[0].start));for(let u=0;u<L.length;u++){const P=N.substring(L[u].start,L[u].end);let V=[];P.split(",").forEach((IA=>{const DA=IA.split(" ").map((bA=>bA.trim())).filter((bA=>bA!="")).join(" "),LA=K.size;K.set(LA,DA),V.push(`${LA}%`),S(DA)&&(x=!0)})),b.push(V.join(",")),u==L.length-1?b.push(N.substring(L[u].end)):b.push(N.substring(L[u].end,L[u+1].start))}return x?(e.block.contents=b.join(""),this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,c),K):new Map}parseQualifiedRule(e){const c=e.index,S=this.parseSelector(e).trim();if(S)return{selector:S,block:this.eatBlock(e),startIndex:c,endIndex:e.index}}removeEnclosingDoubleQuotes(e){let c=e[0]=='"'?1:0,S=e[e.length-1]=='"'?e.length-1:e.length;return e.substring(c,S)}assertString(e,c){if(e.sheetSrc.substr(e.index,c.length)!=c)throw this.parseError(e,`Did not find expected sequence ${c}`);e.index+=c.length}replacePart(e,c,S,N){if(N.sheetSrc=N.sheetSrc.slice(0,e)+S+N.sheetSrc.slice(c),N.index>=c){const L=N.index-c;N.index=e+S.length+L}}eatComment(e){this.assertString(e,"/*"),this.eatUntil("*/",e,!0),this.assertString(e,"*/")}eatBlock(e){const c=e.index;this.assertString(e,"{");let S=1;for(;S!=0;)this.lookAhead("/*",e)?this.eatComment(e):(e.sheetSrc[e.index]==="{"?S++:e.sheetSrc[e.index]==="}"&&S--,this.advance(e));const N=e.index;return{startIndex:c,endIndex:N,contents:e.sheetSrc.slice(c,N)}}advance(e){if(e.index++,e.index>e.sheetSrc.length)throw this.parseError(e,"Advanced beyond the end")}parseError(e,c){return Error(`(${e.name?e.name:"<anonymous file>"}): ${c}`)}eatUntil(e,c,S=!1){const N=c.index;for(;!this.lookAhead(e,c);)this.advance(c);return S&&(c.sheetSrc=c.sheetSrc.slice(0,N)+" ".repeat(c.index-N)+c.sheetSrc.slice(c.index)),c.sheetSrc.slice(N,c.index)}parseSelector(e){let c=e.index;if(this.eatUntil("{",e),c===e.index)throw Error("Empty selector");return e.sheetSrc.slice(c,e.index)}eatWhitespace(e){jA.WHITE_SPACE.lastIndex=e.index;const c=jA.WHITE_SPACE.exec(e.sheetSrc);c&&(e.index+=c[0].length)}lookAhead(e,c){return c.sheetSrc.substr(c.index,e.length)==e}peek(e){return e.sheetSrc[e.index]}extractMatches(e,c,S=","){return c.exec(e)[1].trim().split(S).map((N=>N.trim()))}split(e){return e.split(" ").map((c=>c.trim())).filter((c=>c!=""))}};function la(e,c,S,N,L,K){const x=Bi(c),b=Ci(c,S);return ko(si(e,x,b,N,L),K,si("cover",x,b,N,L),S)}function fa(e,c,S){const N=qg.getAnimationTimelineOptions(c,S);if(!N)return null;const L=N["animation-timeline"];if(!L)return null;let K=qg.getScrollTimelineOptions(L,S)||qg.getViewTimelineOptions(L,S);return K?(K.subject&&(function(x,b){const u=oi(b.subject),P=b.axis||b.axis;function V(DA,LA){let bA=null;for(const[JI,Ig]of DA)if(JI==100*LA.offset){if(Ig=="from")bA=0;else if(Ig=="to")bA=100;else{const PI=Ig.split(" ");bA=PI.length==1?parseFloat(PI[0]):100*la(PI[0],u,b.subject,P,b.inset,CSS.percent(parseFloat(PI[1])))}break}return bA}const IA=qg.keyframeNamesSelectors.get(x.animationName);if(IA&&IA.size){const DA=[];x.effect.getKeyframes().forEach((bA=>{const JI=V(IA,bA);JI!==null&&JI>=0&&JI<=100&&(bA.offset=JI/100,DA.push(bA))}));const LA=DA.sort(((bA,JI)=>bA.offset<JI.offset?-1:bA.affset>JI.offset?1:0));x.effect.setKeyframes(LA)}})(e,K),{timeline:K.source?new yI(K):new kQ(K),animOptions:N}):null}function xa(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function c(N){if(N.innerHTML.trim().length===0||"aphrodite"in N.dataset)return;let L=qg.transpileStyleSheet(N.innerHTML,!0);L=qg.transpileStyleSheet(L,!1),N.innerHTML=L}function S(N){N.type!="text/css"&&N.rel!="stylesheet"||!N.href||new URL(N.href,document.baseURI).origin==location.origin&&fetch(N.getAttribute("href")).then((async L=>{const K=await L.text();let x=qg.transpileStyleSheet(K,!0);if(x=qg.transpileStyleSheet(K,!1),x!=K){const b=new Blob([x],{type:"text/css"}),u=URL.createObjectURL(b);N.setAttribute("href",u)}}))}new MutationObserver((N=>{for(const L of N)for(const K of L.addedNodes)K instanceof HTMLStyleElement&&c(K),K instanceof HTMLLinkElement&&S(K)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((N=>c(N))),document.querySelectorAll("link").forEach((N=>S(N)))})();const e=CSS.supports;CSS.supports=c=>(c=c.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),e(c)),window.addEventListener("animationstart",(c=>{c.target.getAnimations().filter((S=>S.animationName===c.animationName)).forEach((S=>{const N=fa(S,S.animationName,c.target);if(N)if(!N.timeline||S instanceof lC)S.timeline=N.timeline;else{const L=new lC(S,N.timeline,N.animOptions);S.pause(),L.play()}}))}))}(function(){if(!xa()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:yI}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:kQ}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Ha}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:lC}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Ya}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Ka}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const VG=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),ZG=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.BatchedParticleRenderer=Y0;exports.Builder=bD;exports.ByteBuffer=mB;exports.ConstantColor=hQ;exports.ConstantValue=nA;exports.Matrix4=tg;exports.MeshBVH=gB;exports.MotionController=Re;exports.PROJECT_DOCUMENT_KEY=XD;exports.ParticleSystem=LE;exports.SIZE_PREFIX_LENGTH=ct;exports.TrailParticle=JE;exports.Vector4=YI;exports.WorkerBase=uG;exports.__viteBrowserExternal=ZG;exports.applyDef=Ut;exports.applyOver=Ht;exports.attachNeedleIdsToLoadedGltf=et;exports.bundler=xc;exports.createNoise4D=d0;exports.createOverApplyState=Lt;exports.deriveInstanceId=Ee;exports.enableProjectDocumentInspection=p0;exports.evaluateProjectDocument=P0;exports.fetchProfile=he;exports.getProjectDocumentInspection=q0;exports.index=Qc;exports.index$1=pG;exports.index$2=OG;exports.isProjectDocument=Mt;exports.reportProjectIssues=f0;exports.resolveDocumentRemoteSrc=rB;exports.resolveMaterialEntity=Yt;exports.scrollTimeline=VG;exports.spark_module=Ky;exports.splitPath=vD;exports.v5=ja;
|