@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 q(-1,-3,1).normalize(),new hQ(1,1,1),new hQ(.5,.5,1),new hQ(1,1,1),new hQ(.25,.25,.5);var ua=(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))(ua||{});const _S=Object.keys(ua);_S.length,new je(0,0,0,"YXZ");var Fo=(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))(Fo||{});const ba=Object.keys(Fo);ba.length;const $S=Object.freeze(Object.defineProperty({__proto__:null,ExtSplats:vg,JOINT_IDS:ba,JointEnum:Fo,LN_SCALE_MAX:bI,LN_SCALE_MIN:uI,OldSparkViewpoint:Go,OldSplatAccumulator:Qi,PackedSplats:Kg,PagedSplats:wC,Readback:oC,RgbaArray:Na,SparkRenderer:bS,SplatAccumulator:aB,SplatEdit:Ai,SplatEditSdf:Ja,SplatEdits:La,SplatFileType:mI,SplatGenerator:wB,SplatLoader:ho,SplatMesh:EQ,SplatModifier:Ha,SplatPager:UQ,SplatTransformer:sC,floatToUint8:AC,fromHalf:rg,getSplatFileType:fa,isAndroid:Ww,isIos:OE,isMobile:TE,isOculus:jw,isVisionPro:zw,setPackedSplat:$D,toHalf:Sg,unpackSplat:PE},Symbol.toStringTag,{value:"Module"})),Ro=0,ma=1,Pa=2,ko=2,no=1.25,Ta=1,SI=32,jA=SI/4,Oa=65535,Bi=Math.pow(2,-24),Ci=Symbol("SKIP_GENERATION"),Xa={strategy:Ro,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ci]:!1};function mA(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 va(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 Za(B,A){A.set(B)}function Va(B,A,I){let g,Q;for(let C=0;C<3;C++){const i=C+3;g=B[C],Q=A[C],I[C]=g<Q?g:Q,g=B[i],Q=A[i],I[i]=g>Q?g:Q}}function Ei(B,A,I){for(let g=0;g<3;g++){const Q=A[B+2*g],C=A[B+2*g+1],i=Q-C,E=Q+C;i<I[g]&&(I[g]=i),E>I[g+3]&&(I[g+3]=E)}}function aC(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 zA(B,A){return A[B+15]===Oa}function rI(B,A){return A[B+6]}function lI(B,A){return A[B+14]}function CI(B){return B+jA}function EI(B,A){const I=A[B+6];return B+I*jA}function No(B,A){return A[B+7]}function Mo(B,A,I,g,Q){let C=1/0,i=1/0,E=1/0,D=-1/0,o=-1/0,s=-1/0,t=1/0,w=1/0,a=1/0,G=-1/0,r=-1/0,c=-1/0;const y=B.offset||0;for(let R=(A-y)*6,S=(A+I-y)*6;R<S;R+=6){const n=B[R+0],N=B[R+1],M=n-N,J=n+N;M<C&&(C=M),J>D&&(D=J),n<t&&(t=n),n>G&&(G=n);const L=B[R+2],H=B[R+3],Y=L-H,d=L+H;Y<i&&(i=Y),d>o&&(o=d),L<w&&(w=L),L>r&&(r=L);const l=B[R+4],p=B[R+5],u=l-p,P=l+p;u<E&&(E=u),P>s&&(s=P),l<a&&(a=l),l>c&&(c=l)}g[0]=C,g[1]=i,g[2]=E,g[3]=D,g[4]=o,g[5]=s,Q[0]=t,Q[1]=w,Q[2]=a,Q[3]=G,Q[4]=r,Q[5]=c}const Zg=32,Ar=(B,A)=>B.candidate-A.candidate,iQ=new Array(Zg).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ii=new Float32Array(6);function Ir(B,A,I,g,Q,C){let i=-1,E=0;if(C===Ro)i=va(A),i!==-1&&(E=(A[i]+A[i+3])/2);else if(C===ma)i=va(B),i!==-1&&(E=gr(I,g,Q,i));else if(C===Pa){const D=aC(B);let o=no*Q;const s=I.offset||0,t=(g-s)*6,w=(g+Q-s)*6;for(let a=0;a<3;a++){const G=A[a],r=(A[a+3]-G)/Zg;if(Q<Zg/4){const c=[...iQ];c.length=Q;let y=0;for(let S=t;S<w;S+=6,y++){const n=c[y];n.candidate=I[S+2*a],n.count=0;const{bounds:N,leftCacheBounds:M,rightCacheBounds:J}=n;for(let L=0;L<3;L++)J[L]=1/0,J[L+3]=-1/0,M[L]=1/0,M[L+3]=-1/0,N[L]=1/0,N[L+3]=-1/0;Ei(S,I,N)}c.sort(Ar);let R=Q;for(let S=0;S<R;S++){const n=c[S];for(;S+1<R&&c[S+1].candidate===n.candidate;)c.splice(S+1,1),R--}for(let S=t;S<w;S+=6){const n=I[S+2*a];for(let N=0;N<R;N++){const M=c[N];n>=M.candidate?Ei(S,I,M.rightCacheBounds):(Ei(S,I,M.leftCacheBounds),M.count++)}}for(let S=0;S<R;S++){const n=c[S],N=n.count,M=Q-n.count,J=n.leftCacheBounds,L=n.rightCacheBounds;let H=0;N!==0&&(H=aC(J)/D);let Y=0;M!==0&&(Y=aC(L)/D);const d=Ta+no*(H*N+Y*M);d<o&&(i=a,o=d,E=n.candidate)}}else{for(let R=0;R<Zg;R++){const S=iQ[R];S.count=0,S.candidate=G+r+R*r;const n=S.bounds;for(let N=0;N<3;N++)n[N]=1/0,n[N+3]=-1/0}for(let R=t;R<w;R+=6){let S=~~((I[R+2*a]-G)/r);S>=Zg&&(S=Zg-1);const n=iQ[S];n.count++,Ei(R,I,n.bounds)}const c=iQ[Zg-1];Za(c.bounds,c.rightCacheBounds);for(let R=Zg-2;R>=0;R--){const S=iQ[R],n=iQ[R+1];Va(S.bounds,n.rightCacheBounds,S.rightCacheBounds)}let y=0;for(let R=0;R<Zg-1;R++){const S=iQ[R],n=S.count,N=S.bounds,M=iQ[R+1].rightCacheBounds;n!==0&&(y===0?Za(N,ii):Va(N,ii,ii)),y+=n;let J=0,L=0;y!==0&&(J=aC(ii)/D);const H=Q-y;H!==0&&(L=aC(M)/D);const Y=Ta+no*(J*y+L*H);Y<o&&(i=a,o=Y,E=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${C} used.`);return{axis:i,pos:E}}function gr(B,A,I,g){let Q=0;const C=B.offset;for(let i=A,E=A+I;i<E;i++)Q+=B[(i-C)*6+g*2];return Q/I}class Jo{constructor(){this.boundingData=new Float32Array(6)}}function Qr(B,A,I,g,Q,C){let i=g,E=g+Q-1;const D=C.pos,o=C.axis*2,s=I.offset||0;for(;;){for(;i<=E&&I[(i-s)*6+o]<D;)i++;for(;i<=E&&I[(E-s)*6+o]>=D;)E--;if(i<E){for(let t=0;t<A;t++){let w=B[i*A+t];B[i*A+t]=B[E*A+t],B[E*A+t]=w}for(let t=0;t<6;t++){const w=i-s,a=E-s,G=I[w*6+t];I[w*6+t]=I[a*6+t],I[a*6+t]=G}i++,E--}else return i}}let Wa,Di,Uo,ja;const Br=Math.pow(2,32);function Lo(B){return"count"in B?1:1+Lo(B.left)+Lo(B.right)}function Cr(B,A,I){return Wa=new Float32Array(I),Di=new Uint32Array(I),Uo=new Uint16Array(I),ja=new Uint8Array(I),Ho(B,A)}function Ho(B,A){const I=B/4,g=B/2,Q="count"in A,C=A.boundingData;for(let i=0;i<6;i++)Wa[I+i]=C[i];if(Q)return A.buffer?(ja.set(new Uint8Array(A.buffer),B),B+A.buffer.byteLength):(Di[I+6]=A.offset,Uo[g+14]=A.count,Uo[g+15]=Oa,B+SI);{const{left:i,right:E,splitAxis:D}=A,o=B+SI;let s=Ho(o,i);const t=B/SI,w=s/SI-t;if(w>Br)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Di[I+6]=w,Di[I+7]=D,Ho(s,E)}}function Er(B,A,I,g,Q){const{maxDepth:C,verbose:i,maxLeafSize:E,strategy:D,onProgress:o}=Q,s=B.primitiveBuffer,t=B.primitiveBufferStride,w=new Float32Array(6);let a=!1;const G=new Jo;return Mo(A,I,g,G.boundingData,w),c(G,I,g,w),G;function r(y){o&&o(y/g)}function c(y,R,S,n=null,N=0){if(!a&&N>=C&&(a=!0,i&&console.warn(`BVH: Max depth of ${C} reached when generating BVH. Consider increasing maxDepth.`)),S<=E||N>=C)return r(R+S),y.offset=R,y.count=S,y;const M=Ir(y.boundingData,n,A,R,S,D);if(M.axis===-1)return r(R+S),y.offset=R,y.count=S,y;const J=Qr(s,t,A,R,S,M);if(J===R||J===R+S)r(R+S),y.offset=R,y.count=S;else{y.splitAxis=M.axis;const L=new Jo,H=R,Y=J-R;y.left=L,Mo(A,H,Y,L.boundingData,w),c(L,H,Y,w,N+1);const d=new Jo,l=J,p=S-Y;y.right=d,Mo(A,l,p,d.boundingData,w),c(d,l,p,w,N+1)}return y}}function ir(B,A){const I=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,g=B.getRootRanges(A.range),Q=g[0],C=g[g.length-1],i={offset:Q.offset,count:C.offset+C.count-Q.offset},E=new Float32Array(6*i.count);E.offset=i.offset,B.computePrimitiveBounds(i.offset,i.count,E),B._roots=g.map(D=>{const o=Er(B,E,D.offset,D.count,A),s=Lo(o),t=new I(SI*s);return Cr(0,o,t),t})}class Yo{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 Dr{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 Dr;let DQ,hB;const cB=[],oi=new Yo(()=>new ag);function or(B,A,I,g,Q,C){DQ=oi.getPrimitive(),hB=oi.getPrimitive(),cB.push(DQ,hB),KA.setBuffer(B._roots[A]);const i=Ko(0,B.geometry,I,g,Q,C);KA.clearBuffer(),oi.releasePrimitive(DQ),oi.releasePrimitive(hB),cB.pop(),cB.pop();const E=cB.length;return E>0&&(hB=cB[E-1],DQ=cB[E-2]),i}function Ko(B,A,I,g,Q=null,C=0,i=0){const{float32Array:E,uint16Array:D,uint32Array:o}=KA;let s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);return mA(B,E,DQ),g(t,w,!1,i,C+B/jA,DQ)}else{let t=function(d){const{uint16Array:l,uint32Array:p}=KA;let u=d*2;for(;!zA(u,l);)d=CI(d),u=d*2;return rI(d,p)},w=function(d){const{uint16Array:l,uint32Array:p}=KA;let u=d*2;for(;!zA(u,l);)d=EI(d,p),u=d*2;return rI(d,p)+lI(u,l)};const a=CI(B),G=EI(B,o);let r=a,c=G,y,R,S,n;if(Q&&(S=DQ,n=hB,mA(r,E,S),mA(c,E,n),y=Q(S),R=Q(n),R<y)){r=G,c=a;const d=y;y=R,R=d,S=n}S||(S=DQ,mA(r,E,S));const N=zA(r*2,D),M=I(S,N,y,i+1,C+r/jA);let J;if(M===ko){const d=t(r),l=w(r)-d;J=g(d,l,!0,i+1,C+r/jA,S)}else J=M&&Ko(r,A,I,g,Q,C,i+1);if(J)return!0;n=hB,mA(c,E,n);const L=zA(c*2,D),H=I(n,L,R,i+1,C+c/jA);let Y;if(H===ko){const d=t(c),l=w(c)-d;Y=g(d,l,!0,i+1,C+c/jA,n)}else Y=H&&Ko(c,A,I,g,Q,C,i+1);return!!Y}}const eC=new KA.constructor,si=new KA.constructor,oQ=new Yo(()=>new ag),yB=new ag,GB=new ag,lo=new ag,fo=new ag;let po=!1;function sr(B,A,I,g){if(po)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");po=!0;const Q=B._roots,C=A._roots;let i,E=0,D=0;const o=new fA().copy(I).invert();for(let s=0,t=Q.length;s<t;s++){eC.setBuffer(Q[s]),D=0;const w=oQ.getPrimitive();mA(0,eC.float32Array,w),w.applyMatrix4(o);for(let a=0,G=C.length;a<G&&(si.setBuffer(C[a]),i=Fg(0,0,I,o,g,E,D,0,0,w),si.clearBuffer(),D+=C[a].byteLength/SI,!i);a++);if(oQ.releasePrimitive(w),eC.clearBuffer(),E+=Q[s].byteLength/SI,i)break}return po=!1,i}function Fg(B,A,I,g,Q,C=0,i=0,E=0,D=0,o=null,s=!1){let t,w;s?(t=si,w=eC):(t=eC,w=si);const a=t.float32Array,G=t.uint32Array,r=t.uint16Array,c=w.float32Array,y=w.uint32Array,R=w.uint16Array,S=B*2,n=A*2,N=zA(S,r),M=zA(n,R);let J=!1;if(M&&N)s?J=Q(rI(A,y),lI(A*2,R),rI(B,G),lI(B*2,r),D,i+A/jA,E,C+B/jA):J=Q(rI(B,G),lI(B*2,r),rI(A,y),lI(A*2,R),E,C+B/jA,D,i+A/jA);else if(M){const L=oQ.getPrimitive();mA(A,c,L),L.applyMatrix4(I);const H=CI(B),Y=EI(B,G);mA(H,a,yB),mA(Y,a,GB);const d=L.intersectsBox(yB),l=L.intersectsBox(GB);J=d&&Fg(A,H,g,I,Q,i,C,D,E+1,L,!s)||l&&Fg(A,Y,g,I,Q,i,C,D,E+1,L,!s),oQ.releasePrimitive(L)}else{const L=CI(A),H=EI(A,y);mA(L,c,lo),mA(H,c,fo);const Y=o.intersectsBox(lo),d=o.intersectsBox(fo);if(Y&&d)J=Fg(B,L,I,g,Q,C,i,E,D+1,o,s)||Fg(B,H,I,g,Q,C,i,E,D+1,o,s);else if(Y)if(N)J=Fg(B,L,I,g,Q,C,i,E,D+1,o,s);else{const l=oQ.getPrimitive();l.copy(lo).applyMatrix4(I);const p=CI(B),u=EI(B,G);mA(p,a,yB),mA(u,a,GB);const P=l.intersectsBox(yB),O=l.intersectsBox(GB);J=P&&Fg(L,p,g,I,Q,i,C,D,E+1,l,!s)||O&&Fg(L,u,g,I,Q,i,C,D,E+1,l,!s),oQ.releasePrimitive(l)}else if(d)if(N)J=Fg(B,H,I,g,Q,C,i,E,D+1,o,s);else{const l=oQ.getPrimitive();l.copy(fo).applyMatrix4(I);const p=CI(B),u=EI(B,G);mA(p,a,yB),mA(u,a,GB);const P=l.intersectsBox(yB),O=l.intersectsBox(GB);J=P&&Fg(H,p,g,I,Q,i,C,D,E+1,l,!s)||O&&Fg(H,u,g,I,Q,i,C,D,E+1,l,!s),oQ.releasePrimitive(l)}}return J}const za=new ag,SB=new Float32Array(6);class _a{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(A){A={...Xa,...A},ir(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,i=1/0,E=1/0,D=-1/0,o=-1/0,s=-1/0;for(let t=A,w=A+I;t<w;t++){this.writePrimitiveBounds(t,SB,0);const[a,G,r,c,y,R]=SB;a<C&&(C=a),c>D&&(D=c),G<i&&(i=G),y>o&&(o=y),r<E&&(E=r),R>s&&(s=R)}return g[Q+0]=C,g[Q+1]=i,g[Q+2]=E,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,i=A+I;C<i;C++){this.writePrimitiveBounds(C,SB,0);const[E,D,o,s,t,w]=SB,a=(E+s)/2,G=(D+t)/2,r=(o+w)/2,c=(s-E)/2,y=(t-D)/2,R=(w-o)/2,S=(C-Q)*6;g[S+0]=a,g[S+1]=c+(Math.abs(a)+c)*Bi,g[S+2]=G,g[S+3]=y+(Math.abs(G)+y)*Bi,g[S+4]=r,g[S+5]=R+(Math.abs(r)+R)*Bi}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],i=new Uint32Array(C),E=new Uint16Array(C),D=C.byteLength/SI;for(let o=0;o<D;o++){const s=jA*o,t=2*s;zA(t,E)&&(i[s+6]+=A)}}}}traverse(A,I=0){const g=this._roots[I],Q=new Uint32Array(g),C=new Uint16Array(g);i(0);function i(E,D=0){const o=E*2,s=zA(o,C);if(s){const t=Q[E+6],w=C[o+14];A(D,s,new Float32Array(g,E*4,6),t,w)}else{const t=CI(E),w=EI(E,Q),a=No(E,Q);A(D,s,new Float32Array(g,E*4,6),a)||(i(t,D+1),i(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),i=new Uint16Array(Q),E=new Float32Array(Q),D=Q.byteLength/SI;for(let o=D-1;o>=0;o--){const s=o*jA,t=s*2;if(zA(t,i)){const w=rI(s,C),a=lI(t,i);this.writePrimitiveRangeBounds(w,a,SB,0),E.set(SB,s)}else{const w=CI(s),a=EI(s,C);for(let G=0;G<3;G++){const r=E[w+G],c=E[w+G+3],y=E[a+G],R=E[a+G+3];E[s+G]=r<y?r:y,E[s+G+3]=c>R?c:R}}}}}getBoundingBox(A){return A.makeEmpty(),this._roots.forEach(I=>{mA(0,new Float32Array(I),za),A.union(za)}),A}shapecast(A){let{boundsTraverseOrder:I,intersectsBounds:g,intersectsRange:Q,intersectsPrimitive:C,scratchPrimitive:i,iterate:E}=A;if(Q&&C){const t=Q;Q=(w,a,G,r,c)=>t(w,a,G,r,c)?!0:E(w,a,this,C,G,r,i)}else Q||(C?Q=(t,w,a,G)=>E(t,w,this,C,a,G,i):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=or(this,t,g,Q,I,o),D)break;o+=a.byteLength/SI}return D}bvhcast(A,I,g){let{intersectsRanges:Q}=g;return sr(this,A,I,Q)}}function tr(){return typeof SharedArrayBuffer<"u"}function xo(B){return B.index?B.index.count:B.attributes.position.count}function ti(B){return xo(B)/3}function wr(B,A=ArrayBuffer){return B>65535?new Uint32Array(new A(4*B)):new Uint16Array(new A(2*B))}function ar(B,A){if(!B.index){const I=B.attributes.position.count,g=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,Q=wr(I,g);B.setIndex(new iI(Q,1));for(let C=0;C<I;C++)Q[C]=C}}function er(B,A,I){const g=xo(B)/I,Q=A||B.drawRange,C=Q.start/I,i=(Q.start+Q.count)/I,E=Math.max(0,C),D=Math.min(g,i)-E;return{offset:Math.floor(E),count:Math.floor(D)}}function hr(B,A){return B.groups.map(I=>({offset:I.start/A,count:I.count/A}))}function $a(B,A,I){const g=er(B,A,I),Q=hr(B,I);if(!Q.length)return[g];const C=[],i=g.offset,E=g.offset+g.count,D=xo(B)/I,o=[];for(const w of Q){const{offset:a,count:G}=w,r=a,c=isFinite(G)?G:D-a,y=a+c;r<E&&y>i&&(o.push({pos:Math.max(i,r),isStart:!0}),o.push({pos:Math.min(E,y),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 Ae(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,i=A?new SharedArrayBuffer(Q*C):new ArrayBuffer(Q*C),E=g?new Uint32Array(i):new Uint16Array(i);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++)E[D+w]=s+w;D+=t}return E}class Ie extends _a{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&&!tr())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={...Xa,...I},I[Ci]||this.init(I)}init(A){const{geometry:I,primitiveStride:g}=this;if(A.indirect){const Q=$a(I,A.range,g),C=Ae(Q,A.useSharedArrayBuffer);this._indirectBuffer=C}else ar(I,A);super.init(A),!I.boundingBox&&A.setBoundingBox&&(I.boundingBox=this.getBoundingBox(new ag))}getRootRanges(A){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:$a(this.geometry,A,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Vg{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(A,I){let g=1/0,Q=-1/0;for(let C=0,i=A.length;C<i;C++){const E=A[C][I];g=E<g?E:g,Q=E>Q?E:Q}this.min=g,this.max=Q}setFromPoints(A,I){let g=1/0,Q=-1/0;for(let C=0,i=I.length;C<i;C++){const E=I[C],D=A.dot(E);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}}Vg.prototype.setFromBox=function(){const B=new q;return function(A,I){const g=I.min,Q=I.max;let C=1/0,i=-1/0;for(let E=0;E<=1;E++)for(let D=0;D<=1;D++)for(let o=0;o<=1;o++){B.x=g.x*E+Q.x*(1-E),B.y=g.y*D+Q.y*(1-D),B.z=g.z*o+Q.z*(1-o);const s=A.dot(B);C=Math.min(s,C),i=Math.max(s,i)}this.min=C,this.max=i}}();const cr=function(){const B=new q,A=new q,I=new q;return function(g,Q,C){const i=g.start,E=B,D=Q.start,o=A;I.subVectors(i,D),B.subVectors(g.end,g.start),A.subVectors(Q.end,Q.start);const s=I.dot(o),t=o.dot(E),w=o.dot(o),a=I.dot(E),G=E.dot(E)*w-t*t;let r,c;G!==0?r=(s*t-a*w)/G:r=0,c=(s+r*t)/w,C.x=r,C.y=c}}(),qo=function(){const B=new JI,A=new q,I=new q;return function(g,Q,C,i){cr(g,Q,B);let E=B.x,D=B.y;if(E>=0&&E<=1&&D>=0&&D<=1){g.at(E,C),Q.at(D,i);return}else if(E>=0&&E<=1){D<0?Q.at(0,i):Q.at(1,i),g.closestPointToPoint(i,!0,C);return}else if(D>=0&&D<=1){E<0?g.at(0,C):g.at(1,C),Q.closestPointToPoint(C,!0,i);return}else{let o;E<0?o=g.start:o=g.end;let s;D<0?s=Q.start:s=Q.end;const t=A,w=I;if(g.closestPointToPoint(s,!0,A),Q.closestPointToPoint(o,!0,I),t.distanceToSquared(s)<=w.distanceToSquared(o)){C.copy(t),i.copy(s);return}else{C.copy(o),i.copy(w);return}}}}(),yr=function(){const B=new q,A=new q,I=new Ys,g=new bg;return function(Q,C){const{radius:i,center:E}=Q,{a:D,b:o,c:s}=C;if(g.start=D,g.end=o,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i||(g.start=D,g.end=s,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i)||(g.start=o,g.end=s,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i))return!0;const t=C.getPlane(I);if(Math.abs(t.distanceToPoint(E))<=i){const w=t.projectPoint(E,A);if(C.containsPoint(w))return!0}return!1}}(),Gr=["x","y","z"],Wg=1e-15,ge=Wg*Wg;function gg(B){return Math.abs(B)<Wg}class Qg extends eQ{constructor(...A){super(...A),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new q),this.satBounds=new Array(4).fill().map(()=>new Vg),this.points=[this.a,this.b,this.c],this.plane=new Ys,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new bg,this.needsUpdate=!0}intersectsSphere(A){return yr(A,this)}update(){const A=this.a,I=this.b,g=this.c,Q=this.points,C=this.satAxes,i=this.satBounds,E=C[0],D=i[0];this.getNormal(E),D.setFromPoints(E,Q);const o=C[1],s=i[1];o.subVectors(A,I),s.setFromPoints(o,Q);const t=C[2],w=i[2];t.subVectors(I,g),w.setFromPoints(t,Q);const a=C[3],G=i[3];a.subVectors(g,A),G.setFromPoints(a,Q);const r=o.length(),c=t.length(),y=a.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,r<Wg?c<Wg||y<Wg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(A),this.degenerateSegment.end.copy(g)):c<Wg?y<Wg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(I),this.degenerateSegment.end.copy(A)):y<Wg&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(g),this.degenerateSegment.end.copy(I)),this.plane.setFromNormalAndCoplanarPoint(E,A),this.needsUpdate=!1}}Qg.prototype.closestPointToSegment=function(){const B=new q,A=new q,I=new bg;return function(g,Q=null,C=null){const{start:i,end:E}=g,D=this.points;let o,s=1/0;for(let t=0;t<3;t++){const w=(t+1)%3;I.start.copy(D[t]),I.end.copy(D[w]),qo(I,g,B,A),o=B.distanceToSquared(A),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(A))}return this.closestPointToPoint(i,B),o=i.distanceToSquared(B),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(i)),this.closestPointToPoint(E,B),o=E.distanceToSquared(B),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(E)),Math.sqrt(s)}}(),Qg.prototype.intersectsTriangle=function(){const B=new Qg,A=new Vg,I=new Vg,g=new q,Q=new q,C=new q,i=new q,E=new bg,D=new bg,o=new q,s=new JI,t=new JI;function w(S,n,N,M){const J=g;!S.isDegenerateIntoPoint&&!S.isDegenerateIntoSegment?J.copy(S.plane.normal):J.copy(n.plane.normal);const L=S.satBounds,H=S.satAxes;for(let l=1;l<4;l++){const p=L[l],u=H[l];if(A.setFromPoints(u,n.points),p.isSeparated(A)||(i.copy(J).cross(u),A.setFromPoints(i,S.points),I.setFromPoints(i,n.points),A.isSeparated(I)))return!1}const Y=n.satBounds,d=n.satAxes;for(let l=1;l<4;l++){const p=Y[l],u=d[l];if(A.setFromPoints(u,S.points),p.isSeparated(A)||(i.crossVectors(J,u),A.setFromPoints(i,S.points),I.setFromPoints(i,n.points),A.isSeparated(I)))return!1}return N&&(M||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),N.start.set(0,0,0),N.end.set(0,0,0)),!0}function a(S,n,N,M,J,L,H,Y,d,l,p){let u=H/(H-Y);l.x=M+(J-M)*u,p.start.subVectors(n,S).multiplyScalar(u).add(S),u=H/(H-d),l.y=M+(L-M)*u,p.end.subVectors(N,S).multiplyScalar(u).add(S)}function G(S,n,N,M,J,L,H,Y,d,l,p){if(J>0)a(S.c,S.a,S.b,M,n,N,d,H,Y,l,p);else if(L>0)a(S.b,S.a,S.c,N,n,M,Y,H,d,l,p);else if(Y*d>0||H!=0)a(S.a,S.b,S.c,n,N,M,H,Y,d,l,p);else if(Y!=0)a(S.b,S.a,S.c,N,n,M,Y,H,d,l,p);else if(d!=0)a(S.c,S.a,S.b,M,n,N,d,H,Y,l,p);else return!0;return!1}function r(S,n,N,M){const J=n.degenerateSegment,L=S.plane.distanceToPoint(J.start),H=S.plane.distanceToPoint(J.end);return gg(L)?gg(H)?w(S,n,N,M):(N&&(N.start.copy(J.start),N.end.copy(J.start)),S.containsPoint(J.start)):gg(H)?(N&&(N.start.copy(J.end),N.end.copy(J.end)),S.containsPoint(J.end)):S.plane.intersectLine(J,g)!=null?(N&&(N.start.copy(g),N.end.copy(g)),S.containsPoint(g)):!1}function c(S,n,N){const M=n.a;return gg(S.plane.distanceToPoint(M))&&S.containsPoint(M)?(N&&(N.start.copy(M),N.end.copy(M)),!0):!1}function y(S,n,N){const M=S.degenerateSegment,J=n.a;return M.closestPointToPoint(J,!0,g),J.distanceToSquared(g)<ge?(N&&(N.start.copy(J),N.end.copy(J)),!0):!1}function R(S,n,N,M){if(S.isDegenerateIntoSegment)if(n.isDegenerateIntoSegment){const J=S.degenerateSegment,L=n.degenerateSegment,H=Q,Y=C;J.delta(H),L.delta(Y);const d=g.subVectors(L.start,J.start),l=H.x*Y.y-H.y*Y.x;if(gg(l))return!1;const p=(d.x*Y.y-d.y*Y.x)/l,u=-(H.x*d.y-H.y*d.x)/l;if(p<0||p>1||u<0||u>1)return!1;const P=J.start.z+H.z*p,O=L.start.z+Y.z*u;return gg(P-O)?(N&&(N.start.copy(J.start).addScaledVector(H,p),N.end.copy(J.start).addScaledVector(H,p)),!0):!1}else return n.isDegenerateIntoPoint?y(S,n,N):r(n,S,N,M);else{if(S.isDegenerateIntoPoint)return n.isDegenerateIntoPoint?n.a.distanceToSquared(S.a)<ge?(N&&(N.start.copy(S.a),N.end.copy(S.a)),!0):!1:n.isDegenerateIntoSegment?y(n,S,N):c(n,S,N);if(n.isDegenerateIntoPoint)return c(S,n,N);if(n.isDegenerateIntoSegment)return r(S,n,N,M)}}return function(S,n=null,N=!1){this.needsUpdate&&this.update(),S.isExtendedTriangle?S.needsUpdate&&S.update():(B.copy(S),B.update(),S=B);const M=R(this,S,n,N);if(M!==void 0)return M;const J=this.plane,L=S.plane;let H=L.distanceToPoint(this.a),Y=L.distanceToPoint(this.b),d=L.distanceToPoint(this.c);gg(H)&&(H=0),gg(Y)&&(Y=0),gg(d)&&(d=0);const l=H*Y,p=H*d;if(l>0&&p>0)return!1;let u=J.distanceToPoint(S.a),P=J.distanceToPoint(S.b),O=J.distanceToPoint(S.c);gg(u)&&(u=0),gg(P)&&(P=0),gg(O)&&(O=0);const W=u*P,T=u*O;if(W>0&&T>0)return!1;Q.copy(J.normal),C.copy(L.normal);const j=Q.cross(C);let EA=0,wA=Math.abs(j.x);const iA=Math.abs(j.y);iA>wA&&(wA=iA,EA=1),Math.abs(j.z)>wA&&(EA=2);const IA=Gr[EA],BA=this.a[IA],AA=this.b[IA],$=this.c[IA],z=S.a[IA],LA=S.b[IA],NA=S.c[IA];if(G(this,BA,AA,$,l,p,H,Y,d,s,E))return w(this,S,n,N);if(G(S,z,LA,NA,W,T,u,P,O,t,D))return w(this,S,n,N);if(s.y<s.x){const MA=s.y;s.y=s.x,s.x=MA,o.copy(E.start),E.start.copy(E.end),E.end.copy(o)}if(t.y<t.x){const MA=t.y;t.y=t.x,t.x=MA,o.copy(D.start),D.start.copy(D.end),D.end.copy(o)}return s.y<t.x||t.y<s.x?!1:(n&&(t.x>s.x?n.start.copy(D.start):n.start.copy(E.start),t.y<s.y?n.end.copy(D.end):n.end.copy(E.end)),!0)}}(),Qg.prototype.distanceToPoint=function(){const B=new q;return function(A){return this.closestPointToPoint(A,B),A.distanceTo(B)}}(),Qg.prototype.distanceToTriangle=function(){const B=new q,A=new q,I=["a","b","c"],g=new bg,Q=new bg;return function(C,i=null,E=null){const D=i||E?g:null;if(this.intersectsTriangle(C,D))return(i||E)&&(i&&D.getCenter(i),E&&D.getCenter(E)),0;let o=1/0;for(let s=0;s<3;s++){let t;const w=I[s],a=C[w];this.closestPointToPoint(a,B),t=a.distanceToSquared(B),t<o&&(o=t,i&&i.copy(B),E&&E.copy(a));const G=this[w];C.closestPointToPoint(G,B),t=G.distanceToSquared(B),t<o&&(o=t,i&&i.copy(G),E&&E.copy(B))}for(let s=0;s<3;s++){const t=I[s],w=I[(s+1)%3];g.set(this[t],this[w]);for(let a=0;a<3;a++){const G=I[a],r=I[(a+1)%3];Q.set(C[G],C[r]),qo(g,Q,B,A);const c=B.distanceToSquared(A);c<o&&(o=c,i&&i.copy(B),E&&E.copy(A))}}return Math.sqrt(o)}}();class FI{constructor(A,I,g){this.isOrientedBox=!0,this.min=new q,this.max=new q,this.matrix=new fA,this.invMatrix=new fA,this.points=new Array(8).fill().map(()=>new q),this.satAxes=new Array(3).fill().map(()=>new q),this.satBounds=new Array(3).fill().map(()=>new Vg),this.alignedSatBounds=new Array(3).fill().map(()=>new Vg),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}}FI.prototype.update=function(){return function(){const B=this.matrix,A=this.min,I=this.max,g=this.points;for(let D=0;D<=1;D++)for(let o=0;o<=1;o++)for(let s=0;s<=1;s++){const t=1*D|2*o|4*s,w=g[t];w.x=D?I.x:A.x,w.y=o?I.y:A.y,w.z=s?I.z:A.z,w.applyMatrix4(B)}const Q=this.satBounds,C=this.satAxes,i=g[0];for(let D=0;D<3;D++){const o=C[D],s=Q[D],t=1<<D,w=g[t];o.subVectors(i,w),s.setFromPoints(o,g)}const E=this.alignedSatBounds;E[0].setFromPointsField(g,"x"),E[1].setFromPointsField(g,"y"),E[2].setFromPointsField(g,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),FI.prototype.intersectsBox=function(){const B=new Vg;return function(A){this.needsUpdate&&this.update();const I=A.min,g=A.max,Q=this.satBounds,C=this.satAxes,i=this.alignedSatBounds;if(B.min=I.x,B.max=g.x,i[0].isSeparated(B)||(B.min=I.y,B.max=g.y,i[1].isSeparated(B))||(B.min=I.z,B.max=g.z,i[2].isSeparated(B)))return!1;for(let E=0;E<3;E++){const D=C[E],o=Q[E];if(B.setFromBox(D,A),o.isSeparated(B))return!1}return!0}}(),FI.prototype.intersectsTriangle=function(){const B=new Qg,A=new Array(3),I=new Vg,g=new Vg,Q=new q;return function(C){this.needsUpdate&&this.update(),C.isExtendedTriangle?C.needsUpdate&&C.update():(B.copy(C),B.update(),C=B);const i=this.satBounds,E=this.satAxes;A[0]=C.a,A[1]=C.b,A[2]=C.c;for(let t=0;t<3;t++){const w=i[t],a=E[t];if(I.setFromPoints(a,A),w.isSeparated(I))return!1}const D=C.satBounds,o=C.satAxes,s=this.points;for(let t=0;t<3;t++){const w=D[t],a=o[t];if(I.setFromPoints(a,s),w.isSeparated(I))return!1}for(let t=0;t<3;t++){const w=E[t];for(let a=0;a<4;a++){const G=o[a];if(Q.crossVectors(w,G),I.setFromPoints(Q,A),g.setFromPoints(Q,s),I.isSeparated(g))return!1}}return!0}}(),FI.prototype.closestPointToPoint=function(){return function(B,A){return this.needsUpdate&&this.update(),A.copy(B).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),A}}(),FI.prototype.distanceToPoint=function(){const B=new q;return function(A){return this.closestPointToPoint(A,B),A.distanceTo(B)}}(),FI.prototype.distanceToBox=function(){const B=["x","y","z"],A=new Array(12).fill().map(()=>new bg),I=new Array(12).fill().map(()=>new bg),g=new q,Q=new q;return function(C,i=0,E=null,D=null){if(this.needsUpdate&&this.update(),this.intersectsBox(C))return(E||D)&&(C.getCenter(Q),this.closestPointToPoint(Q,g),C.closestPointToPoint(g,Q),E&&E.copy(g),D&&D.copy(Q)),0;const o=i*i,s=C.min,t=C.max,w=this.points;let a=1/0;for(let r=0;r<8;r++){const c=w[r];Q.copy(c).clamp(s,t);const y=c.distanceToSquared(Q);if(y<a&&(a=y,E&&E.copy(c),D&&D.copy(Q),y<o))return Math.sqrt(y)}let G=0;for(let r=0;r<3;r++)for(let c=0;c<=1;c++)for(let y=0;y<=1;y++){const R=(r+1)%3,S=(r+2)%3,n=c<<R|y<<S,N=1<<r|c<<R|y<<S,M=w[n],J=w[N];A[G].set(M,J);const L=B[r],H=B[R],Y=B[S],d=I[G],l=d.start,p=d.end;l[L]=s[L],l[H]=c?s[H]:t[H],l[Y]=y?s[Y]:t[H],p[L]=t[L],p[H]=c?s[H]:t[H],p[Y]=y?s[Y]:t[H],G++}for(let r=0;r<=1;r++)for(let c=0;c<=1;c++)for(let y=0;y<=1;y++){Q.x=r?t.x:s.x,Q.y=c?t.y:s.y,Q.z=y?t.z:s.z,this.closestPointToPoint(Q,g);const R=Q.distanceToSquared(g);if(R<a&&(a=R,E&&E.copy(g),D&&D.copy(Q),R<o))return Math.sqrt(R)}for(let r=0;r<12;r++){const c=A[r];for(let y=0;y<12;y++){const R=I[y];qo(c,R,g,Q);const S=g.distanceToSquared(Q);if(S<a&&(a=S,E&&E.copy(g),D&&D.copy(Q),S<o))return Math.sqrt(S)}}return Math.sqrt(a)}}();class Sr extends Yo{constructor(){super(()=>new Qg)}}const Bg=new Sr,hC=new q,uo=new q;function rr(B,A,I={},g=0,Q=1/0){const C=g*g,i=Q*Q;let E=1/0,D=null;if(B.shapecast({boundsTraverseOrder:s=>(hC.copy(A).clamp(s.min,s.max),hC.distanceToSquared(A)),intersectsBounds:(s,t,w)=>w<E&&w<i,intersectsTriangle:(s,t)=>{s.closestPointToPoint(A,hC);const w=A.distanceToSquared(hC);return w<E&&(uo.copy(hC),E=w,D=t),w<C}}),E===1/0)return null;const o=Math.sqrt(E);return I.point?I.point.copy(uo):I.point=uo.clone(),I.distance=o,I.faceIndex=D,I}const wi=parseInt(ji)>=169,Fr=parseInt(ji)<=161,HQ=new q,YQ=new q,KQ=new q,ai=new JI,ei=new JI,hi=new JI,Qe=new q,Be=new q,Ce=new q,cC=new q;function Rr(B,A,I,g,Q,C,i,E){let D;if(C===ze?D=B.intersectTriangle(g,I,A,!0,Q):D=B.intersectTriangle(A,I,g,C!==dB,Q),D===null)return null;const o=B.origin.distanceTo(Q);return o<i||o>E?null:{distance:o,point:Q.clone()}}function Ee(B,A,I,g,Q,C,i,E,D,o,s){HQ.fromBufferAttribute(A,C),YQ.fromBufferAttribute(A,i),KQ.fromBufferAttribute(A,E);const t=Rr(B,HQ,YQ,KQ,cC,D,o,s);if(t){if(g){ai.fromBufferAttribute(g,C),ei.fromBufferAttribute(g,i),hi.fromBufferAttribute(g,E),t.uv=new JI;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,ai,ei,hi,t.uv);wi||(t.uv=a)}if(Q){ai.fromBufferAttribute(Q,C),ei.fromBufferAttribute(Q,i),hi.fromBufferAttribute(Q,E),t.uv1=new JI;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,ai,ei,hi,t.uv1);wi||(t.uv1=a),Fr&&(t.uv2=t.uv1)}if(I){Qe.fromBufferAttribute(I,C),Be.fromBufferAttribute(I,i),Ce.fromBufferAttribute(I,E),t.normal=new q;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,Qe,Be,Ce,t.normal);t.normal.dot(B.direction)>0&&t.normal.multiplyScalar(-1),wi||(t.normal=a)}const w={a:C,b:i,c:E,normal:new q,materialIndex:0};if(eQ.getNormal(HQ,YQ,KQ,w.normal),t.face=w,t.faceIndex=C,wi){const a=new q;eQ.getBarycoord(cC,HQ,YQ,KQ,a),t.barycoord=a}}return t}function ie(B){return B&&B.isMaterial?B.side:B}function ci(B,A,I,g,Q,C,i){const E=g*3;let D=E+0,o=E+1,s=E+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:G,uv:r,uv1:c}=B.attributes;if(Array.isArray(A)){const y=g*3;for(let R=0,S=w.length;R<S;R++){const{start:n,count:N,materialIndex:M}=w[R];if(y>=n&&y<n+N){const J=ie(A[M]),L=Ee(I,a,G,r,c,D,o,s,J,C,i);if(L)if(L.faceIndex=g,L.face.materialIndex=M,Q)Q.push(L);else return L}}}else{const y=ie(A),R=Ee(I,a,G,r,c,D,o,s,y,C,i);if(R)if(R.faceIndex=g,R.face.materialIndex=0,Q)Q.push(R);else return R}return null}function vA(B,A,I,g){const Q=B.a,C=B.b,i=B.c;let E=A,D=A+1,o=A+2;I&&(E=I.getX(E),D=I.getX(D),o=I.getX(o)),Q.x=g.getX(E),Q.y=g.getY(E),Q.z=g.getZ(E),C.x=g.getX(D),C.y=g.getY(D),C.z=g.getZ(D),i.x=g.getX(o),i.y=g.getY(o),i.z=g.getZ(o)}function kr(B,A,I,g,Q,C,i,E){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++)ci(D,A,I,s,C,i,E)}function nr(B,A,I,g,Q,C,i){const{geometry:E,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=ci(E,A,I,t,null,C,i),a&&a.distance<o&&(s=a,o=a.distance)}return s}function Nr(B,A,I,g,Q,C,i){const{geometry:E}=I,{index:D}=E,o=E.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=s,vA(i,w*3,D,o),i.needsUpdate=!0,g(i,w,Q,C))return!0}return!1}function Mr(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,i,E,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],i=new Uint32Array(C),E=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,G=!1){const r=w*2;if(zA(r,E)){const c=rI(w,i),y=lI(r,E);let R=1/0,S=1/0,n=1/0,N=-1/0,M=-1/0,J=-1/0;for(let L=3*c,H=3*(c+y);L<H;L++){let Y=g[L];const d=Q.getX(Y),l=Q.getY(Y),p=Q.getZ(Y);d<R&&(R=d),d>N&&(N=d),l<S&&(S=l),l>M&&(M=l),p<n&&(n=p),p>J&&(J=p)}return D[w+0]!==R||D[w+1]!==S||D[w+2]!==n||D[w+3]!==N||D[w+4]!==M||D[w+5]!==J?(D[w+0]=R,D[w+1]=S,D[w+2]=n,D[w+3]=N,D[w+4]=M,D[w+5]=J,!0):!1}else{const c=CI(w),y=EI(w,i);let R=G,S=!1,n=!1;if(A){if(!R){const Y=c/jA+a/SI,d=y/jA+a/SI;S=A.has(Y),n=A.has(d),R=!S&&!n}}else S=!0,n=!0;const N=R||S,M=R||n;let J=!1;N&&(J=t(c,a,R));let L=!1;M&&(L=t(y,a,R));const H=J||L;if(H)for(let Y=0;Y<3;Y++){const d=c+Y,l=y+Y,p=D[d],u=D[d+3],P=D[l],O=D[l+3];D[w+Y]=p<P?p:P,D[w+Y+3]=u>O?u:O}return H}}}function sQ(B,A,I,g,Q){let C,i,E,D,o,s;const t=1/I.direction.x,w=1/I.direction.y,a=1/I.direction.z,G=I.origin.x,r=I.origin.y,c=I.origin.z;let y=A[B],R=A[B+3],S=A[B+1],n=A[B+3+1],N=A[B+2],M=A[B+3+2];return t>=0?(C=(y-G)*t,i=(R-G)*t):(C=(R-G)*t,i=(y-G)*t),w>=0?(E=(S-r)*w,D=(n-r)*w):(E=(n-r)*w,D=(S-r)*w),C>D||E>i||((E>C||isNaN(C))&&(C=E),(D<i||isNaN(i))&&(i=D),a>=0?(o=(N-c)*a,s=(M-c)*a):(o=(M-c)*a,s=(N-c)*a),C>s||o>i)?!1:((o>C||C!==C)&&(C=o),(s<i||i!==i)&&(i=s),C<=Q&&i>=g)}function Jr(B,A,I,g,Q,C,i,E){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++){let w=o?o[s]:s;ci(D,A,I,w,C,i,E)}}function Ur(B,A,I,g,Q,C,i){const{geometry:E,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=ci(E,A,I,D?D[t]:t,null,C,i),a&&a.distance<o&&(s=a,o=a.distance)}return s}function Lr(B,A,I,g,Q,C,i){const{geometry:E}=I,{index:D}=E,o=E.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=I.resolveTriangleIndex(s),vA(i,w*3,D,o),i.needsUpdate=!0,g(i,w,Q,C))return!0}return!1}function Hr(B,A,I,g,Q,C,i){KA.setBuffer(B._roots[A]),bo(0,B,I,g,Q,C,i),KA.clearBuffer()}function bo(B,A,I,g,Q,C,i){const{float32Array:E,uint16Array:D,uint32Array:o}=KA,s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);kr(A,I,g,t,w,Q,C,i)}else{const t=CI(B);sQ(t,E,g,C,i)&&bo(t,A,I,g,Q,C,i);const w=EI(B,o);sQ(w,E,g,C,i)&&bo(w,A,I,g,Q,C,i)}}const Yr=["x","y","z"];function Kr(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const i=mo(0,B,I,g,Q,C);return KA.clearBuffer(),i}function mo(B,A,I,g,Q,C){const{float32Array:i,uint16Array:E,uint32Array:D}=KA;let o=B*2;if(zA(o,E)){const s=rI(B,D),t=lI(o,E);return nr(A,I,g,s,t,Q,C)}else{const s=No(B,D),t=Yr[s],w=g.direction[t]>=0;let a,G;w?(a=CI(B),G=EI(B,D)):(a=EI(B,D),G=CI(B));const r=sQ(a,i,g,Q,C)?mo(a,A,I,g,Q,C):null;if(r){const y=r.point[t];if(w?y<=i[G+s]:y>=i[G+s+3])return r}const c=sQ(G,i,g,Q,C)?mo(G,A,I,g,Q,C):null;return r&&c?r.distance<=c.distance?r:c:r||c||null}}const yi=new ag,rB=new Qg,FB=new Qg,yC=new fA,De=new FI,Gi=new FI;function dr(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=Po(0,B,I,g);return KA.clearBuffer(),Q}function Po(B,A,I,g,Q=null){const{float32Array:C,uint16Array:i,uint32Array:E}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),De.set(I.boundingBox.min,I.boundingBox.max,g),Q=De),zA(D,i)){const o=A.geometry,s=o.index,t=o.attributes.position,w=I.index,a=I.attributes.position,G=rI(B,E),r=lI(D,i);if(yC.copy(g).invert(),I.boundsTree)return mA(B,C,Gi),Gi.matrix.copy(yC),Gi.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:c=>Gi.intersectsBox(c),intersectsTriangle:c=>{c.a.applyMatrix4(g),c.b.applyMatrix4(g),c.c.applyMatrix4(g),c.needsUpdate=!0;for(let y=G*3,R=(r+G)*3;y<R;y+=3)if(vA(FB,y,s,t),FB.needsUpdate=!0,c.intersectsTriangle(FB))return!0;return!1}});{const c=ti(I);for(let y=G*3,R=(r+G)*3;y<R;y+=3){vA(rB,y,s,t),rB.a.applyMatrix4(yC),rB.b.applyMatrix4(yC),rB.c.applyMatrix4(yC),rB.needsUpdate=!0;for(let S=0,n=c*3;S<n;S+=3)if(vA(FB,S,w,a),FB.needsUpdate=!0,rB.intersectsTriangle(FB))return!0}}}else{const o=CI(B),s=EI(B,E);return mA(o,C,yi),!!(Q.intersectsBox(yi)&&Po(o,A,I,g,Q)||(mA(s,C,yi),Q.intersectsBox(yi)&&Po(s,A,I,g,Q)))}}const Si=new fA,To=new FI,GC=new FI,lr=new q,fr=new q,pr=new q,xr=new q;function qr(B,A,I,g={},Q={},C=0,i=1/0){A.boundingBox||A.computeBoundingBox(),To.set(A.boundingBox.min,A.boundingBox.max,I),To.needsUpdate=!0;const E=B.geometry,D=E.attributes.position,o=E.index,s=A.attributes.position,t=A.index,w=Bg.getPrimitive(),a=Bg.getPrimitive();let G=lr,r=fr,c=null,y=null;Q&&(c=pr,y=xr);let R=1/0,S=null,n=null;return Si.copy(I).invert(),GC.matrix.copy(Si),B.shapecast({boundsTraverseOrder:N=>To.distanceToBox(N),intersectsBounds:(N,M,J)=>J<R&&J<i?(M&&(GC.min.copy(N.min),GC.max.copy(N.max),GC.needsUpdate=!0),!0):!1,intersectsRange:(N,M)=>{if(A.boundsTree)return A.boundsTree.shapecast({boundsTraverseOrder:J=>GC.distanceToBox(J),intersectsBounds:(J,L,H)=>H<R&&H<i,intersectsRange:(J,L)=>{for(let H=J,Y=J+L;H<Y;H++){vA(a,3*H,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let d=N,l=N+M;d<l;d++){vA(w,3*d,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,G,c);if(p<R&&(r.copy(G),y&&y.copy(c),R=p,S=d,n=H),p<C)return!0}}}});{const J=ti(A);for(let L=0,H=J;L<H;L++){vA(a,3*L,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let Y=N,d=N+M;Y<d;Y++){vA(w,3*Y,o,D),w.needsUpdate=!0;const l=w.distanceToTriangle(a,G,c);if(l<R&&(r.copy(G),y&&y.copy(c),R=l,S=Y,n=L),l<C)return!0}}}}}),Bg.releasePrimitive(w),Bg.releasePrimitive(a),R===1/0?null:(g.point?g.point.copy(r):g.point=r.clone(),g.distance=R,g.faceIndex=S,Q&&(Q.point?Q.point.copy(y):Q.point=y.clone(),Q.point.applyMatrix4(Si),r.applyMatrix4(Si),Q.distance=r.sub(Q.point).length(),Q.faceIndex=n),g)}function ur(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,i,E,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],i=new Uint32Array(C),E=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,G=!1){const r=w*2;if(zA(r,E)){const c=rI(w,i),y=lI(r,E);let R=1/0,S=1/0,n=1/0,N=-1/0,M=-1/0,J=-1/0;for(let L=c,H=c+y;L<H;L++){const Y=3*B.resolveTriangleIndex(L);for(let d=0;d<3;d++){let l=Y+d;l=g?g[l]:l;const p=Q.getX(l),u=Q.getY(l),P=Q.getZ(l);p<R&&(R=p),p>N&&(N=p),u<S&&(S=u),u>M&&(M=u),P<n&&(n=P),P>J&&(J=P)}}return D[w+0]!==R||D[w+1]!==S||D[w+2]!==n||D[w+3]!==N||D[w+4]!==M||D[w+5]!==J?(D[w+0]=R,D[w+1]=S,D[w+2]=n,D[w+3]=N,D[w+4]=M,D[w+5]=J,!0):!1}else{const c=CI(w),y=EI(w,i);let R=G,S=!1,n=!1;if(A){if(!R){const Y=c/jA+a/SI,d=y/jA+a/SI;S=A.has(Y),n=A.has(d),R=!S&&!n}}else S=!0,n=!0;const N=R||S,M=R||n;let J=!1;N&&(J=t(c,a,R));let L=!1;M&&(L=t(y,a,R));const H=J||L;if(H)for(let Y=0;Y<3;Y++){const d=c+Y,l=y+Y,p=D[d],u=D[d+3],P=D[l],O=D[l+3];D[w+Y]=p<P?p:P,D[w+Y+3]=u>O?u:O}return H}}}function br(B,A,I,g,Q,C,i){KA.setBuffer(B._roots[A]),Oo(0,B,I,g,Q,C,i),KA.clearBuffer()}function Oo(B,A,I,g,Q,C,i){const{float32Array:E,uint16Array:D,uint32Array:o}=KA,s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);Jr(A,I,g,t,w,Q,C,i)}else{const t=CI(B);sQ(t,E,g,C,i)&&Oo(t,A,I,g,Q,C,i);const w=EI(B,o);sQ(w,E,g,C,i)&&Oo(w,A,I,g,Q,C,i)}}const mr=["x","y","z"];function Pr(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const i=Xo(0,B,I,g,Q,C);return KA.clearBuffer(),i}function Xo(B,A,I,g,Q,C){const{float32Array:i,uint16Array:E,uint32Array:D}=KA;let o=B*2;if(zA(o,E)){const s=rI(B,D),t=lI(o,E);return Ur(A,I,g,s,t,Q,C)}else{const s=No(B,D),t=mr[s],w=g.direction[t]>=0;let a,G;w?(a=CI(B),G=EI(B,D)):(a=EI(B,D),G=CI(B));const r=sQ(a,i,g,Q,C)?Xo(a,A,I,g,Q,C):null;if(r){const y=r.point[t];if(w?y<=i[G+s]:y>=i[G+s+3])return r}const c=sQ(G,i,g,Q,C)?Xo(G,A,I,g,Q,C):null;return r&&c?r.distance<=c.distance?r:c:r||c||null}}const ri=new ag,RB=new Qg,kB=new Qg,SC=new fA,oe=new FI,Fi=new FI;function Tr(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=vo(0,B,I,g);return KA.clearBuffer(),Q}function vo(B,A,I,g,Q=null){const{float32Array:C,uint16Array:i,uint32Array:E}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),oe.set(I.boundingBox.min,I.boundingBox.max,g),Q=oe),zA(D,i)){const o=A.geometry,s=o.index,t=o.attributes.position,w=I.index,a=I.attributes.position,G=rI(B,E),r=lI(D,i);if(SC.copy(g).invert(),I.boundsTree)return mA(B,C,Fi),Fi.matrix.copy(SC),Fi.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:c=>Fi.intersectsBox(c),intersectsTriangle:c=>{c.a.applyMatrix4(g),c.b.applyMatrix4(g),c.c.applyMatrix4(g),c.needsUpdate=!0;for(let y=G,R=r+G;y<R;y++)if(vA(kB,3*A.resolveTriangleIndex(y),s,t),kB.needsUpdate=!0,c.intersectsTriangle(kB))return!0;return!1}});{const c=ti(I);for(let y=G,R=r+G;y<R;y++){const S=A.resolveTriangleIndex(y);vA(RB,3*S,s,t),RB.a.applyMatrix4(SC),RB.b.applyMatrix4(SC),RB.c.applyMatrix4(SC),RB.needsUpdate=!0;for(let n=0,N=c*3;n<N;n+=3)if(vA(kB,n,w,a),kB.needsUpdate=!0,RB.intersectsTriangle(kB))return!0}}}else{const o=CI(B),s=EI(B,E);return mA(o,C,ri),!!(Q.intersectsBox(ri)&&vo(o,A,I,g,Q)||(mA(s,C,ri),Q.intersectsBox(ri)&&vo(s,A,I,g,Q)))}}const Ri=new fA,Zo=new FI,rC=new FI,Or=new q,Xr=new q,vr=new q,Zr=new q;function Vr(B,A,I,g={},Q={},C=0,i=1/0){A.boundingBox||A.computeBoundingBox(),Zo.set(A.boundingBox.min,A.boundingBox.max,I),Zo.needsUpdate=!0;const E=B.geometry,D=E.attributes.position,o=E.index,s=A.attributes.position,t=A.index,w=Bg.getPrimitive(),a=Bg.getPrimitive();let G=Or,r=Xr,c=null,y=null;Q&&(c=vr,y=Zr);let R=1/0,S=null,n=null;return Ri.copy(I).invert(),rC.matrix.copy(Ri),B.shapecast({boundsTraverseOrder:N=>Zo.distanceToBox(N),intersectsBounds:(N,M,J)=>J<R&&J<i?(M&&(rC.min.copy(N.min),rC.max.copy(N.max),rC.needsUpdate=!0),!0):!1,intersectsRange:(N,M)=>{if(A.boundsTree){const J=A.boundsTree;return J.shapecast({boundsTraverseOrder:L=>rC.distanceToBox(L),intersectsBounds:(L,H,Y)=>Y<R&&Y<i,intersectsRange:(L,H)=>{for(let Y=L,d=L+H;Y<d;Y++){const l=J.resolveTriangleIndex(Y);vA(a,3*l,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let p=N,u=N+M;p<u;p++){const P=B.resolveTriangleIndex(p);vA(w,3*P,o,D),w.needsUpdate=!0;const O=w.distanceToTriangle(a,G,c);if(O<R&&(r.copy(G),y&&y.copy(c),R=O,S=p,n=Y),O<C)return!0}}}})}else{const J=ti(A);for(let L=0,H=J;L<H;L++){vA(a,3*L,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let Y=N,d=N+M;Y<d;Y++){const l=B.resolveTriangleIndex(Y);vA(w,3*l,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,G,c);if(p<R&&(r.copy(G),y&&y.copy(c),R=p,S=Y,n=L),p<C)return!0}}}}}),Bg.releasePrimitive(w),Bg.releasePrimitive(a),R===1/0?null:(g.point?g.point.copy(r):g.point=r.clone(),g.distance=R,g.faceIndex=S,Q&&(Q.point?Q.point.copy(y):Q.point=y.clone(),Q.point.applyMatrix4(Ri),r.applyMatrix4(Ri),Q.distance=r.sub(Q.point).length(),Q.faceIndex=n),g)}function se(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 ki=new FI,ni=new _e,te=new q,we=new fA,ae=new q,Vo=["getX","getY","getZ"];class UB extends Ie{static serialize(A,I={}){I={cloneBuffers:!0,...I};const g=A.geometry,Q=A._roots,C=A._indirectBuffer,i=g.getIndex(),E={version:1,roots:null,index:null,indirectBuffer:null};return I.cloneBuffers?(E.roots=Q.map(D=>D.slice()),E.index=i?i.array.slice():null,E.indirectBuffer=C?C.slice():null):(E.roots=Q,E.index=i?i.array:null,E.indirectBuffer=C),E}static deserialize(A,I,g={}){g={setIndex:!0,indirect:!!A.indirectBuffer,...g};const{index:Q,roots:C,indirectBuffer:i}=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 E=new UB(I,{...g,[Ci]:!0});if(E._roots=C,E._indirectBuffer=i||null,g.setIndex){const o=I.getIndex();if(o===null){const s=new iI(A.index,1,!1);I.setIndex(s)}else o.array!==Q&&(o.array.set(Q),o.needsUpdate=!0)}return E;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 G=0,r=t.byteLength/SI;G<r;G++){const c=jA*G,y=2*c;zA(y,a)||(w[c+6]=w[c+6]/jA-G)}}}}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,i=Q.attributes.position,E=Q.index?Q.index.array:null,D=(C?C[A]:A)*3;let o=D+0,s=D+1,t=D+2;E&&(o=E[o],s=E[s],t=E[t]);for(let w=0;w<3;w++){const a=i[Vo[w]](o),G=i[Vo[w]](s),r=i[Vo[w]](t);let c=a;G<c&&(c=G),r<c&&(c=r);let y=a;G>y&&(y=G),r>y&&(y=r),I[g+w]=c,I[g+w+3]=y}return I}computePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,i=Q.attributes.position,E=Q.index?Q.index.array:null,D=i.normalized;if(A<0||I+A-g.offset>g.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const o=i.array,s=i.offset||0;let t=3;i.isInterleavedBufferAttribute&&(t=i.data.stride);const w=["getX","getY","getZ"],a=g.offset;for(let G=A,r=A+I;G<r;G++){const c=(C?C[G]:G)*3,y=(G-a)*6;let R=c+0,S=c+1,n=c+2;E&&(R=E[R],S=E[S],n=E[n]),D||(R=R*t+s,S=S*t+s,n=n*t+s);for(let N=0;N<3;N++){let M,J,L;D?(M=i[w[N]](R),J=i[w[N]](S),L=i[w[N]](n)):(M=o[R+N],J=o[S+N],L=o[n+N]);let H=M;J<H&&(H=J),L<H&&(H=L);let Y=M;J>Y&&(Y=J),L>Y&&(Y=L);const d=(Y-H)/2,l=N*2;g[y+l+0]=H+d,g[y+l+1]=d+(Math.abs(H)+d)*Bi}}return g}raycastObject3D(A,I,g=[]){const{material:Q}=A;if(Q===void 0)return;we.copy(A.matrixWorld).invert(),ni.copy(I.ray).applyMatrix4(we),ae.setFromMatrixScale(A.matrixWorld),te.copy(ni.direction).multiply(ae);const C=te.length(),i=I.near/C,E=I.far/C;if(I.firstHitOnly===!0){let D=this.raycastFirst(ni,Q,i,E);D=se(D,A,I),D&&g.push(D)}else{const D=this.raycast(ni,Q,i,E);for(let o=0,s=D.length;o<s;o++){const t=se(D[o],A,I);t&&g.push(t)}}return g}refit(A=null){return(this.indirect?ur:Mr)(this,A)}raycast(A,I=Ks,g=0,Q=1/0){const C=this._roots,i=[],E=this.indirect?br:Hr;for(let D=0,o=C.length;D<o;D++)E(this,D,I,A,i,g,Q);return i}raycastFirst(A,I=Ks,g=0,Q=1/0){const C=this._roots;let i=null;const E=this.indirect?Pr:Kr;for(let D=0,o=C.length;D<o;D++){const s=E(this,D,I,A,g,Q);s!=null&&(i==null||s.distance<i.distance)&&(i=s)}return i}intersectsGeometry(A,I){let g=!1;const Q=this._roots,C=this.indirect?Tr:dr;for(let i=0,E=Q.length;i<E&&(g=C(this,i,A,I),!g);i++);return g}shapecast(A){const I=Bg.getPrimitive(),g=super.shapecast({...A,intersectsPrimitive:A.intersectsTriangle,scratchPrimitive:I,iterate:this.indirect?Lr:Nr});return Bg.releasePrimitive(I),g}bvhcast(A,I,g){let{intersectsRanges:Q,intersectsTriangles:C}=g;const i=Bg.getPrimitive(),E=this.geometry.index,D=this.geometry.attributes.position,o=this.indirect?G=>{const r=this.resolveTriangleIndex(G);vA(i,r*3,E,D)}:G=>{vA(i,G*3,E,D)},s=Bg.getPrimitive(),t=A.geometry.index,w=A.geometry.attributes.position,a=A.indirect?G=>{const r=A.resolveTriangleIndex(G);vA(s,r*3,t,w)}:G=>{vA(s,G*3,t,w)};if(C){if(!(A instanceof UB))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const G=(r,c,y,R,S,n,N,M)=>{for(let J=y,L=y+R;J<L;J++){a(J),s.a.applyMatrix4(I),s.b.applyMatrix4(I),s.c.applyMatrix4(I),s.needsUpdate=!0;for(let H=r,Y=r+c;H<Y;H++)if(o(H),i.needsUpdate=!0,C(i,s,H,J,S,n,N,M))return!0}return!1};if(Q){const r=Q;Q=function(c,y,R,S,n,N,M,J){return r(c,y,R,S,n,N,M,J)?!0:G(c,y,R,S,n,N,M,J)}}else Q=G}return super.bvhcast(A,I,{intersectsRanges:Q})}intersectsBox(A,I){return ki.set(A.min,A.max,I),ki.needsUpdate=!0,this.shapecast({intersectsBounds:g=>ki.intersectsBox(g),intersectsTriangle:g=>ki.intersectsTriangle(g)})}intersectsSphere(A){return this.shapecast({intersectsBounds:I=>A.intersectsBox(I),intersectsTriangle:I=>I.intersectsSphere(A)})}closestPointToGeometry(A,I,g={},Q={},C=0,i=1/0){return(this.indirect?Vr:qr)(this,A,I,g,Q,C,i)}closestPointToPoint(A,I={},g=0,Q=1/0){return rr(this,A,I,g,Q)}}const nB={Mesh:IQ.prototype.raycast,Line:fs.prototype.raycast,LineSegments:ds.prototype.raycast,LineLoop:ls.prototype.raycast,Points:ps.prototype.raycast,BatchedMesh:A0.prototype.raycast},aI=new IQ,Ni=[];function Wr(B,A){if(this.isBatchedMesh)jr.call(this,B,A);else{const{geometry:I}=this;if(I.boundsTree)I.boundsTree.raycastObject3D(this,B,A);else{let g;if(this instanceof IQ)g=nB.Mesh;else if(this instanceof ds)g=nB.LineSegments;else if(this instanceof ls)g=nB.LineLoop;else if(this instanceof fs)g=nB.Line;else if(this instanceof ps)g=nB.Points;else throw new Error("BVH: Fallback raycast function not found.");g.call(this,B,A)}}}function jr(B,A){if(this.boundsTrees){const I=this.boundsTrees,g=this._drawInfo||this._instanceInfo,Q=this._drawRanges||this._geometryInfo,C=this.matrixWorld;aI.material=this.material,aI.geometry=this.geometry;const i=aI.geometry.boundsTree,E=aI.geometry.drawRange;aI.geometry.boundingSphere===null&&(aI.geometry.boundingSphere=new $e);for(let D=0,o=g.length;D<o;D++){if(!this.getVisibleAt(D))continue;const s=g[D].geometryIndex;if(aI.geometry.boundsTree=I[s],this.getMatrixAt(D,aI.matrixWorld).premultiply(C),!aI.geometry.boundsTree){this.getBoundingBoxAt(s,aI.geometry.boundingBox),this.getBoundingSphereAt(s,aI.geometry.boundingSphere);const t=Q[s];aI.geometry.setDrawRange(t.start,t.count)}aI.raycast(B,Ni);for(let t=0,w=Ni.length;t<w;t++){const a=Ni[t];a.object=this,a.batchId=D,A.push(a)}Ni.length=0}aI.geometry.boundsTree=i,aI.geometry.drawRange=E,aI.material=null,aI.geometry=null}else nB.BatchedMesh.call(this,B,A)}function zr(B={}){const{type:A=UB}=B;return this.boundsTree=new A(this,B),this.boundsTree}const dQ=new q,lQ=new q,fQ=new q,ee=new MI,Mi=new q,Wo=new q,he=new MI,ce=new MI,Ji=new fA,ye=new fA;function FC(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 RC(B,A=null){const I=B.array.constructor,g=B.normalized,Q=B.itemSize,C=A===null?B.count:A;return new iI(new I(Q*C),Q,g)}function Ge(B,A,I=0){if(B.isInterleavedBufferAttribute){const g=B.itemSize;for(let Q=0,C=B.count;Q<C;Q++){const i=Q+I;A.setX(i,B.getX(Q)),g>=2&&A.setY(i,B.getY(Q)),g>=3&&A.setZ(i,B.getZ(Q)),g>=4&&A.setW(i,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 _r(B,A,I){const g=B.elements,Q=A.elements;for(let C=0,i=Q.length;C<i;C++)g[C]+=Q[C]*I}function Se(B,A,I){const g=B.skeleton,Q=B.geometry,C=g.bones,i=g.boneInverses;he.fromBufferAttribute(Q.attributes.skinIndex,A),ce.fromBufferAttribute(Q.attributes.skinWeight,A),Ji.elements.fill(0);for(let E=0;E<4;E++){const D=ce.getComponent(E);if(D!==0){const o=he.getComponent(E);ye.multiplyMatrices(C[o].matrixWorld,i[o]),_r(Ji,ye,D)}}return Ji.multiply(B.bindMatrix).premultiply(B.bindMatrixInverse),I.transformDirection(Ji),I}function jo(B,A,I,g,Q){Mi.set(0,0,0);for(let C=0,i=B.length;C<i;C++){const E=A[C],D=B[C];E!==0&&(Wo.fromBufferAttribute(D,g),I?Mi.addScaledVector(Wo,E):Mi.addScaledVector(Wo.sub(Q),E))}Q.add(Mi)}function $r(B,A={useGroups:!1,updateIndex:!1,skipAttributes:[]},I=new ZQ){const g=B[0].index!==null,{useGroups:Q=!1,updateIndex:C=!1,skipAttributes:i=[]}=A,E=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(!E.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!==E.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 iI(new Uint32Array(t),1,!1)),s=!0}if(C||s){const t=I.index;let w=0,a=0;for(let G=0;G<B.length;++G){const r=B[G],c=r.index;if(i[G]!==!0)for(let y=0;y<c.count;++y)t.setX(w,c.getX(y)+a),w++;a+=r.attributes.position.count}}}for(const s in D){const t=D[s];if(!(s in I.attributes)){let G=0;for(const r in t)G+=t[r].count;I.setAttribute(s,RC(D[s][0],G))}const w=I.attributes[s];let a=0;for(let G=0,r=t.length;G<r;G++){const c=t[G];i[G]!==!0&&Ge(c,w,a),a+=c.count}}return I}function AF(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 IF(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),i=A.getX(g+2);A.setX(g,i),A.setX(g+2,C)}else for(const g in I){const Q=I[g],C=Q.itemSize;for(let i=0,E=Q.count;i<E;i+=3)for(let D=0;D<C;D++){const o=Q.getComponent(i,D),s=Q.getComponent(i+2,D);Q.setComponent(i,D,s),Q.setComponent(i+2,D,o)}}return B}class gF{constructor(A){this.matrixWorld=new fA,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&&AF(A.skeleton&&A.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===g)}}class QF{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 ZQ),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 ZQ){let I=[];const{meshes:g,useGroups:Q,_intermediateGeometry:C,_diffMap:i}=this;for(let E=0,D=g.length;E<D;E++){const o=g[E],s=C[E],t=i.get(o);!t||t.didChange(o)?(this._convertToStaticGeometry(o,s),I.push(!1),t?t.update():i.set(o,new gF(o))):I.push(!0)}if(C.length===0){A.setIndex(null);const E=A.attributes;for(const D in E)A.deleteAttribute(D);for(const D in this.attributes)A.setAttribute(this.attributes[D],new iI(new Float32Array(0),4,!1))}else $r(C,{useGroups:Q,skipAttributes:I},A);for(const E in A.attributes)A.attributes[E].needsUpdate=!0;return A}_convertToStaticGeometry(A,I=new ZQ){const g=A.geometry,Q=this.applyWorldTransforms,C=this.attributes.includes("normal"),i=this.attributes.includes("tangent"),E=g.attributes,D=I.attributes;!I.index&&g.index&&(I.index=g.index.clone()),D.position||I.setAttribute("position",RC(E.position)),C&&!D.normal&&E.normal&&I.setAttribute("normal",RC(E.normal)),i&&!D.tangent&&E.tangent&&I.setAttribute("tangent",RC(E.tangent)),FC(g.index,I.index),FC(E.position,D.position),C&&FC(E.normal,D.normal),i&&FC(E.tangent,D.tangent);const o=E.position,s=C?E.normal:null,t=i?E.tangent:null,w=g.morphAttributes.position,a=g.morphAttributes.normal,G=g.morphAttributes.tangent,r=g.morphTargetsRelative,c=A.morphTargetInfluences,y=new VQ;y.getNormalMatrix(A.matrixWorld),g.index&&I.index.array.set(g.index.array);for(let R=0,S=E.position.count;R<S;R++)dQ.fromBufferAttribute(o,R),s&&lQ.fromBufferAttribute(s,R),t&&(ee.fromBufferAttribute(t,R),fQ.fromBufferAttribute(t,R)),c&&(w&&jo(w,c,r,R,dQ),a&&jo(a,c,r,R,lQ),G&&jo(G,c,r,R,fQ)),A.isSkinnedMesh&&(A.applyBoneTransform(R,dQ),s&&Se(A,R,lQ),t&&Se(A,R,fQ)),Q&&dQ.applyMatrix4(A.matrixWorld),D.position.setXYZ(R,dQ.x,dQ.y,dQ.z),s&&(Q&&lQ.applyNormalMatrix(y),D.normal.setXYZ(R,lQ.x,lQ.y,lQ.z)),t&&(Q&&fQ.transformDirection(A.matrixWorld),D.tangent.setXYZW(R,fQ.x,fQ.y,fQ.z,ee.w));for(const R in this.attributes){const S=this.attributes[R];S==="position"||S==="tangent"||S==="normal"||!(S in E)||(D[S]||I.setAttribute(S,RC(E[S])),FC(E[S],D[S]),Ge(E[S],D[S]))}return A.matrixWorld.determinant()<0&&IF(I),I}}const BF=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:ma,BVH:_a,CENTER:Ro,CONTAINED:ko,ExtendedTriangle:Qg,GeometryBVH:Ie,MeshBVH:UB,OrientedBox:FI,SAH:Pa,SKIP_GENERATION:Ci,StaticGeometryGenerator:QF,acceleratedRaycast:Wr,computeBoundsTree:zr,generateIndirectBuffer:Ae},Symbol.toStringTag,{value:"Module"}));class CF{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 Cg={node:"node",material:"material",camera:"camera",light:"light"},pQ="KHR_animation_pointer",EF={CUBICSPLINE:void 0,LINEAR:xs,STEP:I0};class iF{constructor(A){this.name=pQ,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){oF();const I=A.target,g=I.extensions&&I.extensions[pQ]&&I.path&&I.path==="pointer";if(!g)return null;let Q,C=Cg.node,i;if(g){const D=I.extensions[pQ];let o=D.pointer;if(!o){console.warn("Invalid path",D,I);return}if(o.startsWith("/materials/")?C=Cg.material:o.startsWith("/extensions/KHR_lights_punctual/lights/")?C=Cg.light:o.startsWith("/cameras/")&&(C=Cg.camera),i=this._tryResolveTargetId(o,C),i===null||isNaN(i)){console.warn("Failed resolving animation node id: "+i,o);return}switch(C){case Cg.material:const t=("/materials/"+i.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 Cg.node:const a=("/nodes/"+i.toString()+"/").length,G=o.substring(0,a);if(Q=o.substring(a),Q.startsWith("weights/")){const R=Q.substring(8);/^\d+$/.test(R)?Q="morphTargetInfluences["+R+"]":console.warn(pQ+": 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=G+Q;break;case Cg.light:const r=("/extensions/KHR_lights_punctual/lights/"+i.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/"+i.toString()+"/"+Q;break;case Cg.camera:const c=("/cameras/"+i.toString()+"/").length,y=o.substring(0,c);switch(Q=o.substring(c),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=y+Q;break}this.animationPointerResolver?.resolvePath&&(o=this.animationPointerResolver.resolvePath(o));const s=D.pointer;this.pointerPathMap.set(s,o)}if(i==null||isNaN(i)){console.warn("Failed resolving animation node id: "+i,I);return}let E;return C===Cg.node?E=this.parser.getDependency("node",i):C===Cg.material?E=this.parser.getDependency("material",i):C===Cg.light?E=this.parser.getDependency("light",i):C===Cg.camera?E=this.parser.getDependency("camera",i):console.error("Unhandled type",C),E}createAnimationTracksWithAnimationPointer(A,I,g,Q,C){if(!(C.extensions&&C.extensions[pQ]&&C.path&&C.path==="pointer"))return null;const i=C.extensions[pQ].pointer;let E=this.pointerPathMap.get(i);if(!E)return null;const D=[];E=E.replaceAll("/",".");const o=E.split(".");var s=A.name!==void 0&&A.name!==null?A.name:A.uuid;if(o[2]=s,o[3]?.startsWith("morphTargetInfluences")){const a=o[3];if(A.type==="Group"){for(const G of A.children)G.morphTargetInfluences&&(o[3]=G.name,o[4]=a,w(this.parser));return D}}w(this.parser);function t(a,G){try{const r=G.split(".").filter(Boolean),c=r[r.length-1].replace(/\[.*\]$/,"");return c in a?typeof a[c]=="boolean":!1}catch{return!1}}function w(a){E=o.join(".");let G,r=!1;switch(g.itemSize){case 1:Object.prototype.toString.call(g.array)==="[object Uint8Array]"&&t(A,E)?(G=E0,r=!0):G=i0;break;case 2:case 3:G=C0;break;case 4:E.endsWith(".quaternion")?G=Q0:G=B0;break}if(!G){console.warn("Unsupported output accessor format",g);return}const c=Q.interpolation!==void 0?EF[Q.interpolation]:xs;let y=a._getArrayFromAccessor(g);E.endsWith(".fov")&&(y=y.map(S=>S/Math.PI*180)),r&&(y=y.map(S=>S>0));const R=new G(E,I.array,y,c);if(c==="CUBICSPLINE"&&a._createCubicSplineTrackInterpolant(R),D.push(R),E&&g.itemSize===4&&E.startsWith(".materials.")&&E.endsWith(".color")){const S=new Float32Array(y.length/4);for(let N=0,M=y.length/4;N<M;N+=1)S[N]=y[N*4+3];const n=new G(E.replace(".color",".opacity"),I.array,S,c);c==="CUBICSPLINE"&&a._createCubicSplineTrackInterpolant(R),D.push(n)}}return D}_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],i=C.name?C.name:"animation_"+A,E=[],D=[],o=[],s=[],t=[];for(let w=0,a=C.channels.length;w<a;w++){const G=C.channels[w],r=C.samplers[G.sampler],c=G.target,y=C.parameters!==void 0?C.parameters[r.input]:r.input,R=C.parameters!==void 0?C.parameters[r.output]:r.output;let S=I.loadAnimationTargetFromChannelWithAnimationPointer(G);S||(S=I.loadAnimationTargetFromChannel(G)),E.push(S),D.push(Q.getDependency("accessor",y)),o.push(Q.getDependency("accessor",R)),s.push(r),t.push(c)}return Promise.all([Promise.all(E),Promise.all(D),Promise.all(o),Promise.all(s),Promise.all(t)]).then(function(w){const a=w[0],G=w[1],r=w[2],c=w[3],y=w[4],R=[];for(let S=0,n=a.length;S<n;S++){const N=a[S],M=G[S],J=r[S],L=c[S],H=y[S];if(N===void 0)continue;N.updateMatrix&&(N.updateMatrix(),N.matrixAutoUpdate=!0);let Y=I.createAnimationTracksWithAnimationPointer(N,M,J,L,H);if(Y||(Y=Q._createAnimationTracks(N,M,J,L,H)),Y)for(let d=0;d<Y.length;d++)R.push(Y[d])}return new g0(i,void 0,R)})}}let re=!1,DF=null;function oF(){if(re)return;re=!0;const B=DF||=qs.findNode;qs.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 i=null;return A.traverse(E=>{i!==null||E.type!=="Mesh"&&E.type!=="SkinnedMesh"||E.material&&(E.material.uuid===C||E.material.name===C)&&(i=E.material,i!==null&&(g.endsWith(".map")?i=i.map:g.endsWith(".emissiveMap")&&(i=i.emissiveMap)))}),i}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 i=g[C];if(i.length==36)Q=A.getObjectByProperty("uuid",i);else if(Q&&Q[i]){const E=Number.parseInt(i);let D=i;E>=0&&(D=E),Q=Q[D]}else{const E=A.getObjectByName(i);E&&(Q=E)}}if(!Q){const C=B(A,g[2]);return C||console.warn(pQ+": Property binding not found",I,A,A.name,g),C}return Q}return B(A,I)}}const sF=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:iF},Symbol.toStringTag,{value:"Module"}));var tF=Object.defineProperty,wF=(B,A,I)=>A in B?tF(B,A,{enumerable:!0,configurable:!0,writable:!0,value:I}):B[A]=I,ZA=(B,A,I)=>(wF(B,typeof A!="symbol"?A+"":A,I),I);(function(){class B{}class A extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class I extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class g extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class Q extends B{constructor(h,F="unrestricted"){super(),ZA(this,"type"),ZA(this,"value"),this.value=h,this.type=F}}class C extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class i extends B{}class E extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class D extends B{}class o extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class s extends B{constructor(h,F="integer"){super(),ZA(this,"value"),ZA(this,"type"),this.value=h,this.type=F}}class t extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class w extends B{constructor(h,F,k){super(),ZA(this,"value"),ZA(this,"type"),ZA(this,"unit"),this.value=h,this.type=F,this.unit=k}}class a extends B{}class G extends B{}class r extends B{}class c extends B{}class y extends B{}class R extends B{}class S extends B{}class n extends B{}class N extends B{}class M extends B{}class J extends B{}class L extends B{}class H{constructor(h){ZA(this,"input"),ZA(this,"index",0),this.input=h}consume(){const h=this.input.codePointAt(this.index);return h!==void 0&&(this.index+=String.fromCodePoint(h).length),h}reconsume(h){h!==void 0&&(this.index-=String.fromCodePoint(h).length)}peek(){const h=[];let F=this.index;for(let k=0;k<3&&F<this.input.length;k++){const U=this.input.codePointAt(F);h.push(U),F+=String.fromCodePoint(U).length}return h}}function Y(e){return e===10}function d(e){return Y(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 u(e){return function(h){return function(F){return F>=65&&F<=90}(h)||function(F){return F>=97&&F<=122}(h)}(e)||function(h){return h>=128}(e)||e===95}function P(e){return u(e)||l(e)||e===45}function O(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function W(e,h){return e===92&&!Y(h)}function T(e,h,F){return e===45?u(h)||h===45||W(h,F):!!u(e)||e===92&&W(e,h)}function j(e,h,F){return e===43||e===45?l(h)||h===46&&l(F):l(e===46?h:e)}function EA(e){const h=e.consume();if(p(h)){let F=[h];for(;p(...e.peek())&&F.length<5;)F.push(e.consume());d(...e.peek())&&e.consume();const k=parseInt(String.fromCodePoint(...F),16);return k===0||k>1114111?65533:k}return h===void 0?65533:h}function wA(e,h){const F=new C("");for(;;){const k=e.consume();if(k===h||k===void 0)return F;if(k===10)return e.reconsume(k),new i;if(k===92){const U=e.peek()[0];U===void 0||(Y(U)?e.consume():F.value+=String.fromCodePoint(EA(e)))}else F.value+=String.fromCodePoint(k)}}function iA(e){let h="";for(;;){const F=e.consume();if(P(F))h+=String.fromCodePoint(F);else{if(!W(...e.peek()))return e.reconsume(F),h;h+=String.fromCodePoint(EA(e))}}}function IA(e){let h=function(F){let k="integer",U="";for([43,45].includes(F.peek()[0])&&(U+=String.fromCodePoint(F.consume()));l(...F.peek());)U+=String.fromCodePoint(F.consume());if(F.peek()[0]===46&&l(F.peek()[1]))for(U+=String.fromCodePoint(F.consume(),F.consume()),k="number";l(...F.peek());)U+=String.fromCodePoint(F.consume());return[69,101].includes(F.peek()[0])&&([45,43].includes(F.peek()[1])&&l(F.peek()[2])?(U+=String.fromCodePoint(F.consume(),F.consume(),F.consume()),k="number"):l(F.peek()[1])&&(U+=String.fromCodePoint(F.consume(),F.consume()),k="number")),{value:parseFloat(U),type:k}}(e);return T(...e.peek())?new w(h.value,h.type,iA(e)):e.peek()[0]===37?(e.consume(),new t(h.value)):new s(h.value,h.type)}function BA(e){for(;;){const h=e.consume();if(h===41||h===void 0)return;W(...e.peek())&&EA(e)}}function AA(e){const h=iA(e);if(h.match(/url/i)&&e.peek()[0]===40){for(e.consume();d(e.peek()[0])&&d(e.peek()[1]);)e.consume();return[34,39].includes(e.peek()[0])||d(e.peek()[0])&&[34,39].includes(e.peek()[1])?new I(h):function(F){const k=new E("");for(;d(...F.peek());)F.consume();for(;;){const U=F.consume();if(U===41||U===void 0)return k;if(d(U)){for(;d(...F.peek());)F.consume();return F.peek()[0]===41||F.peek()[0]===void 0?(F.consume(),k):(BA(F),new D)}if([34,39,40].includes(U)||O(U))return BA(F),new D;if(U===92){if(!W(...F.peek()))return BA(F),new D;k.value+=EA(F)}else k.value+=String.fromCodePoint(U)}}(e)}return e.peek()[0]===40?(e.consume(),new I(h)):new A(h)}function $(e){const h=e.consume(),F=e.peek();if(d(h)){for(;d(...e.peek());)e.consume();return new a}if(h===34)return wA(e,h);if(h===35){if(P(F[0])||W(...F)){const k=new Q;return T(...F)&&(k.type="id"),k.value=iA(e),k}return new o(String.fromCodePoint(h))}return h===39?wA(e,h):h===40?new N:h===41?new M:h===43?j(...F)?(e.reconsume(h),IA(e)):new o(String.fromCodePoint(h)):h===44?new R:h===45?j(...e.peek())?(e.reconsume(h),IA(e)):e.peek()[0]===45&&e.peek()[1]===62?(e.consume(),e.consume(),new r):T(...e.peek())?(e.reconsume(h),AA(e)):new o(String.fromCodePoint(h)):h===46?j(...e.peek())?(e.reconsume(h),IA(e)):new o(String.fromCodePoint(h)):h===58?new c:h===59?new y:h===60?F[0]===33&&F[1]===45&&F[2]===45?(e.consume(),e.consume(),e.consume(),new G):new o(String.fromCodePoint(h)):h===64?T(...F)?new g(iA(e)):new o(String.fromCodePoint(h)):h===91?new S:h===92?W(...F)?(e.reconsume(h),AA(e)):new o(String.fromCodePoint(h)):h===93?new n:h===123?new J:h===125?new L:l(h)?(e.reconsume(h),IA(e)):u(h)?(e.reconsume(h),AA(e)):h===void 0?void 0:new o(String.fromCodePoint(h))}const z=new Set(["px","deg","s","hz","dppx","number","fr"]);function LA(e){return z.has(e.toLowerCase())}function NA(e,h){if(["x","y"].includes(e))return e;if(!h)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const F=h.writingMode=="horizontal-tb";if(e==="block")e=F?"y":"x";else{if(e!=="inline")throw new TypeError(`Invalid axis \u201C${e}\u201D`);e=F?"x":"y"}return e}function MA(e){const h=[];let F=0;function k(){let K=0;const f=F;for(;F<e.length;){const b=e.slice(F,F+1);if(/\s/.test(b)&&K===0)break;if(b==="(")K+=1;else if(b===")"&&(K-=1,K===0)){F++;break}F++}return e.slice(f,F)}function U(){for(;/\s/.test(e.slice(F,F+1));)F++}for(;F<e.length;){const K=e.slice(F,F+1);/\s/.test(K)?U():h.push(k())}return h}function xA(e,h){return e.reduce((F,k)=>(F.has(k[h])?F.get(k[h]).push(k):F.set(k[h],[k]),F),new Map)}function aA(e,h){const F=[],k=[];for(const U of e)h(U)?F.push(U):k.push(U);return[F,k]}function DA(e,h={}){function F(k){return Array.from(k).map(U=>DA(U,h))}if(e instanceof CSSUnitValue){if(e.unit==="percent"&&h.percentageReference){const U=e.value/100*h.percentageReference.value,K=h.percentageReference.unit;return new CSSUnitValue(U,K)}const k=e.toSum();if(k&&k.values.length===1&&(e=k.values[0]),e instanceof CSSUnitValue&&e.unit==="em"&&h.fontSize&&(e=new CSSUnitValue(e.value*h.fontSize.value,h.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(...F(e.values));break;case"product":e=new CSSMathProduct(...F(e.values));break;case"negate":e=new CSSMathNegate(DA(e.value,h));break;case"clamp":e=new CSSMathClamp(DA(e.lower,h),DA(e.value,h),DA(e.upper,h));break;case"invert":e=new CSSMathInvert(DA(e.value,h));break;case"min":e=new CSSMathMin(...F(e.values));break;case"max":e=new CSSMathMax(...F(e.values))}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const k=Array.from(e.values);if(k.every(U=>U instanceof CSSUnitValue&&U.unit!=="percent"&&LA(U.unit)&&U.unit===k[0].unit)){const U=Math[e.operator].apply(Math,k.map(({value:K})=>K));return new CSSUnitValue(U,k[0].unit)}}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const k=Array.from(e.values),[U,K]=aA(k,b=>b instanceof CSSUnitValue&&b.unit!=="percent"),f=Array.from(xA(U,"unit").values());if(f.some(b=>b.length>0)){const b=f.map(x=>{const m=Math[e.operator].apply(Math,x.map(({value:V})=>V));return new CSSUnitValue(m,x[0].unit)});e=e instanceof CSSMathMin?new CSSMathMin(...b,...K):new CSSMathMax(...b,...K)}return k.length===1?k[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 k=function(K){const f=K.filter(b=>b instanceof CSSUnitValue);return[...K.filter(b=>!(b instanceof CSSUnitValue)),...Array.from(xA(f,"unit").entries()).map(([b,x])=>{const m=x.reduce((V,{value:QA})=>V+QA,0);return new CSSUnitValue(m,b)})]},U=[];for(const K of e.values)K instanceof CSSMathSum?U.push(...K.values):U.push(K);return U=k(U),U.length===1?U[0]:new CSSMathSum(...U)}if(e instanceof CSSMathProduct){let k=[];for(const f of e.values)f instanceof CSSMathProduct?k.push(...f.values):k.push(f);const[U,K]=aA(k,f=>f instanceof CSSUnitValue&&f.unit==="number");if(U.length>1){const f=U.reduce((b,{value:x})=>b*x,1);k=[new CSSUnitValue(f,"number"),...K]}if(k.length===2){let f,b;for(const x of k)x instanceof CSSUnitValue&&x.unit==="number"?f=x:x instanceof CSSMathSum&&[...x.values].every(m=>m instanceof CSSUnitValue)&&(b=x);if(f&&b)return new CSSMathSum(...[...b.values].map(x=>new CSSUnitValue(x.value*f.value,x.unit)))}if(k.every(f=>f instanceof CSSUnitValue&&LA(f.unit)||f instanceof CSSMathInvert&&f.value instanceof CSSUnitValue&&LA(f.value.unit))){const f=new CSSMathProduct(...k).toSum();if(f&&f.values.length===1)return f.values[0]}return new CSSMathProduct(...k)}return e}const JA=null,jI=["percent","length","angle","time","frequency","resolution","flex"],_A={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}}},HA=new Map;for(const e of Object.values(_A))if(e.compatible)for(const h of e.units)HA.set(h,e);function fI(e){return HA.get(e)}function Eg(e,h){const F={...e};for(const k of Object.keys(h))F[k]?F[k]+=h[k]:F[k]=h[k];return F}function ig(e){return e==="number"?{}:e==="percent"?{percent:1}:_A.absoluteLengths.units.has(e)||_A.fontRelativeLengths.units.has(e)||_A.viewportRelativeLengths.units.has(e)?{length:1}:_A.angle.units.has(e)?{angle:1}:_A.time.units.has(e)?{time:1}:_A.frequency.units.has(e)?{frequency:1}:_A.resolution.units.has(e)?{resolution:1}:e==="fr"?{flex:1}:JA}function pI(e){if(e instanceof CSSUnitValue){let{unit:h,value:F}=e;const k=fI(e.unit);return k&&h!==k.canonicalUnit&&(F*=k.ratios[h],h=k.canonicalUnit),h==="number"?[[F,{}]]:[[F,{[h]:1}]]}if(e instanceof CSSMathInvert){if(!(e.value instanceof CSSUnitValue))throw new Error("Not implemented");const h=pI(e.value);if(h===JA||h.length>1)return JA;const F=h[0],k={};for(const[U,K]of Object.entries(F[1]))k[U]=-1*K;return h[0]=[1/F[0],k],h}if(e instanceof CSSMathProduct){let h=[[1,{}]];for(const F of e.values){const k=pI(F),U=[];if(k===JA)return JA;for(const K of h)for(const f of k)U.push([K[0]*f[0],Eg(K[1],f[1])]);h=U}return h}throw new Error("Not implemented")}function Dg(e,h){if(ig(h)===JA)throw new SyntaxError("The string did not match the expected pattern.");const F=pI(e);if(!F)throw new TypeError;if(F.length>1)throw new TypeError("Sum has more than one item");const k=function(U,K){const f=U.unit,b=U.value,x=fI(f),m=fI(K);return!m||x!==m?JA:new CSSUnitValue(b*m.ratios[f]/m.ratios[K],K)}(zI(F[0]),h);if(k===JA)throw new TypeError;return k}function zI(e){const[h,F]=e,k=Object.entries(F);if(k.length>1)return JA;if(k.length===0)return new CSSUnitValue(h,"number");const U=k[0];return U[1]!==1?JA:new CSSUnitValue(h,U[0])}function _I(e,...h){if(h&&h.length)throw new Error("Not implemented");const F=pI(e).map(k=>zI(k));if(F.some(k=>k===JA))throw new TypeError("Type error");return new CSSMathSum(...F)}function XI(e,h){if(e.percentHint&&h.percentHint&&e.percentHint!==h.percentHint)return JA;const F={...e,percentHint:e.percentHint??h.percentHint};for(const k of jI)h[k]&&(F[k]??(F[k]=0),F[k]+=h[k]);return F}class $A{constructor(h,F){ZA(this,"name"),ZA(this,"values"),this.name=h,this.values=F}}class kI{constructor(h,F){ZA(this,"value"),ZA(this,"associatedToken"),this.value=h,this.associatedToken=F}}function vI(e){if(Array.isArray(e))return e;if(typeof e=="string")return function(h){const F=new H(h),k=[];for(;;){const U=$(F);if(U===void 0)return k;k.push(U)}}(e);throw new TypeError("Invalid input type "+typeof e)}function nI(e){const h=e.shift();return h instanceof J||h instanceof S||h instanceof N?function(F,k){let U;if(k instanceof J)U=L;else if(k instanceof N)U=M;else{if(!(k instanceof S))return;U=n}const K=new kI([],k);for(;;){const f=F.shift();if(f instanceof U||f===void 0)return K;F.unshift(f),K.value.push(nI(F))}}(e,h):h instanceof I?function(F,k){const U=new $A(F.value,[]);for(;;){const K=k.shift();if(K instanceof M||K===void 0)return U;k.unshift(K),U.values.push(nI(k))}}(h,e):h}function eA(e){if(e instanceof N||e instanceof M)return 6;if(e instanceof o)switch(e.value){case"*":case"/":return 4;case"+":case"-":return 2}}function og(e){return e[e.length-1]}function lg(e,h,F){const k=["+","-"].includes(e.value)?"ADDITION":"MULTIPLICATION",U=h.type===k?h.values:[h],K=F.type===k?F.values:[F];return e.value==="-"?K[0]={type:"NEGATE",value:K[0]}:e.value==="/"&&(K[0]={type:"INVERT",value:K[0]}),{type:k,values:[...U,...K]}}function sg(e){if(e.type==="ADDITION")return new CSSMathSum(...e.values.map(h=>sg(h)));if(e.type==="MULTIPLICATION")return new CSSMathProduct(...e.values.map(h=>sg(h)));if(e.type==="NEGATE")return new CSSMathNegate(sg(e.value));if(e.type==="INVERT")return new CSSMathInvert(sg(e.value));if(e instanceof kI)return kA(new $A("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 $o(e)}function kA(e){if(e.name==="min"||e.name==="max"){const k=e.values.filter(U=>!(U instanceof a||U instanceof R)).map(U=>DA(kA(new $A("calc",U))));return e.name==="min"?new CSSMathMin(...k):new CSSMathMax(...k)}if(e.name!=="calc")return null;const h=sg(function(k){const U=[],K=[];for(;k.length;){const f=k.shift();if(f instanceof s||f instanceof w||f instanceof t||f instanceof $A||f instanceof kI||f instanceof A)K.push(f);else if(f instanceof o&&["*","/","+","-"].includes(f.value)){for(;U.length&&!(og(U)instanceof N)&&eA(og(U))>eA(f);){const b=U.pop(),x=K.pop(),m=K.pop();K.push(lg(b,m,x))}U.push(f)}else if(f instanceof N)U.push(f);else if(f instanceof M){if(!U.length)return null;for(;!(og(U)instanceof N);){const b=U.pop(),x=K.pop(),m=K.pop();K.push(lg(b,m,x))}if(!(og(U)instanceof N))return null;U.pop()}else if(!(f instanceof a))return null}for(;U.length;){if(og(U)instanceof N)return null;const f=U.pop(),b=K.pop(),x=K.pop();K.push(lg(f,x,b))}return K[0]}([...e.values]));let F;try{F=DA(h)}catch{new CSSStyleSheet().insertRule("error",0)}return F instanceof CSSUnitValue?new CSSMathSum(F):F}function $o(e){return e instanceof $A&&["calc","min","max","clamp"].includes(e.name)?kA(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 ke(e){const h=function(F){const k=vI(F);for(;k[0]instanceof a;)k.shift();if(k[0]===void 0)return null;const U=nI(k);for(;k[0]instanceof a;)k.shift();return k[0]===void 0?U:null}(e);return h===null&&new CSSStyleSheet().insertRule("error",0),h instanceof s||h instanceof t||h instanceof w||h instanceof $A||new CSSStyleSheet().insertRule("error",0),h instanceof w&&ig(h.unit)===null&&new CSSStyleSheet().insertRule("error",0),$o(h)}(function(){let e=new WeakMap;function h(K){const f=[];for(let x=0;x<K.length;x++)f[x]=typeof(b=K[x])=="number"?new CSSUnitValue(b,"number"):b;var b;return f}class F{static parse(f){return f instanceof F?f:DA(ke(f),{})}}class k extends F{constructor(f,b,x,m){super(),e.set(this,{values:h(f),operator:b,name:x||b,delimiter:m||", "})}get operator(){return e.get(this).operator}get values(){return e.get(this).values}toString(){const f=e.get(this);return`${f.name}(${f.values.join(f.delimiter)})`}}const U={CSSNumericValue:F,CSSMathValue:k,CSSUnitValue:class extends F{constructor(K,f){super(),e.set(this,{value:K,unit:f})}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 Dg(this,K)}toSum(...K){return _I(this,...K)}type(){return ig(e.get(this).unit)}toString(){const K=e.get(this);return`${K.value}${function(f){switch(f){case"percent":return"%";case"number":return"";default:return f.toLowerCase()}}(K.unit)}`}},CSSKeywordValue:class{constructor(K){this.value=K}toString(){return this.value.toString()}},CSSMathSum:class extends k{constructor(K){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends k{constructor(K){super(arguments,"product","calc"," * ")}toSum(...K){return _I(this,...K)}type(){return e.get(this).values.map(K=>K.type()).reduce(XI)}},CSSMathNegate:class extends k{constructor(K){super([arguments[0]],"negate","-")}get value(){return e.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends k{constructor(K){super([1,arguments[0]],"invert","calc"," / ")}get value(){return e.get(this).values[1]}type(){return function(K){const f={};for(const b of jI)f[b]=-1*K[b];return f}(e.get(this).values[1].type())}},CSSMathMax:class extends k{constructor(){super(arguments,"max")}},CSSMathMin:class extends k{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:f=>new CSSUnitValue(f,K)}))throw Error(`Error installing CSS.${K}`)});for(let[K,f]of Object.entries(U))if(!(K in window)&&!Reflect.defineProperty(window,K,{value:f}))throw Error(`Error installing CSSOM support for ${K}`)})();const As="block";let eI=new WeakMap,fg=new WeakMap;const IE=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Is(e){return e===document.scrollingElement?document:e}function wQ(e){di(e);let h=eI.get(e).animations;if(h.length===0)return;let F=e.currentTime;for(let k=0;k<h.length;k++)h[k].tickAnimation(F)}function gs(e,h){if(!e)return null;const F=fg.get(e).sourceMeasurements,k=getComputedStyle(e);let U=F.scrollTop;return NA(h,k)==="x"&&(U=Math.abs(F.scrollLeft)),U}function Ki(e,h){const F=DA(e,h);if(F instanceof CSSUnitValue){if(F.unit==="px")return F.value;throw TypeError("Unhandled unit type "+F.unit)}throw TypeError("Unsupported value type: "+typeof e)}function di(e){if(!(e instanceof PQ))return void function(F){const k=eI.get(F);if(!k.anonymousSource)return;const U=Bs(k.anonymousSource,k.anonymousTarget);LB(F,U)}(e);const h=e.subject;if(!h||getComputedStyle(h).display=="none")return void LB(e,null);LB(e,ui(h))}function Qs(e){return["block","inline","x","y"].includes(e)}function li(e){const h=getComputedStyle(e);return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight,clientWidth:e.clientWidth,clientHeight:e.clientHeight,writingMode:h.writingMode,direction:h.direction,scrollPaddingTop:h.scrollPaddingTop,scrollPaddingBottom:h.scrollPaddingBottom,scrollPaddingLeft:h.scrollPaddingLeft,scrollPaddingRight:h.scrollPaddingRight}}function fi(e,h){if(!e||!h)return;let F=0,k=0,U=h;const K=e.offsetParent;for(;U&&U!=K;)k+=U.offsetLeft,F+=U.offsetTop,U=U.offsetParent;k-=e.offsetLeft+e.clientLeft,F-=e.offsetTop+e.clientTop;const f=getComputedStyle(h);return{top:F,left:k,offsetWidth:h.offsetWidth,offsetHeight:h.offsetHeight,fontSize:f.fontSize}}function gE(e){let h=fg.get(e);h.sourceMeasurements=li(e);for(const F of h.timelineRefs){const k=F.deref();k instanceof PQ&&(eI.get(k).subjectMeasurements=fi(e,k.subject))}h.updateScheduled||(setTimeout(()=>{for(const F of h.timelineRefs){const k=F.deref();k&&wQ(k)}h.updateScheduled=!1}),h.updateScheduled=!0)}function LB(e,h){const F=eI.get(e),k=F.source;if(k!=h){if(k){const U=fg.get(k);if(U){U.timelineRefs.delete(e);const K=Array.from(U.timelineRefs).filter(f=>f.deref()===void 0);for(const f of K)U.timelineRefs.delete(f);U.timelineRefs.size===0&&(U.disconnect(),fg.delete(k))}}if(F.source=h,h){let U=fg.get(h);if(!U){U={timelineRefs:new Set,sourceMeasurements:li(h)},fg.set(h,U);const K=new ResizeObserver(x=>{for(const m of x)gE(F.source)});K.observe(h);for(const x of h.children)K.observe(x);const f=new MutationObserver(x=>{for(const m of x)gE(m.target)});f.observe(h,{attributes:!0,attributeFilter:["style","class"]});const b=()=>{U.sourceMeasurements.scrollLeft=h.scrollLeft,U.sourceMeasurements.scrollTop=h.scrollTop;for(const x of U.timelineRefs){const m=x.deref();m&&wQ(m)}};Is(h).addEventListener("scroll",b),U.disconnect=()=>{K.disconnect(),f.disconnect(),Is(h).removeEventListener("scroll",b)}}U.timelineRefs.add(new WeakRef(e))}}}function pi(e,h){let F=eI.get(e).animations;for(let k=0;k<F.length;k++)F[k].animation==h&&F.splice(k,1)}function xi(e,h,F){let k=eI.get(e).animations;for(let U=0;U<k.length;U++)if(k[U].animation==h)return;k.push({animation:h,tickAnimation:F}),queueMicrotask(()=>{wQ(e)})}class NI{constructor(h){if(eI.set(this,{source:null,axis:As,anonymousSource:h?h.anonymousSource:null,anonymousTarget:h?h.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),LB(this,h&&h.source!==void 0?h.source:document.scrollingElement),h&&h.axis!==void 0&&h.axis!=As){if(!Qs(h.axis))throw TypeError("Invalid axis");eI.get(this).axis=h.axis}wQ(this)}set source(h){LB(this,h),wQ(this)}get source(){return eI.get(this).source}set axis(h){if(!Qs(h))throw TypeError("Invalid axis");eI.get(this).axis=h,wQ(this)}get axis(){return eI.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const h=this.source;if(!h)return"inactive";let F=getComputedStyle(h);return F.display=="none"?"inactive":h==document.scrollingElement||F.overflow!="visible"&&F.overflow!="clip"?"active":"inactive"}get currentTime(){const h=this.source;if(!h||!h.isConnected||this.phase=="inactive")return null;const F=getComputedStyle(h);if(F.display==="inline"||F.display==="none")return null;const k=this.axis,U=gs(h,k),K=function(f,b){const x=fg.get(f).sourceMeasurements,m=getComputedStyle(f).writingMode=="horizontal-tb";return b==="block"?b=m?"y":"x":b==="inline"&&(b=m?"x":"y"),b==="y"?x.scrollHeight-x.clientHeight:b==="x"?x.scrollWidth-x.clientWidth:void 0}(h,k);return K>0?CSS.percent(100*U/K):CSS.percent(100)}get __polyfill(){return!0}}function qi(e,h){let F=e.parentElement;for(;F!=null;){if(h(F))return F;F=F.parentElement}}function Bs(e,h){switch(e){case"root":return document.scrollingElement;case"nearest":return ui(h);case"self":return h;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function ne(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 Cs(e){const h=getComputedStyle(e);return h.transform!="none"||h.perspective!="none"||h.willChange=="transform"||h.willChange=="perspective"||h.filter!="none"||h.willChange=="filter"||h.backdropFilter!="none"}function Ne(e){return getComputedStyle(e).position!="static"||Cs(e)}function Me(e){switch(getComputedStyle(e).position){case"static":case"relative":case"sticky":return qi(e,ne);case"absolute":return qi(e,Ne);case"fixed":return qi(e,Cs)}}function ui(e){if(e&&e.isConnected){for(;e=Me(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 HB(e,h){const F=eI.get(e),k=F.subjectMeasurements,U=fg.get(F.source).sourceMeasurements;return e.phase==="inactive"?null:e instanceof PQ?bi(h,U,k,F.axis,F.inset):null}function bi(e,h,F,k,U){const K=h.direction=="rtl"||h.writingMode=="vertical-rl";let f,b,x={fontSize:F.fontSize};NA(k,h)==="x"?(f=F.offsetWidth,b=F.left,x.scrollPadding=[h.scrollPaddingLeft,h.scrollPaddingRight],K&&(b+=h.scrollWidth-h.clientWidth,x.scrollPadding=[h.scrollPaddingRight,h.scrollPaddingLeft]),x.containerSize=h.clientWidth):(f=F.offsetHeight,b=F.top,x.scrollPadding=[h.scrollPaddingTop,h.scrollPaddingBottom],x.containerSize=h.clientHeight);const m=function(Oi,iE){const qe={start:0,end:0};if(!Oi)return qe;const[ue,be]=[Oi.start,Oi.end].map((rs,Fs)=>rs==="auto"?iE.scrollPadding[Fs]==="auto"?0:parseFloat(iE.scrollPadding[Fs]):Ki(rs,{percentageReference:CSS.px(iE.containerSize),fontSize:CSS.px(parseFloat(iE.fontSize))}));return{start:ue,end:be}}(U,x),V=b-x.containerSize+m.end,QA=b+f-m.start,CA=V+f,YA=QA-f,OA=Math.min(CA,YA),xI=Math.max(CA,YA);let tg,$I;const Ss=f>x.containerSize-m.start-m.end;switch(e){case"cover":tg=V,$I=QA;break;case"contain":tg=OA,$I=xI;break;case"entry":tg=V,$I=OA;break;case"exit":tg=xI,$I=QA;break;case"entry-crossing":tg=V,$I=Ss?xI:OA;break;case"exit-crossing":tg=Ss?OA:xI,$I=QA}return{start:tg,end:$I}}function Es(e,h){if(e instanceof PQ){const{rangeName:F,offset:k}=h;return is(HB(e,F),k,HB(e,"cover"),e.subject)}if(e instanceof NI){const{axis:F,source:k}=e,{sourceMeasurements:U}=fg.get(k);let K;return K=NA(F,U)==="x"?U.scrollWidth-U.clientWidth:U.scrollHeight-U.clientHeight,Ki(h,{percentageReference:CSS.px(K)})/K}unsupportedTimeline(e)}function is(e,h,F,k){if(!e||!F)return 0;let U=getComputedStyle(k);return(Ki(h,{percentageReference:CSS.px(e.end-e.start),fontSize:CSS.px(parseFloat(U.fontSize))})+e.start-F.start)/(F.end-F.start)}let PQ=class extends NI{constructor(e){super(e);const h=eI.get(this);h.subject=e&&e.subject?e.subject:void 0,e&&e.inset&&(h.inset=function(F){if(!F)return{start:0,end:0};let k;if(k=typeof F=="string"?MA(F).map(U=>{if(U==="auto")return"auto";try{return CSSNumericValue.parse(U)}catch{throw TypeError(`Could not parse inset "${F}"`)}}):Array.isArray(F)?F:[F],k.length===0||k.length>2)throw TypeError("Invalid inset");for(const U of k){if(U==="auto")continue;const K=U.type();if(K.length!==1&&K.percent!==1)throw TypeError("Invalid inset")}return{start:k[0],end:k[1]??k[0]}}(e.inset)),h.subject&&(new ResizeObserver(()=>{gE(h.source)}).observe(h.subject),new MutationObserver(()=>{gE(h.source)}).observe(h.subject,{attributes:!0,attributeFilter:["class","style"]})),di(this),h.subjectMeasurements=fi(h.source,h.subject),wQ(this)}get source(){return di(this),eI.get(this).source}set source(e){throw new Error("Cannot set the source of a view timeline")}get subject(){return eI.get(this).subject}get axis(){return eI.get(this).axis}get currentTime(){const e=gs(this.source,this.axis);if(e==null)return null;const h=HB(this,"cover");if(!h)return null;const F=(e-h.start)/(h.end-h.start);return CSS.percent(100*F)}get startOffset(){return CSS.px(HB(this,"cover").start)}get endOffset(){return CSS.px(HB(this,"cover").end)}};const Je=document.getAnimations,Ue=window.Element.prototype.getAnimations,Le=window.Element.prototype.animate,Ds=window.Animation;class TQ{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((h,F)=>{this.nativeResolve=h,this.nativeReject=F})}resolve(h){this.state="resolved",this.nativeResolve(h)}reject(h){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(h)}}function YB(e){e.readyPromise=new TQ,requestAnimationFrame(()=>{var h;(((h=e.timeline)==null?void 0:h.currentTime)??null)!==null&&(QE(e),e.pendingTask!=="play"||e.startTime===null&&e.holdTime===null?e.pendingTask==="pause"&&ts(e):ss(e))})}function os(){return new DOMException("The user aborted a request","AbortError")}function aQ(e,h){if(h===null)return h;if(typeof h!="number")throw new DOMException(`Unexpected value: ${h}. Cannot convert to CssNumberish`,"InvalidStateError");const F=e.rangeDuration??100,k=xg(e),U=k?F*h/k:0;return CSS.percent(U)}function uA(e,h){if(e.timeline){if(h===null)return h;if(h.unit==="percent"){const F=e.rangeDuration??100,k=xg(e);return h.value*k/F}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(h==null||typeof h=="number")return h;const F=h.to("ms");if(F)return F.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function ss(e){const h=uA(e,e.timeline.currentTime);if(e.holdTime!=null)ng(e),e.animation.playbackRate==0?e.startTime=h:(e.startTime=h-e.holdTime/e.animation.playbackRate,e.holdTime=null);else if(e.startTime!==null&&e.pendingPlaybackRate!==null){const F=(h-e.startTime)*e.animation.playbackRate;ng(e);const k=e.animation.playbackRate;k==0?(e.holdTime=null,e.startTime=h):e.startTime=h-F/k}e.readyPromise&&e.readyPromise.state=="pending"&&e.readyPromise.resolve(e.proxy),pg(e,!1,!1),qg(e),e.pendingTask=null}function ts(e){const h=uA(e,e.timeline.currentTime);e.startTime!=null&&e.holdTime==null&&(e.holdTime=(h-e.startTime)*e.animation.playbackRate),ng(e),e.startTime=null,e.readyPromise.resolve(e.proxy),pg(e,!1,!1),qg(e),e.pendingTask=null}function ws(e){if(!e.finishedPromise||e.finishedPromise.state!="pending"||e.proxy.playState!="finished")return;e.finishedPromise.resolve(e.proxy),e.animation.pause();const h=new CustomEvent("finish",{detail:{currentTime:e.proxy.currentTime,timelineTime:e.proxy.timeline.currentTime}});Object.defineProperty(h,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(h,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{e.animation.dispatchEvent(h)})})}function OQ(e){return e.pendingPlaybackRate!==null?e.pendingPlaybackRate:e.animation.playbackRate}function ng(e){e.pendingPlaybackRate!==null&&(e.animation.playbackRate=e.pendingPlaybackRate,e.pendingPlaybackRate=null)}function as(e){if(!e.timeline)return null;const h=uA(e,e.timeline.currentTime);if(h===null||e.startTime===null)return null;let F=(h-e.startTime)*e.animation.playbackRate;return F==-0&&(F=0),F}function pg(e,h,F){if(!e.timeline)return;let k=h?uA(e,e.proxy.currentTime):as(e);if(k&&e.startTime!=null&&!e.proxy.pending){const U=OQ(e),K=xg(e);let f=e.previousCurrentTime;U>0&&k>=K&&e.previousCurrentTime!=null?((f===null||f<K)&&(f=K),e.holdTime=h?k:f):U<0&&k<=0?((f==null||f>0)&&(f=0),e.holdTime=h?k:f):U!=0&&(h&&e.holdTime!==null&&(e.startTime=function(b,x){if(!b.timeline)return null;const m=uA(b,b.timeline.currentTime);return m==null?null:m-x/b.animation.playbackRate}(e,e.holdTime)),e.holdTime=null)}qg(e),e.previousCurrentTime=uA(e,e.proxy.currentTime),e.proxy.playState=="finished"?(e.finishedPromise||(e.finishedPromise=new TQ),e.finishedPromise.state=="pending"&&(F?ws(e):Promise.resolve().then(()=>{ws(e)}))):(e.finishedPromise&&e.finishedPromise.state=="resolved"&&(e.finishedPromise=new TQ),e.animation.playState!="paused"&&e.animation.pause())}function xg(e){const h=function(k){const U=k.proxy.effect.getTiming();return k.normalizedTiming||U}(e),F=h.delay+h.endDelay+h.iterations*h.duration;return Math.max(0,F)}function qg(e){if(e.timeline)if(e.startTime!==null){const h=e.timeline.currentTime;if(h==null)return;mi(e,(uA(e,h)-e.startTime)*e.animation.playbackRate)}else e.holdTime!==null&&mi(e,e.holdTime)}function mi(e,h){const F=e.timeline,k=e.animation.playbackRate,U=F.currentTime&&F.currentTime.value==(k<0?0:100)?k<0?.001:-.001:0;e.animation.currentTime=h+U}function Pi(e,h){if(!e.timeline)return;const F=e.proxy.playState=="paused"&&e.proxy.pending;let k=!1,U=uA(e,e.proxy.currentTime);OQ(e)==0&&U==null&&(e.holdTime=0),U==null&&(e.autoAlignStartTime=!0),(e.proxy.playState==="finished"||F)&&(e.holdTime=null,e.startTime=null,e.autoAlignStartTime=!0),e.holdTime&&(e.startTime=null),e.pendingTask&&(e.pendingTask=null,k=!0),(e.holdTime!==null||e.autoAlignStartTime||F||e.pendingPlaybackRate!==null)&&(e.readyPromise&&!k&&(e.readyPromise=null),qg(e),e.readyPromise||YB(e),e.pendingTask="play",xi(e.timeline,e.animation,Ti.bind(e.proxy)),pg(e,!1,!1))}function Ti(e){const h=gA.get(this);if(!h)return;if(e==null)return void(h.proxy.playState!=="paused"&&h.animation.playState!="idle"&&h.animation.cancel());QE(h),h.pendingTask&&requestAnimationFrame(()=>{h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&ts(h):ss(h)});const F=this.playState;if(F=="running"||F=="finished"){const k=uA(h,e);mi(h,(k-uA(h,this.startTime))*this.playbackRate),pg(h,!1,!1)}}function es(e){e.specifiedTiming=null}let gA=new WeakMap;window.addEventListener("pagehide",e=>{gA=new WeakMap},!1);let hs=new WeakMap;function QE(e){if(!e.autoAlignStartTime||!e.timeline||!e.timeline.currentTime||e.proxy.playState==="idle"||e.proxy.playState==="paused"&&e.holdTime!==null)return;const h=e.rangeDuration;let F,k;try{F=CSS.percent(100*function(K){if(!K.animationRange)return 0;const f=K.animationRange.start==="normal"?cs(K.timeline):K.animationRange.start;return Es(K.timeline,f)}(e))}catch(K){F=CSS.percent(0),e.animationRange.start="normal",console.warn("Exception when calculating start offset",K)}try{k=CSS.percent(100*(1-function(K){if(!K.animationRange)return 0;const f=K.animationRange.end==="normal"?ys(K.timeline):K.animationRange.end;return 1-Es(K.timeline,f)}(e)))}catch(K){k=CSS.percent(100),e.animationRange.end="normal",console.warn("Exception when calculating end offset",K)}e.rangeDuration=k.value-F.value;const U=OQ(e);e.startTime=uA(e,U>=0?F:k),e.holdTime=null,e.rangeDuration!==h&&es(e)}function BE(e){throw new Error("Unsupported timeline class")}function cs(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:e instanceof NI?CSS.percent(0):void BE()}function ys(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:e instanceof NI?CSS.percent(100):void BE()}function He(e,h){if(!h)return{start:"normal",end:"normal"};const F={start:cs(e),end:ys(e)};if(e instanceof ViewTimeline){const k=MA(h),U=[],K=[];if(k.forEach(f=>{if(IE.includes(f))U.push(f);else try{K.push(CSSNumericValue.parse(f))}catch{throw TypeError(`Could not parse range "${h}"`)}}),U.length>2||K.length>2||K.length==1)throw TypeError("Invalid time range or unsupported time range format.");return U.length&&(F.start.rangeName=U[0],F.end.rangeName=U.length>1?U[1]:U[0]),K.length>1&&(F.start.offset=K[0],F.end.offset=K[1]),F}if(e instanceof NI){const k=h.split(" ");if(k.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return F.start=CSSNumericValue.parse(k[0]),F.end=CSSNumericValue.parse(k[1]),F}BE()}function CE(e,h,F){if(!h||h==="normal")return"normal";if(e instanceof ViewTimeline){let k="cover",U=F==="start"?CSS.percent(0):CSS.percent(100);if(h instanceof Object)h.rangeName!==void 0&&(k=h.rangeName),h.offset!==void 0&&(U=h.offset);else{const K=MA(h);K.length===1?IE.includes(K[0])?k=K[0]:U=DA(CSSNumericValue.parse(K[0]),{}):K.length===2&&(k=K[0],U=DA(CSSNumericValue.parse(K[1]),{}))}if(!IE.includes(k))throw TypeError("Invalid range name");return{rangeName:k,offset:U}}if(e instanceof NI)return CSSNumericValue.parse(h);BE()}class EE{constructor(h,F,k={}){const U=F instanceof NI,K=h instanceof Ds?h:new Ds(h,U?void 0:F);hs.set(K,this),gA.set(this,{animation:K,timeline:U?F:void 0,playState:U?"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:U?He(F,k["animation-range"]):null,proxy:this})}get effect(){const h=gA.get(this);return h.timeline?(h.effect||(h.effect=function(F){const k=F.animation.effect,U=k.updateTiming,K={apply:function(m){k.getTiming();const V=m.apply(k);if(F.timeline){const QA=F.duration??100;V.localTime=aQ(F,V.localTime),V.endTime=aQ(F,V.endTime),V.activeDuration=aQ(F,V.activeDuration);const CA=xg(F),YA=V.iterations?(CA-V.delay-V.endDelay)/V.iterations:0;V.duration=CA?CSS.percent(QA*YA/CA):CSS.percent(0),F.timeline.currentTime===void 0&&(V.localTime=null)}return V}},f={apply:function(m,V){if(F.specifiedTiming)return F.specifiedTiming;F.specifiedTiming=m.apply(k);let QA,CA=Object.assign({},F.specifiedTiming);if(CA.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(CA.duration===null||CA.duration==="auto"||F.autoDurationEffect)&&F.timeline&&(F.autoDurationEffect=!0,CA.delay=0,CA.endDelay=0,QA=CA.iterations?1e5:0,CA.duration=CA.iterations?(QA-CA.delay-CA.endDelay)/CA.iterations:0,CA.duration<0&&(CA.duration=0,CA.endDelay=QA-CA.delay),U.apply(k,[CA])),F.normalizedTiming=CA,F.specifiedTiming}},b={apply:function(m,V,QA){if(QA&&QA.length){if(F.timeline&&QA[0]){const CA=QA[0],YA=CA.duration;if(YA===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(CA.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");YA!==void 0&&YA!=="auto"&&(F.autoDurationEffect=null)}F.specifiedTiming&&m.apply(k,[F.specifiedTiming]),m.apply(k,QA),es(F)}}},x=new Proxy(k,{get:function(m,V){const QA=m[V];return typeof QA=="function"?QA.bind(k):QA},set:function(m,V,QA){return m[V]=QA,!0}});return x.getComputedTiming=new Proxy(k.getComputedTiming,K),x.getTiming=new Proxy(k.getTiming,f),x.updateTiming=new Proxy(k.updateTiming,b),x}(h)),h.effect):h.animation.effect}set effect(h){const F=gA.get(this);F.animation.effect=h,F.effect=null,F.autoDurationEffect=null}get timeline(){const h=gA.get(this);return h.timeline||h.animation.timeline}set timeline(h){const F=gA.get(this),k=this.timeline;if(k==h)return;const U=this.playState,K=this.currentTime;let f,b=xg(F);f=K===null?null:b===0?0:uA(F,K)/b;const x=k instanceof NI,m=h instanceof NI,V=this.pending;if(x&&pi(F.timeline,F.animation),m)return F.timeline=h,ng(F),F.autoAlignStartTime=!0,F.startTime=null,F.holdTime=null,U!=="running"&&U!=="finished"||(F.readyPromise&&F.readyPromise.state!=="resolved"||YB(F),F.pendingTask="play",xi(F.timeline,F.animation,Ti.bind(this))),U==="paused"&&f!==null&&(F.holdTime=f*b),V&&(F.readyPromise&&F.readyPromise.state!="resolved"||YB(F),F.pendingTask=U=="paused"?"pause":"play"),F.startTime!==null&&(F.holdTime=null),void pg(F,!1,!1);if(F.animation.timeline!=h)throw TypeError("Unsupported timeline: "+h);if(pi(F.timeline,F.animation),F.timeline=null,x)switch(K!==null&&(F.animation.currentTime=f*xg(F)),U){case"paused":F.animation.pause();break;case"running":case"finished":F.animation.play()}}get startTime(){const h=gA.get(this);return h.timeline?aQ(h,h.startTime):h.animation.startTime}set startTime(h){const F=gA.get(this);if(h=uA(F,h),!F.timeline)return void(F.animation.startTime=h);F.autoAlignStartTime=!1,uA(F,F.timeline.currentTime)==null&&F.startTime!=null&&(F.holdTime=null,qg(F));const k=uA(F,this.currentTime);ng(F),F.startTime=h,F.startTime!==null&&F.animation.playbackRate!=0?F.holdTime=null:F.holdTime=k,F.pendingTask&&(F.pendingTask=null,F.readyPromise.resolve(this)),pg(F,!0,!1),qg(F)}get currentTime(){const h=gA.get(this);return h.timeline?h.holdTime!=null?aQ(h,h.holdTime):aQ(h,as(h)):h.animation.currentTime}set currentTime(h){const F=gA.get(this);F.timeline?(function(k,U){if(U==null&&k.currentTime!==null)throw new TypeError;U=uA(k,U),k.autoAlignStartTime=!1,k.holdTime!==null||k.startTime===null||k.timeline.phase==="inactive"||k.animation.playbackRate===0?k.holdTime=U:k.startTime=uA(k,k.timeline.currentTime)-U/k.animation.playbackRate,k.timeline.phase==="inactive"&&(k.startTime=null),k.previousCurrentTime=null}(F,h),F.pendingTask=="pause"&&(F.holdTime=uA(F,h),ng(F),F.startTime=null,F.pendingTask=null,F.readyPromise.resolve(this)),pg(F,!0,!1)):F.animation.currentTime=h}get playbackRate(){return gA.get(this).animation.playbackRate}set playbackRate(h){const F=gA.get(this);if(!F.timeline)return void(F.animation.playbackRate=h);F.pendingPlaybackRate=null;const k=this.currentTime;F.animation.playbackRate=h,k!==null&&(this.currentTime=k)}get playState(){const h=gA.get(this);if(!h.timeline)return h.animation.playState;const F=uA(h,this.currentTime);return F===null&&h.startTime===null&&h.pendingTask==null?"idle":h.pendingTask=="pause"||h.startTime===null&&h.pendingTask!="play"?"paused":F!=null&&(h.animation.playbackRate>0&&F>=xg(h)||h.animation.playbackRate<0&&F<=0)?"finished":"running"}get rangeStart(){var h;return((h=gA.get(this).animationRange)==null?void 0:h.start)??"normal"}set rangeStart(h){const F=gA.get(this);if(!F.timeline)return F.animation.rangeStart=h;F.timeline instanceof NI&&(F.animationRange.start=CE(F.timeline,h,"start"),QE(F),qg(F))}get rangeEnd(){var h;return((h=gA.get(this).animationRange)==null?void 0:h.end)??"normal"}set rangeEnd(h){const F=gA.get(this);if(!F.timeline)return F.animation.rangeEnd=h;F.timeline instanceof NI&&(F.animationRange.end=CE(F.timeline,h,"end"),QE(F),qg(F))}get replaceState(){return gA.get(this).animation.pending}get pending(){const h=gA.get(this);return h.timeline?!!h.readyPromise&&h.readyPromise.state=="pending":h.animation.pending}finish(){const h=gA.get(this);if(!h.timeline)return void h.animation.finish();const F=OQ(h),k=xg(h);if(F==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(F>0&&k==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");ng(h);const U=F<0?0:k;this.currentTime=aQ(h,U);const K=uA(h,h.timeline.currentTime);h.startTime===null&&K!==null&&(h.startTime=K-U/h.animation.playbackRate),h.pendingTask=="pause"&&h.startTime!==null&&(h.holdTime=null,h.pendingTask=null,h.readyPromise.resolve(this)),h.pendingTask=="play"&&h.startTime!==null&&(h.pendingTask=null,h.readyPromise.resolve(this)),pg(h,!0,!0)}play(){const h=gA.get(this);h.timeline?Pi(h):h.animation.play()}pause(){const h=gA.get(this);h.timeline?this.playState!="paused"&&(h.animation.currentTime===null&&(h.autoAlignStartTime=!0),h.pendingTask=="play"?h.pendingTask=null:h.readyPromise=null,h.readyPromise||YB(h),h.pendingTask="pause",xi(h.timeline,h.animation,Ti.bind(h.proxy))):h.animation.pause()}reverse(){const h=gA.get(this),F=OQ(h),k=uA(h,this.currentTime),U=xg(h)==1/0,K=F!=0&&(F<0||k>0||!U);if(!h.timeline||!K)return K&&(h.pendingPlaybackRate=-OQ(h)),void h.animation.reverse();if(h.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-F),Pi(h)}updatePlaybackRate(h){const F=gA.get(this);if(F.pendingPlaybackRate=h,!F.timeline)return void F.animation.updatePlaybackRate(h);const k=this.playState;if(!F.readyPromise||F.readyPromise.state!="pending")switch(k){case"idle":case"paused":ng(F);break;case"finished":const U=uA(F,F.timeline.currentTime),K=U!==null?(U-F.startTime)*F.animation.playbackRate:null;F.startTime=h==0?U:U!=null&&K!=null?(U-K)/h:null,ng(F),pg(F,!1,!1),qg(F);break;default:Pi(F)}}persist(){gA.get(this).animation.persist()}get id(){return gA.get(this).animation.id}set id(h){gA.get(this).animation.id=h}cancel(){const h=gA.get(this);h.timeline?(this.playState!="idle"&&(function(F){F.pendingTask&&(F.pendingTask=null,ng(F),F.readyPromise.reject(os()),YB(F),F.readyPromise.resolve(F.proxy))}(h),h.finishedPromise&&h.finishedPromise.state=="pending"&&h.finishedPromise.reject(os()),h.finishedPromise=new TQ,h.animation.cancel()),h.startTime=null,h.holdTime=null,pi(h.timeline,h.animation)):h.animation.cancel()}get onfinish(){return gA.get(this).animation.onfinish}set onfinish(h){gA.get(this).animation.onfinish=h}get oncancel(){return gA.get(this).animation.oncancel}set oncancel(h){gA.get(this).animation.oncancel=h}get onremove(){return gA.get(this).animation.onremove}set onremove(h){gA.get(this).animation.onremove=h}get finished(){const h=gA.get(this);return h.timeline?(h.finishedPromise||(h.finishedPromise=new TQ),h.finishedPromise.promise):h.animation.finished}get ready(){const h=gA.get(this);return h.timeline?(h.readyPromise||(h.readyPromise=new TQ,h.readyPromise.resolve(this)),h.readyPromise.promise):h.animation.ready}addEventListener(h,F,k){gA.get(this).animation.addEventListener(h,F,k)}removeEventListener(h,F,k){gA.get(this).animation.removeEventListener(h,F,k)}dispatchEvent(h){gA.get(this).animation.dispatchEvent(h)}}function Ye(e,h){const F=h.timeline;F instanceof NI&&delete h.timeline;const k=Le.apply(this,[e,h]),U=new EE(k,F);return F instanceof NI&&(k.pause(),gA.get(U).animationRange={start:CE(F,h.rangeStart,"start"),end:CE(F,h.rangeEnd,"end")},U.play()),U}function Gs(e){for(let h=0;h<e.length;++h){let F=hs.get(e[h]);F&&(e[h]=F)}return e}function Ke(e){return Gs(Ue.apply(this,[e]))}function de(e){return Gs(Je.apply(this,[e]))}const AI={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\(([^)]*)\)/},XQ=["block","inline","x","y"],le=["nearest","root","self"],$g=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,h,F){const k={sheetSrc:e,index:0,name:F};for(;k.index<k.sheetSrc.length&&(this.eatWhitespace(k),!(k.index>=k.sheetSrc.length));){if(this.lookAhead("/*",k)){for(;this.lookAhead("/*",k);)this.eatComment(k),this.eatWhitespace(k);continue}const U=this.parseQualifiedRule(k);U&&(h?this.parseKeyframesAndSaveNameMapping(U,k):this.handleScrollTimelineProps(U,k))}return k.sheetSrc}getAnimationTimelineOptions(e,h){for(let F=this.cssRulesWithTimelineName.length-1;F>=0;F--){const k=this.cssRulesWithTimelineName[F];try{if(h.matches(k.selector)&&(!k["animation-name"]||k["animation-name"]==e))return{"animation-timeline":k["animation-timeline"],"animation-range":k["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(e,h){const F=this.anonymousScrollTimelineOptions.get(e);return F?{anonymousSource:F.source,anonymousTarget:h,source:Bs(F.source??"nearest",h),axis:F.axis?F.axis:"block"}:null}getScrollTimelineOptions(e,h){const F=this.getAnonymousScrollTimelineOptions(e,h);if(F)return F;for(let k=this.sourceSelectorToScrollTimeline.length-1;k>=0;k--){const U=this.sourceSelectorToScrollTimeline[k];if(U.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(h,U.selector);if(K)return{source:K,...U.axis?{axis:U.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(e,h){let F=e;for(;F;){if(F.matches(h))return F;F=F.previousElementSibling||F.parentElement}return null}getAnonymousViewTimelineOptions(e,h){const F=this.anonymousViewTimelineOptions.get(e);return F?{subject:h,axis:F.axis?F.axis:"block",inset:F.inset?F.inset:"auto"}:null}getViewTimelineOptions(e,h){const F=this.getAnonymousViewTimelineOptions(e,h);if(F)return F;for(let k=this.subjectSelectorToViewTimeline.length-1;k>=0;k--){const U=this.subjectSelectorToViewTimeline[k];if(U.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(h,U.selector);if(K)return{subject:K,axis:U.axis,inset:U.inset}}}return null}handleScrollTimelineProps(e,h){if(e.selector.includes("@keyframes"))return;const F=e.block.contents.includes("animation-name:"),k=e.block.contents.includes("animation-timeline:"),U=e.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(e),this.saveSubjectSelectorToViewTimeline(e),!k&&!F&&!U)return;let K=[],f=[],b=!1;k&&(K=this.extractScrollTimelineNames(e.block.contents)),F&&(f=this.extractMatches(e.block.contents,AI.ANIMATION_NAME)),k&&F||(U&&this.extractMatches(e.block.contents,AI.ANIMATION).forEach(x=>{const m=this.extractAnimationName(x);m&&k&&f.push(m),k&&(this.hasDuration(x)||(this.hasAutoDuration(x)&&(e.block.contents=e.block.contents.replace("auto"," ")),e.block.contents=e.block.contents.replace(x," 1s "+x),b=!0))}),b&&this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,h)),this.saveRelationInList(e,K,f)}saveSourceSelectorToScrollTimeline(e){const h=e.block.contents.includes("scroll-timeline:"),F=e.block.contents.includes("scroll-timeline-name:"),k=e.block.contents.includes("scroll-timeline-axis:");if(!h&&!F)return;let U=[];if(h){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE);for(const b of f){const x=this.split(b);let m={selector:e.selector,name:""};x.length==1?m.name=x[0]:x.length==2&&(XQ.includes(x[0])?(m.axis=x[0],m.name=x[1]):(m.axis=x[1],m.name=x[0])),U.push(m)}}if(F){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE_NAME);for(let b=0;b<f.length;b++)if(b<U.length)U[b].name=f[b];else{let x={selector:e.selector,name:f[b]};U.push(x)}}let K=[];if(k){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE_AXIS);if(K=f.filter(b=>XQ.includes(b)),K.length!=f.length)throw new Error("Invalid axis")}for(let f=0;f<U.length;f++)K.length&&(U[f].axis=K[f%U.length]);this.sourceSelectorToScrollTimeline.push(...U)}saveSubjectSelectorToViewTimeline(e){const h=e.block.contents.includes("view-timeline:"),F=e.block.contents.includes("view-timeline-name:"),k=e.block.contents.includes("view-timeline-axis:"),U=e.block.contents.includes("view-timeline-inset:");if(!h&&!F)return;let K=[];if(h){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE);for(let m of x){const V=this.split(m);let QA={selector:e.selector,name:"",inset:null};V.length==1?QA.name=V[0]:V.length==2&&(XQ.includes(V[0])?(QA.axis=V[0],QA.name=V[1]):(QA.axis=V[1],QA.name=V[0])),K.push(QA)}}if(F){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_NAME);for(let m=0;m<x.length;m++)if(m<K.length)K[m].name=x[m];else{let V={selector:e.selector,name:x[m],inset:null};K.push(V)}}let f=[],b=[];if(U&&(f=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_INSET)),k){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_AXIS);if(b=x.filter(m=>XQ.includes(m)),b.length!=x.length)throw new Error("Invalid axis")}for(let x=0;x<K.length;x++)f.length&&(K[x].inset=f[x%K.length]),b.length&&(K[x].axis=b[x%K.length]);this.subjectSelectorToViewTimeline.push(...K)}hasDuration(e){return e.split(" ").filter(h=>{return F=h,AI.TIME.exec(F);var F}).length>=1}hasAutoDuration(e){return e.split(" ").filter(h=>h==="auto").length>=1}saveRelationInList(e,h,F){let k=[];e.block.contents.includes("animation-range:")&&(k=this.extractMatches(e.block.contents,AI.ANIMATION_TIME_RANGE));const U=Math.max(h.length,F.length,k.length);for(let K=0;K<U;K++)this.cssRulesWithTimelineName.push({selector:e.selector,"animation-timeline":h[K%h.length],...F.length?{"animation-name":F[K%F.length]}:{},...k.length?{"animation-range":k[K%k.length]}:{}})}extractScrollTimelineNames(e){const h=AI.ANIMATION_TIMELINE.exec(e)[1].trim(),F=[];return h.split(",").map(k=>k.trim()).forEach(k=>{if(function(U){return(U.startsWith("scroll")||U.startsWith("view"))&&U.includes("(")}(k)){const U=this.saveAnonymousTimelineName(k);F.push(U)}else F.push(k)}),F}saveAnonymousTimelineName(e){const h=":t"+this.nextAnonymousTimelineNameIndex++;return e.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(h,this.parseAnonymousScrollTimeline(e)):this.anonymousViewTimelineOptions.set(h,this.parseAnonymousViewTimeline(e)),h}parseAnonymousScrollTimeline(e){const h=AI.ANONYMOUS_SCROLL_TIMELINE.exec(e);if(!h)return null;const F=h[1],k={};return F.split(" ").forEach(U=>{XQ.includes(U)?k.axis=U:le.includes(U)&&(k.source=U)}),k}parseAnonymousViewTimeline(e){const h=AI.ANONYMOUS_VIEW_TIMELINE.exec(e);if(!h)return null;const F=h[1],k={};return F.split(" ").forEach(U=>{XQ.includes(U)?k.axis=U:k.inset=k.inset?`${k.inset} ${U}`:U}),k}extractAnimationName(e){return this.findMatchingEntryInContainer(e,this.keyframeNamesSelectors)}findMatchingEntryInContainer(e,h){const F=e.split(" ").filter(k=>h.has(k));return F?F[0]:null}parseIdentifier(e){AI.IDENTIFIER.lastIndex=e.index;const h=AI.IDENTIFIER.exec(e.sheetSrc);if(!h)throw this.parseError(e,"Expected an identifier");return e.index+=h[0].length,h[0]}parseKeyframesAndSaveNameMapping(e,h){if(e.selector.startsWith("@keyframes")){const F=this.replaceKeyframesAndGetMapping(e,h);e.selector.split(" ").forEach((k,U)=>{U>0&&this.keyframeNamesSelectors.set(k,F)})}}replaceKeyframesAndGetMapping(e,h){function F(x){return IE.some(m=>x.startsWith(m))}const k=e.block.contents,U=function(x){let m=0,V=-1,QA=-1;const CA=[];for(let YA=0;YA<x.length;YA++)x[YA]=="{"?m++:x[YA]=="}"&&m--,m==1&&x[YA]!="{"&&x[YA]!="}"&&V==-1&&(V=YA),m==2&&x[YA]=="{"&&(QA=YA,CA.push({start:V,end:QA}),V=QA=-1);return CA}(k);if(U.length==0)return new Map;const K=new Map;let f=!1;const b=[];b.push(k.substring(0,U[0].start));for(let x=0;x<U.length;x++){const m=k.substring(U[x].start,U[x].end);let V=[];m.split(",").forEach(QA=>{const CA=QA.split(" ").map(OA=>OA.trim()).filter(OA=>OA!="").join(" "),YA=K.size;K.set(YA,CA),V.push(`${YA}%`),F(CA)&&(f=!0)}),b.push(V.join(",")),x==U.length-1?b.push(k.substring(U[x].end)):b.push(k.substring(U[x].end,U[x+1].start))}return f?(e.block.contents=b.join(""),this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,h),K):new Map}parseQualifiedRule(e){const h=e.index,F=this.parseSelector(e).trim();if(F)return{selector:F,block:this.eatBlock(e),startIndex:h,endIndex:e.index}}removeEnclosingDoubleQuotes(e){let h=e[0]=='"'?1:0,F=e[e.length-1]=='"'?e.length-1:e.length;return e.substring(h,F)}assertString(e,h){if(e.sheetSrc.substr(e.index,h.length)!=h)throw this.parseError(e,`Did not find expected sequence ${h}`);e.index+=h.length}replacePart(e,h,F,k){if(k.sheetSrc=k.sheetSrc.slice(0,e)+F+k.sheetSrc.slice(h),k.index>=h){const U=k.index-h;k.index=e+F.length+U}}eatComment(e){this.assertString(e,"/*"),this.eatUntil("*/",e,!0),this.assertString(e,"*/")}eatBlock(e){const h=e.index;this.assertString(e,"{");let F=1;for(;F!=0;)this.lookAhead("/*",e)?this.eatComment(e):(e.sheetSrc[e.index]==="{"?F++:e.sheetSrc[e.index]==="}"&&F--,this.advance(e));const k=e.index;return{startIndex:h,endIndex:k,contents:e.sheetSrc.slice(h,k)}}advance(e){if(e.index++,e.index>e.sheetSrc.length)throw this.parseError(e,"Advanced beyond the end")}parseError(e,h){return Error(`(${e.name?e.name:"<anonymous file>"}): ${h}`)}eatUntil(e,h,F=!1){const k=h.index;for(;!this.lookAhead(e,h);)this.advance(h);return F&&(h.sheetSrc=h.sheetSrc.slice(0,k)+" ".repeat(h.index-k)+h.sheetSrc.slice(h.index)),h.sheetSrc.slice(k,h.index)}parseSelector(e){let h=e.index;if(this.eatUntil("{",e),h===e.index)throw Error("Empty selector");return e.sheetSrc.slice(h,e.index)}eatWhitespace(e){AI.WHITE_SPACE.lastIndex=e.index;const h=AI.WHITE_SPACE.exec(e.sheetSrc);h&&(e.index+=h[0].length)}lookAhead(e,h){return h.sheetSrc.substr(h.index,e.length)==e}peek(e){return e.sheetSrc[e.index]}extractMatches(e,h,F=","){return h.exec(e)[1].trim().split(F).map(k=>k.trim())}split(e){return e.split(" ").map(h=>h.trim()).filter(h=>h!="")}};function fe(e,h,F,k,U,K){const f=li(h),b=fi(h,F);return is(bi(e,f,b,k,U),K,bi("cover",f,b,k,U),F)}function pe(e,h,F){const k=$g.getAnimationTimelineOptions(h,F);if(!k)return null;const U=k["animation-timeline"];if(!U)return null;let K=$g.getScrollTimelineOptions(U,F)||$g.getViewTimelineOptions(U,F);return K?(K.subject&&function(f,b){const x=ui(b.subject),m=b.axis||b.axis;function V(CA,YA){let OA=null;for(const[xI,tg]of CA)if(xI==100*YA.offset){if(tg=="from")OA=0;else if(tg=="to")OA=100;else{const $I=tg.split(" ");OA=$I.length==1?parseFloat($I[0]):100*fe($I[0],x,b.subject,m,b.inset,CSS.percent(parseFloat($I[1])))}break}return OA}const QA=$g.keyframeNamesSelectors.get(f.animationName);if(QA&&QA.size){const CA=[];f.effect.getKeyframes().forEach(OA=>{const xI=V(QA,OA);xI!==null&&xI>=0&&xI<=100&&(OA.offset=xI/100,CA.push(OA))});const YA=CA.sort((OA,xI)=>OA.offset<xI.offset?-1:OA.affset>xI.offset?1:0);f.effect.setKeyframes(YA)}}(e,K),{timeline:K.source?new NI(K):new PQ(K),animOptions:k}):null}function xe(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function h(k){if(k.innerHTML.trim().length===0||"aphrodite"in k.dataset)return;let U=$g.transpileStyleSheet(k.innerHTML,!0);U=$g.transpileStyleSheet(U,!1),k.innerHTML=U}function F(k){k.type!="text/css"&&k.rel!="stylesheet"||!k.href||new URL(k.href,document.baseURI).origin==location.origin&&fetch(k.getAttribute("href")).then(async U=>{const K=await U.text();let f=$g.transpileStyleSheet(K,!0);if(f=$g.transpileStyleSheet(K,!1),f!=K){const b=new Blob([f],{type:"text/css"}),x=URL.createObjectURL(b);k.setAttribute("href",x)}})}new MutationObserver(k=>{for(const U of k)for(const K of U.addedNodes)K instanceof HTMLStyleElement&&h(K),K instanceof HTMLLinkElement&&F(K)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(k=>h(k)),document.querySelectorAll("link").forEach(k=>F(k))})();const e=CSS.supports;CSS.supports=h=>(h=h.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),e(h)),window.addEventListener("animationstart",h=>{h.target.getAnimations().filter(F=>F.animationName===h.animationName).forEach(F=>{const k=pe(F,F.animationName,h.target);if(k)if(!k.timeline||F instanceof EE)F.timeline=k.timeline;else{const U=new EE(F,k.timeline,k.animOptions);F.pause(),U.play()}})})}(function(){if(!xe()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:NI}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:PQ}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Ye}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:EE}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Ke}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:de}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const aF=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),eF=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{$h as BatchedParticleRenderer,zo as Builder,nC as ByteBuffer,qQ as ConstantColor,rA as ConstantValue,kg as Matrix4,UB as MeshBVH,O0 as MotionController,yD as PROJECT_DOCUMENT_KEY,Yi as ParticleSystem,X as RenderMode,Os as SIZE_PREFIX_LENGTH,RE as TrailParticle,OI as Vector4,CF as WorkerBase,eF as __viteBrowserExternal,at as applyDef,ht as applyOver,Ts as attachNeedleIdsToLoadedGltf,By as bundler,Ic as createNoise4D,et as createOverApplyState,U0 as deriveInstanceId,Cc as enableProjectDocumentInspection,sc as evaluateProjectDocument,u0 as fetchProfile,ic as getProjectDocumentInspection,Nc as index,BF as index$1,sF as index$2,st as isProjectDocument,Qc as reportProjectIssues,bB as resolveDocumentRemoteSrc,yt as resolveMaterialEntity,aF as scrollTimeline,$S as spark_module,SD as splitPath,G0 as v5};
|
|
13104
|
+
`),new q(-1,-3,1).normalize(),new hQ(1,1,1),new hQ(.5,.5,1),new hQ(1,1,1),new hQ(.25,.25,.5);var ua=(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))(ua||{});const _S=Object.keys(ua);_S.length,new je(0,0,0,"YXZ");var Fo=(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))(Fo||{});const ba=Object.keys(Fo);ba.length;const $S=Object.freeze(Object.defineProperty({__proto__:null,ExtSplats:vg,JOINT_IDS:ba,JointEnum:Fo,LN_SCALE_MAX:bI,LN_SCALE_MIN:uI,OldSparkViewpoint:Go,OldSplatAccumulator:Qi,PackedSplats:Kg,PagedSplats:wC,Readback:oC,RgbaArray:Na,SparkRenderer:bS,SplatAccumulator:aB,SplatEdit:Ai,SplatEditSdf:Ja,SplatEdits:La,SplatFileType:mI,SplatGenerator:wB,SplatLoader:ho,SplatMesh:EQ,SplatModifier:Ha,SplatPager:UQ,SplatTransformer:sC,floatToUint8:AC,fromHalf:rg,getSplatFileType:fa,isAndroid:Ww,isIos:OE,isMobile:TE,isOculus:jw,isVisionPro:zw,setPackedSplat:$D,toHalf:Sg,unpackSplat:PE},Symbol.toStringTag,{value:"Module"})),Ro=0,ma=1,Pa=2,ko=2,no=1.25,Ta=1,SI=32,jA=SI/4,Oa=65535,Bi=Math.pow(2,-24),Ci=Symbol("SKIP_GENERATION"),Xa={strategy:Ro,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ci]:!1};function mA(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 va(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 Za(B,A){A.set(B)}function Va(B,A,I){let g,Q;for(let C=0;C<3;C++){const i=C+3;g=B[C],Q=A[C],I[C]=g<Q?g:Q,g=B[i],Q=A[i],I[i]=g>Q?g:Q}}function Ei(B,A,I){for(let g=0;g<3;g++){const Q=A[B+2*g],C=A[B+2*g+1],i=Q-C,E=Q+C;i<I[g]&&(I[g]=i),E>I[g+3]&&(I[g+3]=E)}}function aC(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 zA(B,A){return A[B+15]===Oa}function rI(B,A){return A[B+6]}function lI(B,A){return A[B+14]}function CI(B){return B+jA}function EI(B,A){const I=A[B+6];return B+I*jA}function No(B,A){return A[B+7]}function Mo(B,A,I,g,Q){let C=1/0,i=1/0,E=1/0,D=-1/0,o=-1/0,s=-1/0,t=1/0,w=1/0,a=1/0,G=-1/0,r=-1/0,c=-1/0;const y=B.offset||0;for(let R=(A-y)*6,S=(A+I-y)*6;R<S;R+=6){const n=B[R+0],N=B[R+1],M=n-N,J=n+N;M<C&&(C=M),J>D&&(D=J),n<t&&(t=n),n>G&&(G=n);const L=B[R+2],H=B[R+3],Y=L-H,d=L+H;Y<i&&(i=Y),d>o&&(o=d),L<w&&(w=L),L>r&&(r=L);const l=B[R+4],p=B[R+5],u=l-p,P=l+p;u<E&&(E=u),P>s&&(s=P),l<a&&(a=l),l>c&&(c=l)}g[0]=C,g[1]=i,g[2]=E,g[3]=D,g[4]=o,g[5]=s,Q[0]=t,Q[1]=w,Q[2]=a,Q[3]=G,Q[4]=r,Q[5]=c}const Zg=32,Ar=(B,A)=>B.candidate-A.candidate,iQ=new Array(Zg).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ii=new Float32Array(6);function Ir(B,A,I,g,Q,C){let i=-1,E=0;if(C===Ro)i=va(A),i!==-1&&(E=(A[i]+A[i+3])/2);else if(C===ma)i=va(B),i!==-1&&(E=gr(I,g,Q,i));else if(C===Pa){const D=aC(B);let o=no*Q;const s=I.offset||0,t=(g-s)*6,w=(g+Q-s)*6;for(let a=0;a<3;a++){const G=A[a],r=(A[a+3]-G)/Zg;if(Q<Zg/4){const c=[...iQ];c.length=Q;let y=0;for(let S=t;S<w;S+=6,y++){const n=c[y];n.candidate=I[S+2*a],n.count=0;const{bounds:N,leftCacheBounds:M,rightCacheBounds:J}=n;for(let L=0;L<3;L++)J[L]=1/0,J[L+3]=-1/0,M[L]=1/0,M[L+3]=-1/0,N[L]=1/0,N[L+3]=-1/0;Ei(S,I,N)}c.sort(Ar);let R=Q;for(let S=0;S<R;S++){const n=c[S];for(;S+1<R&&c[S+1].candidate===n.candidate;)c.splice(S+1,1),R--}for(let S=t;S<w;S+=6){const n=I[S+2*a];for(let N=0;N<R;N++){const M=c[N];n>=M.candidate?Ei(S,I,M.rightCacheBounds):(Ei(S,I,M.leftCacheBounds),M.count++)}}for(let S=0;S<R;S++){const n=c[S],N=n.count,M=Q-n.count,J=n.leftCacheBounds,L=n.rightCacheBounds;let H=0;N!==0&&(H=aC(J)/D);let Y=0;M!==0&&(Y=aC(L)/D);const d=Ta+no*(H*N+Y*M);d<o&&(i=a,o=d,E=n.candidate)}}else{for(let R=0;R<Zg;R++){const S=iQ[R];S.count=0,S.candidate=G+r+R*r;const n=S.bounds;for(let N=0;N<3;N++)n[N]=1/0,n[N+3]=-1/0}for(let R=t;R<w;R+=6){let S=~~((I[R+2*a]-G)/r);S>=Zg&&(S=Zg-1);const n=iQ[S];n.count++,Ei(R,I,n.bounds)}const c=iQ[Zg-1];Za(c.bounds,c.rightCacheBounds);for(let R=Zg-2;R>=0;R--){const S=iQ[R],n=iQ[R+1];Va(S.bounds,n.rightCacheBounds,S.rightCacheBounds)}let y=0;for(let R=0;R<Zg-1;R++){const S=iQ[R],n=S.count,N=S.bounds,M=iQ[R+1].rightCacheBounds;n!==0&&(y===0?Za(N,ii):Va(N,ii,ii)),y+=n;let J=0,L=0;y!==0&&(J=aC(ii)/D);const H=Q-y;H!==0&&(L=aC(M)/D);const Y=Ta+no*(J*y+L*H);Y<o&&(i=a,o=Y,E=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${C} used.`);return{axis:i,pos:E}}function gr(B,A,I,g){let Q=0;const C=B.offset;for(let i=A,E=A+I;i<E;i++)Q+=B[(i-C)*6+g*2];return Q/I}class Jo{constructor(){this.boundingData=new Float32Array(6)}}function Qr(B,A,I,g,Q,C){let i=g,E=g+Q-1;const D=C.pos,o=C.axis*2,s=I.offset||0;for(;;){for(;i<=E&&I[(i-s)*6+o]<D;)i++;for(;i<=E&&I[(E-s)*6+o]>=D;)E--;if(i<E){for(let t=0;t<A;t++){let w=B[i*A+t];B[i*A+t]=B[E*A+t],B[E*A+t]=w}for(let t=0;t<6;t++){const w=i-s,a=E-s,G=I[w*6+t];I[w*6+t]=I[a*6+t],I[a*6+t]=G}i++,E--}else return i}}let Wa,Di,Uo,ja;const Br=Math.pow(2,32);function Lo(B){return"count"in B?1:1+Lo(B.left)+Lo(B.right)}function Cr(B,A,I){return Wa=new Float32Array(I),Di=new Uint32Array(I),Uo=new Uint16Array(I),ja=new Uint8Array(I),Ho(B,A)}function Ho(B,A){const I=B/4,g=B/2,Q="count"in A,C=A.boundingData;for(let i=0;i<6;i++)Wa[I+i]=C[i];if(Q)return A.buffer?(ja.set(new Uint8Array(A.buffer),B),B+A.buffer.byteLength):(Di[I+6]=A.offset,Uo[g+14]=A.count,Uo[g+15]=Oa,B+SI);{const{left:i,right:E,splitAxis:D}=A,o=B+SI;let s=Ho(o,i);const t=B/SI,w=s/SI-t;if(w>Br)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Di[I+6]=w,Di[I+7]=D,Ho(s,E)}}function Er(B,A,I,g,Q){const{maxDepth:C,verbose:i,maxLeafSize:E,strategy:D,onProgress:o}=Q,s=B.primitiveBuffer,t=B.primitiveBufferStride,w=new Float32Array(6);let a=!1;const G=new Jo;return Mo(A,I,g,G.boundingData,w),c(G,I,g,w),G;function r(y){o&&o(y/g)}function c(y,R,S,n=null,N=0){if(!a&&N>=C&&(a=!0,i&&console.warn(`BVH: Max depth of ${C} reached when generating BVH. Consider increasing maxDepth.`)),S<=E||N>=C)return r(R+S),y.offset=R,y.count=S,y;const M=Ir(y.boundingData,n,A,R,S,D);if(M.axis===-1)return r(R+S),y.offset=R,y.count=S,y;const J=Qr(s,t,A,R,S,M);if(J===R||J===R+S)r(R+S),y.offset=R,y.count=S;else{y.splitAxis=M.axis;const L=new Jo,H=R,Y=J-R;y.left=L,Mo(A,H,Y,L.boundingData,w),c(L,H,Y,w,N+1);const d=new Jo,l=J,p=S-Y;y.right=d,Mo(A,l,p,d.boundingData,w),c(d,l,p,w,N+1)}return y}}function ir(B,A){const I=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,g=B.getRootRanges(A.range),Q=g[0],C=g[g.length-1],i={offset:Q.offset,count:C.offset+C.count-Q.offset},E=new Float32Array(6*i.count);E.offset=i.offset,B.computePrimitiveBounds(i.offset,i.count,E),B._roots=g.map(D=>{const o=Er(B,E,D.offset,D.count,A),s=Lo(o),t=new I(SI*s);return Cr(0,o,t),t})}class Yo{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 Dr{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 Dr;let DQ,hB;const cB=[],oi=new Yo(()=>new ag);function or(B,A,I,g,Q,C){DQ=oi.getPrimitive(),hB=oi.getPrimitive(),cB.push(DQ,hB),KA.setBuffer(B._roots[A]);const i=Ko(0,B.geometry,I,g,Q,C);KA.clearBuffer(),oi.releasePrimitive(DQ),oi.releasePrimitive(hB),cB.pop(),cB.pop();const E=cB.length;return E>0&&(hB=cB[E-1],DQ=cB[E-2]),i}function Ko(B,A,I,g,Q=null,C=0,i=0){const{float32Array:E,uint16Array:D,uint32Array:o}=KA;let s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);return mA(B,E,DQ),g(t,w,!1,i,C+B/jA,DQ)}else{let t=function(d){const{uint16Array:l,uint32Array:p}=KA;let u=d*2;for(;!zA(u,l);)d=CI(d),u=d*2;return rI(d,p)},w=function(d){const{uint16Array:l,uint32Array:p}=KA;let u=d*2;for(;!zA(u,l);)d=EI(d,p),u=d*2;return rI(d,p)+lI(u,l)};const a=CI(B),G=EI(B,o);let r=a,c=G,y,R,S,n;if(Q&&(S=DQ,n=hB,mA(r,E,S),mA(c,E,n),y=Q(S),R=Q(n),R<y)){r=G,c=a;const d=y;y=R,R=d,S=n}S||(S=DQ,mA(r,E,S));const N=zA(r*2,D),M=I(S,N,y,i+1,C+r/jA);let J;if(M===ko){const d=t(r),l=w(r)-d;J=g(d,l,!0,i+1,C+r/jA,S)}else J=M&&Ko(r,A,I,g,Q,C,i+1);if(J)return!0;n=hB,mA(c,E,n);const L=zA(c*2,D),H=I(n,L,R,i+1,C+c/jA);let Y;if(H===ko){const d=t(c),l=w(c)-d;Y=g(d,l,!0,i+1,C+c/jA,n)}else Y=H&&Ko(c,A,I,g,Q,C,i+1);return!!Y}}const eC=new KA.constructor,si=new KA.constructor,oQ=new Yo(()=>new ag),yB=new ag,GB=new ag,lo=new ag,fo=new ag;let po=!1;function sr(B,A,I,g){if(po)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");po=!0;const Q=B._roots,C=A._roots;let i,E=0,D=0;const o=new fA().copy(I).invert();for(let s=0,t=Q.length;s<t;s++){eC.setBuffer(Q[s]),D=0;const w=oQ.getPrimitive();mA(0,eC.float32Array,w),w.applyMatrix4(o);for(let a=0,G=C.length;a<G&&(si.setBuffer(C[a]),i=Fg(0,0,I,o,g,E,D,0,0,w),si.clearBuffer(),D+=C[a].byteLength/SI,!i);a++);if(oQ.releasePrimitive(w),eC.clearBuffer(),E+=Q[s].byteLength/SI,i)break}return po=!1,i}function Fg(B,A,I,g,Q,C=0,i=0,E=0,D=0,o=null,s=!1){let t,w;s?(t=si,w=eC):(t=eC,w=si);const a=t.float32Array,G=t.uint32Array,r=t.uint16Array,c=w.float32Array,y=w.uint32Array,R=w.uint16Array,S=B*2,n=A*2,N=zA(S,r),M=zA(n,R);let J=!1;if(M&&N)s?J=Q(rI(A,y),lI(A*2,R),rI(B,G),lI(B*2,r),D,i+A/jA,E,C+B/jA):J=Q(rI(B,G),lI(B*2,r),rI(A,y),lI(A*2,R),E,C+B/jA,D,i+A/jA);else if(M){const L=oQ.getPrimitive();mA(A,c,L),L.applyMatrix4(I);const H=CI(B),Y=EI(B,G);mA(H,a,yB),mA(Y,a,GB);const d=L.intersectsBox(yB),l=L.intersectsBox(GB);J=d&&Fg(A,H,g,I,Q,i,C,D,E+1,L,!s)||l&&Fg(A,Y,g,I,Q,i,C,D,E+1,L,!s),oQ.releasePrimitive(L)}else{const L=CI(A),H=EI(A,y);mA(L,c,lo),mA(H,c,fo);const Y=o.intersectsBox(lo),d=o.intersectsBox(fo);if(Y&&d)J=Fg(B,L,I,g,Q,C,i,E,D+1,o,s)||Fg(B,H,I,g,Q,C,i,E,D+1,o,s);else if(Y)if(N)J=Fg(B,L,I,g,Q,C,i,E,D+1,o,s);else{const l=oQ.getPrimitive();l.copy(lo).applyMatrix4(I);const p=CI(B),u=EI(B,G);mA(p,a,yB),mA(u,a,GB);const P=l.intersectsBox(yB),O=l.intersectsBox(GB);J=P&&Fg(L,p,g,I,Q,i,C,D,E+1,l,!s)||O&&Fg(L,u,g,I,Q,i,C,D,E+1,l,!s),oQ.releasePrimitive(l)}else if(d)if(N)J=Fg(B,H,I,g,Q,C,i,E,D+1,o,s);else{const l=oQ.getPrimitive();l.copy(fo).applyMatrix4(I);const p=CI(B),u=EI(B,G);mA(p,a,yB),mA(u,a,GB);const P=l.intersectsBox(yB),O=l.intersectsBox(GB);J=P&&Fg(H,p,g,I,Q,i,C,D,E+1,l,!s)||O&&Fg(H,u,g,I,Q,i,C,D,E+1,l,!s),oQ.releasePrimitive(l)}}return J}const za=new ag,SB=new Float32Array(6);class _a{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(A){A={...Xa,...A},ir(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,i=1/0,E=1/0,D=-1/0,o=-1/0,s=-1/0;for(let t=A,w=A+I;t<w;t++){this.writePrimitiveBounds(t,SB,0);const[a,G,r,c,y,R]=SB;a<C&&(C=a),c>D&&(D=c),G<i&&(i=G),y>o&&(o=y),r<E&&(E=r),R>s&&(s=R)}return g[Q+0]=C,g[Q+1]=i,g[Q+2]=E,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,i=A+I;C<i;C++){this.writePrimitiveBounds(C,SB,0);const[E,D,o,s,t,w]=SB,a=(E+s)/2,G=(D+t)/2,r=(o+w)/2,c=(s-E)/2,y=(t-D)/2,R=(w-o)/2,S=(C-Q)*6;g[S+0]=a,g[S+1]=c+(Math.abs(a)+c)*Bi,g[S+2]=G,g[S+3]=y+(Math.abs(G)+y)*Bi,g[S+4]=r,g[S+5]=R+(Math.abs(r)+R)*Bi}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],i=new Uint32Array(C),E=new Uint16Array(C),D=C.byteLength/SI;for(let o=0;o<D;o++){const s=jA*o,t=2*s;zA(t,E)&&(i[s+6]+=A)}}}}traverse(A,I=0){const g=this._roots[I],Q=new Uint32Array(g),C=new Uint16Array(g);i(0);function i(E,D=0){const o=E*2,s=zA(o,C);if(s){const t=Q[E+6],w=C[o+14];A(D,s,new Float32Array(g,E*4,6),t,w)}else{const t=CI(E),w=EI(E,Q),a=No(E,Q);A(D,s,new Float32Array(g,E*4,6),a)||(i(t,D+1),i(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),i=new Uint16Array(Q),E=new Float32Array(Q),D=Q.byteLength/SI;for(let o=D-1;o>=0;o--){const s=o*jA,t=s*2;if(zA(t,i)){const w=rI(s,C),a=lI(t,i);this.writePrimitiveRangeBounds(w,a,SB,0),E.set(SB,s)}else{const w=CI(s),a=EI(s,C);for(let G=0;G<3;G++){const r=E[w+G],c=E[w+G+3],y=E[a+G],R=E[a+G+3];E[s+G]=r<y?r:y,E[s+G+3]=c>R?c:R}}}}}getBoundingBox(A){return A.makeEmpty(),this._roots.forEach(I=>{mA(0,new Float32Array(I),za),A.union(za)}),A}shapecast(A){let{boundsTraverseOrder:I,intersectsBounds:g,intersectsRange:Q,intersectsPrimitive:C,scratchPrimitive:i,iterate:E}=A;if(Q&&C){const t=Q;Q=(w,a,G,r,c)=>t(w,a,G,r,c)?!0:E(w,a,this,C,G,r,i)}else Q||(C?Q=(t,w,a,G)=>E(t,w,this,C,a,G,i):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=or(this,t,g,Q,I,o),D)break;o+=a.byteLength/SI}return D}bvhcast(A,I,g){let{intersectsRanges:Q}=g;return sr(this,A,I,Q)}}function tr(){return typeof SharedArrayBuffer<"u"}function xo(B){return B.index?B.index.count:B.attributes.position.count}function ti(B){return xo(B)/3}function wr(B,A=ArrayBuffer){return B>65535?new Uint32Array(new A(4*B)):new Uint16Array(new A(2*B))}function ar(B,A){if(!B.index){const I=B.attributes.position.count,g=A.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,Q=wr(I,g);B.setIndex(new iI(Q,1));for(let C=0;C<I;C++)Q[C]=C}}function er(B,A,I){const g=xo(B)/I,Q=A||B.drawRange,C=Q.start/I,i=(Q.start+Q.count)/I,E=Math.max(0,C),D=Math.min(g,i)-E;return{offset:Math.floor(E),count:Math.floor(D)}}function hr(B,A){return B.groups.map(I=>({offset:I.start/A,count:I.count/A}))}function $a(B,A,I){const g=er(B,A,I),Q=hr(B,I);if(!Q.length)return[g];const C=[],i=g.offset,E=g.offset+g.count,D=xo(B)/I,o=[];for(const w of Q){const{offset:a,count:G}=w,r=a,c=isFinite(G)?G:D-a,y=a+c;r<E&&y>i&&(o.push({pos:Math.max(i,r),isStart:!0}),o.push({pos:Math.min(E,y),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 Ae(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,i=A?new SharedArrayBuffer(Q*C):new ArrayBuffer(Q*C),E=g?new Uint32Array(i):new Uint16Array(i);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++)E[D+w]=s+w;D+=t}return E}class Ie extends _a{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&&!tr())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={...Xa,...I},I[Ci]||this.init(I)}init(A){const{geometry:I,primitiveStride:g}=this;if(A.indirect){const Q=$a(I,A.range,g),C=Ae(Q,A.useSharedArrayBuffer);this._indirectBuffer=C}else ar(I,A);super.init(A),!I.boundingBox&&A.setBoundingBox&&(I.boundingBox=this.getBoundingBox(new ag))}getRootRanges(A){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:$a(this.geometry,A,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Vg{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(A,I){let g=1/0,Q=-1/0;for(let C=0,i=A.length;C<i;C++){const E=A[C][I];g=E<g?E:g,Q=E>Q?E:Q}this.min=g,this.max=Q}setFromPoints(A,I){let g=1/0,Q=-1/0;for(let C=0,i=I.length;C<i;C++){const E=I[C],D=A.dot(E);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}}Vg.prototype.setFromBox=function(){const B=new q;return function(A,I){const g=I.min,Q=I.max;let C=1/0,i=-1/0;for(let E=0;E<=1;E++)for(let D=0;D<=1;D++)for(let o=0;o<=1;o++){B.x=g.x*E+Q.x*(1-E),B.y=g.y*D+Q.y*(1-D),B.z=g.z*o+Q.z*(1-o);const s=A.dot(B);C=Math.min(s,C),i=Math.max(s,i)}this.min=C,this.max=i}}();const cr=function(){const B=new q,A=new q,I=new q;return function(g,Q,C){const i=g.start,E=B,D=Q.start,o=A;I.subVectors(i,D),B.subVectors(g.end,g.start),A.subVectors(Q.end,Q.start);const s=I.dot(o),t=o.dot(E),w=o.dot(o),a=I.dot(E),G=E.dot(E)*w-t*t;let r,c;G!==0?r=(s*t-a*w)/G:r=0,c=(s+r*t)/w,C.x=r,C.y=c}}(),qo=function(){const B=new JI,A=new q,I=new q;return function(g,Q,C,i){cr(g,Q,B);let E=B.x,D=B.y;if(E>=0&&E<=1&&D>=0&&D<=1){g.at(E,C),Q.at(D,i);return}else if(E>=0&&E<=1){D<0?Q.at(0,i):Q.at(1,i),g.closestPointToPoint(i,!0,C);return}else if(D>=0&&D<=1){E<0?g.at(0,C):g.at(1,C),Q.closestPointToPoint(C,!0,i);return}else{let o;E<0?o=g.start:o=g.end;let s;D<0?s=Q.start:s=Q.end;const t=A,w=I;if(g.closestPointToPoint(s,!0,A),Q.closestPointToPoint(o,!0,I),t.distanceToSquared(s)<=w.distanceToSquared(o)){C.copy(t),i.copy(s);return}else{C.copy(o),i.copy(w);return}}}}(),yr=function(){const B=new q,A=new q,I=new Ys,g=new bg;return function(Q,C){const{radius:i,center:E}=Q,{a:D,b:o,c:s}=C;if(g.start=D,g.end=o,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i||(g.start=D,g.end=s,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i)||(g.start=o,g.end=s,g.closestPointToPoint(E,!0,B).distanceTo(E)<=i))return!0;const t=C.getPlane(I);if(Math.abs(t.distanceToPoint(E))<=i){const w=t.projectPoint(E,A);if(C.containsPoint(w))return!0}return!1}}(),Gr=["x","y","z"],Wg=1e-15,ge=Wg*Wg;function gg(B){return Math.abs(B)<Wg}class Qg extends eQ{constructor(...A){super(...A),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new q),this.satBounds=new Array(4).fill().map(()=>new Vg),this.points=[this.a,this.b,this.c],this.plane=new Ys,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new bg,this.needsUpdate=!0}intersectsSphere(A){return yr(A,this)}update(){const A=this.a,I=this.b,g=this.c,Q=this.points,C=this.satAxes,i=this.satBounds,E=C[0],D=i[0];this.getNormal(E),D.setFromPoints(E,Q);const o=C[1],s=i[1];o.subVectors(A,I),s.setFromPoints(o,Q);const t=C[2],w=i[2];t.subVectors(I,g),w.setFromPoints(t,Q);const a=C[3],G=i[3];a.subVectors(g,A),G.setFromPoints(a,Q);const r=o.length(),c=t.length(),y=a.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,r<Wg?c<Wg||y<Wg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(A),this.degenerateSegment.end.copy(g)):c<Wg?y<Wg?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(I),this.degenerateSegment.end.copy(A)):y<Wg&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(g),this.degenerateSegment.end.copy(I)),this.plane.setFromNormalAndCoplanarPoint(E,A),this.needsUpdate=!1}}Qg.prototype.closestPointToSegment=function(){const B=new q,A=new q,I=new bg;return function(g,Q=null,C=null){const{start:i,end:E}=g,D=this.points;let o,s=1/0;for(let t=0;t<3;t++){const w=(t+1)%3;I.start.copy(D[t]),I.end.copy(D[w]),qo(I,g,B,A),o=B.distanceToSquared(A),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(A))}return this.closestPointToPoint(i,B),o=i.distanceToSquared(B),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(i)),this.closestPointToPoint(E,B),o=E.distanceToSquared(B),o<s&&(s=o,Q&&Q.copy(B),C&&C.copy(E)),Math.sqrt(s)}}(),Qg.prototype.intersectsTriangle=function(){const B=new Qg,A=new Vg,I=new Vg,g=new q,Q=new q,C=new q,i=new q,E=new bg,D=new bg,o=new q,s=new JI,t=new JI;function w(S,n,N,M){const J=g;!S.isDegenerateIntoPoint&&!S.isDegenerateIntoSegment?J.copy(S.plane.normal):J.copy(n.plane.normal);const L=S.satBounds,H=S.satAxes;for(let l=1;l<4;l++){const p=L[l],u=H[l];if(A.setFromPoints(u,n.points),p.isSeparated(A)||(i.copy(J).cross(u),A.setFromPoints(i,S.points),I.setFromPoints(i,n.points),A.isSeparated(I)))return!1}const Y=n.satBounds,d=n.satAxes;for(let l=1;l<4;l++){const p=Y[l],u=d[l];if(A.setFromPoints(u,S.points),p.isSeparated(A)||(i.crossVectors(J,u),A.setFromPoints(i,S.points),I.setFromPoints(i,n.points),A.isSeparated(I)))return!1}return N&&(M||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),N.start.set(0,0,0),N.end.set(0,0,0)),!0}function a(S,n,N,M,J,L,H,Y,d,l,p){let u=H/(H-Y);l.x=M+(J-M)*u,p.start.subVectors(n,S).multiplyScalar(u).add(S),u=H/(H-d),l.y=M+(L-M)*u,p.end.subVectors(N,S).multiplyScalar(u).add(S)}function G(S,n,N,M,J,L,H,Y,d,l,p){if(J>0)a(S.c,S.a,S.b,M,n,N,d,H,Y,l,p);else if(L>0)a(S.b,S.a,S.c,N,n,M,Y,H,d,l,p);else if(Y*d>0||H!=0)a(S.a,S.b,S.c,n,N,M,H,Y,d,l,p);else if(Y!=0)a(S.b,S.a,S.c,N,n,M,Y,H,d,l,p);else if(d!=0)a(S.c,S.a,S.b,M,n,N,d,H,Y,l,p);else return!0;return!1}function r(S,n,N,M){const J=n.degenerateSegment,L=S.plane.distanceToPoint(J.start),H=S.plane.distanceToPoint(J.end);return gg(L)?gg(H)?w(S,n,N,M):(N&&(N.start.copy(J.start),N.end.copy(J.start)),S.containsPoint(J.start)):gg(H)?(N&&(N.start.copy(J.end),N.end.copy(J.end)),S.containsPoint(J.end)):S.plane.intersectLine(J,g)!=null?(N&&(N.start.copy(g),N.end.copy(g)),S.containsPoint(g)):!1}function c(S,n,N){const M=n.a;return gg(S.plane.distanceToPoint(M))&&S.containsPoint(M)?(N&&(N.start.copy(M),N.end.copy(M)),!0):!1}function y(S,n,N){const M=S.degenerateSegment,J=n.a;return M.closestPointToPoint(J,!0,g),J.distanceToSquared(g)<ge?(N&&(N.start.copy(J),N.end.copy(J)),!0):!1}function R(S,n,N,M){if(S.isDegenerateIntoSegment)if(n.isDegenerateIntoSegment){const J=S.degenerateSegment,L=n.degenerateSegment,H=Q,Y=C;J.delta(H),L.delta(Y);const d=g.subVectors(L.start,J.start),l=H.x*Y.y-H.y*Y.x;if(gg(l))return!1;const p=(d.x*Y.y-d.y*Y.x)/l,u=-(H.x*d.y-H.y*d.x)/l;if(p<0||p>1||u<0||u>1)return!1;const P=J.start.z+H.z*p,O=L.start.z+Y.z*u;return gg(P-O)?(N&&(N.start.copy(J.start).addScaledVector(H,p),N.end.copy(J.start).addScaledVector(H,p)),!0):!1}else return n.isDegenerateIntoPoint?y(S,n,N):r(n,S,N,M);else{if(S.isDegenerateIntoPoint)return n.isDegenerateIntoPoint?n.a.distanceToSquared(S.a)<ge?(N&&(N.start.copy(S.a),N.end.copy(S.a)),!0):!1:n.isDegenerateIntoSegment?y(n,S,N):c(n,S,N);if(n.isDegenerateIntoPoint)return c(S,n,N);if(n.isDegenerateIntoSegment)return r(S,n,N,M)}}return function(S,n=null,N=!1){this.needsUpdate&&this.update(),S.isExtendedTriangle?S.needsUpdate&&S.update():(B.copy(S),B.update(),S=B);const M=R(this,S,n,N);if(M!==void 0)return M;const J=this.plane,L=S.plane;let H=L.distanceToPoint(this.a),Y=L.distanceToPoint(this.b),d=L.distanceToPoint(this.c);gg(H)&&(H=0),gg(Y)&&(Y=0),gg(d)&&(d=0);const l=H*Y,p=H*d;if(l>0&&p>0)return!1;let u=J.distanceToPoint(S.a),P=J.distanceToPoint(S.b),O=J.distanceToPoint(S.c);gg(u)&&(u=0),gg(P)&&(P=0),gg(O)&&(O=0);const W=u*P,T=u*O;if(W>0&&T>0)return!1;Q.copy(J.normal),C.copy(L.normal);const j=Q.cross(C);let EA=0,wA=Math.abs(j.x);const iA=Math.abs(j.y);iA>wA&&(wA=iA,EA=1),Math.abs(j.z)>wA&&(EA=2);const IA=Gr[EA],BA=this.a[IA],AA=this.b[IA],$=this.c[IA],z=S.a[IA],LA=S.b[IA],NA=S.c[IA];if(G(this,BA,AA,$,l,p,H,Y,d,s,E))return w(this,S,n,N);if(G(S,z,LA,NA,W,T,u,P,O,t,D))return w(this,S,n,N);if(s.y<s.x){const MA=s.y;s.y=s.x,s.x=MA,o.copy(E.start),E.start.copy(E.end),E.end.copy(o)}if(t.y<t.x){const MA=t.y;t.y=t.x,t.x=MA,o.copy(D.start),D.start.copy(D.end),D.end.copy(o)}return s.y<t.x||t.y<s.x?!1:(n&&(t.x>s.x?n.start.copy(D.start):n.start.copy(E.start),t.y<s.y?n.end.copy(D.end):n.end.copy(E.end)),!0)}}(),Qg.prototype.distanceToPoint=function(){const B=new q;return function(A){return this.closestPointToPoint(A,B),A.distanceTo(B)}}(),Qg.prototype.distanceToTriangle=function(){const B=new q,A=new q,I=["a","b","c"],g=new bg,Q=new bg;return function(C,i=null,E=null){const D=i||E?g:null;if(this.intersectsTriangle(C,D))return(i||E)&&(i&&D.getCenter(i),E&&D.getCenter(E)),0;let o=1/0;for(let s=0;s<3;s++){let t;const w=I[s],a=C[w];this.closestPointToPoint(a,B),t=a.distanceToSquared(B),t<o&&(o=t,i&&i.copy(B),E&&E.copy(a));const G=this[w];C.closestPointToPoint(G,B),t=G.distanceToSquared(B),t<o&&(o=t,i&&i.copy(G),E&&E.copy(B))}for(let s=0;s<3;s++){const t=I[s],w=I[(s+1)%3];g.set(this[t],this[w]);for(let a=0;a<3;a++){const G=I[a],r=I[(a+1)%3];Q.set(C[G],C[r]),qo(g,Q,B,A);const c=B.distanceToSquared(A);c<o&&(o=c,i&&i.copy(B),E&&E.copy(A))}}return Math.sqrt(o)}}();class FI{constructor(A,I,g){this.isOrientedBox=!0,this.min=new q,this.max=new q,this.matrix=new fA,this.invMatrix=new fA,this.points=new Array(8).fill().map(()=>new q),this.satAxes=new Array(3).fill().map(()=>new q),this.satBounds=new Array(3).fill().map(()=>new Vg),this.alignedSatBounds=new Array(3).fill().map(()=>new Vg),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}}FI.prototype.update=function(){return function(){const B=this.matrix,A=this.min,I=this.max,g=this.points;for(let D=0;D<=1;D++)for(let o=0;o<=1;o++)for(let s=0;s<=1;s++){const t=1*D|2*o|4*s,w=g[t];w.x=D?I.x:A.x,w.y=o?I.y:A.y,w.z=s?I.z:A.z,w.applyMatrix4(B)}const Q=this.satBounds,C=this.satAxes,i=g[0];for(let D=0;D<3;D++){const o=C[D],s=Q[D],t=1<<D,w=g[t];o.subVectors(i,w),s.setFromPoints(o,g)}const E=this.alignedSatBounds;E[0].setFromPointsField(g,"x"),E[1].setFromPointsField(g,"y"),E[2].setFromPointsField(g,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),FI.prototype.intersectsBox=function(){const B=new Vg;return function(A){this.needsUpdate&&this.update();const I=A.min,g=A.max,Q=this.satBounds,C=this.satAxes,i=this.alignedSatBounds;if(B.min=I.x,B.max=g.x,i[0].isSeparated(B)||(B.min=I.y,B.max=g.y,i[1].isSeparated(B))||(B.min=I.z,B.max=g.z,i[2].isSeparated(B)))return!1;for(let E=0;E<3;E++){const D=C[E],o=Q[E];if(B.setFromBox(D,A),o.isSeparated(B))return!1}return!0}}(),FI.prototype.intersectsTriangle=function(){const B=new Qg,A=new Array(3),I=new Vg,g=new Vg,Q=new q;return function(C){this.needsUpdate&&this.update(),C.isExtendedTriangle?C.needsUpdate&&C.update():(B.copy(C),B.update(),C=B);const i=this.satBounds,E=this.satAxes;A[0]=C.a,A[1]=C.b,A[2]=C.c;for(let t=0;t<3;t++){const w=i[t],a=E[t];if(I.setFromPoints(a,A),w.isSeparated(I))return!1}const D=C.satBounds,o=C.satAxes,s=this.points;for(let t=0;t<3;t++){const w=D[t],a=o[t];if(I.setFromPoints(a,s),w.isSeparated(I))return!1}for(let t=0;t<3;t++){const w=E[t];for(let a=0;a<4;a++){const G=o[a];if(Q.crossVectors(w,G),I.setFromPoints(Q,A),g.setFromPoints(Q,s),I.isSeparated(g))return!1}}return!0}}(),FI.prototype.closestPointToPoint=function(){return function(B,A){return this.needsUpdate&&this.update(),A.copy(B).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),A}}(),FI.prototype.distanceToPoint=function(){const B=new q;return function(A){return this.closestPointToPoint(A,B),A.distanceTo(B)}}(),FI.prototype.distanceToBox=function(){const B=["x","y","z"],A=new Array(12).fill().map(()=>new bg),I=new Array(12).fill().map(()=>new bg),g=new q,Q=new q;return function(C,i=0,E=null,D=null){if(this.needsUpdate&&this.update(),this.intersectsBox(C))return(E||D)&&(C.getCenter(Q),this.closestPointToPoint(Q,g),C.closestPointToPoint(g,Q),E&&E.copy(g),D&&D.copy(Q)),0;const o=i*i,s=C.min,t=C.max,w=this.points;let a=1/0;for(let r=0;r<8;r++){const c=w[r];Q.copy(c).clamp(s,t);const y=c.distanceToSquared(Q);if(y<a&&(a=y,E&&E.copy(c),D&&D.copy(Q),y<o))return Math.sqrt(y)}let G=0;for(let r=0;r<3;r++)for(let c=0;c<=1;c++)for(let y=0;y<=1;y++){const R=(r+1)%3,S=(r+2)%3,n=c<<R|y<<S,N=1<<r|c<<R|y<<S,M=w[n],J=w[N];A[G].set(M,J);const L=B[r],H=B[R],Y=B[S],d=I[G],l=d.start,p=d.end;l[L]=s[L],l[H]=c?s[H]:t[H],l[Y]=y?s[Y]:t[H],p[L]=t[L],p[H]=c?s[H]:t[H],p[Y]=y?s[Y]:t[H],G++}for(let r=0;r<=1;r++)for(let c=0;c<=1;c++)for(let y=0;y<=1;y++){Q.x=r?t.x:s.x,Q.y=c?t.y:s.y,Q.z=y?t.z:s.z,this.closestPointToPoint(Q,g);const R=Q.distanceToSquared(g);if(R<a&&(a=R,E&&E.copy(g),D&&D.copy(Q),R<o))return Math.sqrt(R)}for(let r=0;r<12;r++){const c=A[r];for(let y=0;y<12;y++){const R=I[y];qo(c,R,g,Q);const S=g.distanceToSquared(Q);if(S<a&&(a=S,E&&E.copy(g),D&&D.copy(Q),S<o))return Math.sqrt(S)}}return Math.sqrt(a)}}();class Sr extends Yo{constructor(){super(()=>new Qg)}}const Bg=new Sr,hC=new q,uo=new q;function rr(B,A,I={},g=0,Q=1/0){const C=g*g,i=Q*Q;let E=1/0,D=null;if(B.shapecast({boundsTraverseOrder:s=>(hC.copy(A).clamp(s.min,s.max),hC.distanceToSquared(A)),intersectsBounds:(s,t,w)=>w<E&&w<i,intersectsTriangle:(s,t)=>{s.closestPointToPoint(A,hC);const w=A.distanceToSquared(hC);return w<E&&(uo.copy(hC),E=w,D=t),w<C}}),E===1/0)return null;const o=Math.sqrt(E);return I.point?I.point.copy(uo):I.point=uo.clone(),I.distance=o,I.faceIndex=D,I}const wi=parseInt(ji)>=169,Fr=parseInt(ji)<=161,HQ=new q,YQ=new q,KQ=new q,ai=new JI,ei=new JI,hi=new JI,Qe=new q,Be=new q,Ce=new q,cC=new q;function Rr(B,A,I,g,Q,C,i,E){let D;if(C===ze?D=B.intersectTriangle(g,I,A,!0,Q):D=B.intersectTriangle(A,I,g,C!==dB,Q),D===null)return null;const o=B.origin.distanceTo(Q);return o<i||o>E?null:{distance:o,point:Q.clone()}}function Ee(B,A,I,g,Q,C,i,E,D,o,s){HQ.fromBufferAttribute(A,C),YQ.fromBufferAttribute(A,i),KQ.fromBufferAttribute(A,E);const t=Rr(B,HQ,YQ,KQ,cC,D,o,s);if(t){if(g){ai.fromBufferAttribute(g,C),ei.fromBufferAttribute(g,i),hi.fromBufferAttribute(g,E),t.uv=new JI;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,ai,ei,hi,t.uv);wi||(t.uv=a)}if(Q){ai.fromBufferAttribute(Q,C),ei.fromBufferAttribute(Q,i),hi.fromBufferAttribute(Q,E),t.uv1=new JI;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,ai,ei,hi,t.uv1);wi||(t.uv1=a),Fr&&(t.uv2=t.uv1)}if(I){Qe.fromBufferAttribute(I,C),Be.fromBufferAttribute(I,i),Ce.fromBufferAttribute(I,E),t.normal=new q;const a=eQ.getInterpolation(cC,HQ,YQ,KQ,Qe,Be,Ce,t.normal);t.normal.dot(B.direction)>0&&t.normal.multiplyScalar(-1),wi||(t.normal=a)}const w={a:C,b:i,c:E,normal:new q,materialIndex:0};if(eQ.getNormal(HQ,YQ,KQ,w.normal),t.face=w,t.faceIndex=C,wi){const a=new q;eQ.getBarycoord(cC,HQ,YQ,KQ,a),t.barycoord=a}}return t}function ie(B){return B&&B.isMaterial?B.side:B}function ci(B,A,I,g,Q,C,i){const E=g*3;let D=E+0,o=E+1,s=E+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:G,uv:r,uv1:c}=B.attributes;if(Array.isArray(A)){const y=g*3;for(let R=0,S=w.length;R<S;R++){const{start:n,count:N,materialIndex:M}=w[R];if(y>=n&&y<n+N){const J=ie(A[M]),L=Ee(I,a,G,r,c,D,o,s,J,C,i);if(L)if(L.faceIndex=g,L.face.materialIndex=M,Q)Q.push(L);else return L}}}else{const y=ie(A),R=Ee(I,a,G,r,c,D,o,s,y,C,i);if(R)if(R.faceIndex=g,R.face.materialIndex=0,Q)Q.push(R);else return R}return null}function vA(B,A,I,g){const Q=B.a,C=B.b,i=B.c;let E=A,D=A+1,o=A+2;I&&(E=I.getX(E),D=I.getX(D),o=I.getX(o)),Q.x=g.getX(E),Q.y=g.getY(E),Q.z=g.getZ(E),C.x=g.getX(D),C.y=g.getY(D),C.z=g.getZ(D),i.x=g.getX(o),i.y=g.getY(o),i.z=g.getZ(o)}function kr(B,A,I,g,Q,C,i,E){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++)ci(D,A,I,s,C,i,E)}function nr(B,A,I,g,Q,C,i){const{geometry:E,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=ci(E,A,I,t,null,C,i),a&&a.distance<o&&(s=a,o=a.distance)}return s}function Nr(B,A,I,g,Q,C,i){const{geometry:E}=I,{index:D}=E,o=E.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=s,vA(i,w*3,D,o),i.needsUpdate=!0,g(i,w,Q,C))return!0}return!1}function Mr(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,i,E,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],i=new Uint32Array(C),E=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,G=!1){const r=w*2;if(zA(r,E)){const c=rI(w,i),y=lI(r,E);let R=1/0,S=1/0,n=1/0,N=-1/0,M=-1/0,J=-1/0;for(let L=3*c,H=3*(c+y);L<H;L++){let Y=g[L];const d=Q.getX(Y),l=Q.getY(Y),p=Q.getZ(Y);d<R&&(R=d),d>N&&(N=d),l<S&&(S=l),l>M&&(M=l),p<n&&(n=p),p>J&&(J=p)}return D[w+0]!==R||D[w+1]!==S||D[w+2]!==n||D[w+3]!==N||D[w+4]!==M||D[w+5]!==J?(D[w+0]=R,D[w+1]=S,D[w+2]=n,D[w+3]=N,D[w+4]=M,D[w+5]=J,!0):!1}else{const c=CI(w),y=EI(w,i);let R=G,S=!1,n=!1;if(A){if(!R){const Y=c/jA+a/SI,d=y/jA+a/SI;S=A.has(Y),n=A.has(d),R=!S&&!n}}else S=!0,n=!0;const N=R||S,M=R||n;let J=!1;N&&(J=t(c,a,R));let L=!1;M&&(L=t(y,a,R));const H=J||L;if(H)for(let Y=0;Y<3;Y++){const d=c+Y,l=y+Y,p=D[d],u=D[d+3],P=D[l],O=D[l+3];D[w+Y]=p<P?p:P,D[w+Y+3]=u>O?u:O}return H}}}function sQ(B,A,I,g,Q){let C,i,E,D,o,s;const t=1/I.direction.x,w=1/I.direction.y,a=1/I.direction.z,G=I.origin.x,r=I.origin.y,c=I.origin.z;let y=A[B],R=A[B+3],S=A[B+1],n=A[B+3+1],N=A[B+2],M=A[B+3+2];return t>=0?(C=(y-G)*t,i=(R-G)*t):(C=(R-G)*t,i=(y-G)*t),w>=0?(E=(S-r)*w,D=(n-r)*w):(E=(n-r)*w,D=(S-r)*w),C>D||E>i||((E>C||isNaN(C))&&(C=E),(D<i||isNaN(i))&&(i=D),a>=0?(o=(N-c)*a,s=(M-c)*a):(o=(M-c)*a,s=(N-c)*a),C>s||o>i)?!1:((o>C||C!==C)&&(C=o),(s<i||i!==i)&&(i=s),C<=Q&&i>=g)}function Jr(B,A,I,g,Q,C,i,E){const{geometry:D,_indirectBuffer:o}=B;for(let s=g,t=g+Q;s<t;s++){let w=o?o[s]:s;ci(D,A,I,w,C,i,E)}}function Ur(B,A,I,g,Q,C,i){const{geometry:E,_indirectBuffer:D}=B;let o=1/0,s=null;for(let t=g,w=g+Q;t<w;t++){let a;a=ci(E,A,I,D?D[t]:t,null,C,i),a&&a.distance<o&&(s=a,o=a.distance)}return s}function Lr(B,A,I,g,Q,C,i){const{geometry:E}=I,{index:D}=E,o=E.attributes.position;for(let s=B,t=A+B;s<t;s++){let w;if(w=I.resolveTriangleIndex(s),vA(i,w*3,D,o),i.needsUpdate=!0,g(i,w,Q,C))return!0}return!1}function Hr(B,A,I,g,Q,C,i){KA.setBuffer(B._roots[A]),bo(0,B,I,g,Q,C,i),KA.clearBuffer()}function bo(B,A,I,g,Q,C,i){const{float32Array:E,uint16Array:D,uint32Array:o}=KA,s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);kr(A,I,g,t,w,Q,C,i)}else{const t=CI(B);sQ(t,E,g,C,i)&&bo(t,A,I,g,Q,C,i);const w=EI(B,o);sQ(w,E,g,C,i)&&bo(w,A,I,g,Q,C,i)}}const Yr=["x","y","z"];function Kr(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const i=mo(0,B,I,g,Q,C);return KA.clearBuffer(),i}function mo(B,A,I,g,Q,C){const{float32Array:i,uint16Array:E,uint32Array:D}=KA;let o=B*2;if(zA(o,E)){const s=rI(B,D),t=lI(o,E);return nr(A,I,g,s,t,Q,C)}else{const s=No(B,D),t=Yr[s],w=g.direction[t]>=0;let a,G;w?(a=CI(B),G=EI(B,D)):(a=EI(B,D),G=CI(B));const r=sQ(a,i,g,Q,C)?mo(a,A,I,g,Q,C):null;if(r){const y=r.point[t];if(w?y<=i[G+s]:y>=i[G+s+3])return r}const c=sQ(G,i,g,Q,C)?mo(G,A,I,g,Q,C):null;return r&&c?r.distance<=c.distance?r:c:r||c||null}}const yi=new ag,rB=new Qg,FB=new Qg,yC=new fA,De=new FI,Gi=new FI;function dr(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=Po(0,B,I,g);return KA.clearBuffer(),Q}function Po(B,A,I,g,Q=null){const{float32Array:C,uint16Array:i,uint32Array:E}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),De.set(I.boundingBox.min,I.boundingBox.max,g),Q=De),zA(D,i)){const o=A.geometry,s=o.index,t=o.attributes.position,w=I.index,a=I.attributes.position,G=rI(B,E),r=lI(D,i);if(yC.copy(g).invert(),I.boundsTree)return mA(B,C,Gi),Gi.matrix.copy(yC),Gi.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:c=>Gi.intersectsBox(c),intersectsTriangle:c=>{c.a.applyMatrix4(g),c.b.applyMatrix4(g),c.c.applyMatrix4(g),c.needsUpdate=!0;for(let y=G*3,R=(r+G)*3;y<R;y+=3)if(vA(FB,y,s,t),FB.needsUpdate=!0,c.intersectsTriangle(FB))return!0;return!1}});{const c=ti(I);for(let y=G*3,R=(r+G)*3;y<R;y+=3){vA(rB,y,s,t),rB.a.applyMatrix4(yC),rB.b.applyMatrix4(yC),rB.c.applyMatrix4(yC),rB.needsUpdate=!0;for(let S=0,n=c*3;S<n;S+=3)if(vA(FB,S,w,a),FB.needsUpdate=!0,rB.intersectsTriangle(FB))return!0}}}else{const o=CI(B),s=EI(B,E);return mA(o,C,yi),!!(Q.intersectsBox(yi)&&Po(o,A,I,g,Q)||(mA(s,C,yi),Q.intersectsBox(yi)&&Po(s,A,I,g,Q)))}}const Si=new fA,To=new FI,GC=new FI,lr=new q,fr=new q,pr=new q,xr=new q;function qr(B,A,I,g={},Q={},C=0,i=1/0){A.boundingBox||A.computeBoundingBox(),To.set(A.boundingBox.min,A.boundingBox.max,I),To.needsUpdate=!0;const E=B.geometry,D=E.attributes.position,o=E.index,s=A.attributes.position,t=A.index,w=Bg.getPrimitive(),a=Bg.getPrimitive();let G=lr,r=fr,c=null,y=null;Q&&(c=pr,y=xr);let R=1/0,S=null,n=null;return Si.copy(I).invert(),GC.matrix.copy(Si),B.shapecast({boundsTraverseOrder:N=>To.distanceToBox(N),intersectsBounds:(N,M,J)=>J<R&&J<i?(M&&(GC.min.copy(N.min),GC.max.copy(N.max),GC.needsUpdate=!0),!0):!1,intersectsRange:(N,M)=>{if(A.boundsTree)return A.boundsTree.shapecast({boundsTraverseOrder:J=>GC.distanceToBox(J),intersectsBounds:(J,L,H)=>H<R&&H<i,intersectsRange:(J,L)=>{for(let H=J,Y=J+L;H<Y;H++){vA(a,3*H,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let d=N,l=N+M;d<l;d++){vA(w,3*d,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,G,c);if(p<R&&(r.copy(G),y&&y.copy(c),R=p,S=d,n=H),p<C)return!0}}}});{const J=ti(A);for(let L=0,H=J;L<H;L++){vA(a,3*L,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let Y=N,d=N+M;Y<d;Y++){vA(w,3*Y,o,D),w.needsUpdate=!0;const l=w.distanceToTriangle(a,G,c);if(l<R&&(r.copy(G),y&&y.copy(c),R=l,S=Y,n=L),l<C)return!0}}}}}),Bg.releasePrimitive(w),Bg.releasePrimitive(a),R===1/0?null:(g.point?g.point.copy(r):g.point=r.clone(),g.distance=R,g.faceIndex=S,Q&&(Q.point?Q.point.copy(y):Q.point=y.clone(),Q.point.applyMatrix4(Si),r.applyMatrix4(Si),Q.distance=r.sub(Q.point).length(),Q.faceIndex=n),g)}function ur(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,i,E,D,o=0;const s=B._roots;for(let w=0,a=s.length;w<a;w++)C=s[w],i=new Uint32Array(C),E=new Uint16Array(C),D=new Float32Array(C),t(0,o),o+=C.byteLength;function t(w,a,G=!1){const r=w*2;if(zA(r,E)){const c=rI(w,i),y=lI(r,E);let R=1/0,S=1/0,n=1/0,N=-1/0,M=-1/0,J=-1/0;for(let L=c,H=c+y;L<H;L++){const Y=3*B.resolveTriangleIndex(L);for(let d=0;d<3;d++){let l=Y+d;l=g?g[l]:l;const p=Q.getX(l),u=Q.getY(l),P=Q.getZ(l);p<R&&(R=p),p>N&&(N=p),u<S&&(S=u),u>M&&(M=u),P<n&&(n=P),P>J&&(J=P)}}return D[w+0]!==R||D[w+1]!==S||D[w+2]!==n||D[w+3]!==N||D[w+4]!==M||D[w+5]!==J?(D[w+0]=R,D[w+1]=S,D[w+2]=n,D[w+3]=N,D[w+4]=M,D[w+5]=J,!0):!1}else{const c=CI(w),y=EI(w,i);let R=G,S=!1,n=!1;if(A){if(!R){const Y=c/jA+a/SI,d=y/jA+a/SI;S=A.has(Y),n=A.has(d),R=!S&&!n}}else S=!0,n=!0;const N=R||S,M=R||n;let J=!1;N&&(J=t(c,a,R));let L=!1;M&&(L=t(y,a,R));const H=J||L;if(H)for(let Y=0;Y<3;Y++){const d=c+Y,l=y+Y,p=D[d],u=D[d+3],P=D[l],O=D[l+3];D[w+Y]=p<P?p:P,D[w+Y+3]=u>O?u:O}return H}}}function br(B,A,I,g,Q,C,i){KA.setBuffer(B._roots[A]),Oo(0,B,I,g,Q,C,i),KA.clearBuffer()}function Oo(B,A,I,g,Q,C,i){const{float32Array:E,uint16Array:D,uint32Array:o}=KA,s=B*2;if(zA(s,D)){const t=rI(B,o),w=lI(s,D);Jr(A,I,g,t,w,Q,C,i)}else{const t=CI(B);sQ(t,E,g,C,i)&&Oo(t,A,I,g,Q,C,i);const w=EI(B,o);sQ(w,E,g,C,i)&&Oo(w,A,I,g,Q,C,i)}}const mr=["x","y","z"];function Pr(B,A,I,g,Q,C){KA.setBuffer(B._roots[A]);const i=Xo(0,B,I,g,Q,C);return KA.clearBuffer(),i}function Xo(B,A,I,g,Q,C){const{float32Array:i,uint16Array:E,uint32Array:D}=KA;let o=B*2;if(zA(o,E)){const s=rI(B,D),t=lI(o,E);return Ur(A,I,g,s,t,Q,C)}else{const s=No(B,D),t=mr[s],w=g.direction[t]>=0;let a,G;w?(a=CI(B),G=EI(B,D)):(a=EI(B,D),G=CI(B));const r=sQ(a,i,g,Q,C)?Xo(a,A,I,g,Q,C):null;if(r){const y=r.point[t];if(w?y<=i[G+s]:y>=i[G+s+3])return r}const c=sQ(G,i,g,Q,C)?Xo(G,A,I,g,Q,C):null;return r&&c?r.distance<=c.distance?r:c:r||c||null}}const ri=new ag,RB=new Qg,kB=new Qg,SC=new fA,oe=new FI,Fi=new FI;function Tr(B,A,I,g){KA.setBuffer(B._roots[A]);const Q=vo(0,B,I,g);return KA.clearBuffer(),Q}function vo(B,A,I,g,Q=null){const{float32Array:C,uint16Array:i,uint32Array:E}=KA;let D=B*2;if(Q===null&&(I.boundingBox||I.computeBoundingBox(),oe.set(I.boundingBox.min,I.boundingBox.max,g),Q=oe),zA(D,i)){const o=A.geometry,s=o.index,t=o.attributes.position,w=I.index,a=I.attributes.position,G=rI(B,E),r=lI(D,i);if(SC.copy(g).invert(),I.boundsTree)return mA(B,C,Fi),Fi.matrix.copy(SC),Fi.needsUpdate=!0,I.boundsTree.shapecast({intersectsBounds:c=>Fi.intersectsBox(c),intersectsTriangle:c=>{c.a.applyMatrix4(g),c.b.applyMatrix4(g),c.c.applyMatrix4(g),c.needsUpdate=!0;for(let y=G,R=r+G;y<R;y++)if(vA(kB,3*A.resolveTriangleIndex(y),s,t),kB.needsUpdate=!0,c.intersectsTriangle(kB))return!0;return!1}});{const c=ti(I);for(let y=G,R=r+G;y<R;y++){const S=A.resolveTriangleIndex(y);vA(RB,3*S,s,t),RB.a.applyMatrix4(SC),RB.b.applyMatrix4(SC),RB.c.applyMatrix4(SC),RB.needsUpdate=!0;for(let n=0,N=c*3;n<N;n+=3)if(vA(kB,n,w,a),kB.needsUpdate=!0,RB.intersectsTriangle(kB))return!0}}}else{const o=CI(B),s=EI(B,E);return mA(o,C,ri),!!(Q.intersectsBox(ri)&&vo(o,A,I,g,Q)||(mA(s,C,ri),Q.intersectsBox(ri)&&vo(s,A,I,g,Q)))}}const Ri=new fA,Zo=new FI,rC=new FI,Or=new q,Xr=new q,vr=new q,Zr=new q;function Vr(B,A,I,g={},Q={},C=0,i=1/0){A.boundingBox||A.computeBoundingBox(),Zo.set(A.boundingBox.min,A.boundingBox.max,I),Zo.needsUpdate=!0;const E=B.geometry,D=E.attributes.position,o=E.index,s=A.attributes.position,t=A.index,w=Bg.getPrimitive(),a=Bg.getPrimitive();let G=Or,r=Xr,c=null,y=null;Q&&(c=vr,y=Zr);let R=1/0,S=null,n=null;return Ri.copy(I).invert(),rC.matrix.copy(Ri),B.shapecast({boundsTraverseOrder:N=>Zo.distanceToBox(N),intersectsBounds:(N,M,J)=>J<R&&J<i?(M&&(rC.min.copy(N.min),rC.max.copy(N.max),rC.needsUpdate=!0),!0):!1,intersectsRange:(N,M)=>{if(A.boundsTree){const J=A.boundsTree;return J.shapecast({boundsTraverseOrder:L=>rC.distanceToBox(L),intersectsBounds:(L,H,Y)=>Y<R&&Y<i,intersectsRange:(L,H)=>{for(let Y=L,d=L+H;Y<d;Y++){const l=J.resolveTriangleIndex(Y);vA(a,3*l,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let p=N,u=N+M;p<u;p++){const P=B.resolveTriangleIndex(p);vA(w,3*P,o,D),w.needsUpdate=!0;const O=w.distanceToTriangle(a,G,c);if(O<R&&(r.copy(G),y&&y.copy(c),R=O,S=p,n=Y),O<C)return!0}}}})}else{const J=ti(A);for(let L=0,H=J;L<H;L++){vA(a,3*L,t,s),a.a.applyMatrix4(I),a.b.applyMatrix4(I),a.c.applyMatrix4(I),a.needsUpdate=!0;for(let Y=N,d=N+M;Y<d;Y++){const l=B.resolveTriangleIndex(Y);vA(w,3*l,o,D),w.needsUpdate=!0;const p=w.distanceToTriangle(a,G,c);if(p<R&&(r.copy(G),y&&y.copy(c),R=p,S=Y,n=L),p<C)return!0}}}}}),Bg.releasePrimitive(w),Bg.releasePrimitive(a),R===1/0?null:(g.point?g.point.copy(r):g.point=r.clone(),g.distance=R,g.faceIndex=S,Q&&(Q.point?Q.point.copy(y):Q.point=y.clone(),Q.point.applyMatrix4(Ri),r.applyMatrix4(Ri),Q.distance=r.sub(Q.point).length(),Q.faceIndex=n),g)}function se(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 ki=new FI,ni=new _e,te=new q,we=new fA,ae=new q,Vo=["getX","getY","getZ"];class UB extends Ie{static serialize(A,I={}){I={cloneBuffers:!0,...I};const g=A.geometry,Q=A._roots,C=A._indirectBuffer,i=g.getIndex(),E={version:1,roots:null,index:null,indirectBuffer:null};return I.cloneBuffers?(E.roots=Q.map(D=>D.slice()),E.index=i?i.array.slice():null,E.indirectBuffer=C?C.slice():null):(E.roots=Q,E.index=i?i.array:null,E.indirectBuffer=C),E}static deserialize(A,I,g={}){g={setIndex:!0,indirect:!!A.indirectBuffer,...g};const{index:Q,roots:C,indirectBuffer:i}=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 E=new UB(I,{...g,[Ci]:!0});if(E._roots=C,E._indirectBuffer=i||null,g.setIndex){const o=I.getIndex();if(o===null){const s=new iI(A.index,1,!1);I.setIndex(s)}else o.array!==Q&&(o.array.set(Q),o.needsUpdate=!0)}return E;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 G=0,r=t.byteLength/SI;G<r;G++){const c=jA*G,y=2*c;zA(y,a)||(w[c+6]=w[c+6]/jA-G)}}}}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,i=Q.attributes.position,E=Q.index?Q.index.array:null,D=(C?C[A]:A)*3;let o=D+0,s=D+1,t=D+2;E&&(o=E[o],s=E[s],t=E[t]);for(let w=0;w<3;w++){const a=i[Vo[w]](o),G=i[Vo[w]](s),r=i[Vo[w]](t);let c=a;G<c&&(c=G),r<c&&(c=r);let y=a;G>y&&(y=G),r>y&&(y=r),I[g+w]=c,I[g+w+3]=y}return I}computePrimitiveBounds(A,I,g){const Q=this.geometry,C=this._indirectBuffer,i=Q.attributes.position,E=Q.index?Q.index.array:null,D=i.normalized;if(A<0||I+A-g.offset>g.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const o=i.array,s=i.offset||0;let t=3;i.isInterleavedBufferAttribute&&(t=i.data.stride);const w=["getX","getY","getZ"],a=g.offset;for(let G=A,r=A+I;G<r;G++){const c=(C?C[G]:G)*3,y=(G-a)*6;let R=c+0,S=c+1,n=c+2;E&&(R=E[R],S=E[S],n=E[n]),D||(R=R*t+s,S=S*t+s,n=n*t+s);for(let N=0;N<3;N++){let M,J,L;D?(M=i[w[N]](R),J=i[w[N]](S),L=i[w[N]](n)):(M=o[R+N],J=o[S+N],L=o[n+N]);let H=M;J<H&&(H=J),L<H&&(H=L);let Y=M;J>Y&&(Y=J),L>Y&&(Y=L);const d=(Y-H)/2,l=N*2;g[y+l+0]=H+d,g[y+l+1]=d+(Math.abs(H)+d)*Bi}}return g}raycastObject3D(A,I,g=[]){const{material:Q}=A;if(Q===void 0)return;we.copy(A.matrixWorld).invert(),ni.copy(I.ray).applyMatrix4(we),ae.setFromMatrixScale(A.matrixWorld),te.copy(ni.direction).multiply(ae);const C=te.length(),i=I.near/C,E=I.far/C;if(I.firstHitOnly===!0){let D=this.raycastFirst(ni,Q,i,E);D=se(D,A,I),D&&g.push(D)}else{const D=this.raycast(ni,Q,i,E);for(let o=0,s=D.length;o<s;o++){const t=se(D[o],A,I);t&&g.push(t)}}return g}refit(A=null){return(this.indirect?ur:Mr)(this,A)}raycast(A,I=Ks,g=0,Q=1/0){const C=this._roots,i=[],E=this.indirect?br:Hr;for(let D=0,o=C.length;D<o;D++)E(this,D,I,A,i,g,Q);return i}raycastFirst(A,I=Ks,g=0,Q=1/0){const C=this._roots;let i=null;const E=this.indirect?Pr:Kr;for(let D=0,o=C.length;D<o;D++){const s=E(this,D,I,A,g,Q);s!=null&&(i==null||s.distance<i.distance)&&(i=s)}return i}intersectsGeometry(A,I){let g=!1;const Q=this._roots,C=this.indirect?Tr:dr;for(let i=0,E=Q.length;i<E&&(g=C(this,i,A,I),!g);i++);return g}shapecast(A){const I=Bg.getPrimitive(),g=super.shapecast({...A,intersectsPrimitive:A.intersectsTriangle,scratchPrimitive:I,iterate:this.indirect?Lr:Nr});return Bg.releasePrimitive(I),g}bvhcast(A,I,g){let{intersectsRanges:Q,intersectsTriangles:C}=g;const i=Bg.getPrimitive(),E=this.geometry.index,D=this.geometry.attributes.position,o=this.indirect?G=>{const r=this.resolveTriangleIndex(G);vA(i,r*3,E,D)}:G=>{vA(i,G*3,E,D)},s=Bg.getPrimitive(),t=A.geometry.index,w=A.geometry.attributes.position,a=A.indirect?G=>{const r=A.resolveTriangleIndex(G);vA(s,r*3,t,w)}:G=>{vA(s,G*3,t,w)};if(C){if(!(A instanceof UB))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const G=(r,c,y,R,S,n,N,M)=>{for(let J=y,L=y+R;J<L;J++){a(J),s.a.applyMatrix4(I),s.b.applyMatrix4(I),s.c.applyMatrix4(I),s.needsUpdate=!0;for(let H=r,Y=r+c;H<Y;H++)if(o(H),i.needsUpdate=!0,C(i,s,H,J,S,n,N,M))return!0}return!1};if(Q){const r=Q;Q=function(c,y,R,S,n,N,M,J){return r(c,y,R,S,n,N,M,J)?!0:G(c,y,R,S,n,N,M,J)}}else Q=G}return super.bvhcast(A,I,{intersectsRanges:Q})}intersectsBox(A,I){return ki.set(A.min,A.max,I),ki.needsUpdate=!0,this.shapecast({intersectsBounds:g=>ki.intersectsBox(g),intersectsTriangle:g=>ki.intersectsTriangle(g)})}intersectsSphere(A){return this.shapecast({intersectsBounds:I=>A.intersectsBox(I),intersectsTriangle:I=>I.intersectsSphere(A)})}closestPointToGeometry(A,I,g={},Q={},C=0,i=1/0){return(this.indirect?Vr:qr)(this,A,I,g,Q,C,i)}closestPointToPoint(A,I={},g=0,Q=1/0){return rr(this,A,I,g,Q)}}const nB={Mesh:IQ.prototype.raycast,Line:fs.prototype.raycast,LineSegments:ds.prototype.raycast,LineLoop:ls.prototype.raycast,Points:ps.prototype.raycast,BatchedMesh:A0.prototype.raycast},aI=new IQ,Ni=[];function Wr(B,A){if(this.isBatchedMesh)jr.call(this,B,A);else{const{geometry:I}=this;if(I.boundsTree)I.boundsTree.raycastObject3D(this,B,A);else{let g;if(this instanceof IQ)g=nB.Mesh;else if(this instanceof ds)g=nB.LineSegments;else if(this instanceof ls)g=nB.LineLoop;else if(this instanceof fs)g=nB.Line;else if(this instanceof ps)g=nB.Points;else throw new Error("BVH: Fallback raycast function not found.");g.call(this,B,A)}}}function jr(B,A){if(this.boundsTrees){const I=this.boundsTrees,g=this._drawInfo||this._instanceInfo,Q=this._drawRanges||this._geometryInfo,C=this.matrixWorld;aI.material=this.material,aI.geometry=this.geometry;const i=aI.geometry.boundsTree,E=aI.geometry.drawRange;aI.geometry.boundingSphere===null&&(aI.geometry.boundingSphere=new $e);for(let D=0,o=g.length;D<o;D++){if(!this.getVisibleAt(D))continue;const s=g[D].geometryIndex;if(aI.geometry.boundsTree=I[s],this.getMatrixAt(D,aI.matrixWorld).premultiply(C),!aI.geometry.boundsTree){this.getBoundingBoxAt(s,aI.geometry.boundingBox),this.getBoundingSphereAt(s,aI.geometry.boundingSphere);const t=Q[s];aI.geometry.setDrawRange(t.start,t.count)}aI.raycast(B,Ni);for(let t=0,w=Ni.length;t<w;t++){const a=Ni[t];a.object=this,a.batchId=D,A.push(a)}Ni.length=0}aI.geometry.boundsTree=i,aI.geometry.drawRange=E,aI.material=null,aI.geometry=null}else nB.BatchedMesh.call(this,B,A)}function zr(B={}){const{type:A=UB}=B;return this.boundsTree=new A(this,B),this.boundsTree}const dQ=new q,lQ=new q,fQ=new q,ee=new MI,Mi=new q,Wo=new q,he=new MI,ce=new MI,Ji=new fA,ye=new fA;function FC(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 RC(B,A=null){const I=B.array.constructor,g=B.normalized,Q=B.itemSize,C=A===null?B.count:A;return new iI(new I(Q*C),Q,g)}function Ge(B,A,I=0){if(B.isInterleavedBufferAttribute){const g=B.itemSize;for(let Q=0,C=B.count;Q<C;Q++){const i=Q+I;A.setX(i,B.getX(Q)),g>=2&&A.setY(i,B.getY(Q)),g>=3&&A.setZ(i,B.getZ(Q)),g>=4&&A.setW(i,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 _r(B,A,I){const g=B.elements,Q=A.elements;for(let C=0,i=Q.length;C<i;C++)g[C]+=Q[C]*I}function Se(B,A,I){const g=B.skeleton,Q=B.geometry,C=g.bones,i=g.boneInverses;he.fromBufferAttribute(Q.attributes.skinIndex,A),ce.fromBufferAttribute(Q.attributes.skinWeight,A),Ji.elements.fill(0);for(let E=0;E<4;E++){const D=ce.getComponent(E);if(D!==0){const o=he.getComponent(E);ye.multiplyMatrices(C[o].matrixWorld,i[o]),_r(Ji,ye,D)}}return Ji.multiply(B.bindMatrix).premultiply(B.bindMatrixInverse),I.transformDirection(Ji),I}function jo(B,A,I,g,Q){Mi.set(0,0,0);for(let C=0,i=B.length;C<i;C++){const E=A[C],D=B[C];E!==0&&(Wo.fromBufferAttribute(D,g),I?Mi.addScaledVector(Wo,E):Mi.addScaledVector(Wo.sub(Q),E))}Q.add(Mi)}function $r(B,A={useGroups:!1,updateIndex:!1,skipAttributes:[]},I=new ZQ){const g=B[0].index!==null,{useGroups:Q=!1,updateIndex:C=!1,skipAttributes:i=[]}=A,E=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(!E.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!==E.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 iI(new Uint32Array(t),1,!1)),s=!0}if(C||s){const t=I.index;let w=0,a=0;for(let G=0;G<B.length;++G){const r=B[G],c=r.index;if(i[G]!==!0)for(let y=0;y<c.count;++y)t.setX(w,c.getX(y)+a),w++;a+=r.attributes.position.count}}}for(const s in D){const t=D[s];if(!(s in I.attributes)){let G=0;for(const r in t)G+=t[r].count;I.setAttribute(s,RC(D[s][0],G))}const w=I.attributes[s];let a=0;for(let G=0,r=t.length;G<r;G++){const c=t[G];i[G]!==!0&&Ge(c,w,a),a+=c.count}}return I}function AF(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 IF(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),i=A.getX(g+2);A.setX(g,i),A.setX(g+2,C)}else for(const g in I){const Q=I[g],C=Q.itemSize;for(let i=0,E=Q.count;i<E;i+=3)for(let D=0;D<C;D++){const o=Q.getComponent(i,D),s=Q.getComponent(i+2,D);Q.setComponent(i,D,s),Q.setComponent(i+2,D,o)}}return B}class gF{constructor(A){this.matrixWorld=new fA,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&&AF(A.skeleton&&A.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===g)}}class QF{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 ZQ),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 ZQ){let I=[];const{meshes:g,useGroups:Q,_intermediateGeometry:C,_diffMap:i}=this;for(let E=0,D=g.length;E<D;E++){const o=g[E],s=C[E],t=i.get(o);!t||t.didChange(o)?(this._convertToStaticGeometry(o,s),I.push(!1),t?t.update():i.set(o,new gF(o))):I.push(!0)}if(C.length===0){A.setIndex(null);const E=A.attributes;for(const D in E)A.deleteAttribute(D);for(const D in this.attributes)A.setAttribute(this.attributes[D],new iI(new Float32Array(0),4,!1))}else $r(C,{useGroups:Q,skipAttributes:I},A);for(const E in A.attributes)A.attributes[E].needsUpdate=!0;return A}_convertToStaticGeometry(A,I=new ZQ){const g=A.geometry,Q=this.applyWorldTransforms,C=this.attributes.includes("normal"),i=this.attributes.includes("tangent"),E=g.attributes,D=I.attributes;!I.index&&g.index&&(I.index=g.index.clone()),D.position||I.setAttribute("position",RC(E.position)),C&&!D.normal&&E.normal&&I.setAttribute("normal",RC(E.normal)),i&&!D.tangent&&E.tangent&&I.setAttribute("tangent",RC(E.tangent)),FC(g.index,I.index),FC(E.position,D.position),C&&FC(E.normal,D.normal),i&&FC(E.tangent,D.tangent);const o=E.position,s=C?E.normal:null,t=i?E.tangent:null,w=g.morphAttributes.position,a=g.morphAttributes.normal,G=g.morphAttributes.tangent,r=g.morphTargetsRelative,c=A.morphTargetInfluences,y=new VQ;y.getNormalMatrix(A.matrixWorld),g.index&&I.index.array.set(g.index.array);for(let R=0,S=E.position.count;R<S;R++)dQ.fromBufferAttribute(o,R),s&&lQ.fromBufferAttribute(s,R),t&&(ee.fromBufferAttribute(t,R),fQ.fromBufferAttribute(t,R)),c&&(w&&jo(w,c,r,R,dQ),a&&jo(a,c,r,R,lQ),G&&jo(G,c,r,R,fQ)),A.isSkinnedMesh&&(A.applyBoneTransform(R,dQ),s&&Se(A,R,lQ),t&&Se(A,R,fQ)),Q&&dQ.applyMatrix4(A.matrixWorld),D.position.setXYZ(R,dQ.x,dQ.y,dQ.z),s&&(Q&&lQ.applyNormalMatrix(y),D.normal.setXYZ(R,lQ.x,lQ.y,lQ.z)),t&&(Q&&fQ.transformDirection(A.matrixWorld),D.tangent.setXYZW(R,fQ.x,fQ.y,fQ.z,ee.w));for(const R in this.attributes){const S=this.attributes[R];S==="position"||S==="tangent"||S==="normal"||!(S in E)||(D[S]||I.setAttribute(S,RC(E[S])),FC(E[S],D[S]),Ge(E[S],D[S]))}return A.matrixWorld.determinant()<0&&IF(I),I}}const BF=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:ma,BVH:_a,CENTER:Ro,CONTAINED:ko,ExtendedTriangle:Qg,GeometryBVH:Ie,MeshBVH:UB,OrientedBox:FI,SAH:Pa,SKIP_GENERATION:Ci,StaticGeometryGenerator:QF,acceleratedRaycast:Wr,computeBoundsTree:zr,generateIndirectBuffer:Ae},Symbol.toStringTag,{value:"Module"}));class CF{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 Cg={node:"node",material:"material",camera:"camera",light:"light"},pQ="KHR_animation_pointer",EF={CUBICSPLINE:void 0,LINEAR:xs,STEP:I0};class iF{constructor(A){this.name=pQ,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){sF();const I=A.target,g=I.extensions&&I.extensions[pQ]&&I.path&&I.path==="pointer";if(!g)return null;let Q,C=Cg.node,i;if(g){const D=I.extensions[pQ];let o=D.pointer;if(!o){console.warn("Invalid path",D,I);return}if(o.startsWith("/materials/")?C=Cg.material:o.startsWith("/extensions/KHR_lights_punctual/lights/")?C=Cg.light:o.startsWith("/cameras/")&&(C=Cg.camera),i=this._tryResolveTargetId(o,C),i===null||isNaN(i)){console.warn("Failed resolving animation node id: "+i,o);return}switch(C){case Cg.material:const t=("/materials/"+i.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 Cg.node:const a=("/nodes/"+i.toString()+"/").length,G=o.substring(0,a);if(Q=o.substring(a),Q.startsWith("weights/")){const R=Q.substring(8);/^\d+$/.test(R)?Q="morphTargetInfluences["+R+"]":console.warn(pQ+": 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=G+Q;break;case Cg.light:const r=("/extensions/KHR_lights_punctual/lights/"+i.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/"+i.toString()+"/"+Q;break;case Cg.camera:const c=("/cameras/"+i.toString()+"/").length,y=o.substring(0,c);switch(Q=o.substring(c),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=y+Q;break}this.animationPointerResolver?.resolvePath&&(o=this.animationPointerResolver.resolvePath(o));const s=D.pointer;this.pointerPathMap.set(s,o)}if(i==null||isNaN(i)){console.warn("Failed resolving animation node id: "+i,I);return}let E;return C===Cg.node?E=this.parser.getDependency("node",i):C===Cg.material?E=this.parser.getDependency("material",i):C===Cg.light?E=this.parser.getDependency("light",i):C===Cg.camera?E=this.parser.getDependency("camera",i):console.error("Unhandled type",C),E}createAnimationTracksWithAnimationPointer(A,I,g,Q,C){if(!(C.extensions&&C.extensions[pQ]&&C.path&&C.path==="pointer"))return null;const i=C.extensions[pQ].pointer;let E=this.pointerPathMap.get(i);if(!E)return null;const D=[];E=E.replaceAll("/",".");const o=E.split(".");var s=A.name!==void 0&&A.name!==null?A.name:A.uuid;if(o[2]=s,o[3]?.startsWith("morphTargetInfluences")){const a=o[3];if(A.type==="Group"){for(const G of A.children)G.morphTargetInfluences&&(o[3]=G.name,o[4]=a,w(this.parser));return D}}w(this.parser);function t(a,G){try{const r=G.split(".").filter(Boolean),c=r[r.length-1].replace(/\[.*\]$/,"");return c in a?typeof a[c]=="boolean":!1}catch{return!1}}function w(a){E=o.join(".");let G,r=!1;switch(g.itemSize){case 1:Object.prototype.toString.call(g.array)==="[object Uint8Array]"&&t(A,E)?(G=E0,r=!0):G=i0;break;case 2:case 3:G=C0;break;case 4:E.endsWith(".quaternion")?G=Q0:G=B0;break}if(!G){console.warn("Unsupported output accessor format",g);return}const c=Q.interpolation!==void 0?EF[Q.interpolation]:xs;let y=a._getArrayFromAccessor(g);E.endsWith(".fov")&&(y=y.map(S=>S/Math.PI*180)),r&&(y=y.map(S=>S>0));const R=new G(E,I.array,y,c);if(c==="CUBICSPLINE"&&a._createCubicSplineTrackInterpolant(R),D.push(R),E&&g.itemSize===4&&E.startsWith(".materials.")&&E.endsWith(".color")){const S=new Float32Array(y.length/4);for(let N=0,M=y.length/4;N<M;N+=1)S[N]=y[N*4+3];const n=new G(E.replace(".color",".opacity"),I.array,S,c);c==="CUBICSPLINE"&&a._createCubicSplineTrackInterpolant(R),D.push(n)}}return D}_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],i=C.name?C.name:"animation_"+A,E=[],D=[],o=[],s=[],t=[];for(let w=0,a=C.channels.length;w<a;w++){const G=C.channels[w],r=C.samplers[G.sampler],c=G.target,y=C.parameters!==void 0?C.parameters[r.input]:r.input,R=C.parameters!==void 0?C.parameters[r.output]:r.output;let S=I.loadAnimationTargetFromChannelWithAnimationPointer(G);S||(S=I.loadAnimationTargetFromChannel(G)),E.push(S),D.push(Q.getDependency("accessor",y)),o.push(Q.getDependency("accessor",R)),s.push(r),t.push(c)}return Promise.all([Promise.all(E),Promise.all(D),Promise.all(o),Promise.all(s),Promise.all(t)]).then(function(w){const a=w[0],G=w[1],r=w[2],c=w[3],y=w[4],R=[];for(let S=0,n=a.length;S<n;S++){const N=a[S],M=G[S],J=r[S],L=c[S],H=y[S];if(N===void 0)continue;N.updateMatrix&&(N.updateMatrix(),N.matrixAutoUpdate=!0);let Y=I.createAnimationTracksWithAnimationPointer(N,M,J,L,H);if(Y||(Y=Q._createAnimationTracks(N,M,J,L,H)),Y)for(let d=0;d<Y.length;d++)R.push(Y[d])}return new g0(i,void 0,R)})}}function DF(B,A){for(const I of B.children){const g=I.getObjectByName(A);if(g)return g}}let re=!1,oF=null;function sF(){if(re)return;re=!0;const B=oF||=qs.findNode;qs.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 i=null;return A.traverse(E=>{i!==null||E.type!=="Mesh"&&E.type!=="SkinnedMesh"||E.material&&(E.material.uuid===C||E.material.name===C)&&(i=E.material,i!==null&&(g.endsWith(".map")?i=i.map:g.endsWith(".emissiveMap")&&(i=i.emissiveMap)))}),i}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 i=g[C];if(i.length==36)Q=A.getObjectByProperty("uuid",i);else if(Q&&Q[i]){const E=Number.parseInt(i);let D=i;E>=0&&(D=E),Q=Q[D]}else if(Q&&Q.isObject3D){const E=DF(Q,i);E&&(Q=E)}else{const E=A.getObjectByName(i);E&&(Q=E)}}if(!Q){const C=B(A,g[2]);return C||console.warn(pQ+": Property binding not found",I,A,A.name,g),C}return Q}return B(A,I)}}const tF=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:iF},Symbol.toStringTag,{value:"Module"}));var wF=Object.defineProperty,aF=(B,A,I)=>A in B?wF(B,A,{enumerable:!0,configurable:!0,writable:!0,value:I}):B[A]=I,ZA=(B,A,I)=>(aF(B,typeof A!="symbol"?A+"":A,I),I);(function(){class B{}class A extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class I extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class g extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class Q extends B{constructor(h,F="unrestricted"){super(),ZA(this,"type"),ZA(this,"value"),this.value=h,this.type=F}}class C extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class i extends B{}class E extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class D extends B{}class o extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class s extends B{constructor(h,F="integer"){super(),ZA(this,"value"),ZA(this,"type"),this.value=h,this.type=F}}class t extends B{constructor(h){super(),ZA(this,"value"),this.value=h}}class w extends B{constructor(h,F,k){super(),ZA(this,"value"),ZA(this,"type"),ZA(this,"unit"),this.value=h,this.type=F,this.unit=k}}class a extends B{}class G extends B{}class r extends B{}class c extends B{}class y extends B{}class R extends B{}class S extends B{}class n extends B{}class N extends B{}class M extends B{}class J extends B{}class L extends B{}class H{constructor(h){ZA(this,"input"),ZA(this,"index",0),this.input=h}consume(){const h=this.input.codePointAt(this.index);return h!==void 0&&(this.index+=String.fromCodePoint(h).length),h}reconsume(h){h!==void 0&&(this.index-=String.fromCodePoint(h).length)}peek(){const h=[];let F=this.index;for(let k=0;k<3&&F<this.input.length;k++){const U=this.input.codePointAt(F);h.push(U),F+=String.fromCodePoint(U).length}return h}}function Y(e){return e===10}function d(e){return Y(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 u(e){return function(h){return function(F){return F>=65&&F<=90}(h)||function(F){return F>=97&&F<=122}(h)}(e)||function(h){return h>=128}(e)||e===95}function P(e){return u(e)||l(e)||e===45}function O(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function W(e,h){return e===92&&!Y(h)}function T(e,h,F){return e===45?u(h)||h===45||W(h,F):!!u(e)||e===92&&W(e,h)}function j(e,h,F){return e===43||e===45?l(h)||h===46&&l(F):l(e===46?h:e)}function EA(e){const h=e.consume();if(p(h)){let F=[h];for(;p(...e.peek())&&F.length<5;)F.push(e.consume());d(...e.peek())&&e.consume();const k=parseInt(String.fromCodePoint(...F),16);return k===0||k>1114111?65533:k}return h===void 0?65533:h}function wA(e,h){const F=new C("");for(;;){const k=e.consume();if(k===h||k===void 0)return F;if(k===10)return e.reconsume(k),new i;if(k===92){const U=e.peek()[0];U===void 0||(Y(U)?e.consume():F.value+=String.fromCodePoint(EA(e)))}else F.value+=String.fromCodePoint(k)}}function iA(e){let h="";for(;;){const F=e.consume();if(P(F))h+=String.fromCodePoint(F);else{if(!W(...e.peek()))return e.reconsume(F),h;h+=String.fromCodePoint(EA(e))}}}function IA(e){let h=function(F){let k="integer",U="";for([43,45].includes(F.peek()[0])&&(U+=String.fromCodePoint(F.consume()));l(...F.peek());)U+=String.fromCodePoint(F.consume());if(F.peek()[0]===46&&l(F.peek()[1]))for(U+=String.fromCodePoint(F.consume(),F.consume()),k="number";l(...F.peek());)U+=String.fromCodePoint(F.consume());return[69,101].includes(F.peek()[0])&&([45,43].includes(F.peek()[1])&&l(F.peek()[2])?(U+=String.fromCodePoint(F.consume(),F.consume(),F.consume()),k="number"):l(F.peek()[1])&&(U+=String.fromCodePoint(F.consume(),F.consume()),k="number")),{value:parseFloat(U),type:k}}(e);return T(...e.peek())?new w(h.value,h.type,iA(e)):e.peek()[0]===37?(e.consume(),new t(h.value)):new s(h.value,h.type)}function BA(e){for(;;){const h=e.consume();if(h===41||h===void 0)return;W(...e.peek())&&EA(e)}}function AA(e){const h=iA(e);if(h.match(/url/i)&&e.peek()[0]===40){for(e.consume();d(e.peek()[0])&&d(e.peek()[1]);)e.consume();return[34,39].includes(e.peek()[0])||d(e.peek()[0])&&[34,39].includes(e.peek()[1])?new I(h):function(F){const k=new E("");for(;d(...F.peek());)F.consume();for(;;){const U=F.consume();if(U===41||U===void 0)return k;if(d(U)){for(;d(...F.peek());)F.consume();return F.peek()[0]===41||F.peek()[0]===void 0?(F.consume(),k):(BA(F),new D)}if([34,39,40].includes(U)||O(U))return BA(F),new D;if(U===92){if(!W(...F.peek()))return BA(F),new D;k.value+=EA(F)}else k.value+=String.fromCodePoint(U)}}(e)}return e.peek()[0]===40?(e.consume(),new I(h)):new A(h)}function $(e){const h=e.consume(),F=e.peek();if(d(h)){for(;d(...e.peek());)e.consume();return new a}if(h===34)return wA(e,h);if(h===35){if(P(F[0])||W(...F)){const k=new Q;return T(...F)&&(k.type="id"),k.value=iA(e),k}return new o(String.fromCodePoint(h))}return h===39?wA(e,h):h===40?new N:h===41?new M:h===43?j(...F)?(e.reconsume(h),IA(e)):new o(String.fromCodePoint(h)):h===44?new R:h===45?j(...e.peek())?(e.reconsume(h),IA(e)):e.peek()[0]===45&&e.peek()[1]===62?(e.consume(),e.consume(),new r):T(...e.peek())?(e.reconsume(h),AA(e)):new o(String.fromCodePoint(h)):h===46?j(...e.peek())?(e.reconsume(h),IA(e)):new o(String.fromCodePoint(h)):h===58?new c:h===59?new y:h===60?F[0]===33&&F[1]===45&&F[2]===45?(e.consume(),e.consume(),e.consume(),new G):new o(String.fromCodePoint(h)):h===64?T(...F)?new g(iA(e)):new o(String.fromCodePoint(h)):h===91?new S:h===92?W(...F)?(e.reconsume(h),AA(e)):new o(String.fromCodePoint(h)):h===93?new n:h===123?new J:h===125?new L:l(h)?(e.reconsume(h),IA(e)):u(h)?(e.reconsume(h),AA(e)):h===void 0?void 0:new o(String.fromCodePoint(h))}const z=new Set(["px","deg","s","hz","dppx","number","fr"]);function LA(e){return z.has(e.toLowerCase())}function NA(e,h){if(["x","y"].includes(e))return e;if(!h)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const F=h.writingMode=="horizontal-tb";if(e==="block")e=F?"y":"x";else{if(e!=="inline")throw new TypeError(`Invalid axis \u201C${e}\u201D`);e=F?"x":"y"}return e}function MA(e){const h=[];let F=0;function k(){let K=0;const f=F;for(;F<e.length;){const b=e.slice(F,F+1);if(/\s/.test(b)&&K===0)break;if(b==="(")K+=1;else if(b===")"&&(K-=1,K===0)){F++;break}F++}return e.slice(f,F)}function U(){for(;/\s/.test(e.slice(F,F+1));)F++}for(;F<e.length;){const K=e.slice(F,F+1);/\s/.test(K)?U():h.push(k())}return h}function xA(e,h){return e.reduce((F,k)=>(F.has(k[h])?F.get(k[h]).push(k):F.set(k[h],[k]),F),new Map)}function aA(e,h){const F=[],k=[];for(const U of e)h(U)?F.push(U):k.push(U);return[F,k]}function DA(e,h={}){function F(k){return Array.from(k).map(U=>DA(U,h))}if(e instanceof CSSUnitValue){if(e.unit==="percent"&&h.percentageReference){const U=e.value/100*h.percentageReference.value,K=h.percentageReference.unit;return new CSSUnitValue(U,K)}const k=e.toSum();if(k&&k.values.length===1&&(e=k.values[0]),e instanceof CSSUnitValue&&e.unit==="em"&&h.fontSize&&(e=new CSSUnitValue(e.value*h.fontSize.value,h.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(...F(e.values));break;case"product":e=new CSSMathProduct(...F(e.values));break;case"negate":e=new CSSMathNegate(DA(e.value,h));break;case"clamp":e=new CSSMathClamp(DA(e.lower,h),DA(e.value,h),DA(e.upper,h));break;case"invert":e=new CSSMathInvert(DA(e.value,h));break;case"min":e=new CSSMathMin(...F(e.values));break;case"max":e=new CSSMathMax(...F(e.values))}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const k=Array.from(e.values);if(k.every(U=>U instanceof CSSUnitValue&&U.unit!=="percent"&&LA(U.unit)&&U.unit===k[0].unit)){const U=Math[e.operator].apply(Math,k.map(({value:K})=>K));return new CSSUnitValue(U,k[0].unit)}}if(e instanceof CSSMathMin||e instanceof CSSMathMax){const k=Array.from(e.values),[U,K]=aA(k,b=>b instanceof CSSUnitValue&&b.unit!=="percent"),f=Array.from(xA(U,"unit").values());if(f.some(b=>b.length>0)){const b=f.map(x=>{const m=Math[e.operator].apply(Math,x.map(({value:V})=>V));return new CSSUnitValue(m,x[0].unit)});e=e instanceof CSSMathMin?new CSSMathMin(...b,...K):new CSSMathMax(...b,...K)}return k.length===1?k[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 k=function(K){const f=K.filter(b=>b instanceof CSSUnitValue);return[...K.filter(b=>!(b instanceof CSSUnitValue)),...Array.from(xA(f,"unit").entries()).map(([b,x])=>{const m=x.reduce((V,{value:QA})=>V+QA,0);return new CSSUnitValue(m,b)})]},U=[];for(const K of e.values)K instanceof CSSMathSum?U.push(...K.values):U.push(K);return U=k(U),U.length===1?U[0]:new CSSMathSum(...U)}if(e instanceof CSSMathProduct){let k=[];for(const f of e.values)f instanceof CSSMathProduct?k.push(...f.values):k.push(f);const[U,K]=aA(k,f=>f instanceof CSSUnitValue&&f.unit==="number");if(U.length>1){const f=U.reduce((b,{value:x})=>b*x,1);k=[new CSSUnitValue(f,"number"),...K]}if(k.length===2){let f,b;for(const x of k)x instanceof CSSUnitValue&&x.unit==="number"?f=x:x instanceof CSSMathSum&&[...x.values].every(m=>m instanceof CSSUnitValue)&&(b=x);if(f&&b)return new CSSMathSum(...[...b.values].map(x=>new CSSUnitValue(x.value*f.value,x.unit)))}if(k.every(f=>f instanceof CSSUnitValue&&LA(f.unit)||f instanceof CSSMathInvert&&f.value instanceof CSSUnitValue&&LA(f.value.unit))){const f=new CSSMathProduct(...k).toSum();if(f&&f.values.length===1)return f.values[0]}return new CSSMathProduct(...k)}return e}const JA=null,jI=["percent","length","angle","time","frequency","resolution","flex"],_A={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}}},HA=new Map;for(const e of Object.values(_A))if(e.compatible)for(const h of e.units)HA.set(h,e);function fI(e){return HA.get(e)}function Eg(e,h){const F={...e};for(const k of Object.keys(h))F[k]?F[k]+=h[k]:F[k]=h[k];return F}function ig(e){return e==="number"?{}:e==="percent"?{percent:1}:_A.absoluteLengths.units.has(e)||_A.fontRelativeLengths.units.has(e)||_A.viewportRelativeLengths.units.has(e)?{length:1}:_A.angle.units.has(e)?{angle:1}:_A.time.units.has(e)?{time:1}:_A.frequency.units.has(e)?{frequency:1}:_A.resolution.units.has(e)?{resolution:1}:e==="fr"?{flex:1}:JA}function pI(e){if(e instanceof CSSUnitValue){let{unit:h,value:F}=e;const k=fI(e.unit);return k&&h!==k.canonicalUnit&&(F*=k.ratios[h],h=k.canonicalUnit),h==="number"?[[F,{}]]:[[F,{[h]:1}]]}if(e instanceof CSSMathInvert){if(!(e.value instanceof CSSUnitValue))throw new Error("Not implemented");const h=pI(e.value);if(h===JA||h.length>1)return JA;const F=h[0],k={};for(const[U,K]of Object.entries(F[1]))k[U]=-1*K;return h[0]=[1/F[0],k],h}if(e instanceof CSSMathProduct){let h=[[1,{}]];for(const F of e.values){const k=pI(F),U=[];if(k===JA)return JA;for(const K of h)for(const f of k)U.push([K[0]*f[0],Eg(K[1],f[1])]);h=U}return h}throw new Error("Not implemented")}function Dg(e,h){if(ig(h)===JA)throw new SyntaxError("The string did not match the expected pattern.");const F=pI(e);if(!F)throw new TypeError;if(F.length>1)throw new TypeError("Sum has more than one item");const k=function(U,K){const f=U.unit,b=U.value,x=fI(f),m=fI(K);return!m||x!==m?JA:new CSSUnitValue(b*m.ratios[f]/m.ratios[K],K)}(zI(F[0]),h);if(k===JA)throw new TypeError;return k}function zI(e){const[h,F]=e,k=Object.entries(F);if(k.length>1)return JA;if(k.length===0)return new CSSUnitValue(h,"number");const U=k[0];return U[1]!==1?JA:new CSSUnitValue(h,U[0])}function _I(e,...h){if(h&&h.length)throw new Error("Not implemented");const F=pI(e).map(k=>zI(k));if(F.some(k=>k===JA))throw new TypeError("Type error");return new CSSMathSum(...F)}function XI(e,h){if(e.percentHint&&h.percentHint&&e.percentHint!==h.percentHint)return JA;const F={...e,percentHint:e.percentHint??h.percentHint};for(const k of jI)h[k]&&(F[k]??(F[k]=0),F[k]+=h[k]);return F}class $A{constructor(h,F){ZA(this,"name"),ZA(this,"values"),this.name=h,this.values=F}}class kI{constructor(h,F){ZA(this,"value"),ZA(this,"associatedToken"),this.value=h,this.associatedToken=F}}function vI(e){if(Array.isArray(e))return e;if(typeof e=="string")return function(h){const F=new H(h),k=[];for(;;){const U=$(F);if(U===void 0)return k;k.push(U)}}(e);throw new TypeError("Invalid input type "+typeof e)}function nI(e){const h=e.shift();return h instanceof J||h instanceof S||h instanceof N?function(F,k){let U;if(k instanceof J)U=L;else if(k instanceof N)U=M;else{if(!(k instanceof S))return;U=n}const K=new kI([],k);for(;;){const f=F.shift();if(f instanceof U||f===void 0)return K;F.unshift(f),K.value.push(nI(F))}}(e,h):h instanceof I?function(F,k){const U=new $A(F.value,[]);for(;;){const K=k.shift();if(K instanceof M||K===void 0)return U;k.unshift(K),U.values.push(nI(k))}}(h,e):h}function eA(e){if(e instanceof N||e instanceof M)return 6;if(e instanceof o)switch(e.value){case"*":case"/":return 4;case"+":case"-":return 2}}function og(e){return e[e.length-1]}function lg(e,h,F){const k=["+","-"].includes(e.value)?"ADDITION":"MULTIPLICATION",U=h.type===k?h.values:[h],K=F.type===k?F.values:[F];return e.value==="-"?K[0]={type:"NEGATE",value:K[0]}:e.value==="/"&&(K[0]={type:"INVERT",value:K[0]}),{type:k,values:[...U,...K]}}function sg(e){if(e.type==="ADDITION")return new CSSMathSum(...e.values.map(h=>sg(h)));if(e.type==="MULTIPLICATION")return new CSSMathProduct(...e.values.map(h=>sg(h)));if(e.type==="NEGATE")return new CSSMathNegate(sg(e.value));if(e.type==="INVERT")return new CSSMathInvert(sg(e.value));if(e instanceof kI)return kA(new $A("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 $o(e)}function kA(e){if(e.name==="min"||e.name==="max"){const k=e.values.filter(U=>!(U instanceof a||U instanceof R)).map(U=>DA(kA(new $A("calc",U))));return e.name==="min"?new CSSMathMin(...k):new CSSMathMax(...k)}if(e.name!=="calc")return null;const h=sg(function(k){const U=[],K=[];for(;k.length;){const f=k.shift();if(f instanceof s||f instanceof w||f instanceof t||f instanceof $A||f instanceof kI||f instanceof A)K.push(f);else if(f instanceof o&&["*","/","+","-"].includes(f.value)){for(;U.length&&!(og(U)instanceof N)&&eA(og(U))>eA(f);){const b=U.pop(),x=K.pop(),m=K.pop();K.push(lg(b,m,x))}U.push(f)}else if(f instanceof N)U.push(f);else if(f instanceof M){if(!U.length)return null;for(;!(og(U)instanceof N);){const b=U.pop(),x=K.pop(),m=K.pop();K.push(lg(b,m,x))}if(!(og(U)instanceof N))return null;U.pop()}else if(!(f instanceof a))return null}for(;U.length;){if(og(U)instanceof N)return null;const f=U.pop(),b=K.pop(),x=K.pop();K.push(lg(f,x,b))}return K[0]}([...e.values]));let F;try{F=DA(h)}catch{new CSSStyleSheet().insertRule("error",0)}return F instanceof CSSUnitValue?new CSSMathSum(F):F}function $o(e){return e instanceof $A&&["calc","min","max","clamp"].includes(e.name)?kA(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 ke(e){const h=function(F){const k=vI(F);for(;k[0]instanceof a;)k.shift();if(k[0]===void 0)return null;const U=nI(k);for(;k[0]instanceof a;)k.shift();return k[0]===void 0?U:null}(e);return h===null&&new CSSStyleSheet().insertRule("error",0),h instanceof s||h instanceof t||h instanceof w||h instanceof $A||new CSSStyleSheet().insertRule("error",0),h instanceof w&&ig(h.unit)===null&&new CSSStyleSheet().insertRule("error",0),$o(h)}(function(){let e=new WeakMap;function h(K){const f=[];for(let x=0;x<K.length;x++)f[x]=typeof(b=K[x])=="number"?new CSSUnitValue(b,"number"):b;var b;return f}class F{static parse(f){return f instanceof F?f:DA(ke(f),{})}}class k extends F{constructor(f,b,x,m){super(),e.set(this,{values:h(f),operator:b,name:x||b,delimiter:m||", "})}get operator(){return e.get(this).operator}get values(){return e.get(this).values}toString(){const f=e.get(this);return`${f.name}(${f.values.join(f.delimiter)})`}}const U={CSSNumericValue:F,CSSMathValue:k,CSSUnitValue:class extends F{constructor(K,f){super(),e.set(this,{value:K,unit:f})}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 Dg(this,K)}toSum(...K){return _I(this,...K)}type(){return ig(e.get(this).unit)}toString(){const K=e.get(this);return`${K.value}${function(f){switch(f){case"percent":return"%";case"number":return"";default:return f.toLowerCase()}}(K.unit)}`}},CSSKeywordValue:class{constructor(K){this.value=K}toString(){return this.value.toString()}},CSSMathSum:class extends k{constructor(K){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends k{constructor(K){super(arguments,"product","calc"," * ")}toSum(...K){return _I(this,...K)}type(){return e.get(this).values.map(K=>K.type()).reduce(XI)}},CSSMathNegate:class extends k{constructor(K){super([arguments[0]],"negate","-")}get value(){return e.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends k{constructor(K){super([1,arguments[0]],"invert","calc"," / ")}get value(){return e.get(this).values[1]}type(){return function(K){const f={};for(const b of jI)f[b]=-1*K[b];return f}(e.get(this).values[1].type())}},CSSMathMax:class extends k{constructor(){super(arguments,"max")}},CSSMathMin:class extends k{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:f=>new CSSUnitValue(f,K)}))throw Error(`Error installing CSS.${K}`)});for(let[K,f]of Object.entries(U))if(!(K in window)&&!Reflect.defineProperty(window,K,{value:f}))throw Error(`Error installing CSSOM support for ${K}`)})();const As="block";let eI=new WeakMap,fg=new WeakMap;const IE=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Is(e){return e===document.scrollingElement?document:e}function wQ(e){di(e);let h=eI.get(e).animations;if(h.length===0)return;let F=e.currentTime;for(let k=0;k<h.length;k++)h[k].tickAnimation(F)}function gs(e,h){if(!e)return null;const F=fg.get(e).sourceMeasurements,k=getComputedStyle(e);let U=F.scrollTop;return NA(h,k)==="x"&&(U=Math.abs(F.scrollLeft)),U}function Ki(e,h){const F=DA(e,h);if(F instanceof CSSUnitValue){if(F.unit==="px")return F.value;throw TypeError("Unhandled unit type "+F.unit)}throw TypeError("Unsupported value type: "+typeof e)}function di(e){if(!(e instanceof PQ))return void function(F){const k=eI.get(F);if(!k.anonymousSource)return;const U=Bs(k.anonymousSource,k.anonymousTarget);LB(F,U)}(e);const h=e.subject;if(!h||getComputedStyle(h).display=="none")return void LB(e,null);LB(e,ui(h))}function Qs(e){return["block","inline","x","y"].includes(e)}function li(e){const h=getComputedStyle(e);return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight,clientWidth:e.clientWidth,clientHeight:e.clientHeight,writingMode:h.writingMode,direction:h.direction,scrollPaddingTop:h.scrollPaddingTop,scrollPaddingBottom:h.scrollPaddingBottom,scrollPaddingLeft:h.scrollPaddingLeft,scrollPaddingRight:h.scrollPaddingRight}}function fi(e,h){if(!e||!h)return;let F=0,k=0,U=h;const K=e.offsetParent;for(;U&&U!=K;)k+=U.offsetLeft,F+=U.offsetTop,U=U.offsetParent;k-=e.offsetLeft+e.clientLeft,F-=e.offsetTop+e.clientTop;const f=getComputedStyle(h);return{top:F,left:k,offsetWidth:h.offsetWidth,offsetHeight:h.offsetHeight,fontSize:f.fontSize}}function gE(e){let h=fg.get(e);h.sourceMeasurements=li(e);for(const F of h.timelineRefs){const k=F.deref();k instanceof PQ&&(eI.get(k).subjectMeasurements=fi(e,k.subject))}h.updateScheduled||(setTimeout(()=>{for(const F of h.timelineRefs){const k=F.deref();k&&wQ(k)}h.updateScheduled=!1}),h.updateScheduled=!0)}function LB(e,h){const F=eI.get(e),k=F.source;if(k!=h){if(k){const U=fg.get(k);if(U){U.timelineRefs.delete(e);const K=Array.from(U.timelineRefs).filter(f=>f.deref()===void 0);for(const f of K)U.timelineRefs.delete(f);U.timelineRefs.size===0&&(U.disconnect(),fg.delete(k))}}if(F.source=h,h){let U=fg.get(h);if(!U){U={timelineRefs:new Set,sourceMeasurements:li(h)},fg.set(h,U);const K=new ResizeObserver(x=>{for(const m of x)gE(F.source)});K.observe(h);for(const x of h.children)K.observe(x);const f=new MutationObserver(x=>{for(const m of x)gE(m.target)});f.observe(h,{attributes:!0,attributeFilter:["style","class"]});const b=()=>{U.sourceMeasurements.scrollLeft=h.scrollLeft,U.sourceMeasurements.scrollTop=h.scrollTop;for(const x of U.timelineRefs){const m=x.deref();m&&wQ(m)}};Is(h).addEventListener("scroll",b),U.disconnect=()=>{K.disconnect(),f.disconnect(),Is(h).removeEventListener("scroll",b)}}U.timelineRefs.add(new WeakRef(e))}}}function pi(e,h){let F=eI.get(e).animations;for(let k=0;k<F.length;k++)F[k].animation==h&&F.splice(k,1)}function xi(e,h,F){let k=eI.get(e).animations;for(let U=0;U<k.length;U++)if(k[U].animation==h)return;k.push({animation:h,tickAnimation:F}),queueMicrotask(()=>{wQ(e)})}class NI{constructor(h){if(eI.set(this,{source:null,axis:As,anonymousSource:h?h.anonymousSource:null,anonymousTarget:h?h.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),LB(this,h&&h.source!==void 0?h.source:document.scrollingElement),h&&h.axis!==void 0&&h.axis!=As){if(!Qs(h.axis))throw TypeError("Invalid axis");eI.get(this).axis=h.axis}wQ(this)}set source(h){LB(this,h),wQ(this)}get source(){return eI.get(this).source}set axis(h){if(!Qs(h))throw TypeError("Invalid axis");eI.get(this).axis=h,wQ(this)}get axis(){return eI.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const h=this.source;if(!h)return"inactive";let F=getComputedStyle(h);return F.display=="none"?"inactive":h==document.scrollingElement||F.overflow!="visible"&&F.overflow!="clip"?"active":"inactive"}get currentTime(){const h=this.source;if(!h||!h.isConnected||this.phase=="inactive")return null;const F=getComputedStyle(h);if(F.display==="inline"||F.display==="none")return null;const k=this.axis,U=gs(h,k),K=function(f,b){const x=fg.get(f).sourceMeasurements,m=getComputedStyle(f).writingMode=="horizontal-tb";return b==="block"?b=m?"y":"x":b==="inline"&&(b=m?"x":"y"),b==="y"?x.scrollHeight-x.clientHeight:b==="x"?x.scrollWidth-x.clientWidth:void 0}(h,k);return K>0?CSS.percent(100*U/K):CSS.percent(100)}get __polyfill(){return!0}}function qi(e,h){let F=e.parentElement;for(;F!=null;){if(h(F))return F;F=F.parentElement}}function Bs(e,h){switch(e){case"root":return document.scrollingElement;case"nearest":return ui(h);case"self":return h;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function ne(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 Cs(e){const h=getComputedStyle(e);return h.transform!="none"||h.perspective!="none"||h.willChange=="transform"||h.willChange=="perspective"||h.filter!="none"||h.willChange=="filter"||h.backdropFilter!="none"}function Ne(e){return getComputedStyle(e).position!="static"||Cs(e)}function Me(e){switch(getComputedStyle(e).position){case"static":case"relative":case"sticky":return qi(e,ne);case"absolute":return qi(e,Ne);case"fixed":return qi(e,Cs)}}function ui(e){if(e&&e.isConnected){for(;e=Me(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 HB(e,h){const F=eI.get(e),k=F.subjectMeasurements,U=fg.get(F.source).sourceMeasurements;return e.phase==="inactive"?null:e instanceof PQ?bi(h,U,k,F.axis,F.inset):null}function bi(e,h,F,k,U){const K=h.direction=="rtl"||h.writingMode=="vertical-rl";let f,b,x={fontSize:F.fontSize};NA(k,h)==="x"?(f=F.offsetWidth,b=F.left,x.scrollPadding=[h.scrollPaddingLeft,h.scrollPaddingRight],K&&(b+=h.scrollWidth-h.clientWidth,x.scrollPadding=[h.scrollPaddingRight,h.scrollPaddingLeft]),x.containerSize=h.clientWidth):(f=F.offsetHeight,b=F.top,x.scrollPadding=[h.scrollPaddingTop,h.scrollPaddingBottom],x.containerSize=h.clientHeight);const m=function(Oi,iE){const qe={start:0,end:0};if(!Oi)return qe;const[ue,be]=[Oi.start,Oi.end].map((rs,Fs)=>rs==="auto"?iE.scrollPadding[Fs]==="auto"?0:parseFloat(iE.scrollPadding[Fs]):Ki(rs,{percentageReference:CSS.px(iE.containerSize),fontSize:CSS.px(parseFloat(iE.fontSize))}));return{start:ue,end:be}}(U,x),V=b-x.containerSize+m.end,QA=b+f-m.start,CA=V+f,YA=QA-f,OA=Math.min(CA,YA),xI=Math.max(CA,YA);let tg,$I;const Ss=f>x.containerSize-m.start-m.end;switch(e){case"cover":tg=V,$I=QA;break;case"contain":tg=OA,$I=xI;break;case"entry":tg=V,$I=OA;break;case"exit":tg=xI,$I=QA;break;case"entry-crossing":tg=V,$I=Ss?xI:OA;break;case"exit-crossing":tg=Ss?OA:xI,$I=QA}return{start:tg,end:$I}}function Es(e,h){if(e instanceof PQ){const{rangeName:F,offset:k}=h;return is(HB(e,F),k,HB(e,"cover"),e.subject)}if(e instanceof NI){const{axis:F,source:k}=e,{sourceMeasurements:U}=fg.get(k);let K;return K=NA(F,U)==="x"?U.scrollWidth-U.clientWidth:U.scrollHeight-U.clientHeight,Ki(h,{percentageReference:CSS.px(K)})/K}unsupportedTimeline(e)}function is(e,h,F,k){if(!e||!F)return 0;let U=getComputedStyle(k);return(Ki(h,{percentageReference:CSS.px(e.end-e.start),fontSize:CSS.px(parseFloat(U.fontSize))})+e.start-F.start)/(F.end-F.start)}let PQ=class extends NI{constructor(e){super(e);const h=eI.get(this);h.subject=e&&e.subject?e.subject:void 0,e&&e.inset&&(h.inset=function(F){if(!F)return{start:0,end:0};let k;if(k=typeof F=="string"?MA(F).map(U=>{if(U==="auto")return"auto";try{return CSSNumericValue.parse(U)}catch{throw TypeError(`Could not parse inset "${F}"`)}}):Array.isArray(F)?F:[F],k.length===0||k.length>2)throw TypeError("Invalid inset");for(const U of k){if(U==="auto")continue;const K=U.type();if(K.length!==1&&K.percent!==1)throw TypeError("Invalid inset")}return{start:k[0],end:k[1]??k[0]}}(e.inset)),h.subject&&(new ResizeObserver(()=>{gE(h.source)}).observe(h.subject),new MutationObserver(()=>{gE(h.source)}).observe(h.subject,{attributes:!0,attributeFilter:["class","style"]})),di(this),h.subjectMeasurements=fi(h.source,h.subject),wQ(this)}get source(){return di(this),eI.get(this).source}set source(e){throw new Error("Cannot set the source of a view timeline")}get subject(){return eI.get(this).subject}get axis(){return eI.get(this).axis}get currentTime(){const e=gs(this.source,this.axis);if(e==null)return null;const h=HB(this,"cover");if(!h)return null;const F=(e-h.start)/(h.end-h.start);return CSS.percent(100*F)}get startOffset(){return CSS.px(HB(this,"cover").start)}get endOffset(){return CSS.px(HB(this,"cover").end)}};const Je=document.getAnimations,Ue=window.Element.prototype.getAnimations,Le=window.Element.prototype.animate,Ds=window.Animation;class TQ{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((h,F)=>{this.nativeResolve=h,this.nativeReject=F})}resolve(h){this.state="resolved",this.nativeResolve(h)}reject(h){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(h)}}function YB(e){e.readyPromise=new TQ,requestAnimationFrame(()=>{var h;(((h=e.timeline)==null?void 0:h.currentTime)??null)!==null&&(QE(e),e.pendingTask!=="play"||e.startTime===null&&e.holdTime===null?e.pendingTask==="pause"&&ts(e):ss(e))})}function os(){return new DOMException("The user aborted a request","AbortError")}function aQ(e,h){if(h===null)return h;if(typeof h!="number")throw new DOMException(`Unexpected value: ${h}. Cannot convert to CssNumberish`,"InvalidStateError");const F=e.rangeDuration??100,k=xg(e),U=k?F*h/k:0;return CSS.percent(U)}function uA(e,h){if(e.timeline){if(h===null)return h;if(h.unit==="percent"){const F=e.rangeDuration??100,k=xg(e);return h.value*k/F}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(h==null||typeof h=="number")return h;const F=h.to("ms");if(F)return F.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function ss(e){const h=uA(e,e.timeline.currentTime);if(e.holdTime!=null)ng(e),e.animation.playbackRate==0?e.startTime=h:(e.startTime=h-e.holdTime/e.animation.playbackRate,e.holdTime=null);else if(e.startTime!==null&&e.pendingPlaybackRate!==null){const F=(h-e.startTime)*e.animation.playbackRate;ng(e);const k=e.animation.playbackRate;k==0?(e.holdTime=null,e.startTime=h):e.startTime=h-F/k}e.readyPromise&&e.readyPromise.state=="pending"&&e.readyPromise.resolve(e.proxy),pg(e,!1,!1),qg(e),e.pendingTask=null}function ts(e){const h=uA(e,e.timeline.currentTime);e.startTime!=null&&e.holdTime==null&&(e.holdTime=(h-e.startTime)*e.animation.playbackRate),ng(e),e.startTime=null,e.readyPromise.resolve(e.proxy),pg(e,!1,!1),qg(e),e.pendingTask=null}function ws(e){if(!e.finishedPromise||e.finishedPromise.state!="pending"||e.proxy.playState!="finished")return;e.finishedPromise.resolve(e.proxy),e.animation.pause();const h=new CustomEvent("finish",{detail:{currentTime:e.proxy.currentTime,timelineTime:e.proxy.timeline.currentTime}});Object.defineProperty(h,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(h,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{e.animation.dispatchEvent(h)})})}function OQ(e){return e.pendingPlaybackRate!==null?e.pendingPlaybackRate:e.animation.playbackRate}function ng(e){e.pendingPlaybackRate!==null&&(e.animation.playbackRate=e.pendingPlaybackRate,e.pendingPlaybackRate=null)}function as(e){if(!e.timeline)return null;const h=uA(e,e.timeline.currentTime);if(h===null||e.startTime===null)return null;let F=(h-e.startTime)*e.animation.playbackRate;return F==-0&&(F=0),F}function pg(e,h,F){if(!e.timeline)return;let k=h?uA(e,e.proxy.currentTime):as(e);if(k&&e.startTime!=null&&!e.proxy.pending){const U=OQ(e),K=xg(e);let f=e.previousCurrentTime;U>0&&k>=K&&e.previousCurrentTime!=null?((f===null||f<K)&&(f=K),e.holdTime=h?k:f):U<0&&k<=0?((f==null||f>0)&&(f=0),e.holdTime=h?k:f):U!=0&&(h&&e.holdTime!==null&&(e.startTime=function(b,x){if(!b.timeline)return null;const m=uA(b,b.timeline.currentTime);return m==null?null:m-x/b.animation.playbackRate}(e,e.holdTime)),e.holdTime=null)}qg(e),e.previousCurrentTime=uA(e,e.proxy.currentTime),e.proxy.playState=="finished"?(e.finishedPromise||(e.finishedPromise=new TQ),e.finishedPromise.state=="pending"&&(F?ws(e):Promise.resolve().then(()=>{ws(e)}))):(e.finishedPromise&&e.finishedPromise.state=="resolved"&&(e.finishedPromise=new TQ),e.animation.playState!="paused"&&e.animation.pause())}function xg(e){const h=function(k){const U=k.proxy.effect.getTiming();return k.normalizedTiming||U}(e),F=h.delay+h.endDelay+h.iterations*h.duration;return Math.max(0,F)}function qg(e){if(e.timeline)if(e.startTime!==null){const h=e.timeline.currentTime;if(h==null)return;mi(e,(uA(e,h)-e.startTime)*e.animation.playbackRate)}else e.holdTime!==null&&mi(e,e.holdTime)}function mi(e,h){const F=e.timeline,k=e.animation.playbackRate,U=F.currentTime&&F.currentTime.value==(k<0?0:100)?k<0?.001:-.001:0;e.animation.currentTime=h+U}function Pi(e,h){if(!e.timeline)return;const F=e.proxy.playState=="paused"&&e.proxy.pending;let k=!1,U=uA(e,e.proxy.currentTime);OQ(e)==0&&U==null&&(e.holdTime=0),U==null&&(e.autoAlignStartTime=!0),(e.proxy.playState==="finished"||F)&&(e.holdTime=null,e.startTime=null,e.autoAlignStartTime=!0),e.holdTime&&(e.startTime=null),e.pendingTask&&(e.pendingTask=null,k=!0),(e.holdTime!==null||e.autoAlignStartTime||F||e.pendingPlaybackRate!==null)&&(e.readyPromise&&!k&&(e.readyPromise=null),qg(e),e.readyPromise||YB(e),e.pendingTask="play",xi(e.timeline,e.animation,Ti.bind(e.proxy)),pg(e,!1,!1))}function Ti(e){const h=gA.get(this);if(!h)return;if(e==null)return void(h.proxy.playState!=="paused"&&h.animation.playState!="idle"&&h.animation.cancel());QE(h),h.pendingTask&&requestAnimationFrame(()=>{h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&ts(h):ss(h)});const F=this.playState;if(F=="running"||F=="finished"){const k=uA(h,e);mi(h,(k-uA(h,this.startTime))*this.playbackRate),pg(h,!1,!1)}}function es(e){e.specifiedTiming=null}let gA=new WeakMap;window.addEventListener("pagehide",e=>{gA=new WeakMap},!1);let hs=new WeakMap;function QE(e){if(!e.autoAlignStartTime||!e.timeline||!e.timeline.currentTime||e.proxy.playState==="idle"||e.proxy.playState==="paused"&&e.holdTime!==null)return;const h=e.rangeDuration;let F,k;try{F=CSS.percent(100*function(K){if(!K.animationRange)return 0;const f=K.animationRange.start==="normal"?cs(K.timeline):K.animationRange.start;return Es(K.timeline,f)}(e))}catch(K){F=CSS.percent(0),e.animationRange.start="normal",console.warn("Exception when calculating start offset",K)}try{k=CSS.percent(100*(1-function(K){if(!K.animationRange)return 0;const f=K.animationRange.end==="normal"?ys(K.timeline):K.animationRange.end;return 1-Es(K.timeline,f)}(e)))}catch(K){k=CSS.percent(100),e.animationRange.end="normal",console.warn("Exception when calculating end offset",K)}e.rangeDuration=k.value-F.value;const U=OQ(e);e.startTime=uA(e,U>=0?F:k),e.holdTime=null,e.rangeDuration!==h&&es(e)}function BE(e){throw new Error("Unsupported timeline class")}function cs(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:e instanceof NI?CSS.percent(0):void BE()}function ys(e){return e instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:e instanceof NI?CSS.percent(100):void BE()}function He(e,h){if(!h)return{start:"normal",end:"normal"};const F={start:cs(e),end:ys(e)};if(e instanceof ViewTimeline){const k=MA(h),U=[],K=[];if(k.forEach(f=>{if(IE.includes(f))U.push(f);else try{K.push(CSSNumericValue.parse(f))}catch{throw TypeError(`Could not parse range "${h}"`)}}),U.length>2||K.length>2||K.length==1)throw TypeError("Invalid time range or unsupported time range format.");return U.length&&(F.start.rangeName=U[0],F.end.rangeName=U.length>1?U[1]:U[0]),K.length>1&&(F.start.offset=K[0],F.end.offset=K[1]),F}if(e instanceof NI){const k=h.split(" ");if(k.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return F.start=CSSNumericValue.parse(k[0]),F.end=CSSNumericValue.parse(k[1]),F}BE()}function CE(e,h,F){if(!h||h==="normal")return"normal";if(e instanceof ViewTimeline){let k="cover",U=F==="start"?CSS.percent(0):CSS.percent(100);if(h instanceof Object)h.rangeName!==void 0&&(k=h.rangeName),h.offset!==void 0&&(U=h.offset);else{const K=MA(h);K.length===1?IE.includes(K[0])?k=K[0]:U=DA(CSSNumericValue.parse(K[0]),{}):K.length===2&&(k=K[0],U=DA(CSSNumericValue.parse(K[1]),{}))}if(!IE.includes(k))throw TypeError("Invalid range name");return{rangeName:k,offset:U}}if(e instanceof NI)return CSSNumericValue.parse(h);BE()}class EE{constructor(h,F,k={}){const U=F instanceof NI,K=h instanceof Ds?h:new Ds(h,U?void 0:F);hs.set(K,this),gA.set(this,{animation:K,timeline:U?F:void 0,playState:U?"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:U?He(F,k["animation-range"]):null,proxy:this})}get effect(){const h=gA.get(this);return h.timeline?(h.effect||(h.effect=function(F){const k=F.animation.effect,U=k.updateTiming,K={apply:function(m){k.getTiming();const V=m.apply(k);if(F.timeline){const QA=F.duration??100;V.localTime=aQ(F,V.localTime),V.endTime=aQ(F,V.endTime),V.activeDuration=aQ(F,V.activeDuration);const CA=xg(F),YA=V.iterations?(CA-V.delay-V.endDelay)/V.iterations:0;V.duration=CA?CSS.percent(QA*YA/CA):CSS.percent(0),F.timeline.currentTime===void 0&&(V.localTime=null)}return V}},f={apply:function(m,V){if(F.specifiedTiming)return F.specifiedTiming;F.specifiedTiming=m.apply(k);let QA,CA=Object.assign({},F.specifiedTiming);if(CA.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(CA.duration===null||CA.duration==="auto"||F.autoDurationEffect)&&F.timeline&&(F.autoDurationEffect=!0,CA.delay=0,CA.endDelay=0,QA=CA.iterations?1e5:0,CA.duration=CA.iterations?(QA-CA.delay-CA.endDelay)/CA.iterations:0,CA.duration<0&&(CA.duration=0,CA.endDelay=QA-CA.delay),U.apply(k,[CA])),F.normalizedTiming=CA,F.specifiedTiming}},b={apply:function(m,V,QA){if(QA&&QA.length){if(F.timeline&&QA[0]){const CA=QA[0],YA=CA.duration;if(YA===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(CA.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");YA!==void 0&&YA!=="auto"&&(F.autoDurationEffect=null)}F.specifiedTiming&&m.apply(k,[F.specifiedTiming]),m.apply(k,QA),es(F)}}},x=new Proxy(k,{get:function(m,V){const QA=m[V];return typeof QA=="function"?QA.bind(k):QA},set:function(m,V,QA){return m[V]=QA,!0}});return x.getComputedTiming=new Proxy(k.getComputedTiming,K),x.getTiming=new Proxy(k.getTiming,f),x.updateTiming=new Proxy(k.updateTiming,b),x}(h)),h.effect):h.animation.effect}set effect(h){const F=gA.get(this);F.animation.effect=h,F.effect=null,F.autoDurationEffect=null}get timeline(){const h=gA.get(this);return h.timeline||h.animation.timeline}set timeline(h){const F=gA.get(this),k=this.timeline;if(k==h)return;const U=this.playState,K=this.currentTime;let f,b=xg(F);f=K===null?null:b===0?0:uA(F,K)/b;const x=k instanceof NI,m=h instanceof NI,V=this.pending;if(x&&pi(F.timeline,F.animation),m)return F.timeline=h,ng(F),F.autoAlignStartTime=!0,F.startTime=null,F.holdTime=null,U!=="running"&&U!=="finished"||(F.readyPromise&&F.readyPromise.state!=="resolved"||YB(F),F.pendingTask="play",xi(F.timeline,F.animation,Ti.bind(this))),U==="paused"&&f!==null&&(F.holdTime=f*b),V&&(F.readyPromise&&F.readyPromise.state!="resolved"||YB(F),F.pendingTask=U=="paused"?"pause":"play"),F.startTime!==null&&(F.holdTime=null),void pg(F,!1,!1);if(F.animation.timeline!=h)throw TypeError("Unsupported timeline: "+h);if(pi(F.timeline,F.animation),F.timeline=null,x)switch(K!==null&&(F.animation.currentTime=f*xg(F)),U){case"paused":F.animation.pause();break;case"running":case"finished":F.animation.play()}}get startTime(){const h=gA.get(this);return h.timeline?aQ(h,h.startTime):h.animation.startTime}set startTime(h){const F=gA.get(this);if(h=uA(F,h),!F.timeline)return void(F.animation.startTime=h);F.autoAlignStartTime=!1,uA(F,F.timeline.currentTime)==null&&F.startTime!=null&&(F.holdTime=null,qg(F));const k=uA(F,this.currentTime);ng(F),F.startTime=h,F.startTime!==null&&F.animation.playbackRate!=0?F.holdTime=null:F.holdTime=k,F.pendingTask&&(F.pendingTask=null,F.readyPromise.resolve(this)),pg(F,!0,!1),qg(F)}get currentTime(){const h=gA.get(this);return h.timeline?h.holdTime!=null?aQ(h,h.holdTime):aQ(h,as(h)):h.animation.currentTime}set currentTime(h){const F=gA.get(this);F.timeline?(function(k,U){if(U==null&&k.currentTime!==null)throw new TypeError;U=uA(k,U),k.autoAlignStartTime=!1,k.holdTime!==null||k.startTime===null||k.timeline.phase==="inactive"||k.animation.playbackRate===0?k.holdTime=U:k.startTime=uA(k,k.timeline.currentTime)-U/k.animation.playbackRate,k.timeline.phase==="inactive"&&(k.startTime=null),k.previousCurrentTime=null}(F,h),F.pendingTask=="pause"&&(F.holdTime=uA(F,h),ng(F),F.startTime=null,F.pendingTask=null,F.readyPromise.resolve(this)),pg(F,!0,!1)):F.animation.currentTime=h}get playbackRate(){return gA.get(this).animation.playbackRate}set playbackRate(h){const F=gA.get(this);if(!F.timeline)return void(F.animation.playbackRate=h);F.pendingPlaybackRate=null;const k=this.currentTime;F.animation.playbackRate=h,k!==null&&(this.currentTime=k)}get playState(){const h=gA.get(this);if(!h.timeline)return h.animation.playState;const F=uA(h,this.currentTime);return F===null&&h.startTime===null&&h.pendingTask==null?"idle":h.pendingTask=="pause"||h.startTime===null&&h.pendingTask!="play"?"paused":F!=null&&(h.animation.playbackRate>0&&F>=xg(h)||h.animation.playbackRate<0&&F<=0)?"finished":"running"}get rangeStart(){var h;return((h=gA.get(this).animationRange)==null?void 0:h.start)??"normal"}set rangeStart(h){const F=gA.get(this);if(!F.timeline)return F.animation.rangeStart=h;F.timeline instanceof NI&&(F.animationRange.start=CE(F.timeline,h,"start"),QE(F),qg(F))}get rangeEnd(){var h;return((h=gA.get(this).animationRange)==null?void 0:h.end)??"normal"}set rangeEnd(h){const F=gA.get(this);if(!F.timeline)return F.animation.rangeEnd=h;F.timeline instanceof NI&&(F.animationRange.end=CE(F.timeline,h,"end"),QE(F),qg(F))}get replaceState(){return gA.get(this).animation.pending}get pending(){const h=gA.get(this);return h.timeline?!!h.readyPromise&&h.readyPromise.state=="pending":h.animation.pending}finish(){const h=gA.get(this);if(!h.timeline)return void h.animation.finish();const F=OQ(h),k=xg(h);if(F==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(F>0&&k==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");ng(h);const U=F<0?0:k;this.currentTime=aQ(h,U);const K=uA(h,h.timeline.currentTime);h.startTime===null&&K!==null&&(h.startTime=K-U/h.animation.playbackRate),h.pendingTask=="pause"&&h.startTime!==null&&(h.holdTime=null,h.pendingTask=null,h.readyPromise.resolve(this)),h.pendingTask=="play"&&h.startTime!==null&&(h.pendingTask=null,h.readyPromise.resolve(this)),pg(h,!0,!0)}play(){const h=gA.get(this);h.timeline?Pi(h):h.animation.play()}pause(){const h=gA.get(this);h.timeline?this.playState!="paused"&&(h.animation.currentTime===null&&(h.autoAlignStartTime=!0),h.pendingTask=="play"?h.pendingTask=null:h.readyPromise=null,h.readyPromise||YB(h),h.pendingTask="pause",xi(h.timeline,h.animation,Ti.bind(h.proxy))):h.animation.pause()}reverse(){const h=gA.get(this),F=OQ(h),k=uA(h,this.currentTime),U=xg(h)==1/0,K=F!=0&&(F<0||k>0||!U);if(!h.timeline||!K)return K&&(h.pendingPlaybackRate=-OQ(h)),void h.animation.reverse();if(h.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-F),Pi(h)}updatePlaybackRate(h){const F=gA.get(this);if(F.pendingPlaybackRate=h,!F.timeline)return void F.animation.updatePlaybackRate(h);const k=this.playState;if(!F.readyPromise||F.readyPromise.state!="pending")switch(k){case"idle":case"paused":ng(F);break;case"finished":const U=uA(F,F.timeline.currentTime),K=U!==null?(U-F.startTime)*F.animation.playbackRate:null;F.startTime=h==0?U:U!=null&&K!=null?(U-K)/h:null,ng(F),pg(F,!1,!1),qg(F);break;default:Pi(F)}}persist(){gA.get(this).animation.persist()}get id(){return gA.get(this).animation.id}set id(h){gA.get(this).animation.id=h}cancel(){const h=gA.get(this);h.timeline?(this.playState!="idle"&&(function(F){F.pendingTask&&(F.pendingTask=null,ng(F),F.readyPromise.reject(os()),YB(F),F.readyPromise.resolve(F.proxy))}(h),h.finishedPromise&&h.finishedPromise.state=="pending"&&h.finishedPromise.reject(os()),h.finishedPromise=new TQ,h.animation.cancel()),h.startTime=null,h.holdTime=null,pi(h.timeline,h.animation)):h.animation.cancel()}get onfinish(){return gA.get(this).animation.onfinish}set onfinish(h){gA.get(this).animation.onfinish=h}get oncancel(){return gA.get(this).animation.oncancel}set oncancel(h){gA.get(this).animation.oncancel=h}get onremove(){return gA.get(this).animation.onremove}set onremove(h){gA.get(this).animation.onremove=h}get finished(){const h=gA.get(this);return h.timeline?(h.finishedPromise||(h.finishedPromise=new TQ),h.finishedPromise.promise):h.animation.finished}get ready(){const h=gA.get(this);return h.timeline?(h.readyPromise||(h.readyPromise=new TQ,h.readyPromise.resolve(this)),h.readyPromise.promise):h.animation.ready}addEventListener(h,F,k){gA.get(this).animation.addEventListener(h,F,k)}removeEventListener(h,F,k){gA.get(this).animation.removeEventListener(h,F,k)}dispatchEvent(h){gA.get(this).animation.dispatchEvent(h)}}function Ye(e,h){const F=h.timeline;F instanceof NI&&delete h.timeline;const k=Le.apply(this,[e,h]),U=new EE(k,F);return F instanceof NI&&(k.pause(),gA.get(U).animationRange={start:CE(F,h.rangeStart,"start"),end:CE(F,h.rangeEnd,"end")},U.play()),U}function Gs(e){for(let h=0;h<e.length;++h){let F=hs.get(e[h]);F&&(e[h]=F)}return e}function Ke(e){return Gs(Ue.apply(this,[e]))}function de(e){return Gs(Je.apply(this,[e]))}const AI={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\(([^)]*)\)/},XQ=["block","inline","x","y"],le=["nearest","root","self"],$g=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,h,F){const k={sheetSrc:e,index:0,name:F};for(;k.index<k.sheetSrc.length&&(this.eatWhitespace(k),!(k.index>=k.sheetSrc.length));){if(this.lookAhead("/*",k)){for(;this.lookAhead("/*",k);)this.eatComment(k),this.eatWhitespace(k);continue}const U=this.parseQualifiedRule(k);U&&(h?this.parseKeyframesAndSaveNameMapping(U,k):this.handleScrollTimelineProps(U,k))}return k.sheetSrc}getAnimationTimelineOptions(e,h){for(let F=this.cssRulesWithTimelineName.length-1;F>=0;F--){const k=this.cssRulesWithTimelineName[F];try{if(h.matches(k.selector)&&(!k["animation-name"]||k["animation-name"]==e))return{"animation-timeline":k["animation-timeline"],"animation-range":k["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(e,h){const F=this.anonymousScrollTimelineOptions.get(e);return F?{anonymousSource:F.source,anonymousTarget:h,source:Bs(F.source??"nearest",h),axis:F.axis?F.axis:"block"}:null}getScrollTimelineOptions(e,h){const F=this.getAnonymousScrollTimelineOptions(e,h);if(F)return F;for(let k=this.sourceSelectorToScrollTimeline.length-1;k>=0;k--){const U=this.sourceSelectorToScrollTimeline[k];if(U.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(h,U.selector);if(K)return{source:K,...U.axis?{axis:U.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(e,h){let F=e;for(;F;){if(F.matches(h))return F;F=F.previousElementSibling||F.parentElement}return null}getAnonymousViewTimelineOptions(e,h){const F=this.anonymousViewTimelineOptions.get(e);return F?{subject:h,axis:F.axis?F.axis:"block",inset:F.inset?F.inset:"auto"}:null}getViewTimelineOptions(e,h){const F=this.getAnonymousViewTimelineOptions(e,h);if(F)return F;for(let k=this.subjectSelectorToViewTimeline.length-1;k>=0;k--){const U=this.subjectSelectorToViewTimeline[k];if(U.name==e){const K=this.findPreviousSiblingOrAncestorMatchingSelector(h,U.selector);if(K)return{subject:K,axis:U.axis,inset:U.inset}}}return null}handleScrollTimelineProps(e,h){if(e.selector.includes("@keyframes"))return;const F=e.block.contents.includes("animation-name:"),k=e.block.contents.includes("animation-timeline:"),U=e.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(e),this.saveSubjectSelectorToViewTimeline(e),!k&&!F&&!U)return;let K=[],f=[],b=!1;k&&(K=this.extractScrollTimelineNames(e.block.contents)),F&&(f=this.extractMatches(e.block.contents,AI.ANIMATION_NAME)),k&&F||(U&&this.extractMatches(e.block.contents,AI.ANIMATION).forEach(x=>{const m=this.extractAnimationName(x);m&&k&&f.push(m),k&&(this.hasDuration(x)||(this.hasAutoDuration(x)&&(e.block.contents=e.block.contents.replace("auto"," ")),e.block.contents=e.block.contents.replace(x," 1s "+x),b=!0))}),b&&this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,h)),this.saveRelationInList(e,K,f)}saveSourceSelectorToScrollTimeline(e){const h=e.block.contents.includes("scroll-timeline:"),F=e.block.contents.includes("scroll-timeline-name:"),k=e.block.contents.includes("scroll-timeline-axis:");if(!h&&!F)return;let U=[];if(h){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE);for(const b of f){const x=this.split(b);let m={selector:e.selector,name:""};x.length==1?m.name=x[0]:x.length==2&&(XQ.includes(x[0])?(m.axis=x[0],m.name=x[1]):(m.axis=x[1],m.name=x[0])),U.push(m)}}if(F){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE_NAME);for(let b=0;b<f.length;b++)if(b<U.length)U[b].name=f[b];else{let x={selector:e.selector,name:f[b]};U.push(x)}}let K=[];if(k){const f=this.extractMatches(e.block.contents,AI.SCROLL_TIMELINE_AXIS);if(K=f.filter(b=>XQ.includes(b)),K.length!=f.length)throw new Error("Invalid axis")}for(let f=0;f<U.length;f++)K.length&&(U[f].axis=K[f%U.length]);this.sourceSelectorToScrollTimeline.push(...U)}saveSubjectSelectorToViewTimeline(e){const h=e.block.contents.includes("view-timeline:"),F=e.block.contents.includes("view-timeline-name:"),k=e.block.contents.includes("view-timeline-axis:"),U=e.block.contents.includes("view-timeline-inset:");if(!h&&!F)return;let K=[];if(h){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE);for(let m of x){const V=this.split(m);let QA={selector:e.selector,name:"",inset:null};V.length==1?QA.name=V[0]:V.length==2&&(XQ.includes(V[0])?(QA.axis=V[0],QA.name=V[1]):(QA.axis=V[1],QA.name=V[0])),K.push(QA)}}if(F){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_NAME);for(let m=0;m<x.length;m++)if(m<K.length)K[m].name=x[m];else{let V={selector:e.selector,name:x[m],inset:null};K.push(V)}}let f=[],b=[];if(U&&(f=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_INSET)),k){const x=this.extractMatches(e.block.contents,AI.VIEW_TIMELINE_AXIS);if(b=x.filter(m=>XQ.includes(m)),b.length!=x.length)throw new Error("Invalid axis")}for(let x=0;x<K.length;x++)f.length&&(K[x].inset=f[x%K.length]),b.length&&(K[x].axis=b[x%K.length]);this.subjectSelectorToViewTimeline.push(...K)}hasDuration(e){return e.split(" ").filter(h=>{return F=h,AI.TIME.exec(F);var F}).length>=1}hasAutoDuration(e){return e.split(" ").filter(h=>h==="auto").length>=1}saveRelationInList(e,h,F){let k=[];e.block.contents.includes("animation-range:")&&(k=this.extractMatches(e.block.contents,AI.ANIMATION_TIME_RANGE));const U=Math.max(h.length,F.length,k.length);for(let K=0;K<U;K++)this.cssRulesWithTimelineName.push({selector:e.selector,"animation-timeline":h[K%h.length],...F.length?{"animation-name":F[K%F.length]}:{},...k.length?{"animation-range":k[K%k.length]}:{}})}extractScrollTimelineNames(e){const h=AI.ANIMATION_TIMELINE.exec(e)[1].trim(),F=[];return h.split(",").map(k=>k.trim()).forEach(k=>{if(function(U){return(U.startsWith("scroll")||U.startsWith("view"))&&U.includes("(")}(k)){const U=this.saveAnonymousTimelineName(k);F.push(U)}else F.push(k)}),F}saveAnonymousTimelineName(e){const h=":t"+this.nextAnonymousTimelineNameIndex++;return e.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(h,this.parseAnonymousScrollTimeline(e)):this.anonymousViewTimelineOptions.set(h,this.parseAnonymousViewTimeline(e)),h}parseAnonymousScrollTimeline(e){const h=AI.ANONYMOUS_SCROLL_TIMELINE.exec(e);if(!h)return null;const F=h[1],k={};return F.split(" ").forEach(U=>{XQ.includes(U)?k.axis=U:le.includes(U)&&(k.source=U)}),k}parseAnonymousViewTimeline(e){const h=AI.ANONYMOUS_VIEW_TIMELINE.exec(e);if(!h)return null;const F=h[1],k={};return F.split(" ").forEach(U=>{XQ.includes(U)?k.axis=U:k.inset=k.inset?`${k.inset} ${U}`:U}),k}extractAnimationName(e){return this.findMatchingEntryInContainer(e,this.keyframeNamesSelectors)}findMatchingEntryInContainer(e,h){const F=e.split(" ").filter(k=>h.has(k));return F?F[0]:null}parseIdentifier(e){AI.IDENTIFIER.lastIndex=e.index;const h=AI.IDENTIFIER.exec(e.sheetSrc);if(!h)throw this.parseError(e,"Expected an identifier");return e.index+=h[0].length,h[0]}parseKeyframesAndSaveNameMapping(e,h){if(e.selector.startsWith("@keyframes")){const F=this.replaceKeyframesAndGetMapping(e,h);e.selector.split(" ").forEach((k,U)=>{U>0&&this.keyframeNamesSelectors.set(k,F)})}}replaceKeyframesAndGetMapping(e,h){function F(x){return IE.some(m=>x.startsWith(m))}const k=e.block.contents,U=function(x){let m=0,V=-1,QA=-1;const CA=[];for(let YA=0;YA<x.length;YA++)x[YA]=="{"?m++:x[YA]=="}"&&m--,m==1&&x[YA]!="{"&&x[YA]!="}"&&V==-1&&(V=YA),m==2&&x[YA]=="{"&&(QA=YA,CA.push({start:V,end:QA}),V=QA=-1);return CA}(k);if(U.length==0)return new Map;const K=new Map;let f=!1;const b=[];b.push(k.substring(0,U[0].start));for(let x=0;x<U.length;x++){const m=k.substring(U[x].start,U[x].end);let V=[];m.split(",").forEach(QA=>{const CA=QA.split(" ").map(OA=>OA.trim()).filter(OA=>OA!="").join(" "),YA=K.size;K.set(YA,CA),V.push(`${YA}%`),F(CA)&&(f=!0)}),b.push(V.join(",")),x==U.length-1?b.push(k.substring(U[x].end)):b.push(k.substring(U[x].end,U[x+1].start))}return f?(e.block.contents=b.join(""),this.replacePart(e.block.startIndex,e.block.endIndex,e.block.contents,h),K):new Map}parseQualifiedRule(e){const h=e.index,F=this.parseSelector(e).trim();if(F)return{selector:F,block:this.eatBlock(e),startIndex:h,endIndex:e.index}}removeEnclosingDoubleQuotes(e){let h=e[0]=='"'?1:0,F=e[e.length-1]=='"'?e.length-1:e.length;return e.substring(h,F)}assertString(e,h){if(e.sheetSrc.substr(e.index,h.length)!=h)throw this.parseError(e,`Did not find expected sequence ${h}`);e.index+=h.length}replacePart(e,h,F,k){if(k.sheetSrc=k.sheetSrc.slice(0,e)+F+k.sheetSrc.slice(h),k.index>=h){const U=k.index-h;k.index=e+F.length+U}}eatComment(e){this.assertString(e,"/*"),this.eatUntil("*/",e,!0),this.assertString(e,"*/")}eatBlock(e){const h=e.index;this.assertString(e,"{");let F=1;for(;F!=0;)this.lookAhead("/*",e)?this.eatComment(e):(e.sheetSrc[e.index]==="{"?F++:e.sheetSrc[e.index]==="}"&&F--,this.advance(e));const k=e.index;return{startIndex:h,endIndex:k,contents:e.sheetSrc.slice(h,k)}}advance(e){if(e.index++,e.index>e.sheetSrc.length)throw this.parseError(e,"Advanced beyond the end")}parseError(e,h){return Error(`(${e.name?e.name:"<anonymous file>"}): ${h}`)}eatUntil(e,h,F=!1){const k=h.index;for(;!this.lookAhead(e,h);)this.advance(h);return F&&(h.sheetSrc=h.sheetSrc.slice(0,k)+" ".repeat(h.index-k)+h.sheetSrc.slice(h.index)),h.sheetSrc.slice(k,h.index)}parseSelector(e){let h=e.index;if(this.eatUntil("{",e),h===e.index)throw Error("Empty selector");return e.sheetSrc.slice(h,e.index)}eatWhitespace(e){AI.WHITE_SPACE.lastIndex=e.index;const h=AI.WHITE_SPACE.exec(e.sheetSrc);h&&(e.index+=h[0].length)}lookAhead(e,h){return h.sheetSrc.substr(h.index,e.length)==e}peek(e){return e.sheetSrc[e.index]}extractMatches(e,h,F=","){return h.exec(e)[1].trim().split(F).map(k=>k.trim())}split(e){return e.split(" ").map(h=>h.trim()).filter(h=>h!="")}};function fe(e,h,F,k,U,K){const f=li(h),b=fi(h,F);return is(bi(e,f,b,k,U),K,bi("cover",f,b,k,U),F)}function pe(e,h,F){const k=$g.getAnimationTimelineOptions(h,F);if(!k)return null;const U=k["animation-timeline"];if(!U)return null;let K=$g.getScrollTimelineOptions(U,F)||$g.getViewTimelineOptions(U,F);return K?(K.subject&&function(f,b){const x=ui(b.subject),m=b.axis||b.axis;function V(CA,YA){let OA=null;for(const[xI,tg]of CA)if(xI==100*YA.offset){if(tg=="from")OA=0;else if(tg=="to")OA=100;else{const $I=tg.split(" ");OA=$I.length==1?parseFloat($I[0]):100*fe($I[0],x,b.subject,m,b.inset,CSS.percent(parseFloat($I[1])))}break}return OA}const QA=$g.keyframeNamesSelectors.get(f.animationName);if(QA&&QA.size){const CA=[];f.effect.getKeyframes().forEach(OA=>{const xI=V(QA,OA);xI!==null&&xI>=0&&xI<=100&&(OA.offset=xI/100,CA.push(OA))});const YA=CA.sort((OA,xI)=>OA.offset<xI.offset?-1:OA.affset>xI.offset?1:0);f.effect.setKeyframes(YA)}}(e,K),{timeline:K.source?new NI(K):new PQ(K),animOptions:k}):null}function xe(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function h(k){if(k.innerHTML.trim().length===0||"aphrodite"in k.dataset)return;let U=$g.transpileStyleSheet(k.innerHTML,!0);U=$g.transpileStyleSheet(U,!1),k.innerHTML=U}function F(k){k.type!="text/css"&&k.rel!="stylesheet"||!k.href||new URL(k.href,document.baseURI).origin==location.origin&&fetch(k.getAttribute("href")).then(async U=>{const K=await U.text();let f=$g.transpileStyleSheet(K,!0);if(f=$g.transpileStyleSheet(K,!1),f!=K){const b=new Blob([f],{type:"text/css"}),x=URL.createObjectURL(b);k.setAttribute("href",x)}})}new MutationObserver(k=>{for(const U of k)for(const K of U.addedNodes)K instanceof HTMLStyleElement&&h(K),K instanceof HTMLLinkElement&&F(K)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(k=>h(k)),document.querySelectorAll("link").forEach(k=>F(k))})();const e=CSS.supports;CSS.supports=h=>(h=h.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),e(h)),window.addEventListener("animationstart",h=>{h.target.getAnimations().filter(F=>F.animationName===h.animationName).forEach(F=>{const k=pe(F,F.animationName,h.target);if(k)if(!k.timeline||F instanceof EE)F.timeline=k.timeline;else{const U=new EE(F,k.timeline,k.animOptions);F.pause(),U.play()}})})}(function(){if(!xe()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:NI}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:PQ}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Ye}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:EE}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Ke}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:de}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();const eF=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),hF=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{$h as BatchedParticleRenderer,zo as Builder,nC as ByteBuffer,qQ as ConstantColor,rA as ConstantValue,kg as Matrix4,UB as MeshBVH,O0 as MotionController,yD as PROJECT_DOCUMENT_KEY,Yi as ParticleSystem,X as RenderMode,Os as SIZE_PREFIX_LENGTH,RE as TrailParticle,OI as Vector4,CF as WorkerBase,hF as __viteBrowserExternal,at as applyDef,ht as applyOver,Ts as attachNeedleIdsToLoadedGltf,By as bundler,Ic as createNoise4D,et as createOverApplyState,U0 as deriveInstanceId,Cc as enableProjectDocumentInspection,sc as evaluateProjectDocument,u0 as fetchProfile,ic as getProjectDocumentInspection,Nc as index,BF as index$1,tF as index$2,st as isProjectDocument,Qc as reportProjectIssues,bB as resolveDocumentRemoteSrc,yt as resolveMaterialEntity,eF as scrollTimeline,$S as spark_module,SD as splitPath,G0 as v5};
|