@splinetool/viewer 0.9.454 → 0.9.455
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/build/spline-viewer.cjs
CHANGED
|
@@ -3135,9 +3135,9 @@ void main() {
|
|
|
3135
3135
|
squared_mean = squared_mean / samples;
|
|
3136
3136
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3137
3137
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3138
|
-
}`;function ZI(e,t,i){let r=new zv,s=new k,n=new k,a=new et,o=new fS({depthPacking:eS}),l=new XI,h={},u=i.maxTextureSize,c={[ns]:xi,[xi]:ns,[br]:br},d=new Ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:YI,fragmentShader:QI}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new qe;f.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new nr(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dv,this.render=function(b,_,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),w=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(si),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],L=P.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let B=L.getFrameExtents();if(s.multiply(B),n.copy(L.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(n.x=Math.floor(u/B.x),s.x=n.x*B.x,L.mapSize.x=n.x),s.y>u&&(n.y=Math.floor(u/B.y),s.y=n.y*B.y,L.mapSize.y=n.y)),L.map===null){let U=this.type!==Rh?{minFilter:Lt,magFilter:Lt}:{};L.map=new Mt(s.x,s.y,U),L.map.texture.name=P.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let V=L.getViewportCount();for(let U=0;U<V;U++){let z=L.getViewport(U);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),L.updateMatrices(P,U),r=L.getFrustum(),x(_,A,L.camera,P,this.type)}L.isPointLightShadow!==!0&&this.type===Rh&&v(L,A),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,w,M)};function v(b,_){let A=t.update(g);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Mt(s.x,s.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(_,null,A,d,g,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(_,null,A,p,g,null)}function y(b,_,A,S,w,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,P=_.uuid,L=h[D];L===void 0&&(L={},h[D]=L);let B=L[P];B===void 0&&(B=C.clone(),L[P]=B),C=B}return C.visible=_.visible,C.wireframe=_.wireframe,M===Rh?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=w),C}function x(b,_,A,S,w){if(b.visible===!1)return;if(b.layers.test(_.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&w===Rh)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,L=D.length;P<L;P++){let B=D[P],V=T[B.materialIndex];if(V&&V.visible){let U=y(b,V,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,U,b,B)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],_,A,S,w)}}function KI(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new et,ge=null,we=new et(0,0,0,0);return{setMask:function(Ge){ge!==Ge&&!Y&&(e.colorMask(Ge,Ge,Ge,Ge),ge=Ge)},setLocked:function(Ge){Y=Ge},setClear:function(Ge,vt,kt,Pi,pa){pa===!0&&(Ge*=Pi,vt*=Pi,kt*=Pi),ne.set(Ge,vt,kt,Pi),we.equals(ne)===!1&&(e.clearColor(Ge,vt,kt,Pi),we.copy(ne))},reset:function(){Y=!1,ge=null,we.set(-1,0,0,0)}}}function n(){let Y=!1,ne=null,ge=null,we=null;return{setTest:function(Ge){Ge?ie(2929):Q(2929)},setMask:function(Ge){ne!==Ge&&!Y&&(e.depthMask(Ge),ne=Ge)},setFunc:function(Ge){if(ge!==Ge){switch(Ge){case vC:e.depthFunc(512);break;case yC:e.depthFunc(519);break;case xC:e.depthFunc(513);break;case Gm:e.depthFunc(515);break;case bC:e.depthFunc(514);break;case wC:e.depthFunc(518);break;case _C:e.depthFunc(516);break;case SC:e.depthFunc(517);break;default:e.depthFunc(515)}ge=Ge}},setLocked:function(Ge){Y=Ge},setClear:function(Ge){we!==Ge&&(e.clearDepth(Ge),we=Ge)},reset:function(){Y=!1,ne=null,ge=null,we=null}}}function a(){let Y=!1,ne=null,ge=null,we=null,Ge=null,vt=null,kt=null,Pi=null,pa=null;return{setTest:function(Nt){Y||(Nt?ie(2960):Q(2960))},setMask:function(Nt){ne!==Nt&&!Y&&(e.stencilMask(Nt),ne=Nt)},setFunc:function(Nt,Ws,Mr){(ge!==Nt||we!==Ws||Ge!==Mr)&&(e.stencilFunc(Nt,Ws,Mr),ge=Nt,we=Ws,Ge=Mr)},setOp:function(Nt,Ws,Mr){(vt!==Nt||kt!==Ws||Pi!==Mr)&&(e.stencilOp(Nt,Ws,Mr),vt=Nt,kt=Ws,Pi=Mr)},setLocked:function(Nt){Y=Nt},setClear:function(Nt){pa!==Nt&&(e.clearStencil(Nt),pa=Nt)},reset:function(){Y=!1,ne=null,ge=null,we=null,Ge=null,vt=null,kt=null,Pi=null,pa=null}}}let o=new s,l=new n,h=new a,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,M=!1,C=null,T=null,D=null,P=null,L=null,B=e.getParameter(35661),V=!1,U=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(U=parseFloat(/^WebGL (\d)/.exec(z)[1]),V=U>=1):z.indexOf("OpenGL ES")!==-1&&(U=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),V=U>=2);let X=null,H={},G=e.getParameter(3088),F=e.getParameter(2978),q=new et().fromArray(G),j=new et().fromArray(F);function W(Y,ne,ge){let we=new Uint8Array(4),Ge=e.createTexture();e.bindTexture(Y,Ge),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let vt=0;vt<ge;vt++)e.texImage2D(ne+vt,0,6408,1,1,0,6408,5121,we);return Ge}let N={};N[3553]=W(3553,3553,1),N[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Gm),Me(!1),Pe(Iy),ie(2884),Ae(si);function ie(Y){d[Y]!==!0&&(e.enable(Y),d[Y]=!0)}function Q(Y){d[Y]!==!1&&(e.disable(Y),d[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ge=g,we=!1;if(Y)if(ge=f.get(ne),ge===void 0&&(ge=[],f.set(ne,ge)),Y.isWebGLMultipleRenderTargets){let Ge=Y.texture;if(ge.length!==Ge.length||ge[0]!==36064){for(let vt=0,kt=Ge.length;vt<kt;vt++)ge[vt]=36064+vt;ge.length=Ge.length,we=!0}}else ge[0]!==36064&&(ge[0]=36064,we=!0);else ge[0]!==1029&&(ge[0]=1029,we=!0);we&&(i.isWebGL2?e.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function ue(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let ae={[jo]:32774,[aC]:32778,[oC]:32779};if(r)ae[By]=32775,ae[zy]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ae[By]=Y.MIN_EXT,ae[zy]=Y.MAX_EXT)}let se={[lC]:0,[hC]:1,[cC]:768,[q_]:770,[gC]:776,[fC]:774,[uC]:772,[dC]:769,[X_]:771,[mC]:775,[pC]:773};function Ae(Y,ne,ge,we,Ge,vt,kt,Pi){if(Y===si){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==nC){if(Y!==y||Pi!==M){if((x!==jo||A!==jo)&&(e.blendEquation(32774),x=jo,A=jo),Pi)switch(Y){case el:e.blendFuncSeparate(1,771,1,771);break;case Ly:e.blendFunc(1,1);break;case Oy:e.blendFuncSeparate(0,769,0,1);break;case Ry:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case el:e.blendFuncSeparate(770,771,1,771);break;case Ly:e.blendFunc(770,1);break;case Oy:e.blendFuncSeparate(0,769,0,1);break;case Ry:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,_=null,S=null,w=null,y=Y,M=Pi}return}Ge=Ge||ne,vt=vt||ge,kt=kt||we,(ne!==x||Ge!==A)&&(e.blendEquationSeparate(ae[ne],ae[Ge]),x=ne,A=Ge),(ge!==b||we!==_||vt!==S||kt!==w)&&(e.blendFuncSeparate(se[ge],se[we],se[vt],se[kt]),b=ge,_=we,S=vt,w=kt),y=Y,M=!1}function Se(Y,ne){Y.side===br?Q(2884):ie(2884);let ge=Y.side===xi;ne&&(ge=!ge),Me(ge),Y.blending===el&&Y.transparent===!1?Ae(si):Ae(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let we=Y.stencilWrite;h.setTest(we),we&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ve(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Me(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Pe(Y){Y!==iC?(ie(2884),Y!==T&&(Y===Iy?e.cullFace(1029):Y===rC?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function xe(Y){Y!==D&&(V&&e.lineWidth(Y),D=Y)}function ve(Y,ne,ge){Y?(ie(32823),(P!==ne||L!==ge)&&(e.polygonOffset(ne,ge),P=ne,L=ge)):Q(32823)}function Be(Y){Y?ie(3089):Q(3089)}function Ze(Y){Y===void 0&&(Y=33984+B-1),X!==Y&&(e.activeTexture(Y),X=Y)}function R(Y,ne,ge){ge===void 0&&(X===null?ge=33984+B-1:ge=X);let we=H[ge];we===void 0&&(we={type:void 0,texture:void 0},H[ge]=we),(we.type!==Y||we.texture!==ne)&&(X!==ge&&(e.activeTexture(ge),X=ge),e.bindTexture(Y,ne||N[Y]),we.type=Y,we.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ye(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Re(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Xe(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ne(Y){j.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function ft(Y,ne){let ge=c.get(ne);ge===void 0&&(ge=new WeakMap,c.set(ne,ge));let we=ge.get(Y);we===void 0&&(we=e.getUniformBlockIndex(ne,Y.name),ge.set(Y,we))}function Rt(Y,ne){let ge=c.get(ne).get(Y);u.get(ne)!==ge&&(e.uniformBlockBinding(ne,ge,Y.__bindingPointIndex),u.set(ne,ge))}function $t(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},X=null,H={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,M=!1,C=null,T=null,D=null,P=null,L=null,q.set(0,0,e.canvas.width,e.canvas.height),j.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:ue,setBlending:Ae,setMaterial:Se,setFlipSided:Me,setCullFace:Pe,setLineWidth:xe,setPolygonOffset:ve,setScissorTest:Be,activeTexture:Ze,bindTexture:R,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:me,texImage2D:Re,texImage3D:Ie,updateUBOMapping:ft,uniformBlockBinding:Rt,texStorage2D:de,texStorage3D:De,texSubImage2D:ce,texSubImage3D:ye,compressedTexSubImage2D:Oe,compressedTexSubImage3D:Ee,scissor:Xe,viewport:Ne,reset:$t}}function JI(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):wu("canvas")}function x(R,I,$,me){let ce=1;if((R.width>me||R.height>me)&&(ce=me/Math.max(R.width,R.height)),ce<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let ye=I?bu:Math.floor,Oe=ye(ce*R.width),Ee=ye(ce*R.height);g===void 0&&(g=y(Oe,Ee));let de=$?y(Oe,Ee):g;return de.width=Oe,de.height=Ee,de.getContext("2d").drawImage(R,0,0,Oe,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Oe+"x"+Ee+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Ym(R.width)&&Ym(R.height)}function _(R){return o?!1:R.wrapS!==Qt||R.wrapT!==Qt||R.minFilter!==Lt&&R.minFilter!==nt}function A(R,I){return R.generateMipmaps&&I&&R.minFilter!==Lt&&R.minFilter!==nt}function S(R){e.generateMipmap(R)}function w(R,I,$,me,ce=!1){if(o===!1)return I;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let ye=I;return I===6403&&($===5126&&(ye=33326),$===5131&&(ye=33325),$===5121&&(ye=33321)),I===33319&&($===5126&&(ye=33328),$===5131&&(ye=33327),$===5121&&(ye=33323)),I===6408&&($===5126&&(ye=34836),$===5131&&(ye=34842),$===5121&&(ye=me===$e&&ce===!1?35907:32856),$===32819&&(ye=32854),$===32820&&(ye=32855)),(ye===33325||ye===33326||ye===33327||ye===33328||ye===34842||ye===34836)&&t.get("EXT_color_buffer_float"),ye}function M(R,I,$){return A(R,$)===!0||R.isFramebufferTexture&&R.minFilter!==Lt&&R.minFilter!==nt?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function C(R){return R===Lt||R===Fy||R===Yp?9728:9729}function T(R){let I=R.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function P(R){let I=r.get(R);if(I.__webglInit===void 0)return;let $=R.source,me=m.get($);if(me){let ce=me[I.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&L(R),Object.keys(me).length===0&&m.delete($)}r.remove(R)}function L(R){let I=r.get(R);e.deleteTexture(I.__webglTexture);let $=R.source,me=m.get($);delete me[I.__cacheKey],a.memory.textures--}function B(R){let I=R.texture,$=r.get(R),me=r.get(I);if(me.__webglTexture!==void 0&&(e.deleteTexture(me.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++)e.deleteFramebuffer($.__webglFramebuffer[ce]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[ce]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let ce=0;ce<$.__webglColorRenderbuffer.length;ce++)$.__webglColorRenderbuffer[ce]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[ce]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let ce=0,ye=I.length;ce<ye;ce++){let Oe=r.get(I[ce]);Oe.__webglTexture&&(e.deleteTexture(Oe.__webglTexture),a.memory.textures--),r.remove(I[ce])}r.remove(I),r.remove(R)}let V=0;function U(){V=0}function z(){let R=V;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),V+=1,R}function X(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function H(R,I){let $=r.get(R);if(R.isVideoTexture&&Be(R),R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,R,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function G(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function F(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){re($,R,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let j={[gn]:10497,[Qt]:33071,[Wm]:33648},W={[Lt]:9728,[Fy]:9984,[Yp]:9986,[nt]:9729,[IC]:9985,[gl]:9987};function N(R,I,$){if($?(e.texParameteri(R,10242,j[I.wrapS]),e.texParameteri(R,10243,j[I.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,j[I.wrapR]),e.texParameteri(R,10240,W[I.magFilter]),e.texParameteri(R,10241,W[I.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(I.wrapS!==Qt||I.wrapT!==Qt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(I.magFilter)),e.texParameteri(R,10241,C(I.minFilter)),I.minFilter!==Lt&&I.minFilter!==nt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Lt||I.minFilter!==Yp&&I.minFilter!==gl||I.type===wr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===vl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(R,I){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",T));let me=I.source,ce=m.get(me);ce===void 0&&(ce={},m.set(me,ce));let ye=X(I);if(ye!==R.__cacheKey){ce[ye]===void 0&&(ce[ye]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,$=!0),ce[ye].usedTimes++;let Oe=ce[R.__cacheKey];Oe!==void 0&&(ce[R.__cacheKey].usedTimes--,Oe.usedTimes===0&&L(I)),R.__cacheKey=ye,R.__webglTexture=ce[ye].texture}return $}function Q(R,I,$){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let ce=ie(R,I),ye=I.source;i.bindTexture(me,R.__webglTexture,33984+$);let Oe=r.get(ye);if(ye.version!==Oe.__version||ce===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ee=_(I)&&b(I.image)===!1,de=x(I.image,Ee,!1,u);de=Ze(I,de);let De=b(de)||o,Re=n.convert(I.format,I.encoding),Ie=n.convert(I.type),Xe=w(I.internalFormat,Re,Ie,I.encoding,I.isVideoTexture);N(me,I,De);let Ne,ft=I.mipmaps,Rt=o&&I.isVideoTexture!==!0,$t=Oe.__version===void 0||ce===!0,Y=M(I,de,De);if(I.isDepthTexture)Xe=6402,o?I.type===wr?Xe=36012:I.type===Wn?Xe=33190:I.type===Ua?Xe=35056:Xe=33189:I.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===ja&&Xe===6402&&I.type!==Z_&&I.type!==Wn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Wn,Ie=n.convert(I.type)),I.format===Qa&&Xe===6402&&(Xe=34041,I.type!==Ua&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Ua,Ie=n.convert(I.type))),$t&&(Rt?i.texStorage2D(3553,1,Xe,de.width,de.height):i.texImage2D(3553,0,Xe,de.width,de.height,0,Re,Ie,null));else if(I.isDataTexture)if(ft.length>0&&De){Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],Rt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ie,Ne.data):i.texImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Re,Ie,Ne.data);I.generateMipmaps=!1}else Rt?($t&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,de.width,de.height,Re,Ie,de.data)):i.texImage2D(3553,0,Xe,de.width,de.height,0,Re,Ie,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){Rt&&$t&&i.texStorage3D(35866,Y,Xe,ft[0].width,ft[0].height,de.depth);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],I.format!==zr?Re!==null?Rt?i.compressedTexSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,de.depth,Re,Ne.data,0,0):i.compressedTexImage3D(35866,ne,Xe,Ne.width,Ne.height,de.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Rt?i.texSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,de.depth,Re,Ie,Ne.data):i.texImage3D(35866,ne,Xe,Ne.width,Ne.height,de.depth,0,Re,Ie,Ne.data)}else{Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],I.format!==zr?Re!==null?Rt?i.compressedTexSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ne.data):i.compressedTexImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Rt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ie,Ne.data):i.texImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Re,Ie,Ne.data)}else if(I.isDataArrayTexture)Rt?($t&&i.texStorage3D(35866,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Re,Ie,de.data)):i.texImage3D(35866,0,Xe,de.width,de.height,de.depth,0,Re,Ie,de.data);else if(I.isData3DTexture)Rt?($t&&i.texStorage3D(32879,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Re,Ie,de.data)):i.texImage3D(32879,0,Xe,de.width,de.height,de.depth,0,Re,Ie,de.data);else if(I.isFramebufferTexture){if($t)if(Rt)i.texStorage2D(3553,Y,Xe,de.width,de.height);else{let ne=de.width,ge=de.height;for(let we=0;we<Y;we++)i.texImage2D(3553,we,Xe,ne,ge,0,Re,Ie,null),ne>>=1,ge>>=1}}else if(ft.length>0&&De){Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],Rt?i.texSubImage2D(3553,ne,0,0,Re,Ie,Ne):i.texImage2D(3553,ne,Xe,Re,Ie,Ne);I.generateMipmaps=!1}else Rt?($t&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,Re,Ie,de)):i.texImage2D(3553,0,Xe,Re,Ie,de);A(I,De)&&S(me),Oe.__version=ye.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function re(R,I,$){if(I.image.length!==6)return;let me=ie(R,I),ce=I.source;i.bindTexture(34067,R.__webglTexture,33984+$);let ye=r.get(ce);if(ce.version!==ye.__version||me===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Oe=I.isCompressedTexture||I.image[0].isCompressedTexture,Ee=I.image[0]&&I.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++)!Oe&&!Ee?de[ne]=x(I.image[ne],!1,!0,h):de[ne]=Ee?I.image[ne].image:I.image[ne],de[ne]=Ze(I,de[ne]);let De=de[0],Re=b(De)||o,Ie=n.convert(I.format,I.encoding),Xe=n.convert(I.type),Ne=w(I.internalFormat,Ie,Xe,I.encoding),ft=o&&I.isVideoTexture!==!0,Rt=ye.__version===void 0||me===!0,$t=M(I,De,Re);N(34067,I,Re);let Y;if(Oe){ft&&Rt&&i.texStorage2D(34067,$t,Ne,De.width,De.height);for(let ne=0;ne<6;ne++){Y=de[ne].mipmaps;for(let ge=0;ge<Y.length;ge++){let we=Y[ge];I.format!==zr?Ie!==null?ft?i.compressedTexSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,we.data):i.compressedTexImage2D(34069+ne,ge,Ne,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?i.texSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge,Ne,we.width,we.height,0,Ie,Xe,we.data)}}}else{Y=I.mipmaps,ft&&Rt&&(Y.length>0&&$t++,i.texStorage2D(34067,$t,Ne,de[0].width,de[0].height));for(let ne=0;ne<6;ne++)if(Ee){ft?i.texSubImage2D(34069+ne,0,0,0,de[ne].width,de[ne].height,Ie,Xe,de[ne].data):i.texImage2D(34069+ne,0,Ne,de[ne].width,de[ne].height,0,Ie,Xe,de[ne].data);for(let ge=0;ge<Y.length;ge++){let we=Y[ge].image[ne].image;ft?i.texSubImage2D(34069+ne,ge+1,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge+1,Ne,we.width,we.height,0,Ie,Xe,we.data)}}else{ft?i.texSubImage2D(34069+ne,0,0,0,Ie,Xe,de[ne]):i.texImage2D(34069+ne,0,Ne,Ie,Xe,de[ne]);for(let ge=0;ge<Y.length;ge++){let we=Y[ge];ft?i.texSubImage2D(34069+ne,ge+1,0,0,Ie,Xe,we.image[ne]):i.texImage2D(34069+ne,ge+1,Ne,Ie,Xe,we.image[ne])}}}A(I,Re)&&S(34067),ye.__version=ce.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,$,me,ce){let ye=n.convert($.format,$.encoding),Oe=n.convert($.type),Ee=w($.internalFormat,ye,Oe,$.encoding);r.get(I).__hasExternalTextures||(ce===32879||ce===35866?i.texImage3D(ce,0,Ee,I.width,I.height,I.depth,0,ye,Oe,null):i.texImage2D(ce,0,Ee,I.width,I.height,0,ye,Oe,null)),i.bindFramebuffer(36160,R),ve(I)?d.framebufferTexture2DMultisampleEXT(36160,me,ce,r.get($).__webglTexture,0,xe(I)):(ce===3553||ce>=34069&&ce<=34074)&&e.framebufferTexture2D(36160,me,ce,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function ue(R,I,$){if(e.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let me=33189;if($||ve(I)){let ce=I.depthTexture;ce&&ce.isDepthTexture&&(ce.type===wr?me=36012:ce.type===Wn&&(me=33190));let ye=xe(I);ve(I)?d.renderbufferStorageMultisampleEXT(36161,ye,me,I.width,I.height):e.renderbufferStorageMultisample(36161,ye,me,I.width,I.height)}else e.renderbufferStorage(36161,me,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let me=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):ve(I)?d.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ce=0;ce<me.length;ce++){let ye=me[ce],Oe=n.convert(ye.format,ye.encoding),Ee=n.convert(ye.type),de=w(ye.internalFormat,Oe,Ee,ye.encoding),De=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,De,de,I.width,I.height):ve(I)?d.renderbufferStorageMultisampleEXT(36161,De,de,I.width,I.height):e.renderbufferStorage(36161,de,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function ae(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,me=xe(I);if(I.depthTexture.format===ja)ve(I)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,me):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===Qa)ve(I)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,me):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function se(R){let I=r.get(R),$=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");ae(I.__webglFramebuffer,R)}else if($){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)i.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=e.createRenderbuffer(),ue(I.__webglDepthbuffer[me],R,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),ue(I.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function Ae(R,I,$){let me=r.get(R);I!==void 0&&Z(me.__webglFramebuffer,R,R.texture,36064,3553),$!==void 0&&se(R)}function Se(R){let I=R.texture,$=r.get(R),me=r.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=e.createTexture()),me.__version=I.version,a.memory.textures++);let ce=R.isWebGLCubeRenderTarget===!0,ye=R.isWebGLMultipleRenderTargets===!0,Oe=b(R)||o;if(ce){$.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)$.__webglFramebuffer[Ee]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),ye)if(s.drawBuffers){let Ee=R.texture;for(let de=0,De=Ee.length;de<De;de++){let Re=r.get(Ee[de]);Re.__webglTexture===void 0&&(Re.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&ve(R)===!1){let Ee=ye?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let de=0;de<Ee.length;de++){let De=Ee[de];$.__webglColorRenderbuffer[de]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[de]);let Re=n.convert(De.format,De.encoding),Ie=n.convert(De.type),Xe=w(De.internalFormat,Re,Ie,De.encoding,R.isXRRenderTarget===!0),Ne=xe(R);e.renderbufferStorageMultisample(36161,Ne,Xe,R.width,R.height),e.framebufferRenderbuffer(36160,36064+de,36161,$.__webglColorRenderbuffer[de])}e.bindRenderbuffer(36161,null),R.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),ue($.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(ce){i.bindTexture(34067,me.__webglTexture),N(34067,I,Oe);for(let Ee=0;Ee<6;Ee++)Z($.__webglFramebuffer[Ee],R,I,36064,34069+Ee);A(I,Oe)&&S(34067),i.unbindTexture()}else if(ye){let Ee=R.texture;for(let de=0,De=Ee.length;de<De;de++){let Re=Ee[de],Ie=r.get(Re);i.bindTexture(3553,Ie.__webglTexture),N(3553,Re,Oe),Z($.__webglFramebuffer,R,Re,36064+de,3553),A(Re,Oe)&&S(3553)}i.unbindTexture()}else{let Ee=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Ee=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ee,me.__webglTexture),N(Ee,I,Oe),Z($.__webglFramebuffer,R,I,36064,Ee),A(I,Oe)&&S(Ee),i.unbindTexture()}R.depthBuffer&&se(R)}function Me(R){let I=b(R)||o,$=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,ce=$.length;me<ce;me++){let ye=$[me];if(A(ye,I)){let Oe=R.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(ye).__webglTexture;i.bindTexture(Oe,Ee),S(Oe),i.unbindTexture()}}}function Pe(R){if(o&&R.samples>0&&ve(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],$=R.width,me=R.height,ce=16384,ye=[],Oe=R.stencilBuffer?33306:36096,Ee=r.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let De=0;De<I.length;De++)i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,null),i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,null,0);i.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let De=0;De<I.length;De++){ye.push(36064+De),R.depthBuffer&&ye.push(Oe);let Re=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(Re===!1&&(R.depthBuffer&&(ce|=256),R.stencilBuffer&&(ce|=1024)),de&&e.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[De]),Re===!0&&(e.invalidateFramebuffer(36008,[Oe]),e.invalidateFramebuffer(36009,[Oe])),de){let Ie=r.get(I[De]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ie,0)}e.blitFramebuffer(0,0,$,me,0,0,$,me,ce,9728),p&&e.invalidateFramebuffer(36008,ye)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),de)for(let De=0;De<I.length;De++){i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,Ee.__webglColorRenderbuffer[De]);let Re=r.get(I[De]).__webglTexture;i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,Re,0)}i.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function xe(R){return Math.min(c,R.samples)}function ve(R){let I=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Be(R){let I=a.render.frame;f.get(R)!==I&&(f.set(R,I),R.update())}function Ze(R,I){let $=R.encoding,me=R.format,ce=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Xm||$!==Bs&&($===$e?o===!1?t.has("EXT_sRGB")===!0&&me===zr?(R.format=Xm,R.minFilter=nt,R.generateMipmaps=!1):I=sS.sRGBToLinear(I):(me!==zr||ce!==Ni)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=U,this.setTexture2D=H,this.setTexture2DArray=G,this.setTexture3D=F,this.setTextureCube=q,this.rebindTextures=Ae,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ve}function $I(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ni)return 5121;if(n===BC)return 32819;if(n===zC)return 32820;if(n===LC)return 5120;if(n===OC)return 5122;if(n===Z_)return 5123;if(n===RC)return 5124;if(n===Wn)return 5125;if(n===wr)return 5126;if(n===vl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===FC)return 6406;if(n===zr)return 6408;if(n===NC)return 6409;if(n===kC)return 6410;if(n===ja)return 6402;if(n===Qa)return 34041;if(n===Xm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===UC)return 6403;if(n===jC)return 36244;if(n===K_)return 33319;if(n===GC)return 33320;if(n===VC)return 36249;if(n===Qp||n===Zp||n===Kp||n===Jp)if(a===$e)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Qp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Zp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Kp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Jp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Qp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Zp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Kp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Jp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ny||n===ky||n===Uy||n===jy)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Ny)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ky)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Uy)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===jy)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===HC)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Gy||n===Vy)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Gy)return a===$e?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Vy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Hy||n===Wy||n===qy||n===Xy||n===Yy||n===Qy||n===Zy||n===Ky||n===Jy||n===$y||n===e1||n===t1||n===i1||n===r1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Hy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Wy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Xy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Yy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Qy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Zy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ky)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Jy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===$y)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===e1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===t1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===i1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===r1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===$p)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===$p)return a===$e?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===WC||n===s1||n===n1||n===a1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===$p)return o.COMPRESSED_RED_RGTC1_EXT;if(n===s1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===n1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===a1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ua?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var eL=class extends Oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Qo=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},tL={type:"move"},Ef=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(tL)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Qo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},xl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:ja,h!==ja&&h!==Qa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===ja&&(i=Wn),i===void 0&&h===Qa&&(i=Ua),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Lt,this.minFilter=o!==void 0?o:Lt,this.flipY=!1,this.generateMipmaps=!1}},iL=class extends Ti{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],x=new Set,b=new Map,_=new Oi;_.layers.enable(1),_.viewport=new et;let A=new Oi;A.layers.enable(2),A.viewport=new et;let S=[_,A],w=new eL;w.layers.enable(1),w.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getTargetRaySpace()},this.getControllerGrip=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getGripSpace()},this.getHand=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getHandSpace()};function T(G){let F=y.indexOf(G.inputSource);if(F===-1)return;let q=v[F];q!==void 0&&q.dispatchEvent({type:G.type,data:G.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",P);for(let G=0;G<v.length;G++){let F=y[G];F!==null&&(y[G]=null,v[G].disconnect(F))}M=null,C=null,e.setRenderTarget(g),d=null,c=null,u=null,r=null,m=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(G){l=G},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(G){if(r=G,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,F),r.updateRenderState({baseLayer:d}),m=new Mt(d.framebufferWidth,d.framebufferHeight,{format:zr,type:Ni,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let F=null,q=null,j=null;f.depth&&(j=f.stencil?35056:33190,F=f.stencil?Qa:ja,q=f.stencil?Ua:Wn);let W={colorFormat:32856,depthFormat:j,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(W),r.updateRenderState({layers:[c]}),m=new Mt(c.textureWidth,c.textureHeight,{format:zr,type:Ni,depthTexture:new xl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let N=e.properties.get(m);N.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(G){for(let F=0;F<G.removed.length;F++){let q=G.removed[F],j=y.indexOf(q);j>=0&&(y[j]=null,v[j].disconnect(q))}for(let F=0;F<G.added.length;F++){let q=G.added[F],j=y.indexOf(q);if(j===-1){for(let N=0;N<v.length;N++)if(N>=y.length){y.push(q),j=N;break}else if(y[N]===null){y[N]=q,j=N;break}if(j===-1)break}let W=v[j];W&&W.connect(q)}}let L=new E,B=new E;function V(G,F,q){L.setFromMatrixPosition(F.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let j=L.distanceTo(B),W=F.projectionMatrix.elements,N=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],ue=(W[8]-1)/W[0],ae=(N[8]+1)/N[0],se=ie*ue,Ae=ie*ae,Se=j/(-ue+ae),Me=Se*-ue;F.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Me),G.translateZ(Se),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Pe=ie+Se,xe=Q+Se,ve=se-Me,Be=Ae+(j-Me),Ze=re*Q/xe*Pe,R=Z*Q/xe*Pe;G.projectionMatrix.makePerspective(ve,Be,Ze,R,Pe,xe)}function U(G,F){F===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(F.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;w.near=A.near=_.near=G.near,w.far=A.far=_.far=G.far,(M!==w.near||C!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),M=w.near,C=w.far);let F=G.parent,q=w.cameras;U(w,F);for(let W=0;W<q.length;W++)U(q[W],F);w.matrixWorld.decompose(w.position,w.quaternion,w.scale),G.matrix.copy(w.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let j=G.children;for(let W=0,N=j.length;W<N;W++)j[W].updateMatrixWorld(!0);q.length===2?V(w,_,A):w.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return w},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(G){o=G,c!==null&&(c.fixedFoveation=G),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=G)},this.getPlanes=function(){return x};let z=null;function X(G,F){if(h=F.getViewerPose(l||n),p=F,h!==null){let q=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let j=!1;q.length!==w.cameras.length&&(w.cameras.length=0,j=!0);for(let W=0;W<q.length;W++){let N=q[W],ie=null;if(d!==null)ie=d.getViewport(N);else{let re=u.getViewSubImage(c,N);ie=re.viewport,W===0&&(e.setRenderTargetTextures(m,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(m))}let Q=S[W];Q===void 0&&(Q=new Oi,Q.layers.enable(W),Q.viewport=new et,S[W]=Q),Q.matrix.fromArray(N.transform.matrix),Q.projectionMatrix.fromArray(N.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&w.matrix.copy(Q.matrix),j===!0&&w.cameras.push(Q)}}for(let q=0;q<v.length;q++){let j=y[q],W=v[q];j!==null&&W!==void 0&&W.update(j,F,l||n)}if(z&&z(G,F),F.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:F.detectedPlanes});let q=null;for(let j of x)F.detectedPlanes.has(j)||(q===null&&(q=[]),q.push(j));if(q!==null)for(let j of q)x.delete(j),b.delete(j),i.dispatchEvent({type:"planeremoved",data:j});for(let j of F.detectedPlanes)if(!x.has(j))x.add(j),b.set(j,F.lastChangedTime),i.dispatchEvent({type:"planeadded",data:j});else{let W=b.get(j);j.lastChangedTime>W&&(b.set(j,j.lastChangedTime),i.dispatchEvent({type:"planechanged",data:j}))}}p=null}let H=new hS;H.setAnimationLoop(X),this.setAnimationLoop=function(G){z=G},this.dispose=function(){}}};function rL(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,lS(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&d(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===xi&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===xi&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===xi&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function sL(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=u(y),s[y.id]=b,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let A=t.render.frame;n[y.id]!==A&&(d(y),n[y.id]=A)}function u(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),_=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,_,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let x=s[y.id],b=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let w=b[A];if(p(w,A,_)===!0){let M=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],L=g(P);typeof P=="number"?(w.__data[0]=P,e.bufferSubData(35345,M+T,w.__data)):P.isMatrix3?(w.__data[0]=P.elements[0],w.__data[1]=P.elements[1],w.__data[2]=P.elements[2],w.__data[3]=P.elements[0],w.__data[4]=P.elements[3],w.__data[5]=P.elements[4],w.__data[6]=P.elements[5],w.__data[7]=P.elements[0],w.__data[8]=P.elements[6],w.__data[9]=P.elements[7],w.__data[10]=P.elements[8],w.__data[11]=P.elements[0]):(P.toArray(w.__data,T),T+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,w.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let _=y.value;if(b[x]===void 0){if(typeof _=="number")b[x]=_;else{let A=Array.isArray(_)?_:[_],S=[];for(let w=0;w<A.length;w++)S.push(A[w].clone());b[x]=S}return!0}else if(typeof _=="number"){if(b[x]!==_)return b[x]=_,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],S=Array.isArray(_)?_:[_];for(let w=0;w<A.length;w++){let M=A[w];if(M.equals(S[w])===!1)return M.copy(S[w]),!0}}return!1}function f(y){let x=y.uniforms,b=0,_=16,A=0;for(let S=0,w=x.length;S<w;S++){let M=x[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let L=T[D],B=g(L);C.boundary+=B.boundary,C.storage+=B.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,S>0){A=b%_;let D=_-A;A!==0&&D-C.boundary<0&&(b+=_-A,M.__offset=b)}b+=C.storage}return A=b%_,A>0&&(b+=_-A),y.__size=b,y.__cache={},this}function g(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let b=a.indexOf(x.__bindingPointIndex);a.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function nL(){let e=wu("canvas");return e.style.display="block",e}function mS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:nL(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Bs,this.physicallyCorrectLights=!1,this.toneMapping=yn,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,b=-1,_=null,A=new et,S=new et,w=null,M=t.width,C=t.height,T=1,D=null,P=null,L=new et(0,0,M,C),B=new et(0,0,M,C),V=!1,U=new zv,z=!1,X=!1,H=null,G=new fe,F=new k,q=new E,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let N=i;function ie(O,ee){for(let oe=0;oe<O.length;oe++){let J=O[oe],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let O={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ol}`),t.addEventListener("webglcontextlost",Xe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",ft,!1),N===null){let ee=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&ee.shift(),N=ie(ee,O),N===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}N.getShaderPrecisionFormat===void 0&&(N.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(O){throw console.error("THREE.WebGLRenderer: "+O.message),O}let Q,re,Z,ue,ae,se,Ae,Se,Me,Pe,xe,ve,Be,Ze,R,I,$,me,ce,ye,Oe,Ee,de,De;function Re(){Q=new yD(N),re=new uD(N,Q,e),Q.init(re),Ee=new $I(N,Q,re),Z=new KI(N,Q,re),ue=new wD,ae=new NI,se=new JI(N,Q,Z,ae,re,Ee,ue),Ae=new fD(g),Se=new vD(g),Me=new DT(N,re),de=new cD(N,Q,Me,re),Pe=new xD(N,Me,ue,de),xe=new MD(N,Pe,Me,ue),ce=new AD(N,re,se),I=new pD(ae),ve=new FI(g,Ae,Se,Q,re,de,I),Be=new rL(g,ae),Ze=new UI,R=new qI(Q,re),me=new hD(g,Ae,Se,Z,xe,u,a),$=new ZI(g,xe,re),De=new sL(N,ue,re,Z),ye=new dD(N,Q,ue,re),Oe=new bD(N,Q,ue,re),ue.programs=ve.programs,g.capabilities=re,g.extensions=Q,g.properties=ae,g.renderLists=Ze,g.shadowMap=$,g.state=Z,g.info=ue}Re();let Ie=new iL(g,N);this.xr=Ie,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let O=Q.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){let O=Q.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(O){O!==void 0&&(T=O,this.setSize(M,C,!1))},this.getSize=function(O){return O.set(M,C)},this.setSize=function(O,ee,oe){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=O,C=ee,t.width=Math.floor(O*T),t.height=Math.floor(ee*T),oe!==!1&&(t.style.width=O+"px",t.style.height=ee+"px"),this.setViewport(0,0,O,ee)},this.getDrawingBufferSize=function(O){return O.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(O,ee,oe){M=O,C=ee,T=oe,t.width=Math.floor(O*oe),t.height=Math.floor(ee*oe),this.setViewport(0,0,O,ee)},this.getCurrentViewport=function(O){return O.copy(A)},this.getViewport=function(O){return O.copy(L)},this.setViewport=function(O,ee,oe,J){O.isVector4?L.set(O.x,O.y,O.z,O.w):L.set(O,ee,oe,J),Z.viewport(A.copy(L).multiplyScalar(T).floor())},this.getScissor=function(O){return O.copy(B)},this.setScissor=function(O,ee,oe,J){O.isVector4?B.set(O.x,O.y,O.z,O.w):B.set(O,ee,oe,J),Z.scissor(S.copy(B).multiplyScalar(T).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(O){Z.setScissorTest(V=O)},this.setOpaqueSort=function(O){D=O},this.setTransparentSort=function(O){P=O},this.getClearColor=function(O){return O.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(O=!0,ee=!0,oe=!0){let J=0;O&&(J|=16384),ee&&(J|=256),oe&&(J|=1024),N.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Xe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",ft,!1),Ze.dispose(),R.dispose(),ae.dispose(),Ae.dispose(),Se.dispose(),xe.dispose(),de.dispose(),De.dispose(),ve.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",we),Ie.removeEventListener("sessionend",Ge),H&&(H.dispose(),H=null),vt.stop()};function Xe(O){O.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let O=ue.autoReset,ee=$.enabled,oe=$.autoUpdate,J=$.needsUpdate,le=$.type;Re(),ue.autoReset=O,$.enabled=ee,$.autoUpdate=oe,$.needsUpdate=J,$.type=le}function ft(O){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Rt(O){let ee=O.target;ee.removeEventListener("dispose",Rt),$t(ee)}function $t(O){Y(O),ae.remove(O)}function Y(O){let ee=ae.get(O).programs;ee!==void 0&&(ee.forEach(function(oe){ve.releaseProgram(oe)}),O.isShaderMaterial&&ve.releaseShaderCache(O))}this.renderBufferDirect=function(O,ee,oe,J,le,ze){ee===null&&(ee=j);let rt=le.isMesh&&le.matrixWorld.determinant()<0,lt=RE(O,ee,oe,J,le);Z.setMaterial(J,rt);let ct=oe.index,Dt=1;J.wireframe===!0&&(ct=Pe.getWireframeAttribute(oe),Dt=2);let yt=oe.drawRange,mt=oe.attributes.position,Di=yt.start*Dt,pr=(yt.start+yt.count)*Dt;ze!==null&&(Di=Math.max(Di,ze.start*Dt),pr=Math.min(pr,(ze.start+ze.count)*Dt)),ct!==null?(Di=Math.max(Di,0),pr=Math.min(pr,ct.count)):mt!=null&&(Di=Math.max(Di,0),pr=Math.min(pr,mt.count));let qs=pr-Di;if(qs<0||qs===1/0)return;de.setup(le,J,lt,oe,ct);let fa,ei=ye;if(ct!==null&&(fa=Me.get(ct),ei=Oe,ei.setIndex(fa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),ei.setMode(1)):ei.setMode(4);else if(le.isLine){let gt=J.linewidth;gt===void 0&&(gt=1),Z.setLineWidth(gt*W()),le.isLineSegments?ei.setMode(1):le.isLineLoop?ei.setMode(2):ei.setMode(3)}else le.isPoints?ei.setMode(0):le.isSprite&&ei.setMode(4);if(le.isInstancedMesh)ei.renderInstances(Di,qs,le.count);else if(oe.isInstancedBufferGeometry){let gt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Vp=Math.min(oe.instanceCount,gt);ei.renderInstances(Di,qs,Vp)}else ei.render(Di,qs)},this.compile=function(O,ee){function oe(J,le,ze){J.transparent===!0&&J.side===br&&J.forceSinglePass===!1?(J.side=xi,J.needsUpdate=!0,Mr(J,le,ze),J.side=ns,J.needsUpdate=!0,Mr(J,le,ze),J.side=br):Mr(J,le,ze)}d=R.get(O),d.init(),f.push(d),O.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(d.pushLight(J),J.castShadow&&d.pushShadow(J))}),d.setupLights(g.physicallyCorrectLights),O.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let ze=0;ze<le.length;ze++){let rt=le[ze];oe(rt,O,J)}else oe(le,O,J)}),f.pop(),d=null};let ne=null;function ge(O){ne&&ne(O)}function we(){vt.stop()}function Ge(){vt.start()}let vt=new hS;vt.setAnimationLoop(ge),typeof self<"u"&&vt.setContext(self),this.setAnimationLoop=function(O){ne=O,Ie.setAnimationLoop(O),O===null?vt.stop():vt.start()},Ie.addEventListener("sessionstart",we),Ie.addEventListener("sessionend",Ge),this.render=function(O,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(ee),ee=Ie.getCamera()),O.isScene===!0&&O.onBeforeRender(g,O,ee,x),d=R.get(O,f.length),d.init(),f.push(d),G.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),U.setFromProjectionMatrix(G),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Ze.get(O,p.length),c.init(),p.push(c),kt(O,ee,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let oe=d.state.shadowsArray;if($.render(oe,O,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(c,O),d.setupLights(g.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,ze=J.length;le<ze;le++){let rt=J[le];Pi(c,O,rt,rt.viewport)}}else Pi(c,O,ee);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),O.isScene===!0&&O.onAfterRender(g,O,ee),de.resetDefaultState(),b=-1,_=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function kt(O,ee,oe,J){if(O.visible===!1)return;if(O.layers.test(ee.layers)){if(O.isGroup)oe=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(ee);else if(O.isLight)d.pushLight(O),O.castShadow&&d.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||U.intersectsSprite(O)){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(O.isSkinnedMesh&&O.skeleton.frame!==ue.render.frame&&(O.skeleton.update(),O.skeleton.frame=ue.render.frame),!O.frustumCulled||U.intersectsObject(O))){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;if(Array.isArray(rt)){let lt=ze.groups;for(let ct=0,Dt=lt.length;ct<Dt;ct++){let yt=lt[ct],mt=rt[yt.materialIndex];mt&&mt.visible&&c.push(O,ze,mt,oe,q.z,yt)}}else rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}let le=O.children;for(let ze=0,rt=le.length;ze<rt;ze++)kt(le[ze],ee,oe,J)}function Pi(O,ee,oe,J){let le=O.opaque,ze=O.transmissive,rt=O.transparent;d.setupLightsView(oe),z===!0&&I.setGlobalState(g.clippingPlanes,oe),ze.length>0&&pa(le,ee,oe),J&&Z.viewport(A.copy(J)),le.length>0&&Nt(le,ee,oe),ze.length>0&&Nt(ze,ee,oe),rt.length>0&&Nt(rt,ee,oe),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function pa(O,ee,oe){let J=re.isWebGL2;H===null&&(H=new Mt(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?vl:Ni,minFilter:gl,samples:J&&n===!0?4:0})),g.getDrawingBufferSize(F),J?H.setSize(F.x,F.y):H.setSize(bu(F.x),bu(F.y));let le=g.getRenderTarget();g.setRenderTarget(H),g.clear();let ze=g.toneMapping;g.toneMapping=yn,Nt(O,ee,oe),g.toneMapping=ze,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),g.setRenderTarget(le)}function Nt(O,ee,oe){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,ze=O.length;le<ze;le++){let rt=O[le],lt=rt.object,ct=rt.geometry,Dt=J===null?rt.material:J,yt=rt.group;lt.layers.test(oe.layers)&&Ws(lt,ee,oe,ct,Dt,yt)}}function Ws(O,ee,oe,J,le,ze){O.onBeforeRender(g,ee,oe,J,le,ze),O.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),le.onBeforeRender(g,ee,oe,J,O,ze),le.transparent===!0&&le.side===br&&le.forceSinglePass===!1?(le.side=xi,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=ns,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=br):g.renderBufferDirect(oe,ee,J,le,O,ze),O.onAfterRender(g,ee,oe,J,le,ze)}function Mr(O,ee,oe){ee.isScene!==!0&&(ee=j);let J=ae.get(O),le=d.state.lights,ze=d.state.shadowsArray,rt=le.state.version,lt=ve.getParameters(O,le.state,ze,ee,oe),ct=ve.getProgramCacheKey(lt),Dt=J.programs;J.environment=O.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(O.isMeshStandardMaterial?Se:Ae).get(O.envMap||J.environment),Dt===void 0&&(O.addEventListener("dispose",Rt),Dt=new Map,J.programs=Dt);let yt=Dt.get(ct);if(yt!==void 0){if(J.currentProgram===yt&&J.lightsStateVersion===rt)return Ey(O,lt),yt}else lt.uniforms=ve.getUniforms(O),O.onBuild(oe,lt,g),O.onBeforeCompile(lt,g),yt=ve.acquireProgram(lt,ct),Dt.set(ct,yt),J.uniforms=lt.uniforms;let mt=J.uniforms;(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(mt.clippingPlanes=I.uniform),Ey(O,lt),J.needsLights=zE(O),J.lightsStateVersion=rt,J.needsLights&&(mt.ambientLightColor.value=le.state.ambient,mt.lightProbe.value=le.state.probe,mt.directionalLights.value=le.state.directional,mt.directionalLightShadows.value=le.state.directionalShadow,mt.spotLights.value=le.state.spot,mt.spotLightShadows.value=le.state.spotShadow,mt.rectAreaLights.value=le.state.rectArea,mt.ltc_1.value=le.state.rectAreaLTC1,mt.ltc_2.value=le.state.rectAreaLTC2,mt.pointLights.value=le.state.point,mt.pointLightShadows.value=le.state.pointShadow,mt.hemisphereLights.value=le.state.hemi,mt.directionalShadowMap.value=le.state.directionalShadowMap,mt.directionalShadowMatrix.value=le.state.directionalShadowMatrix,mt.spotShadowMap.value=le.state.spotShadowMap,mt.spotLightMatrix.value=le.state.spotLightMatrix,mt.spotLightMap.value=le.state.spotLightMap,mt.pointShadowMap.value=le.state.pointShadowMap,mt.pointShadowMatrix.value=le.state.pointShadowMatrix);let Di=yt.getUniforms(),pr=au.seqWithValue(Di.seq,mt);return J.currentProgram=yt,J.uniformsList=pr,yt}function Ey(O,ee){let oe=ae.get(O);oe.outputEncoding=ee.outputEncoding,oe.instancing=ee.instancing,oe.skinning=ee.skinning,oe.morphTargets=ee.morphTargets,oe.morphNormals=ee.morphNormals,oe.morphColors=ee.morphColors,oe.morphTargetsCount=ee.morphTargetsCount,oe.numClippingPlanes=ee.numClippingPlanes,oe.numIntersection=ee.numClipIntersection,oe.vertexAlphas=ee.vertexAlphas,oe.vertexTangents=ee.vertexTangents,oe.toneMapping=ee.toneMapping}function RE(O,ee,oe,J,le){ee.isScene!==!0&&(ee=j),se.resetTextureUnits();let ze=ee.fog,rt=J.isMeshStandardMaterial?ee.environment:null,lt=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Bs,ct=(J.isMeshStandardMaterial?Se:Ae).get(J.envMap||rt),Dt=J.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,yt=!!J.normalMap&&!!oe.attributes.tangent,mt=!!oe.morphAttributes.position,Di=!!oe.morphAttributes.normal,pr=!!oe.morphAttributes.color,qs=J.toneMapped?g.toneMapping:yn,fa=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,ei=fa!==void 0?fa.length:0,gt=ae.get(J),Vp=d.state.lights;if(z===!0&&(X===!0||O!==_)){let fr=O===_&&J.id===b;I.setState(J,O,fr)}let Hp=!1;J.version===gt.__version?(gt.needsLights&>.lightsStateVersion!==Vp.state.version||gt.outputEncoding!==lt||le.isInstancedMesh&>.instancing===!1||!le.isInstancedMesh&>.instancing===!0||le.isSkinnedMesh&>.skinning===!1||!le.isSkinnedMesh&>.skinning===!0||gt.envMap!==ct||J.fog===!0&>.fog!==ze||gt.numClippingPlanes!==void 0&&(gt.numClippingPlanes!==I.numPlanes||gt.numIntersection!==I.numIntersection)||gt.vertexAlphas!==Dt||gt.vertexTangents!==yt||gt.morphTargets!==mt||gt.morphNormals!==Di||gt.morphColors!==pr||gt.toneMapping!==qs||re.isWebGL2===!0&>.morphTargetsCount!==ei)&&(Hp=!0):(Hp=!0,gt.__version=J.version);let ma=gt.currentProgram;Hp===!0&&(ma=Mr(J,ee,le));let Cy=!1,th=!1,Wp=!1,Ai=ma.getUniforms(),ga=gt.uniforms;if(Z.useProgram(ma.program)&&(Cy=!0,th=!0,Wp=!0),J.id!==b&&(b=J.id,th=!0),Cy||_!==O){if(Ai.setValue(N,"projectionMatrix",O.projectionMatrix),re.logarithmicDepthBuffer&&Ai.setValue(N,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),_!==O&&(_=O,th=!0,Wp=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let fr=Ai.map.cameraPosition;fr!==void 0&&fr.setValue(N,q.setFromMatrixPosition(O.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ai.setValue(N,"isOrthographic",O.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&Ai.setValue(N,"viewMatrix",O.matrixWorldInverse)}if(le.isSkinnedMesh){Ai.setOptional(N,le,"bindMatrix"),Ai.setOptional(N,le,"bindMatrixInverse");let fr=le.skeleton;fr&&(re.floatVertexTextures?(fr.boneTexture===null&&fr.computeBoneTexture(),Ai.setValue(N,"boneTexture",fr.boneTexture,se),Ai.setValue(N,"boneTextureSize",fr.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let qp=oe.morphAttributes;if((qp.position!==void 0||qp.normal!==void 0||qp.color!==void 0&&re.isWebGL2===!0)&&ce.update(le,oe,J,ma),(th||gt.receiveShadow!==le.receiveShadow)&&(gt.receiveShadow=le.receiveShadow,Ai.setValue(N,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ga.envMap.value=ct,ga.flipEnvMap.value=ct.isCubeTexture&&ct.isRenderTargetTexture===!1?-1:1),th&&(Ai.setValue(N,"toneMappingExposure",g.toneMappingExposure),gt.needsLights&&BE(ga,Wp),ze&&J.fog===!0&&Be.refreshFogUniforms(ga,ze),Be.refreshMaterialUniforms(ga,J,T,C,H),au.upload(N,gt.uniformsList,ga,se)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(au.upload(N,gt.uniformsList,ga,se),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ai.setValue(N,"center",le.center),Ai.setValue(N,"modelViewMatrix",le.modelViewMatrix),Ai.setValue(N,"normalMatrix",le.normalMatrix),Ai.setValue(N,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&Ai.setValue(N,"previousModelViewMatrix",le.previousModelViewMatrix),O.previousProjectionMatrix&&Ai.setValue(N,"previousProjectionMatrix",O.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let fr=J.uniformsGroups;for(let Xp=0,FE=fr.length;Xp<FE;Xp++)if(re.isWebGL2){let Ty=fr[Xp];De.update(Ty,ma),De.bind(Ty,ma)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ma}function BE(O,ee){O.ambientLightColor.needsUpdate=ee,O.lightProbe.needsUpdate=ee,O.directionalLights.needsUpdate=ee,O.directionalLightShadows.needsUpdate=ee,O.pointLights.needsUpdate=ee,O.pointLightShadows.needsUpdate=ee,O.spotLights.needsUpdate=ee,O.spotLightShadows.needsUpdate=ee,O.rectAreaLights.needsUpdate=ee,O.hemisphereLights.needsUpdate=ee}function zE(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(O,ee,oe){ae.get(O.texture).__webglTexture=ee,ae.get(O.depthTexture).__webglTexture=oe;let J=ae.get(O);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=oe===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(O,ee){let oe=ae.get(O);oe.__webglFramebuffer=ee,oe.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(O,ee=0,oe=0){x=O,v=ee,y=oe;let J=!0,le=null,ze=!1,rt=!1;if(O){let lt=ae.get(O);lt.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):lt.__webglFramebuffer===void 0?se.setupRenderTarget(O):lt.__hasExternalTextures&&se.rebindTextures(O,ae.get(O.texture).__webglTexture,ae.get(O.depthTexture).__webglTexture);let ct=O.texture;(ct.isData3DTexture||ct.isDataArrayTexture||ct.isCompressedArrayTexture)&&(rt=!0);let Dt=ae.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(le=Dt[ee],ze=!0):re.isWebGL2&&O.samples>0&&se.useMultisampledRTT(O)===!1?le=ae.get(O).__webglMultisampledFramebuffer:le=Dt,A.copy(O.viewport),S.copy(O.scissor),w=O.scissorTest}else A.copy(L).multiplyScalar(T).floor(),S.copy(B).multiplyScalar(T).floor(),w=V;if(Z.bindFramebuffer(36160,le)&&re.drawBuffers&&J&&Z.drawBuffers(O,le),Z.viewport(A),Z.scissor(S),Z.setScissorTest(w),ze){let lt=ae.get(O.texture);N.framebufferTexture2D(36160,36064,34069+ee,lt.__webglTexture,oe)}else if(rt){let lt=ae.get(O.texture),ct=ee||0;N.framebufferTextureLayer(36160,36064,lt.__webglTexture,oe||0,ct)}b=-1},this.readRenderTargetPixels=function(O,ee,oe,J,le,ze,rt){if(!(O&&O.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let lt=ae.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&rt!==void 0&&(lt=lt[rt]),lt){Z.bindFramebuffer(36160,lt);try{let ct=O.texture,Dt=ct.format,yt=ct.type;if(Dt!==zr&&Ee.convert(Dt)!==N.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let mt=yt===vl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(yt!==Ni&&Ee.convert(yt)!==N.getParameter(35738)&&!(yt===wr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!mt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=O.width-J&&oe>=0&&oe<=O.height-le&&N.readPixels(ee,oe,J,le,Ee.convert(Dt),Ee.convert(yt),ze)}finally{let ct=x!==null?ae.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ct)}}},this.copyFramebufferToTexture=function(O,ee,oe=0){let J=Math.pow(2,-oe),le=Math.floor(ee.image.width*J),ze=Math.floor(ee.image.height*J);se.setTexture2D(ee,0),N.copyTexSubImage2D(3553,oe,0,0,O.x,O.y,le,ze),Z.unbindTexture()},this.copyTextureToTexture=function(O,ee,oe,J=0){let le=ee.image.width,ze=ee.image.height,rt=Ee.convert(oe.format),lt=Ee.convert(oe.type);se.setTexture2D(oe,0),N.pixelStorei(37440,oe.flipY),N.pixelStorei(37441,oe.premultiplyAlpha),N.pixelStorei(3317,oe.unpackAlignment),ee.isDataTexture?N.texSubImage2D(3553,J,O.x,O.y,le,ze,rt,lt,ee.image.data):ee.isCompressedTexture?N.compressedTexSubImage2D(3553,J,O.x,O.y,ee.mipmaps[0].width,ee.mipmaps[0].height,rt,ee.mipmaps[0].data):N.texSubImage2D(3553,J,O.x,O.y,rt,lt,ee.image),J===0&&oe.generateMipmaps&&N.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(O,ee,oe,J,le=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ze=O.max.x-O.min.x+1,rt=O.max.y-O.min.y+1,lt=O.max.z-O.min.z+1,ct=Ee.convert(J.format),Dt=Ee.convert(J.type),yt;if(J.isData3DTexture)se.setTexture3D(J,0),yt=32879;else if(J.isDataArrayTexture)se.setTexture2DArray(J,0),yt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(37440,J.flipY),N.pixelStorei(37441,J.premultiplyAlpha),N.pixelStorei(3317,J.unpackAlignment);let mt=N.getParameter(3314),Di=N.getParameter(32878),pr=N.getParameter(3316),qs=N.getParameter(3315),fa=N.getParameter(32877),ei=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;N.pixelStorei(3314,ei.width),N.pixelStorei(32878,ei.height),N.pixelStorei(3316,O.min.x),N.pixelStorei(3315,O.min.y),N.pixelStorei(32877,O.min.z),oe.isDataTexture||oe.isData3DTexture?N.texSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,Dt,ei.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,ei.data)):N.texSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,Dt,ei),N.pixelStorei(3314,mt),N.pixelStorei(32878,Di),N.pixelStorei(3316,pr),N.pixelStorei(3315,qs),N.pixelStorei(32877,fa),le===0&&J.generateMipmaps&&N.generateMipmap(yt),Z.unbindTexture()},this.initTexture=function(O){O.isCubeTexture?se.setTextureCube(O,0):O.isData3DTexture?se.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?se.setTexture2DArray(O,0):se.setTexture2D(O,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var aL=class extends mS{};aL.prototype.isWebGL1Renderer=!0;var gS=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new je(e),this.near=t,this.far=i}clone(){return new gS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},$n=class extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},oL=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=qm,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Nr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ui=new E,Zm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyMatrix4(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyNormalMatrix(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.transformDirection(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=vn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=vn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=vn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=vn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array),r=It(r,this.array),s=It(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Ye(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Zm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},vS=class extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}},_u=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=Lt,h=Lt,u,c){super(null,n,a,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},j1=new fe,lL=new fe,kv=class{constructor(e=[],t=[]){this.uuid=Nr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new fe;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,n=e.length;s<n;s++){let a=e[s]?e[s].matrixWorld:lL;j1.multiplyMatrices(a,t[s]),j1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new kv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=tS(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new _u(t,e,e,zr,wr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],n=t[s];n===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),n=new vS),this.bones.push(n),this.boneInverses.push(new fe().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let n=t[r];e.bones.push(n.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},hL=class extends Ye{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},la=class extends Cc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},G1=new E,V1=new E,H1=new fe,Cf=new Rl,hd=new Sr,Su=class extends Et{constructor(e=new qe,t=new la){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)G1.fromBufferAttribute(t,r-1),V1.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=G1.distanceTo(V1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),hd.copy(i.boundingSphere),hd.applyMatrix4(r),hd.radius+=s,e.ray.intersectsSphere(hd)===!1)return;H1.copy(r).invert(),Cf.copy(e.ray).applyMatrix4(H1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new E,h=new E,u=new E,c=new E,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),Cf.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Cf.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},W1=new E,q1=new E,Pc=class extends Su{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)W1.fromBufferAttribute(t,r),q1.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+W1.distanceTo(q1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},cL=class extends ci{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:nt,this.magFilter=s!==void 0?s:nt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},js=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(n-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new k:new E);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],n=[],a=new E,o=new fe;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,n[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),n[d]=n[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(hi(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,p))}n[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(hi(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},pp=class extends js{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},dL=class extends pp{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Uv(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,u,c){let d=(a-n)/h-(o-n)/(h+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+c)+(l-o)/c;d*=u,p*=u,s(a,o,d,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var cd=new E,Tf=new Uv,Pf=new Uv,Df=new Uv,uL=class extends js{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new E){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(cd.subVectors(r[0],r[1]).add(r[0]),l=cd);let u=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(cd.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=cd),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),g=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),Tf.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,g),Pf.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,g),Df.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(Tf.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Pf.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Df.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Tf.calc(o),Pf.calc(o),Df.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new E().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function X1(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function pL(e,t){let i=1-e;return i*i*t}function fL(e,t){return 2*(1-e)*e*t}function mL(e,t){return e*e*t}function Wh(e,t,i,r){return pL(e,t)+fL(e,i)+mL(e,r)}function gL(e,t){let i=1-e;return i*i*i*t}function vL(e,t){let i=1-e;return 3*i*i*e*t}function yL(e,t){return 3*(1-e)*e*e*t}function xL(e,t){return e*e*e*t}function qh(e,t,i,r,s){return gL(e,t)+vL(e,i)+yL(e,r)+xL(e,s)}var $r=class extends js{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qh(e,r.x,s.x,n.x,a.x),qh(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ou=class extends js{constructor(e=new E,t=new E,i=new E,r=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qh(e,r.x,s.x,n.x,a.x),qh(e,r.y,s.y,n.y,a.y),qh(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ss=class extends js{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},yS=class extends js{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},na=class extends js{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Wh(e,r.x,s.x,n.x),Wh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},bL=class extends js{constructor(e=new E,t=new E,i=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Wh(e,r.x,s.x,n.x),Wh(e,r.y,s.y,n.y),Wh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},jv=class extends js{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],u=r[n>r.length-3?r.length-1:n+2];return i.set(X1(a,o.x,l.x,h.x,u.x),X1(a,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},wL=Object.freeze({__proto__:null,ArcCurve:dL,CatmullRomCurve3:uL,CubicBezierCurve:$r,CubicBezierCurve3:ou,EllipseCurve:pp,LineCurve:ss,LineCurve3:yS,QuadraticBezierCurve:na,QuadraticBezierCurve3:bL,SplineCurve:jv}),xS=class extends js{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new ss(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new wL[r.type]().fromJSON(r))}return this}},Au=class extends xS{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ss(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new na(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new $r(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new jv(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new pp(e,t,i,r,s,n,a,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},bS=class extends qe{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,u=new E,c=new k,d=new E,p=new E,f=new E,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),b=Math.cos(y);for(let _=0;_<=e.length-1;_++){u.x=e[_].x*x,u.y=e[_].y,u.z=e[_].x*b,n.push(u.x,u.y,u.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let A=o[3*_+0]*x,S=o[3*_+1],w=o[3*_+0]*b;l.push(A,S,w)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,_=x+e.length,A=x+e.length+1,S=x+1;s.push(b,_,S),s.push(A,S,_)}this.setIndex(s),this.setAttribute("position",new Le(n,3)),this.setAttribute("uv",new Le(a,2)),this.setAttribute("normal",new Le(l,3))}static fromJSON(e){return new bS(e.points,e.segments,e.phiStart,e.phiLength)}},Gv=class extends qe{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Le(u,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(d,2));function v(){let x=new E,b=new E,_=0,A=(t-e)/i;for(let S=0;S<=s;S++){let w=[],M=S/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+a,L=Math.sin(P),B=Math.cos(P);b.x=C*L,b.y=-M*i+g,b.z=C*B,u.push(b.x,b.y,b.z),x.set(L,A,B).normalize(),c.push(x.x,x.y,x.z),d.push(D,1-M),w.push(p++)}f.push(w)}for(let S=0;S<r;S++)for(let w=0;w<s;w++){let M=f[w][S],C=f[w+1][S],T=f[w+1][S+1],D=f[w][S+1];h.push(M,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let b=p,_=new k,A=new E,S=0,w=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,g*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+a,P=Math.cos(D),L=Math.sin(D);A.x=w*L,A.y=g*M,A.z=w*P,u.push(A.x,A.y,A.z),c.push(0,M,0),_.x=P*.5+.5,_.y=L*.5*M+.5,d.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(m,S,x===!0?1:2),m+=S}}static fromJSON(e){return new Gv(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},wS=class extends Gv{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new wS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vv=class extends qe{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new Le(s,3)),this.setAttribute("normal",new Le(s.slice(),3)),this.setAttribute("uv",new Le(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,x=new E,b=new E;for(let _=0;_<t.length;_+=3)d(t[_+0],y),d(t[_+1],x),d(t[_+2],b),o(y,x,b,v)}function o(v,y,x,b){let _=b+1,A=[];for(let S=0;S<=_;S++){A[S]=[];let w=v.clone().lerp(x,S/_),M=y.clone().lerp(x,S/_),C=_-S;for(let T=0;T<=C;T++)T===0&&S===_?A[S][T]=w:A[S][T]=w.clone().lerp(M,T/C)}for(let S=0;S<_;S++)for(let w=0;w<2*(_-S)-1;w++){let M=Math.floor(w/2);w%2===0?(c(A[S][M+1]),c(A[S+1][M]),c(A[S][M])):(c(A[S][M+1]),c(A[S+1][M+1]),c(A[S+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=g(v)/2/Math.PI+.5,b=m(v)/Math.PI+.5;n.push(x,1-b)}p(),u()}function u(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],b=n[v+4],_=Math.max(y,x,b),A=Math.min(y,x,b);_>.9&&A<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),b<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,_=new k,A=new k,S=new k;for(let w=0,M=0;w<s.length;w+=9,M+=6){v.set(s[w+0],s[w+1],s[w+2]),y.set(s[w+3],s[w+4],s[w+5]),x.set(s[w+6],s[w+7],s[w+8]),_.set(n[M+0],n[M+1]),A.set(n[M+2],n[M+3]),S.set(n[M+4],n[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=g(b);f(_,M+0,v,C),f(A,M+2,y,C),f(S,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=b/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Vv(e.vertices,e.indices,e.radius,e.details)}},_S=class extends Vv{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new _S(e.radius,e.detail)}},Mu=class extends Au{constructor(e){super(e),this.uuid=Nr(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Au().fromJSON(r))}return this}},_L={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=SS(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,u,c,d,p;if(r&&(n=CL(e,t,n,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return oc(n,a,i,o,l,p,0),a}};function SS(e,t,i,r,s){let n,a;if(s===NL(e,t,i,r)>0)for(n=t;n<i;n+=r)a=Y1(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=Y1(n,e[n],e[n+1],a);return a&&fp(a,a.next)&&(hc(a),a=a.next),a}function Za(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(fp(i,i.next)||Ut(i.prev,i,i.next)===0)){if(hc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function oc(e,t,i,r,s,n,a){if(!e)return;!a&&n&&LL(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?AL(e,r,s,n):SL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),hc(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=ML(Za(e),t,i),oc(e,t,i,r,s,n,2)):a===2&&EL(e,t,i,r,s,n):oc(Za(e),t,i,r,s,n,1);break}}}function SL(e){let t=e.prev,i=e,r=e.next;if(Ut(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,u=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,d=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Zo(s,o,n,l,a,h,f.x,f.y)&&Ut(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function AL(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ut(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,u=s.y,c=n.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,g=o>l?o>h?o:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=Km(p,f,t,i,r),y=Km(g,m,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Zo(o,u,l,c,h,d,x.x,x.y)&&Ut(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Zo(o,u,l,c,h,d,b.x,b.y)&&Ut(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Zo(o,u,l,c,h,d,x.x,x.y)&&Ut(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Zo(o,u,l,c,h,d,b.x,b.y)&&Ut(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ML(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!fp(s,n)&&AS(s,r,r.next,n)&&lc(s,n)&&lc(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),hc(r),hc(r.next),r=e=n),r=r.next}while(r!==e);return Za(r)}function EL(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&BL(a,o)){let l=MS(a,o);a=Za(a,a.next),l=Za(l,l.next),oc(a,t,i,r,s,n,0),oc(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function CL(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=SS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(RL(h));for(s.sort(TL),n=0;n<s.length;n++)i=PL(s[n],i);return i}function TL(e,t){return e.x-t.x}function PL(e,t){let i=DL(e,t);if(!i)return t;let r=MS(i,e);return Za(r,r.next),Za(i,i.next)}function DL(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let d=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,u=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&Zo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),lc(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&IL(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function IL(e,t){return Ut(e.prev,e,t.prev)<0&&Ut(t.next,e,e.next)<0}function LL(e,t,i,r){let s=e;do s.z===0&&(s.z=Km(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,OL(s)}function OL(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function Km(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function RL(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Zo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function BL(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!zL(e,t)&&(lc(e,t)&&lc(t,e)&&FL(e,t)&&(Ut(e.prev,e,t.prev)||Ut(e,t.prev,t))||fp(e,t)&&Ut(e.prev,e,e.next)>0&&Ut(t.prev,t,t.next)>0)}function Ut(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function fp(e,t){return e.x===t.x&&e.y===t.y}function AS(e,t,i,r){let s=ud(Ut(e,t,i)),n=ud(Ut(e,t,r)),a=ud(Ut(i,r,e)),o=ud(Ut(i,r,t));return!!(s!==n&&a!==o||s===0&&dd(e,i,t)||n===0&&dd(e,r,t)||a===0&&dd(i,e,r)||o===0&&dd(i,t,r))}function dd(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function ud(e){return e>0?1:e<0?-1:0}function zL(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&AS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function lc(e,t){return Ut(e.prev,e,e.next)<0?Ut(e,t,e.next)>=0&&Ut(e,e.prev,t)>=0:Ut(e,t,e.prev)<0||Ut(e,e.next,t)<0}function FL(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function MS(e,t){let i=new Jm(e.i,e.x,e.y),r=new Jm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Y1(e,t,i,r){let s=new Jm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function hc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Jm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function NL(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var ES=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return ES.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Q1(e),Z1(i,e);let n=e.length;t.forEach(Q1);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Z1(i,t[o]);let a=_L.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Q1(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Z1(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var CS=class extends Vv{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new CS(e.radius,e.detail)}},Hv=class extends qe{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let _=b/t;u.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),u.y=e*Math.cos(n+y*a),u.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],b=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&d.push(y,x,_),(m!==i-1||o<Math.PI)&&d.push(x,b,_)}this.setIndex(d),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(g,2))}static fromJSON(e){return new Hv(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},TS=class extends qe{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,g=new E,m=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,d),v(x+.01,s,n,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let b=0;b<=r;++b){let _=b/r*Math.PI*2,A=-t*Math.cos(_),S=t*Math.sin(_);u.x=d.x+(A*m.x+S*f.x),u.y=d.y+(A*m.y+S*f.y),u.z=d.z+(A*m.z+S*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;a.push(b,_,S),a.push(_,A,S)}this.setIndex(a),this.setAttribute("position",new Le(o,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(h,2));function v(y,x,b,_,A){let S=Math.cos(y),w=Math.sin(y),M=b/x*y,C=Math.cos(M);A.x=_*(2+C)*.5*S,A.y=_*(2+C)*w*.5,A.z=_*Math.sin(M)*.5}}static fromJSON(e){return new TS(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function In(e,t,i){return PS(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function pd(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function PS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function kL(e){function t(s,n){return e[s]-e[n]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function K1(e,t,i){let r=e.length,s=new e.constructor(r);for(let n=0,a=0;a!==r;++n){let o=i[n]*t;for(let l=0;l!==t;++l)s[a++]=e[o+l]}return s}function DS(e,t,i,r){let s=1,n=e[0];for(;n!==void 0&&n[r]===void 0;)n=e[s++];if(n===void 0)return;let a=n[r];if(a!==void 0)if(Array.isArray(a))do a=n[r],a!==void 0&&(t.push(n.time),i.push.apply(i,a)),n=e[s++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[r],a!==void 0&&(t.push(n.time),a.toArray(i,i.length)),n=e[s++];while(n!==void 0);else do a=n[r],a!==void 0&&(t.push(n.time),i.push(a)),n=e[s++];while(n!==void 0)}var mp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let n;i:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}n=t.length;break i}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}n=i,i=0;break i}break e}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},UL=class extends mp{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:qo,endingEnd:qo}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case Xo:s=e,a=2*t-i;break;case yu:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case Xo:n=e,o=2*i-t;break;case yu:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*g+(1.5+d)*f+.5*p,x=d*g-d*f;for(let b=0;b!==a;++b)s[b]=m*n[h+b]+v*n[l+b]+y*n[o+b]+x*n[u+b];return s}},IS=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*u+n[o+c]*h;return s}},jL=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Gs=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=pd(t,this.TimeBufferType),this.values=pd(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:pd(e.times,Array),values:pd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new jL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new IS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new UL(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case gu:t=this.InterpolantFactoryMethodDiscrete;break;case vu:t=this.InterpolantFactoryMethodLinear;break;case ef:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gu;case this.InterpolantFactoryMethodLinear:return vu;case this.InterpolantFactoryMethodSmooth:return ef}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=In(i,s,n),this.values=In(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&PS(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=In(this.times),t=In(this.values),i=this.getValueSize(),r=this.getInterpolation()===ef,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let u=a*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let u=a*i,c=n*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=In(e,0,n),this.values=In(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=In(this.times,0),t=In(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Gs.prototype.TimeBufferType=Float32Array;Gs.prototype.ValueBufferType=Float32Array;Gs.prototype.DefaultInterpolation=vu;var Nl=class extends Gs{};Nl.prototype.ValueTypeName="bool";Nl.prototype.ValueBufferType=Array;Nl.prototype.DefaultInterpolation=gu;Nl.prototype.InterpolantFactoryMethodLinear=void 0;Nl.prototype.InterpolantFactoryMethodSmooth=void 0;var LS=class extends Gs{};LS.prototype.ValueTypeName="color";var Eu=class extends Gs{};Eu.prototype.ValueTypeName="number";var GL=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)it.slerpFlat(s,0,n,l-a,n,l,o);return s}},Dc=class extends Gs{InterpolantFactoryMethodLinear(e){return new GL(this.times,this.values,this.getValueSize(),e)}};Dc.prototype.ValueTypeName="quaternion";Dc.prototype.DefaultInterpolation=vu;Dc.prototype.InterpolantFactoryMethodSmooth=void 0;var kl=class extends Gs{};kl.prototype.ValueTypeName="string";kl.prototype.ValueBufferType=Array;kl.prototype.DefaultInterpolation=gu;kl.prototype.InterpolantFactoryMethodLinear=void 0;kl.prototype.InterpolantFactoryMethodSmooth=void 0;var Cu=class extends Gs{};Cu.prototype.ValueTypeName="vector";var $m=class{constructor(e,t=-1,i,r=Lv){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Nr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let n=0,a=i.length;n!==a;++n)t.push(HL(i[n]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,n=i.length;s!==n;++s)t.push(Gs.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,n=[];for(let a=0;a<s;a++){let o=[],l=[];o.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let h=kL(o);o=K1(o,1,h),l=K1(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),n.push(new Eu(".morphTargetInfluences["+t[a].name+"]",o,l).scale(1/i))}return new this(e,-1,n)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let l=e[a],h=l.name.match(s);if(h&&h.length>1){let u=h[1],c=r[u];c||(r[u]=c=[]),c.push(l)}}let n=[];for(let a in r)n.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,u,c,d,p){if(c.length!==0){let f=[],g=[];DS(c,f,g,d),f.length!==0&&p.push(new h(u,f,g))}},r=[],s=e.name||"default",n=e.fps||30,a=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],g=[];for(let m=0;m!==u[d].morphTargets.length;++m){let v=u[d];f.push(v.time),g.push(v.morphTarget===p?1:0)}r.push(new Eu(".morphTargetInfluence["+p+"]",f,g))}o=c.length*n}else{let c=".bones["+t[h].name+"]";i(Cu,c+".position",u,"pos",r),i(Dc,c+".quaternion",u,"rot",r),i(Cu,c+".scale",u,"scl",r)}}return r.length===0?null:new this(s,o,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function VL(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Eu;case"vector":case"vector2":case"vector3":case"vector4":return Cu;case"color":return LS;case"quaternion":return Dc;case"bool":case"boolean":return Nl;case"string":return kl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function HL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=VL(e.type);if(e.times===void 0){let i=[],r=[];DS(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var J1={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},OS=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},WL=new OS,Wv=class{constructor(e){this.manager=e!==void 0?e:WL,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Js={},qL=class extends Error{constructor(e,t){super(e),this.response=t}},eg=class extends Wv{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=J1.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Js[e]!==void 0){Js[e].push({onLoad:t,onProgress:i,onError:r});return}Js[e]=[],Js[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Js[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,g=new ReadableStream({start(m){v();function v(){u.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let _=0,A=h.length;_<A;_++){let S=h[_];S.onProgress&&S.onProgress(b)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new qL(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{J1.add(e,l);let h=Js[e];delete Js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=Js[e];if(h===void 0)throw this.manager.itemError(e),l;delete Js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Ic=class extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},XL=class extends Ic{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},If=new fe,$1=new E,ex=new E,qv=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zv,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;$1.setFromMatrixPosition(e.matrixWorld),t.position.copy($1),ex.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ex),t.updateMatrixWorld(),If.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(If),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(If)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},YL=class extends qv{constructor(){super(new Oi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ac*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},QL=class extends Ic{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new YL}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},tx=new fe,dh=new E,Lf=new E,ZL=class extends qv{constructor(){super(new Oi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new et(2,1,1,1),new et(0,1,1,1),new et(3,1,1,1),new et(1,1,1,1),new et(3,0,1,1),new et(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),dh.setFromMatrixPosition(e.matrixWorld),i.position.copy(dh),Lf.copy(i.position),Lf.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Lf),i.updateMatrixWorld(),r.makeTranslation(-dh.x,-dh.y,-dh.z),tx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx)}},KL=class extends Ic{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new ZL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},JL=class extends qv{constructor(){super(new Fv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},$L=class extends Ic{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new JL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},eO=class extends qe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},RS=class extends Wv{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new eg(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),g=Hc(p.type,f),m=new oL(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let n=e.isInstancedBufferGeometry?new eO:new qe,a=e.data.index;if(a!==void 0){let c=Hc(a.type,a.array);n.setIndex(new Ye(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new Zm(f,d.itemSize,d.offset,d.normalized)}else{let f=Hc(d.type,d.array),g=d.isInstancedBufferAttribute?hL:Ye;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Zm(y,m.itemSize,m.offset,m.normalized)}else{let y=Hc(m.type,m.array);v=new Ye(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new E;u.center!==void 0&&c.fromArray(u.center),n.boundingSphere=new Sr(c,u.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},tO=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ix(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=ix();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function ix(){return(typeof performance>"u"?Date:performance).now()}var iO=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,n;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,n=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,n=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,n=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=n,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,n=this.cumulativeWeight;if(n===0){for(let a=0;a!==r;++a)i[s+a]=i[a];n=t}else{n+=t;let a=t/n;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=n}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,n=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}n>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,n=r;s!==n;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let n=0;n!==s;++n)e[t+n]=e[i+n]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let n=this._workIndex*s;it.multiplyQuaternionsFlat(e,n,e,t,e,i),it.slerpFlat(e,t,e,t,e,n,r)}_lerp(e,t,i,r,s){let n=1-r;for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]*n+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let n=0;n!==s;++n){let a=t+n;e[a]=e[a]+e[i+n]*r}}},Xv="\\[\\]\\.:\\/",rO=new RegExp("["+Xv+"]","g"),Yv="[^"+Xv+"]",sO="[^"+Xv.replace("\\.","")+"]",nO=/((?:WC+[\/:])*)/.source.replace("WC",Yv),aO=/(WCOD+)?/.source.replace("WCOD",sO),oO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yv),lO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yv),hO=new RegExp("^"+nO+aO+oO+lO+"$"),cO=["material","materials","bones","map"],dO=class{constructor(e,t,i){let r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Tt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(rO,"")}static parseTrackName(e){let t=hO.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);cO.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Tt.Composite=dO;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var uO=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,n=s.length,a=new Array(n),o={endingStart:qo,endingEnd:qo};for(let l=0;l!==n;++l){let h=s[l].createInterpolant(null);a[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=$_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,n=s/r,a=r/s;e.warp(1,n,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,n=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/n,l[1]=t/n,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let n=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case qC:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(n),l[h].accumulateAdditive(a);break;case Lv:default:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(n),l[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,n=i===Iv;if(e===0)return s===-1?r:n&&(s&1)===1?t-r:r;if(i===J_){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(n&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Xo,r.endingEnd=Xo):(e?r.endingStart=this.zeroSlopeAtStart?Xo:qo:r.endingStart=yu,t?r.endingEnd=this.zeroSlopeAtEnd?Xo:qo:r.endingEnd=yu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,n=this._weightInterpolant;n===null&&(n=r._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=s,o[0]=t,a[1]=s+e,o[1]=i,this}},pO=new Float32Array(1),fO=class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,n=e._propertyBindings,a=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,n[u]=p;else{if(p=n[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new iO(Tt.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),n[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,n=s[t];if(n===void 0)n={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=n;else{let a=n.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),n.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,n=this._actionsByClip,a=n[s],o=a.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],o.length===0&&delete n[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,n=r[t];n===void 0&&(n={},r[t]=n),n[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,n=this._bindingsByRootAndName,a=n[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[s],Object.keys(a).length===0&&delete n[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new IS(new Float32Array(2),new Float32Array(2),1,pO),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,n=typeof e=="string"?$m.findByName(r,e):e,a=n!==null?n.uuid:e,o=this._actionsByClip[a],l=null;if(i===void 0&&(n!==null?i=n.blendMode:i=Lv),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],n===null&&(n=l._clip)}if(n===null)return null;let h=new uO(this,n,t,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?$m.findByName(i,e):e,n=s?s.uuid:e,a=this._actionsByClip[n];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),n=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,n);let a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(n);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let n=s.knownActions;for(let a=0,o=n.length;a!==o;++a){let l=n[a];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let n in i){let a=i[n].actionByRoot,o=a[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let n in s){let a=s[n];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},pe=class{constructor(e){this.value=e}clone(){return new pe(this.value.clone===void 0?this.value:this.value.clone())}},BS=class{constructor(e,t,i=0,r=1/0){this.ray=new Rl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Rv,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return tg(e,this,i,t),i.sort(rx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)tg(e[r],this,i,t);return i.sort(rx),i}};function rx(e,t){return e.distance-t.distance}function tg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)tg(s[n],t,i,!0)}}var sx=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},nx=new k,mO=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=nx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return nx.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ax=new E,fd=new E,kr=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){ax.subVectors(e,this.start),fd.subVectors(this.end,this.start);let i=fd.dot(fd),r=fd.dot(ax)/i;return t&&(r=hi(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},ox=new E,gO=class extends Et{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new qe,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Le(r,3));let s=new la({fog:!1,toneMapped:!1});this.cone=new Pc(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ox.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ox),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},vO=class extends nr{constructor(e,t,i){let r=new Hv(t,4,2),s=new Tc({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},lx=new E,md=new E,hx=new E,yO=class extends Et{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new qe;r.setAttribute("position",new Le([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new la({fog:!1,toneMapped:!1});this.lightPlane=new Su(r,s),this.add(this.lightPlane),r=new qe,r.setAttribute("position",new Le([0,0,0,0,0,1],3)),this.targetLine=new Su(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),lx.setFromMatrixPosition(this.light.matrixWorld),md.setFromMatrixPosition(this.light.target.matrixWorld),hx.subVectors(md,lx),this.lightPlane.lookAt(md),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(md),this.targetLine.scale.z=hx.length()}},gd=new E,jt=new zl,Tu=class extends Pc{constructor(e){let t=new qe,i=new la({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new Le(r,3)),t.setAttribute("color",new Le(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new je(16755200),h=new je(16711680),u=new je(43775),c=new je(16777215),d=new je(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;jt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),qt("c",t,e,jt,0,0,-1),qt("t",t,e,jt,0,0,1),qt("n1",t,e,jt,-i,-r,-1),qt("n2",t,e,jt,i,-r,-1),qt("n3",t,e,jt,-i,r,-1),qt("n4",t,e,jt,i,r,-1),qt("f1",t,e,jt,-i,-r,1),qt("f2",t,e,jt,i,-r,1),qt("f3",t,e,jt,-i,r,1),qt("f4",t,e,jt,i,r,1),qt("u1",t,e,jt,i*.7,r*1.1,-1),qt("u2",t,e,jt,-i*.7,r*1.1,-1),qt("u3",t,e,jt,0,r*2,-1),qt("cf1",t,e,jt,-i,0,1),qt("cf2",t,e,jt,i,0,1),qt("cf3",t,e,jt,0,-r,1),qt("cf4",t,e,jt,0,r,1),qt("cn1",t,e,jt,-i,0,-1),qt("cn2",t,e,jt,i,0,-1),qt("cn3",t,e,jt,0,-r,-1),qt("cn4",t,e,jt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function qt(e,t,i,r,s,n,a){gd.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],gd.x,gd.y,gd.z)}}var Pu=class extends Pc{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new qe;s.setIndex(new Ye(i,1)),s.setAttribute("position",new Le(r,3)),super(s,new la({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},xO=class extends Pc{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new qe;r.setAttribute("position",new Le(t,3)),r.setAttribute("color",new Le(i,3));let s=new la({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new je,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ol}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ol);var uh=".",Qv=Symbol("target"),zS=Symbol("unsubscribe");function ig(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function bO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Cs=Array.isArray;function Zv(e){return typeof e=="symbol"}var wO={after:(e,t)=>Cs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Cs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=uh),Zv(t)?e+t.toString():e+t):e,initial:e=>{if(Cs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(uh);return t===-1?"":e.slice(0,t)},last:e=>{if(Cs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(uh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Cs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(uh);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(uh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Or=wO;function _O(e){return typeof e=="object"&&typeof e.next=="function"}function SO(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Qv].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function cx(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Zv(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var AO=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Or.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function rg(e){return toString.call(e)==="[object Object]"}function vd(){return!0}function Ao(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var FS=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),MO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),NS={push:vd,pop:vd,shift:vd,unshift:vd,copyWithin:Ao,reverse:Ao,sort:Ao,splice:Ao,flat:Ao,fill:Ao},EO=new Set([...FS,...MO,...Object.keys(NS)]);function yd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var kS=["keys","values","entries"],US=new Set(["has","toString"]),jS={add:yd,clear:yd,delete:yd,forEach:yd},CO=new Set([...US,...Object.keys(jS),...kS]);function xd(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var TO=new Set([...US,"get"]),GS={set:xd,clear:xd,delete:xd,forEach:xd},PO=new Set([...TO,...Object.keys(GS),...kS]),aa=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return FS.has(e)}_shallowClone(e){let t=e;if(rg(e))t={...e};else if(Cs(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Cs(r)?this._onIsChanged=NS[t]:r instanceof Set?this._onIsChanged=jS[t]:r instanceof Map&&(this._onIsChanged=GS[t]),r):i}update(e,t,i){let r=Or.after(e,this._path);if(t!=="length"){let s=this.clone;Or.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Or.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},dx=class extends aa{static isHandledMethod(e){return EO.has(e)}},DO=class extends aa{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},ux=class extends aa{static isHandledMethod(e){return CO.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},px=class extends aa{static isHandledMethod(e){return PO.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},IO=class extends aa{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},LO=class extends aa{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Go=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return rg(e)||Cs(e)||ig(e)}static isHandledMethod(e,t){return rg(e)?aa.isHandledMethod(t):Cs(e)?dx.isHandledMethod(t):e instanceof Set?ux.isHandledMethod(t):e instanceof Map?px.isHandledMethod(t):ig(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=aa;Cs(e)?r=dx:e instanceof Date?r=DO:e instanceof Set?r=ux:e instanceof Map?r=px:e instanceof WeakSet?r=IO:e instanceof WeakMap&&(r=LO),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Go.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},OO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Kv=(e,t,i={})=>{i={...OO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new AO(s),h=typeof i.onValidate=="function",u=new Go(h),c=(y,x,b,_,A)=>!h||u.isCloning||i.onValidate(Or.concat(l.getPath(y),x),b,_,A)===!0,d=(y,x,b,_)=>{!cx(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,b,_)},p=(y,x,b,_,A)=>{u.isCloning?u.update(y,x,_):t(Or.concat(y,x),b,_,A)},f=y=>y&&(y[r]||y),g=(y,x,b,_)=>bO(y)||b==="constructor"||n&&!Go.isHandledMethod(x,b)||cx(l,i,b)||l.isGetInvariant(x,b)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Or.concat(_,b),m,r)),m={get(y,x,b){if(Zv(x)){if(x===r||x===Qv)return y;if(x===zS&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=ig(y)?Reflect.get(y,x):Reflect.get(y,x,b);return g(_,y,x)},set(y,x,b,_){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let w=c(y,x,b,S);return w&&l.setProperty(A,x,b,_,S)?(d(y,x,y[x],S),!0):!w},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let _=y[x];c(y,x,b.value,_)&&l.defineProperty(y,x,b,_)&&d(y,x,b.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),_=c(y,x,void 0,b);return _&&l.deleteProperty(y,x,b)?(d(y,x,void 0,b),!0):!_},apply(y,x,b){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,b);if((o===!1||o!==!0&&!o.includes(y.name))&&Go.isHandledType(_)){let A=Or.initial(l.getPath(y)),S=Go.isHandledMethod(_,y.name);u.start(_,A,b);let w=Reflect.apply(y,u.preferredThisArg(y,x,_),S?b.map(T=>f(T)):b),M=u.isChanged(_,s),C=u.stop();if(Go.isHandledType(w)&&S&&(x instanceof Map&&y.name==="get"&&(A=Or.concat(A,b[0])),w=l.getProxy(w,A,m)),M){let T={name:y.name,args:b,result:w},D=u.isCloning?Or.initial(A):A,P=u.isCloning?Or.last(A):"";c(Or.get(e,D),P,_,C,T)?p(D,P,_,C,T):u.undo(_)}return(x instanceof Map||x instanceof Set)&&_O(w)?SO(w,y,x,A,g):w}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};Kv.target=e=>e&&e[Qv]||e;Kv.unsubscribe=e=>e[zS]||e;var fx=Kv,RO=typeof global=="object"&&global&&global.Object===Object&&global,VS=RO,BO=typeof self=="object"&&self&&self.Object===Object&&self,zO=VS||BO||Function("return this")(),os=zO,FO=os.Symbol,jr=FO,HS=Object.prototype,NO=HS.hasOwnProperty,kO=HS.toString,ph=jr?jr.toStringTag:void 0;function UO(e){var t=NO.call(e,ph),i=e[ph];try{e[ph]=void 0;var r=!0}catch{}var s=kO.call(e);return r&&(t?e[ph]=i:delete e[ph]),s}var jO=UO,GO=Object.prototype,VO=GO.toString;function HO(e){return VO.call(e)}var WO=HO,qO="[object Null]",XO="[object Undefined]",mx=jr?jr.toStringTag:void 0;function YO(e){return e==null?e===void 0?XO:qO:mx&&mx in Object(e)?jO(e):WO(e)}var eo=YO;function QO(e){return e!=null&&typeof e=="object"}var _n=QO,ZO="[object Symbol]";function KO(e){return typeof e=="symbol"||_n(e)&&eo(e)==ZO}var gp=KO;function JO(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var WS=JO,$O=Array.isArray,Fs=$O,e4=1/0,gx=jr?jr.prototype:void 0,vx=gx?gx.toString:void 0;function qS(e){if(typeof e=="string")return e;if(Fs(e))return WS(e,qS)+"";if(gp(e))return vx?vx.call(e):"";var t=e+"";return t=="0"&&1/e==-e4?"-0":t}var t4=qS,i4=/\s/;function r4(e){for(var t=e.length;t--&&i4.test(e.charAt(t)););return t}var s4=r4,n4=/^\s+/;function a4(e){return e&&e.slice(0,s4(e)+1).replace(n4,"")}var o4=a4;function l4(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var as=l4,yx=0/0,h4=/^[-+]0x[0-9a-f]+$/i,c4=/^0b[01]+$/i,d4=/^0o[0-7]+$/i,u4=parseInt;function p4(e){if(typeof e=="number")return e;if(gp(e))return yx;if(as(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=as(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=o4(e);var i=c4.test(e);return i||d4.test(e)?u4(e.slice(2),i?2:8):h4.test(e)?yx:+e}var xx=p4;function f4(e){return e}var m4=f4,g4="[object AsyncFunction]",v4="[object Function]",y4="[object GeneratorFunction]",x4="[object Proxy]";function b4(e){if(!as(e))return!1;var t=eo(e);return t==v4||t==y4||t==g4||t==x4}var XS=b4,w4=os["__core-js_shared__"],Of=w4,bx=function(){var e=/[^.]+$/.exec(Of&&Of.keys&&Of.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function _4(e){return!!bx&&bx in e}var S4=_4,A4=Function.prototype,M4=A4.toString;function E4(e){if(e!=null){try{return M4.call(e)}catch{}try{return e+""}catch{}}return""}var to=E4,C4=/[\\^$.*+?()[\]{}|]/g,T4=/^\[object .+?Constructor\]$/,P4=Function.prototype,D4=Object.prototype,I4=P4.toString,L4=D4.hasOwnProperty,O4=RegExp("^"+I4.call(L4).replace(C4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R4(e){if(!as(e)||S4(e))return!1;var t=XS(e)?O4:T4;return t.test(to(e))}var B4=R4;function z4(e,t){return e?.[t]}var F4=z4;function N4(e,t){var i=F4(e,t);return B4(i)?i:void 0}var io=N4,k4=io(os,"WeakMap"),sg=k4,wx=Object.create,U4=function(){function e(){}return function(t){if(!as(t))return{};if(wx)return wx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),j4=U4;function G4(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var V4=G4;function H4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var W4=H4,q4=800,X4=16,Y4=Date.now;function Q4(e){var t=0,i=0;return function(){var r=Y4(),s=X4-(r-i);if(i=r,s>0){if(++t>=q4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Z4=Q4;function K4(e){return function(){return e}}var J4=K4,$4=function(){try{var e=io(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Du=$4,eR=Du?function(e,t){return Du(e,"toString",{configurable:!0,enumerable:!1,value:J4(t),writable:!0})}:m4,tR=eR,iR=Z4(tR),rR=iR;function sR(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var nR=sR,aR=9007199254740991,oR=/^(?:0|[1-9]\d*)$/;function lR(e,t){var i=typeof e;return t=t??aR,!!t&&(i=="number"||i!="symbol"&&oR.test(e))&&e>-1&&e%1==0&&e<t}var Jv=lR;function hR(e,t,i){t=="__proto__"&&Du?Du(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var YS=hR;function cR(e,t){return e===t||e!==e&&t!==t}var $v=cR,dR=Object.prototype,uR=dR.hasOwnProperty;function pR(e,t,i){var r=e[t];(!(uR.call(e,t)&&$v(r,i))||i===void 0&&!(t in e))&&YS(e,t,i)}var e0=pR;function fR(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?YS(i,o,l):e0(i,o,l)}return i}var Lc=fR,_x=Math.max;function mR(e,t,i){return t=_x(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=_x(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),V4(e,this,o)}}var gR=mR,vR=9007199254740991;function yR(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=vR}var t0=yR;function xR(e){return e!=null&&t0(e.length)&&!XS(e)}var QS=xR,bR=Object.prototype;function wR(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||bR;return e===i}var i0=wR;function _R(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var SR=_R,AR="[object Arguments]";function MR(e){return _n(e)&&eo(e)==AR}var Sx=MR,ZS=Object.prototype,ER=ZS.hasOwnProperty,CR=ZS.propertyIsEnumerable,TR=Sx(function(){return arguments}())?Sx:function(e){return _n(e)&&ER.call(e,"callee")&&!CR.call(e,"callee")},r0=TR;function PR(){return!1}var DR=PR,KS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ax=KS&&typeof module=="object"&&module&&!module.nodeType&&module,IR=Ax&&Ax.exports===KS,Mx=IR?os.Buffer:void 0,LR=Mx?Mx.isBuffer:void 0,OR=LR||DR,Iu=OR,RR="[object Arguments]",BR="[object Array]",zR="[object Boolean]",FR="[object Date]",NR="[object Error]",kR="[object Function]",UR="[object Map]",jR="[object Number]",GR="[object Object]",VR="[object RegExp]",HR="[object Set]",WR="[object String]",qR="[object WeakMap]",XR="[object ArrayBuffer]",YR="[object DataView]",QR="[object Float32Array]",ZR="[object Float64Array]",KR="[object Int8Array]",JR="[object Int16Array]",$R="[object Int32Array]",eB="[object Uint8Array]",tB="[object Uint8ClampedArray]",iB="[object Uint16Array]",rB="[object Uint32Array]",Ft={};Ft[QR]=Ft[ZR]=Ft[KR]=Ft[JR]=Ft[$R]=Ft[eB]=Ft[tB]=Ft[iB]=Ft[rB]=!0;Ft[RR]=Ft[BR]=Ft[XR]=Ft[zR]=Ft[YR]=Ft[FR]=Ft[NR]=Ft[kR]=Ft[UR]=Ft[jR]=Ft[GR]=Ft[VR]=Ft[HR]=Ft[WR]=Ft[qR]=!1;function sB(e){return _n(e)&&t0(e.length)&&!!Ft[eo(e)]}var nB=sB;function aB(e){return function(t){return e(t)}}var s0=aB,JS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xh=JS&&typeof module=="object"&&module&&!module.nodeType&&module,oB=Xh&&Xh.exports===JS,Rf=oB&&VS.process,lB=function(){try{var e=Xh&&Xh.require&&Xh.require("util").types;return e||Rf&&Rf.binding&&Rf.binding("util")}catch{}}(),bl=lB,Ex=bl&&bl.isTypedArray,hB=Ex?s0(Ex):nB,$S=hB,cB=Object.prototype,dB=cB.hasOwnProperty;function uB(e,t){var i=Fs(e),r=!i&&r0(e),s=!i&&!r&&Iu(e),n=!i&&!r&&!s&&$S(e),a=i||r||s||n,o=a?SR(e.length,String):[],l=o.length;for(var h in e)(t||dB.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Jv(h,l)))&&o.push(h);return o}var eA=uB;function pB(e,t){return function(i){return e(t(i))}}var tA=pB,fB=tA(Object.keys,Object),mB=fB,gB=Object.prototype,vB=gB.hasOwnProperty;function yB(e){if(!i0(e))return mB(e);var t=[];for(var i in Object(e))vB.call(e,i)&&i!="constructor"&&t.push(i);return t}var xB=yB;function bB(e){return QS(e)?eA(e):xB(e)}var n0=bB;function wB(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var _B=wB,SB=Object.prototype,AB=SB.hasOwnProperty;function MB(e){if(!as(e))return _B(e);var t=i0(e),i=[];for(var r in e)r=="constructor"&&(t||!AB.call(e,r))||i.push(r);return i}var EB=MB;function CB(e){return QS(e)?eA(e,!0):EB(e)}var a0=CB,TB=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,PB=/^\w*$/;function DB(e,t){if(Fs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||gp(e)?!0:PB.test(e)||!TB.test(e)||t!=null&&e in Object(t)}var IB=DB,LB=io(Object,"create"),cc=LB;function OB(){this.__data__=cc?cc(null):{},this.size=0}var RB=OB;function BB(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var zB=BB,FB="__lodash_hash_undefined__",NB=Object.prototype,kB=NB.hasOwnProperty;function UB(e){var t=this.__data__;if(cc){var i=t[e];return i===FB?void 0:i}return kB.call(t,e)?t[e]:void 0}var jB=UB,GB=Object.prototype,VB=GB.hasOwnProperty;function HB(e){var t=this.__data__;return cc?t[e]!==void 0:VB.call(t,e)}var WB=HB,qB="__lodash_hash_undefined__";function XB(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=cc&&t===void 0?qB:t,this}var YB=XB;function Ul(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ul.prototype.clear=RB;Ul.prototype.delete=zB;Ul.prototype.get=jB;Ul.prototype.has=WB;Ul.prototype.set=YB;var Cx=Ul;function QB(){this.__data__=[],this.size=0}var ZB=QB;function KB(e,t){for(var i=e.length;i--;)if($v(e[i][0],t))return i;return-1}var vp=KB,JB=Array.prototype,$B=JB.splice;function ez(e){var t=this.__data__,i=vp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():$B.call(t,i,1),--this.size,!0}var tz=ez;function iz(e){var t=this.__data__,i=vp(t,e);return i<0?void 0:t[i][1]}var rz=iz;function sz(e){return vp(this.__data__,e)>-1}var nz=sz;function az(e,t){var i=this.__data__,r=vp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var oz=az;function jl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}jl.prototype.clear=ZB;jl.prototype.delete=tz;jl.prototype.get=rz;jl.prototype.has=nz;jl.prototype.set=oz;var yp=jl,lz=io(os,"Map"),dc=lz;function hz(){this.size=0,this.__data__={hash:new Cx,map:new(dc||yp),string:new Cx}}var cz=hz;function dz(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var uz=dz;function pz(e,t){var i=e.__data__;return uz(t)?i[typeof t=="string"?"string":"hash"]:i.map}var xp=pz;function fz(e){var t=xp(this,e).delete(e);return this.size-=t?1:0,t}var mz=fz;function gz(e){return xp(this,e).get(e)}var vz=gz;function yz(e){return xp(this,e).has(e)}var xz=yz;function bz(e,t){var i=xp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var wz=bz;function Gl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Gl.prototype.clear=cz;Gl.prototype.delete=mz;Gl.prototype.get=vz;Gl.prototype.has=xz;Gl.prototype.set=wz;var bp=Gl,_z="Expected a function";function o0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(_z);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(o0.Cache||bp),i}o0.Cache=bp;var Sz=o0,Az=500;function Mz(e){var t=Sz(e,function(r){return i.size===Az&&i.clear(),r}),i=t.cache;return t}var Ez=Mz,Cz=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tz=/\\(\\)?/g,Pz=Ez(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Cz,function(i,r,s,n){t.push(s?n.replace(Tz,"$1"):r||i)}),t}),Dz=Pz;function Iz(e){return e==null?"":t4(e)}var Lz=Iz;function Oz(e,t){return Fs(e)?e:IB(e,t)?[e]:Dz(Lz(e))}var Vl=Oz,Rz=1/0;function Bz(e){if(typeof e=="string"||gp(e))return e;var t=e+"";return t=="0"&&1/e==-Rz?"-0":t}var wp=Bz;function zz(e,t){t=Vl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[wp(t[i++])];return i&&i==r?e:void 0}var iA=zz;function Fz(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var l0=Fz,Tx=jr?jr.isConcatSpreadable:void 0;function Nz(e){return Fs(e)||r0(e)||!!(Tx&&e&&e[Tx])}var kz=Nz;function rA(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=kz),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?rA(o,t-1,i,r,s):l0(s,o):r||(s[s.length]=o)}return s}var Uz=rA;function jz(e){var t=e==null?0:e.length;return t?Uz(e,1):[]}var Gz=jz;function Vz(e){return rR(gR(e,void 0,Gz),e+"")}var sA=Vz,Hz=tA(Object.getPrototypeOf,Object),h0=Hz,Wz="[object Object]",qz=Function.prototype,Xz=Object.prototype,nA=qz.toString,Yz=Xz.hasOwnProperty,Qz=nA.call(Object);function Zz(e){if(!_n(e)||eo(e)!=Wz)return!1;var t=h0(e);if(t===null)return!0;var i=Yz.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&nA.call(i)==Qz}var Kz=Zz;function Jz(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var $z=Jz;function e5(){this.__data__=new yp,this.size=0}var t5=e5;function i5(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var r5=i5;function s5(e){return this.__data__.get(e)}var n5=s5;function a5(e){return this.__data__.has(e)}var o5=a5,l5=200;function h5(e,t){var i=this.__data__;if(i instanceof yp){var r=i.__data__;if(!dc||r.length<l5-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new bp(r)}return i.set(e,t),this.size=i.size,this}var c5=h5;function Hl(e){var t=this.__data__=new yp(e);this.size=t.size}Hl.prototype.clear=t5;Hl.prototype.delete=r5;Hl.prototype.get=n5;Hl.prototype.has=o5;Hl.prototype.set=c5;var lu=Hl;function d5(e,t){return e&&Lc(t,n0(t),e)}var u5=d5;function p5(e,t){return e&&Lc(t,a0(t),e)}var f5=p5,aA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Px=aA&&typeof module=="object"&&module&&!module.nodeType&&module,m5=Px&&Px.exports===aA,Dx=m5?os.Buffer:void 0,Ix=Dx?Dx.allocUnsafe:void 0;function g5(e,t){if(t)return e.slice();var i=e.length,r=Ix?Ix(i):new e.constructor(i);return e.copy(r),r}var v5=g5;function y5(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var x5=y5;function b5(){return[]}var oA=b5,w5=Object.prototype,_5=w5.propertyIsEnumerable,Lx=Object.getOwnPropertySymbols,S5=Lx?function(e){return e==null?[]:(e=Object(e),x5(Lx(e),function(t){return _5.call(e,t)}))}:oA,c0=S5;function A5(e,t){return Lc(e,c0(e),t)}var M5=A5,E5=Object.getOwnPropertySymbols,C5=E5?function(e){for(var t=[];e;)l0(t,c0(e)),e=h0(e);return t}:oA,lA=C5;function T5(e,t){return Lc(e,lA(e),t)}var P5=T5;function D5(e,t,i){var r=t(e);return Fs(e)?r:l0(r,i(e))}var hA=D5;function I5(e){return hA(e,n0,c0)}var ng=I5;function L5(e){return hA(e,a0,lA)}var cA=L5,O5=io(os,"DataView"),ag=O5,R5=io(os,"Promise"),og=R5,B5=io(os,"Set"),lg=B5,Ox="[object Map]",z5="[object Object]",Rx="[object Promise]",Bx="[object Set]",zx="[object WeakMap]",Fx="[object DataView]",F5=to(ag),N5=to(dc),k5=to(og),U5=to(lg),j5=to(sg),Ea=eo;(ag&&Ea(new ag(new ArrayBuffer(1)))!=Fx||dc&&Ea(new dc)!=Ox||og&&Ea(og.resolve())!=Rx||lg&&Ea(new lg)!=Bx||sg&&Ea(new sg)!=zx)&&(Ea=function(e){var t=eo(e),i=t==z5?e.constructor:void 0,r=i?to(i):"";if(r)switch(r){case F5:return Fx;case N5:return Ox;case k5:return Rx;case U5:return Bx;case j5:return zx}return t});var uc=Ea,G5=Object.prototype,V5=G5.hasOwnProperty;function H5(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&V5.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var W5=H5,q5=os.Uint8Array,Lu=q5;function X5(e){var t=new e.constructor(e.byteLength);return new Lu(t).set(new Lu(e)),t}var d0=X5;function Y5(e,t){var i=t?d0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var Q5=Y5,Z5=/\w*$/;function K5(e){var t=new e.constructor(e.source,Z5.exec(e));return t.lastIndex=e.lastIndex,t}var J5=K5,Nx=jr?jr.prototype:void 0,kx=Nx?Nx.valueOf:void 0;function $5(e){return kx?Object(kx.call(e)):{}}var eF=$5;function tF(e,t){var i=t?d0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var iF=tF,rF="[object Boolean]",sF="[object Date]",nF="[object Map]",aF="[object Number]",oF="[object RegExp]",lF="[object Set]",hF="[object String]",cF="[object Symbol]",dF="[object ArrayBuffer]",uF="[object DataView]",pF="[object Float32Array]",fF="[object Float64Array]",mF="[object Int8Array]",gF="[object Int16Array]",vF="[object Int32Array]",yF="[object Uint8Array]",xF="[object Uint8ClampedArray]",bF="[object Uint16Array]",wF="[object Uint32Array]";function _F(e,t,i){var r=e.constructor;switch(t){case dF:return d0(e);case rF:case sF:return new r(+e);case uF:return Q5(e,i);case pF:case fF:case mF:case gF:case vF:case yF:case xF:case bF:case wF:return iF(e,i);case nF:return new r;case aF:case hF:return new r(e);case oF:return J5(e);case lF:return new r;case cF:return eF(e)}}var SF=_F;function AF(e){return typeof e.constructor=="function"&&!i0(e)?j4(h0(e)):{}}var MF=AF,EF="[object Map]";function CF(e){return _n(e)&&uc(e)==EF}var TF=CF,Ux=bl&&bl.isMap,PF=Ux?s0(Ux):TF,DF=PF,IF="[object Set]";function LF(e){return _n(e)&&uc(e)==IF}var OF=LF,jx=bl&&bl.isSet,RF=jx?s0(jx):OF,BF=RF,zF=1,FF=2,NF=4,dA="[object Arguments]",kF="[object Array]",UF="[object Boolean]",jF="[object Date]",GF="[object Error]",uA="[object Function]",VF="[object GeneratorFunction]",HF="[object Map]",WF="[object Number]",pA="[object Object]",qF="[object RegExp]",XF="[object Set]",YF="[object String]",QF="[object Symbol]",ZF="[object WeakMap]",KF="[object ArrayBuffer]",JF="[object DataView]",$F="[object Float32Array]",eN="[object Float64Array]",tN="[object Int8Array]",iN="[object Int16Array]",rN="[object Int32Array]",sN="[object Uint8Array]",nN="[object Uint8ClampedArray]",aN="[object Uint16Array]",oN="[object Uint32Array]",Bt={};Bt[dA]=Bt[kF]=Bt[KF]=Bt[JF]=Bt[UF]=Bt[jF]=Bt[$F]=Bt[eN]=Bt[tN]=Bt[iN]=Bt[rN]=Bt[HF]=Bt[WF]=Bt[pA]=Bt[qF]=Bt[XF]=Bt[YF]=Bt[QF]=Bt[sN]=Bt[nN]=Bt[aN]=Bt[oN]=!0;Bt[GF]=Bt[uA]=Bt[ZF]=!1;function hu(e,t,i,r,s,n){var a,o=t&zF,l=t&FF,h=t&NF;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!as(e))return e;var u=Fs(e);if(u){if(a=W5(e),!o)return W4(e,a)}else{var c=uc(e),d=c==uA||c==VF;if(Iu(e))return v5(e,o);if(c==pA||c==dA||d&&!s){if(a=l||d?{}:MF(e),!o)return l?P5(e,f5(a,e)):M5(e,u5(a,e))}else{if(!Bt[c])return s?e:{};a=SF(e,c,o)}}n||(n=new lu);var p=n.get(e);if(p)return p;n.set(e,a),BF(e)?e.forEach(function(m){a.add(hu(m,t,i,m,e,n))}):DF(e)&&e.forEach(function(m,v){a.set(v,hu(m,t,i,v,e,n))});var f=h?l?cA:ng:l?a0:n0,g=u?void 0:f(e);return nR(g||e,function(m,v){g&&(v=m,m=e[v]),e0(a,v,hu(m,t,i,v,e,n))}),a}var fA=hu,lN=1,hN=4;function cN(e){return fA(e,lN|hN)}var _p=cN,dN="__lodash_hash_undefined__";function uN(e){return this.__data__.set(e,dN),this}var pN=uN;function fN(e){return this.__data__.has(e)}var mN=fN;function Ou(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new bp;++t<i;)this.add(e[t])}Ou.prototype.add=Ou.prototype.push=pN;Ou.prototype.has=mN;var gN=Ou;function vN(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var yN=vN;function xN(e,t){return e.has(t)}var bN=xN,wN=1,_N=2;function SN(e,t,i,r,s,n){var a=i&wN,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),u=n.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&_N?new gN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!yN(t,function(v,y){if(!bN(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,n))){d=!1;break}}return n.delete(e),n.delete(t),d}var mA=SN;function AN(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var MN=AN;function EN(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var CN=EN,TN=1,PN=2,DN="[object Boolean]",IN="[object Date]",LN="[object Error]",ON="[object Map]",RN="[object Number]",BN="[object RegExp]",zN="[object Set]",FN="[object String]",NN="[object Symbol]",kN="[object ArrayBuffer]",UN="[object DataView]",Gx=jr?jr.prototype:void 0,Bf=Gx?Gx.valueOf:void 0;function jN(e,t,i,r,s,n,a){switch(i){case UN:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case kN:return!(e.byteLength!=t.byteLength||!n(new Lu(e),new Lu(t)));case DN:case IN:case RN:return $v(+e,+t);case LN:return e.name==t.name&&e.message==t.message;case BN:case FN:return e==t+"";case ON:var o=MN;case zN:var l=r&TN;if(o||(o=CN),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=PN,a.set(e,t);var u=mA(o(e),o(t),r,s,n,a);return a.delete(e),u;case NN:if(Bf)return Bf.call(e)==Bf.call(t)}return!1}var GN=jN,VN=1,HN=Object.prototype,WN=HN.hasOwnProperty;function qN(e,t,i,r,s,n){var a=i&VN,o=ng(e),l=o.length,h=ng(t),u=h.length;if(l!=u&&!a)return!1;for(var c=l;c--;){var d=o[c];if(!(a?d in t:WN.call(t,d)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var x=a?r(y,v,d,t,e,n):r(v,y,d,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var b=e.constructor,_=t.constructor;b!=_&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return n.delete(e),n.delete(t),g}var XN=qN,YN=1,Vx="[object Arguments]",Hx="[object Array]",bd="[object Object]",QN=Object.prototype,Wx=QN.hasOwnProperty;function ZN(e,t,i,r,s,n){var a=Fs(e),o=Fs(t),l=a?Hx:uc(e),h=o?Hx:uc(t);l=l==Vx?bd:l,h=h==Vx?bd:h;var u=l==bd,c=h==bd,d=l==h;if(d&&Iu(e)){if(!Iu(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new lu),a||$S(e)?mA(e,t,i,r,s,n):GN(e,t,l,i,r,s,n);if(!(i&YN)){var p=u&&Wx.call(e,"__wrapped__"),f=c&&Wx.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new lu),s(g,m,i,r,n)}}return d?(n||(n=new lu),XN(e,t,i,r,s,n)):!1}var KN=ZN;function gA(e,t,i,r,s){return e===t?!0:e==null||t==null||!_n(e)&&!_n(t)?e!==e&&t!==t:KN(e,t,i,r,gA,s)}var JN=gA;function $N(e,t){return e!=null&&t in Object(e)}var ek=$N;function tk(e,t,i){t=Vl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=wp(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&t0(s)&&Jv(a,s)&&(Fs(e)||r0(e)))}var ik=tk;function rk(e,t){return e!=null&&ik(e,t,ek)}var sk=rk,nk=function(){return os.Date.now()},zf=nk,ak="Expected a function",ok=Math.max,lk=Math.min;function hk(e,t,i){var r,s,n,a,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(ak);t=xx(t)||0,as(i)&&(u=!!i.leading,c="maxWait"in i,n=c?ok(xx(i.maxWait)||0,t):n,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,w=s;return r=s=void 0,h=A,a=e.apply(w,S),a}function f(A){return h=A,o=setTimeout(v,t),u?p(A):a}function g(A){var S=A-l,w=A-h,M=t-S;return c?lk(M,n-w):M}function m(A){var S=A-l,w=A-h;return l===void 0||S>=t||S<0||c&&w>=n}function v(){var A=zf();if(m(A))return y(A);o=setTimeout(v,g(A))}function y(A){return o=void 0,d&&r?p(A):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?a:y(zf())}function _(){var A=zf(),S=m(A);if(r=arguments,s=this,l=A,S){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=b,_}var u0=hk;function ck(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var dk=ck;function uk(e,t){return t.length<2?e:iA(e,$z(t,0,-1))}var pk=uk;function fk(e,t){return JN(e,t)}var p0=fk;function mk(e,t){return t=Vl(t,e),e=pk(e,t),e==null||delete e[wp(dk(t))]}var gk=mk;function vk(e){return Kz(e)?void 0:e}var yk=vk,xk=1,bk=2,wk=4,_k=sA(function(e,t){var i={};if(e==null)return i;var r=!1;t=WS(t,function(n){return n=Vl(n,e),r||(r=n.length>1),n}),Lc(e,cA(e),i),r&&(i=fA(i,xk|bk|wk,yk));for(var s=t.length;s--;)gk(i,t[s]);return i}),hg=_k;function Sk(e,t,i,r){if(!as(e))return e;t=Vl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=wp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=as(u)?u:Jv(t[s+1])?[]:{})}e0(o,l,h),o=o[l]}return e}var Ak=Sk;function Mk(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=iA(e,a);i(o,a)&&Ak(n,Vl(a,e),o)}return n}var Ek=Mk;function Ck(e,t){return Ek(e,t,function(i,r){return sk(e,r)})}var Tk=Ck,Pk=sA(function(e,t){return e==null?{}:Tk(e,t)}),xn=Pk,Dk="Expected a function";function Ik(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(Dk);return as(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),u0(e,t,{leading:r,maxWait:t,trailing:s})}var Lk=Ik;function Ok(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ka(e,t){return Object.setPrototypeOf(e,t),e}var Rk=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),Bk=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),zk=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Sp&&"ontouchend"in document,Fk=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Nk=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,kk=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},Uk=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},jk=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Gk=Rk(),Hq=Gk?jk():void 0,Sp=Bk(),vA=zk(),Vk=Fk(),_r=Nk(),qx=kk(),Xx=Number(Uk());function yA(e){return Array.isArray(e)?e:[e]}function Hk(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function wd(e){return Sp?e.metaKey:e.ctrlKey}var Ve=[],Ru={},zh={},cu={};function xA(e){Ve.includes(e)||Ve.push(e)}function il(e){delete Ru[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function Wk(){Ve.splice(0,Ve.length)}function Bu(e){if(e.pointerType!=="touch")return;let t=Ru[e.pointerId];t===void 0&&(t={x:0,y:0},Ru[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Ff(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return Ru[t.pointerId]}function bA(e){zh[e.key]=!0,cu[e.key]=cu[e.key]===void 0?1:cu[e.key]+1}function wA(e){if(Sp&&zh.Meta)for(let t in zh)zh[t]=!1;else zh[e.key]=!1;cu={}}function qk(e){e.addEventListener("pointerdown",xA,!0),e.addEventListener("pointerdown",Bu,!0),e.addEventListener("pointermove",Bu,!0),e.addEventListener("pointerup",il,!0),e.addEventListener("pointercancel",il,!0),e.addEventListener("pointerleave",il,!0),window.addEventListener("keydown",bA,!0),window.addEventListener("keyup",wA,!0)}function Xk(e){e.removeEventListener("pointerdown",xA,!0),e.removeEventListener("pointerdown",Bu,!0),e.removeEventListener("pointermove",Bu,!0),e.removeEventListener("pointerup",il,!0),e.removeEventListener("pointercancel",il,!0),e.removeEventListener("pointerleave",il,!0),window.removeEventListener("keydown",bA,!0),window.removeEventListener("keyup",wA,!0)}var _A,Yk=new Promise(e=>{_A=e}),_d;function Qk(){if(_d)return _d;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.454/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});_A(a)}return _d=e(),_d}var SA,Zk=new Promise(e=>{SA=e}),Sd;function Kk(){if(Sd)return Sd;async function e(){let t=await import("./physics.js");await t.init(),SA(t)}return Sd=e(),Sd}var ot=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ot.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,ot.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,ot.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function f0(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&f0(r)}return Object.freeze(e)}function Jk(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var AA=class extends Error{};function Nf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function qn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function m0(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function $k(){return typeof process<"u"}function MA(e,t){for(let i of e)t(i.id,i.data)!==!0&&MA(i.children,t)}function EA(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)EA(i,t)}var lr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,lr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)f0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&EA(i,t)}}traverse(e){MA(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,lr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new AA("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>Jk(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return qn(0,i,i);{let s=r[0].fi;return qn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return qn(a,a+i,i)}else return qn(s.fi,n.fi,i)}}},zu;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})(zu||(zu={}));var Qe=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Qe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)f0(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Qe.prototype);let t=e;return $k()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return qn(0,t,t);{let r=i[0].fi;return qn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return qn(n,n+t,t)}else return qn(r.fi,s.fi,t)}}};function wl(e){return e&&typeof e=="object"&&e instanceof di}var di=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!wl(i))return null;r+=1}i=i?Nf(i):new di;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=Nf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Nf(o);l[e.path[r-1]]=i,i=l}else{let l=new di;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,di.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},ea;(e=>{function t(s,n){return pc(s,n)??s}e.apply=t;function i(s,n){return v0(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=Os.zoomOnce(l,o[a]),l===void 0)return n;if(!wl(l))return;a+=1}if(l===void 0)return n;if(wl(l))if(n.type===0){let h={...n.props};for(let u of Object.keys(l))delete h[u];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=g0([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(ea||(ea={}));function g0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=pc(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=g0(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function eU(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=pc(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function pc(e,t){if(!wl(t))return t;if(e instanceof lr){let i=g0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof Qe)return eU(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=pc(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof di)return v0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=pc(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function v0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!wl(t))return t;if(!wl(e))return ea.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new di;for(let s of i){let n=v0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function tU(e,t){let i={cur:[],result:[],len:0};return e=fc(e,t,i)??e,[e,i.result]}function Fu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Nu(e){e&&(e.len-=1)}function iU(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function CA(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=fc(n.data,t,Fu(i,a));Nu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=CA(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function rU(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=fc(n.data,t,Fu(i,a));return Nu(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function fc(e,t,i){if(e instanceof lr){let r=CA(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof Qe)return rU(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=fc(n,t,Fu(i,a));return Nu(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!m0(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=fc(a,t,Fu(i,n));Nu(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&iU(i),r}else return}}var cg;(e=>{function t(i,r){let s=Os.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(cg||(cg={}));var Xi;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof di&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof lr||l instanceof Qe||l instanceof ot?d=l.runOp(h):d=zu.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=c.length-1;m>=0;m--){let v=u[m],y=c[m];if(y instanceof lr){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof Qe){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof ot){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof di){let x={...y,[v]:g};g=Object.setPrototypeOf(x,di.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let x=g;g=[...y],g[v]=x}else g={...y,[v]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof lr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof Qe){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Xi||(Xi={}));var dg;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function n(h,u){return[...h.filter(c=>!u.some(d=>Xi.subsumed(c,d))),...u]}e.compress=n;function a(h,u){return h.every(c=>u.every(d=>Xi.commutative(c,d)))}e.commutative=a;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3){let g=Os.zoom(c,[...f.path,f.id]),m=Xi.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=tU(c,{[f.id]:g});c=v;for(let x of y){let b=x[x.length-1];x.splice(x.length-1,1),d.push({type:0,path:x,props:{[b]:g}}),p.push({type:0,path:x,props:{[b]:f.id}})}p.push(m.reverse),d.push(m.actual)}}else{let g=Xi.apply(c,f);g!==null&&(d.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof AA)return null;throw g}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(dg||(dg={}));var TA=Symbol(),sU=Symbol(),Ap=Symbol(),Oc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof DA);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Ap];i&&i(),delete this._children[e]}}}},nU=class extends Oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,zu.runOp(this._current,e),e.path)}},aU=class extends Oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ot.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},PA={get(e,t){if(t===Ap)return()=>{e._parent=null};if(t===TA)return e._current;if(t===sU)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=Mp(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},oU={...PA,set(e,t,i){let r={type:0,props:{[t]:wi(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},lU={...PA,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},y0=class extends Oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ap]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Mp(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},x0=class extends Oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ap]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Mp(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function kf(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Os.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var DA=class extends Oc{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){kf(this.ts,t,e),kf(this.actual,i,e),kf(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Mp(e,t,i){return i instanceof lr?new y0(e,t,i):i instanceof Qe?new x0(e,t,i):i instanceof ot?new Proxy(new aU(e,t,i),lU):i!==null&&typeof i=="object"?m0(i)?i:new Proxy(new nU(e,t,i),oU):i}function IA(e){let t=new DA(e);return[Mp(t,"",e),t]}function mc(e,t){let[i,r]=IA(e);return t(i),r.result()}function wi(e){return e instanceof y0||e instanceof x0?e._current:e!==null&&typeof e=="object"?e[TA]:e}var Os;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof lr||n instanceof y0)&&typeof a=="string"||(n instanceof Qe||n instanceof x0)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(Os||(Os={}));function hU(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fr(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var LA=class{},Yx=class extends LA{constructor(e){super(),this.id=e}},Qx=class extends LA{constructor(e){super(),this.data=e}},ug;try{ug=new TextDecoder}catch{}var Te,ta,K=0,OA=[],pg=OA,fg=0,rr={},xt,Xn,Rr=0,Ts=0,yr,bn,Ki=[],wt,Zx={useRecords:!1,mapsAsObjects:!0},RA=class{},BA=new RA;BA.name="MessagePack 0xC1";var _l=!1,ku=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Te)return jA(()=>(gg(),this?this.unpack(e,t):ku.prototype.unpack.call(Zx,e,t)));ta=t>-1?t:e.length,K=0,fg=0,Ts=0,Xn=null,pg=OA,yr=null,Te=e;try{wt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Te=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof ku){if(rr=this,this.structures)return xt=this.structures,Ad();(!xt||xt.length>0)&&(xt=[])}else rr=Zx,(!xt||xt.length>0)&&(xt=[]);return Ad()}unpackMultiple(e,t){let i,r=0;try{_l=!0;let s=e.length,n=this?this.unpack(e,s):Cp.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(Ad())===!1)return}else{for(i=[n];K<s;)r=K,i.push(Ad());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{_l=!1,gg()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Ad(){try{if(!rr.trusted&&!_l){let t=xt.sharedLength||0;t<xt.length&&(xt.length=t)}let e=Vt();if(K==ta)xt.restoreStructures&&Kx(),xt=null,Te=null,bn&&(bn=null);else if(K>ta){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!_l)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw xt.restoreStructures&&Kx(),gg(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Kx(){for(let e in xt.restoreStructures)xt[e]=xt.restoreStructures[e];xt.restoreStructures=null}function Vt(){let e=Te[K++];if(e<160)if(e<128){if(e<64)return e;{let t=xt[e&63]||rr.getStructures&&zA()[e&63];return t?(t.read||(t.read=b0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,rr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NA()]=Vt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Vt(),Vt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vt();return t}else if(e<192){let t=e-160;if(Ts>=K)return Xn.slice(K-Rr,(K+=t)-Rr);if(Ts==0&&ta<140){let i=t<16?w0(t):FA(t);if(i!=null)return i}return mg(t)}else{let t;switch(e){case 192:return null;case 193:return yr?(t=Vt(),t>0?yr[1].slice(yr.position1,yr.position1+=t):yr[0].slice(yr.position0,yr.position0-=t)):BA;case 194:return!1;case 195:return!0;case 196:return Uf(Te[K++]);case 197:return t=wt.getUint16(K),K+=2,Uf(t);case 198:return t=wt.getUint32(K),K+=4,Uf(t);case 199:return ba(Te[K++]);case 200:return t=wt.getUint16(K),K+=2,ba(t);case 201:return t=wt.getUint32(K),K+=4,ba(t);case 202:if(t=wt.getFloat32(K),rr.useFloat32>2){let i=_0[(Te[K]&127)<<1|Te[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=wt.getFloat64(K),K+=8,t;case 204:return Te[K++];case 205:return t=wt.getUint16(K),K+=2,t;case 206:return t=wt.getUint32(K),K+=4,t;case 207:return rr.int64AsNumber?(t=wt.getUint32(K)*4294967296,t+=wt.getUint32(K+4)):t=wt.getBigUint64(K),K+=8,t;case 208:return wt.getInt8(K++);case 209:return t=wt.getInt16(K),K+=2,t;case 210:return t=wt.getInt32(K),K+=4,t;case 211:return rr.int64AsNumber?(t=wt.getInt32(K)*4294967296,t+=wt.getUint32(K+4)):t=wt.getBigInt64(K),K+=8,t;case 212:if(t=Te[K++],t==114)return ib(Te[K++]&63);{let i=Ki[t];if(i)return i.read?(K++,i.read(Vt())):i.noBuffer?(K++,i()):i(Te.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Te[K],t==114?(K++,ib(Te[K++]&63,Te[K++])):ba(2);case 214:return ba(4);case 215:return ba(8);case 216:return ba(16);case 217:return t=Te[K++],Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):dU(t);case 218:return t=wt.getUint16(K),K+=2,Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):uU(t);case 219:return t=wt.getUint32(K),K+=4,Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):pU(t);case 220:return t=wt.getUint16(K),K+=2,$x(t);case 221:return t=wt.getUint32(K),K+=4,$x(t);case 222:return t=wt.getUint16(K),K+=2,eb(t);case 223:return t=wt.getUint32(K),K+=4,eb(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var cU=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function b0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>cU.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Vt);return e.highByte===0&&(e.read=Jx(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Vt()}return r}return i.count=0,e.highByte===0?Jx(t,i):i}var Jx=(e,t)=>function(){let i=Te[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=xt[r]||zA()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=b0(s,e)),s.read()};function zA(){let e=jA(()=>(Te=null,rr.getStructures()));return xt=rr._mergeStructures(e,xt)}var mg=Ep,dU=Ep,uU=Ep,pU=Ep;function Ep(e){let t;if(e<16&&(t=w0(e)))return t;if(e>64&&ug)return ug.decode(Te.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Te[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Te[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Te[K++]&63,a=Te[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Te[K++]&63,a=Te[K++]&63,o=Te[K++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=vi.apply(String,r),r.length=0)}return r.length>0&&(t+=vi.apply(String,r)),t}function $x(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vt();return t}function eb(e){if(rr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NA()]=Vt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Vt(),Vt());return t}}var vi=String.fromCharCode;function FA(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Te[K++];if((s&128)>0){K=t;return}i[r]=s}return vi.apply(String,i)}function w0(e){if(e<4)if(e<2){if(e===0)return"";{let t=Te[K++];if((t&128)>1){K-=1;return}return vi(t)}}else{let t=Te[K++],i=Te[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return vi(t,i);let r=Te[K++];if((r&128)>0){K-=3;return}return vi(t,i,r)}else{let t=Te[K++],i=Te[K++],r=Te[K++],s=Te[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return vi(t,i,r,s);{let n=Te[K++];if((n&128)>0){K-=5;return}return vi(t,i,r,s,n)}}else if(e<8){let n=Te[K++],a=Te[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return vi(t,i,r,s,n,a);let o=Te[K++];if((o&128)>0){K-=7;return}return vi(t,i,r,s,n,a,o)}else{let n=Te[K++],a=Te[K++],o=Te[K++],l=Te[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return vi(t,i,r,s,n,a,o,l);{let h=Te[K++];if((h&128)>0){K-=9;return}return vi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Te[K++],u=Te[K++];if((h&128)>0||(u&128)>0){K-=10;return}if(e<11)return vi(t,i,r,s,n,a,o,l,h,u);let c=Te[K++];if((c&128)>0){K-=11;return}return vi(t,i,r,s,n,a,o,l,h,u,c)}else{let h=Te[K++],u=Te[K++],c=Te[K++],d=Te[K++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){K-=12;return}if(e<14){if(e===12)return vi(t,i,r,s,n,a,o,l,h,u,c,d);{let p=Te[K++];if((p&128)>0){K-=13;return}return vi(t,i,r,s,n,a,o,l,h,u,c,d,p)}}else{let p=Te[K++],f=Te[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return vi(t,i,r,s,n,a,o,l,h,u,c,d,p,f);let g=Te[K++];if((g&128)>0){K-=15;return}return vi(t,i,r,s,n,a,o,l,h,u,c,d,p,f,g)}}}}}function Uf(e){return rr.copyBuffers?Uint8Array.prototype.slice.call(Te,K,K+=e):Te.subarray(K,K+=e)}function ba(e){let t=Te[K++];if(Ki[t])return Ki[t](Te.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var tb=new Array(4096);function NA(){let e=Te[K++];if(e>=160&&e<192){if(e=e-160,Ts>=K)return Xn.slice(K-Rr,(K+=e)-Rr);if(!(Ts==0&&ta<180))return mg(e)}else return K--,Vt();let t=(e<<5^(e>1?wt.getUint16(K):e>0?Te[K]:0))&4095,i=tb[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=wt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Te[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],tb[t]=i,i.bytes=e;r<s;)n=wt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Te[r++],i.push(n);let o=e<16?w0(e):FA(e);return o!=null?i.string=o:i.string=mg(e)}var ib=(e,t)=>{var i=Vt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=xt[e];return s&&s.isShared&&((xt.restoreStructures||(xt.restoreStructures=[]))[e]=s),xt[e]=i,i.read=b0(i,r),i.read()},kA=typeof self=="object"?self:global;Ki[0]=()=>{};Ki[0].noBuffer=!0;Ki[101]=()=>{let e=Vt();return(kA[e[0]]||Error)(e[1])};Ki[105]=e=>{let t=wt.getUint32(K-4);bn||(bn=new Map);let i=Te[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};bn.set(t,s);let n=Vt();return s.used?Object.assign(r,n):(s.target=n,n)};Ki[112]=e=>{let t=wt.getUint32(K-4),i=bn.get(t);return i.used=!0,i.target};Ki[115]=()=>new Set(Vt());var UA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ki[116]=e=>{let t=e[0],i=UA[t];if(!i)throw new Error("Could not find typed array for code "+t);return new kA[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ki[120]=()=>{let e=Vt();return new RegExp(e[0],e[1])};Ki[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,yr=[Vt(),Vt()],yr.position0=0,yr.position1=0;let r=K;K=i;try{return Vt()}finally{K=r}};Ki[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function jA(e){let t=ta,i=K,r=fg,s=Rr,n=Ts,a=Xn,o=pg,l=bn,h=yr,u=new Uint8Array(Te.slice(0,ta)),c=xt,d=xt.slice(0,xt.length),p=rr,f=_l,g=e();return ta=t,K=i,fg=r,Rr=s,Ts=n,Xn=a,pg=o,bn=l,yr=h,Te=u,_l=f,xt=c,xt.splice(0,xt.length,...d),rr=p,wt=new DataView(Te.buffer,Te.byteOffset,Te.byteLength),g}function gg(){Te=null,bn=null,xt=null}function fU(e){e.unpack?Ki[e.type]=e.unpack:Ki[e.type]=e}var _0=new Array(147);for(let e=0;e<256;e++)_0[e]=+("1e"+Math.floor(45.15-e*.30103));var Cp=new ku({useRecords:!1}),Wq=Cp.unpack,qq=Cp.unpackMultiple,Xq=Cp.unpack,mU={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},gU=new Float32Array(1),Yq=new Uint8Array(gU.buffer,0,4),du;try{du=new TextEncoder}catch{}var Uu,S0,Tp=typeof Buffer<"u",jf=Tp?Buffer.allocUnsafeSlow:Uint8Array,GA=Tp?Buffer:Uint8Array,rb=Tp?4294967296:2144337920,he,Xt,te=0,cs,ds=null,vU=/[\u0080-\uFFFF]/,fh=Symbol("record-id"),VA=class extends ku{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=GA.prototype.utf8Write?function(S,w,M){return he.utf8Write(S,w,M)}:du&&du.encodeInto?function(S,w){return du.encodeInto(S,he.subarray(w)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,w){if(he||(he=new jf(8192),Xt=new DataView(he.buffer,0,8192),te=0),cs=he.length-10,cs-te<2048?(he=new jf(he.length),Xt=new DataView(he.buffer,0,he.length),cs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(ds=["",""],he[te++]=214,he[te++]=98,ds.position=te-i,te+=4):ds=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let L=0,B=T.length;L<B;L++){let V=T[L];D=P[V],D||(D=P[V]=Object.create(null)),P=D}P[fh]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(b(S),ds){Xt.setUint32(ds.position+i,te-ds.position-i);let M=ds;ds=null,b(M[0]),b(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>cs&&A(te),h.offset=te;let M=xU(he.subarray(i,te),a.idsToInsert);return a=null,M}return w&bU?(he.start=i,he.end=te,he):he.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let M=0,C=v.length;M<C;M++)v[M][fh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}w&wU&&(te=i)}};let b=S=>{te>cs&&(he=A(te));var w=typeof S,M;if(w==="string"){let C=S.length;if(ds&&C>=8&&C<4096){let P=vU.test(S);ds[P?0:1]+=S,he[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>cs&&(he=A(te+D)),C<64||!l){let P,L,B,V=te+T;for(P=0;P<C;P++)L=S.charCodeAt(P),L<128?he[V++]=L:L<2048?(he[V++]=L>>6|192,he[V++]=L&63|128):(L&64512)===55296&&((B=S.charCodeAt(P+1))&64512)===56320?(L=65536+((L&1023)<<10)+(B&1023),P++,he[V++]=L>>18|240,he[V++]=L>>12&63|128,he[V++]=L>>6&63|128,he[V++]=L&63|128):(he[V++]=L>>12|224,he[V++]=L>>6&63|128,he[V++]=L&63|128);M=V-te-T}else M=l(S,te+T,D);M<32?he[te++]=160|M:M<256?(T<2&&he.copyWithin(te+2,te+1,te+1+M),he[te++]=217,he[te++]=M):M<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+M),he[te++]=218,he[te++]=M>>8,he[te++]=M&255):(T<5&&he.copyWithin(te+5,te+3,te+3+M),he[te++]=219,Xt.setUint32(te,M),te+=4),te+=M}else if(w==="number")if(S>>>0===S)S<64?he[te++]=S:S<256?(he[te++]=204,he[te++]=S):S<65536?(he[te++]=205,he[te++]=S>>8,he[te++]=S&255):(he[te++]=206,Xt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?he[te++]=256+S:S>=-128?(he[te++]=208,he[te++]=S+256):S>=-32768?(he[te++]=209,Xt.setInt16(te,S),te+=2):(he[te++]=210,Xt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[te++]=202,Xt.setFloat32(te,S);let T;if(C<4||(T=S*_0[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,Xt.setFloat64(te,S),te+=8}else if(w==="object")if(!S)he[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let D=a.idsToInsert||(a.idsToInsert=[]);T.id=D.push(T)}he[te++]=214,he[te++]=112,Xt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)_(S,!0);else if(C===Array){M=S.length,M<16?he[te++]=144|M:M<65536?(he[te++]=220,he[te++]=M>>8,he[te++]=M&255):(he[te++]=221,Xt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(S[T])}else if(C===Map){M=S.size,M<16?he[te++]=128|M:M<65536?(he[te++]=222,he[te++]=M>>8,he[te++]=M&255):(he[te++]=223,Xt.setUint32(te,M),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Uu.length;T<D;T++){let P=S0[T];if(S instanceof P){let L=Uu[T];if(L.write){L.type&&(he[te++]=212,he[te++]=L.type,he[te++]=0),b(L.write.call(this,S));return}let B=he,V=Xt,U=te;he=null;let z;try{z=L.pack.call(this,S,X=>(he=B,B=null,te+=X,te>cs&&A(te),{target:he,targetView:Xt,position:te-X}),b)}finally{B&&(he=B,Xt=V,te=U,cs=he.length-10)}z&&(z.length+te>cs&&A(z.length+te),te=yU(z,he,te,L.type));return}}_(S,!S.hasOwnProperty)}}else if(w==="boolean")he[te++]=S?195:194;else if(w==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[te++]=211,Xt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[te++]=207,Xt.setBigUint64(te,S);else if(this.largeBigIntToFloat)he[te++]=203,Xt.setFloat64(te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(w==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(w==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+w)},_=this.useRecords===!1?this.variableMapSize?S=>{let w=Object.keys(S),M=w.length;M<16?he[te++]=128|M:M<65536?(he[te++]=222,he[te++]=M>>8,he[te++]=M&255):(he[te++]=223,Xt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=w[T]),b(S[C])}:(S,w)=>{he[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(w||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);he[M+++i]=C>>8,he[M+i]=C&255}:S=>{let w=Object.keys(S),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let P=0,L=w.length;P<L;P++){let B=w[P];M=C[B],M||(M=C[B]=Object.create(null),T++),C=M}let D=C[fh];if(D)D>=96&&f?(he[te++]=((D-=96)&31)+96,he[te++]=D>>5):he[te++]=D;else{D=n.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(w)?(D=n.nextOwnId,D<m||(D=g),n.nextOwnId=D+1):(D>=m&&(D=g),n.nextId=D+1);let P=w.highByte=D>=96&&f?D-96>>5:-1;C[fh]=D,n[D-64]=w,D<g?(w.isShared=!0,n.sharedLength=D-63,s=!0,P>=0?(he[te++]=(D&31)+96,he[te++]=P):he[te++]=D):(P>=0?(he[te++]=213,he[te++]=114,he[te++]=(D&31)+96,he[te++]=P):(he[te++]=212,he[te++]=114,he[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[fh]=0),v.push(C),b(w))}for(let P=0,L=w.length;P<L;P++)b(S[w[P]])},A=S=>{let w;if(S>16777216){if(S-i>rb)throw new Error("Packed buffer would be larger than maximum buffer size");w=Math.min(rb,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else w=(Math.max(S-i<<2,he.length-1)>>12)+1<<12;let M=new jf(w);return Xt=new DataView(M.buffer,0,w),he.copy?he.copy(M,0,i,S):M.set(he.slice(i,S)),te-=i,i=0,cs=M.length-10,he=M}}useBuffer(e){he=e,Xt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};S0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,RA];Uu=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?sb(e,16,t):nb(Tp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==GA&&this.structuredClone?sb(e,UA.indexOf(i.name),t):nb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function sb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function nb(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function yU(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function xU(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function Wl(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");S0.unshift(e.Class),Uu.unshift(e)}fU(e)}var HA=new VA({useRecords:!1}),Qq=HA.pack,Zq=HA.pack,{NEVER:Kq,ALWAYS:Jq,DECIMAL_ROUND:$q,DECIMAL_FIT:eX}=mU,bU=512,wU=1024,ab=new VA({structuredClone:!0});Wl({Class:ot.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ot.prototype),e}});Wl({Class:Qe.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Qe.prototype),e}});Wl({Class:lr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,lr.prototype),e}});Wl({Class:Yx.prototype.constructor,type:4,write(e){return e.id},read(e){return new Yx(e)}});Wl({Class:Qx.prototype.constructor,type:5,write(e){return e.data},read(e){return new Qx(e)}});Wl({Class:di.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,di.prototype),e}});function _U(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function vg(e){if(m0(e))return e;if(Array.isArray(e))return e.map(vg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=vg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var yg;(e=>{function t(s){return ab.pack(s)}e.serialize=t;function i(s){return ab.unpack(s)}e.deserialize=i;function r(s){return _U(t(vg(s))).toString()}e.checksum=r})(yg||(yg={}));var us={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],Scroll:["Transition","Animation","Create"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],GameControl:["Transition","Animation","Audio","Video","Create"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},ob;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new Qe}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new Qe}}e.defaultData=i})(ob||(ob={}));var ju;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(ju||(ju={}));var xg;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:ju.propertyDefaultData(s),rOperand:{...ju.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(xg||(xg={}));var lb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new Qe,outActions:new Qe,condition:xg.distanceDefaultData(r)}}e.defaultData=i})(lb||(lb={}));var hb;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Qe,drop:new Qe}})(hb||(hb={}));var bg;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Qe})(bg||(bg={}));var wg;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(wg||(wg={}));var cb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new Qe}}e.defaultData=i})(cb||(cb={}));var db;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Qe}}e.defaultData=i})(db||(db={}));var ub;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new Qe}}e.defaultData=i})(ub||(ub={}));var pb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new Qe}}e.defaultData=i})(pb||(pb={}));var fb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new Qe,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(fb||(fb={}));var _g;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}e.is=t;function i(a){return typeof a=="string"?a:"custom"}e.sizeToDevice=i;function r(a){return typeof a=="string"?[...e.defaultSizes[a]]:[...a]}e.deviceToSize=r;function s(){let a={size:"mobile",operator:"<",actions:new Qe},o={size:"tablet",operator:"<",actions:new Qe},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new Qe},h=new Qe;return h.push({id:st.generateUUID(),fi:0,data:a},{id:st.generateUUID(),fi:1,data:o},{id:st.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function n(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new Qe}}e.defaultBreakpointData=n})(_g||(_g={}));var ql="personal camera",Yh="a218fcc3-276b-49b9-b485-49037fd14f5f",SU=2960946,Gr=5526619,Ko;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(Ko||(Ko={}));var Va;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(Va||(Va={}));var Gu;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(Gu||(Gu={}));var Sl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(Sl||(Sl={}));var Hi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(Hi||(Hi={}));var es;(e=>{e.white={...Hi.white,a:1},e.transparent={...Hi.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...Hi.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return Hi.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(es||(es={}));var Sg;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Sg||(Sg={}));var mb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(mb||(mb={}));var gb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(gb||(gb={}));var jn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(jn||(jn={}));var Ja;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ja||(Ja={}));var Al;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Al||(Al={}));var Yn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(WA.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;qA.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;XA.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;YA.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;QA.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;ZA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Yn||(Yn={}));var Ag;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Ag||(Ag={}));var WA=["count"],qA=["radius","start","end","position","scale","rotation"],XA=["position","scale","rotation"],YA=["count","size"],QA=["count","position","scale","rotation"],ZA=["strength","scale","rotation","position","movement","seed","freqScale"],Mg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Mg||(Mg={}));var Eg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:es.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Eg||(Eg={}));var Ml;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Ml||(Ml={}));var Cg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Cg||(Cg={}));var Tg;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Tg||(Tg={}));var Pg;(e=>e.defaultData={...Tg.defaultData,...Cg.defaultData})(Pg||(Pg={}));var vb;(e=>{function t(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}e.getMaterialData=t})(vb||(vb={}));var Vu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Vu||(Vu={}));var yb;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(yb||(yb={}));function AU(e){return e.type!=="displace"}var xb;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(xb||(xb={}));var KA=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],MU=["wrapping","image","video","name"],tr;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Vu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Hi.fromHex(Gr)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Hi.fromHex(6710886),a:1},colorB:{...Hi.fromHex(6710886),a:1},colorC:{...Hi.fromHex(16777215),a:1},colorD:{...Hi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:es.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:es.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:es.fromHexAndA(0,1),contourColor:es.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Hi.fromHex(0),a:1},colorB:{...Hi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(tr||(tr={}));var zi;(e=>{function t(h){return!h.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(h){let u="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([d,p])=>{u+=`${d}${p}`,Array.isArray(p)?p.forEach(f=>u+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${p}`})}),u}e.getHash=i;function r(){return{layers:new Qe}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return a("phong",h,u)}e.defaultData=s;function n(h,u){return{...h,name:u}}e.withName=n;function a(h,u="layer1",c="layer2"){let d=new Qe;return d.push({fi:0,data:tr.defaultData("light",h),id:u}),d.push({fi:1,data:tr.defaultData("color"),id:c}),{layers:d}}e.defaultTwoLayerData=a;function o(h,u="phong",c="layer1",d="layer2"){let p=tr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new Qe;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:tr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,u="phong",c="layer1",d="layer2"){let p=tr.defaultData("video");Object.assign(p.texture,{video:h});let f=new Qe;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:tr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(zi||(zi={}));var Hu;(e=>{function t(){return{points:new Qe,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Hu||(Hu={}));var Wu;(e=>{function t(){return{points:new Qe,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Wu||(Wu={}));var JA={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Dg;(e=>{function t(i,r){let s={...i};return e2.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Dg||(Dg={}));var $A={shape:JA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},e2=["depth","offset","angle","twist","startScale","endScale"],qu;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(qu||(qu={}));var Ig;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Dg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Ig||(Ig={}));var rl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Wu.defaultData(),extrusion:$A};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Hu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(rl||(rl={}));var bb=["width","height","depth"],Lg;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Hi.white,near:.1,far:2e3})(Lg||(Lg={}));var Xu;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(Xu||(Xu={}));var Og;(e=>e.defaultData={softShadowQuality:"low"})(Og||(Og={}));var Rg;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Rg||(Rg={}));var Bg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Bg||(Bg={}));var El;(e=>e.defaultData={usePhysics:!1,gravity:-10})(El||(El={}));var zg;(e=>e.defaultData={playCamera:ql,gameControlObject:null})(zg||(zg={}));var Fg;(e=>e.defaultData={backgroundColor:es.fromHexAndA(SU,1),postprocessing:Xu.defaultData,fog:Lg.defaultData,globalPhysics:El.defaultData,ambient:Rg.defaultData,ao:Bg.defaultData,shadow:Og.defaultData,publish:zg.defaultData})(Fg||(Fg={}));var wb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(wb||(wb={}));var Cl;(e=>{e.identity={...Sg.identity,hiddenMatrix:Sl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return Ok({position:Va.isEqual(s.position,n.position)?void 0:n.position,rotation:Va.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:Va.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Sl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(Cl||(Cl={}));var Zi;(e=>e.defaultData={states:new Qe,events:new Qe,visible:!0,raycastLock:!1,physics:Ml.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Cl.identity,cloner:null})(Zi||(Zi={}));var Ng;(e=>e.defaultData={type:"Empty",...Zi.defaultData})(Ng||(Ng={}));var _b;(e=>e.defaultData={type:"Component",...Zi.defaultData})(_b||(_b={}));var sl;(e=>e.defaultData={type:"Mesh",...Zi.defaultData,...Pg.defaultData})(sl||(sl={}));var gc;(e=>e.defaultData={...Zi.defaultData,...Cl.identity,position:[0,0,Al.DefaultTargetOffset],...Al.defaultData})(gc||(gc={}));var kg;(e=>{function t(i){return{...Zi.defaultData,...Eg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(kg||(kg={}));var Yu;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(Yu||(Yu={}));var Qn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Zi.defaultData,...s,component:r,overrides:new di,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Cl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Qn||(Qn={}));var Tl;(e=>e.defaultData={type:"Page",...Zi.defaultData,physics:{...Ml.defaultData,fusedBody:!1},...Fg.defaultData,camera:gc.defaultData})(Tl||(Tl={}));var Ug;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Sl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ml.defaultData,states:new Qe,events:new Qe,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Al.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("RectangleGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("BooleanGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("TextGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")}))(Ug||(Ug={}));var Ba;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new di}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new di})))):Ja.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=mc(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&tr.patch(c,u)}}).data),o.materials&&a.materials&&(o.materials=mc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=a.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&tr.patch(p,d)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,d]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Ag.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,Cl.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ja.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:Ig.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Yn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Yn.merge(o.cloner,a.cloner)});else if(Mg.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Hi.clone(l.color))}return o}e.patch=s})(Ba||(Ba={}));var Qu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qu||(Qu={}));var Ha;(e=>e.defaultData={orbitControls:Qu.defaultData,playPage:Yh,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Ha||(Ha={}));var jg;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(jg||(jg={}));var Gg;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Gg||(Gg={}));var nl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...jg.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Gg.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(nl||(nl={}));var vc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,n){r.scene.objects.traverseFrom(s,(a,o)=>{if(o.type==="Instance"){let l=Ju.getComponentData(r,o.component)?.data;l&&n(a,o,l.events)}else n(a,o,o.events)})}e.traverseModuleInstances=i})(vc||(vc={}));var al;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=[],a=Ug.defaultMeshObject;s.withLight===!0&&n.push({fi:-1,data:kg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]});let o=new lr;return o.push({fi:1,id:Yh,data:{...Tl.defaultData,name:"Scene 1"},children:n}),o}e.defaultData={objects:t(),publish:Ha.defaultData,styles:nl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new lr,publish:Ha.defaultData,styles:nl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Ha.defaultData,styles:nl.defaultData()}};function i(s){return{...e.defaultData,objects:Ka(s,lr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(al||(al={}));var Qh;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Qh||(Qh={}));var Zu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Zu||(Zu={}));var Vg;(e=>e.all=["images","videos","colors","audios","fonts","materials"])(Vg||(Vg={}));var Sb;(e=>e.all=[...Vg.all,"components"])(Sb||(Sb={}));var Ab;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot}}e.defaultData=t})(Ab||(Ab={}));var yc;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot}}e.defaultData=t})(yc||(yc={}));var un;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ka(s,ot.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Zu.emptyImage,name:"AI generated image"}),Ka(n,ot.prototype)}e.defaultImages=i;function r(){return{catelogs:new ot,materials:new ot,images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,lib:yc.defaultData()}}e.emptyData=r})(un||(un={}));var Hg;(e=>e.list=["idle","move","jump","run"])(Hg||(Hg={}));var Ku;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Qe,move:new Qe,jump:new Qe,run:new Qe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:es.fromHexAndA(3728051,1)}}))(Ku||(Ku={}));function Mb(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...xn(wi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Gn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Vn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=zi.defaultData(),s=r.materials[n]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function EU(e){Object.assign(e.scene.publish,{orbitControls:{...Qu.defaultData,...wi(e.scene.publish.orbitControls)}})}function CU(e){Object.assign(e.scene.publish.settings,{video:{...Ha.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function TU(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((KA.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(MU.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function PU(e){e.scene.publish.withBackground=!0}function DU(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function IU(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function LU(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function OU(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function RU(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function BU(e){function t(r){Object.setPrototypeOf(r,di.prototype),r.texture&&Object.setPrototypeOf(r.texture,di.prototype)}function i(r){Object.setPrototypeOf(r,di.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=wi(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=wi(l).layers;i(h),l.layers=h}})})}function Eb(e){e.layers===void 0&&Object.assign(e,zi.defaultTwoLayerData("lambert"))}function Gf(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function zU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Cb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Gf(r)}):"material"in i&&typeof i.material!="string"&&Gf(i.material)}),Object.values(e.shared.materials).forEach(t=>Gf(t))}function FU(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function NU(e){e.shared.audios=Ka({},ot.prototype)}function kU(e){e.shared.videos=Ka({},ot.prototype)}function UU(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function jU(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function GU(e){e.scene.publish.settings.web.preload=!1}function Tb(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Pb(e){e.layers&&e.layers.forEach(t=>{AU(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function VU(e){e.shared.fonts=Ka({},ot.prototype)}function HU(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function WU(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=zi.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=HU(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Zi.defaultData,...sl.defaultData,flatShading:!1,wireframe:!1,geometry:{...rl.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function qU(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new Qe,move:new Qe,jump:new Qe}});else{let n=new Qe;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:st.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,xn(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Qe({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:d})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function XU(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new Qe,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...xn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...xn(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:st.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Db(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=tr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Ib(e){Gn(e,Db),Vn(e,Db)}function YU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function QU(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function ZU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=zi.defaultTwoLayerData("phong"))})}function KU(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function JU(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function $U(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function e6(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function t6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function i6(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function r6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Ku.defaultDataThirdPerson.navmesh)})})}function s6(e){e.scene.styles||(e.scene.styles=nl.defaultData())}function Lb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function n6(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Vn(e,Lb),Gn(e,Lb)}function a6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Qe})})})}function o6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Ob(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function l6(e,t){if(t<1&&(Vn(e,Mb),Gn(e,Mb),e.schema=1),t<2&&(EU(e),e.schema=2),t<3&&(TU(e),e.schema=3),t<4&&(PU(e),e.schema=4),t<5&&(DU(e),e.schema=5),t<6&&(IU(e),e.schema=6),t<7&&(LU(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Cb(e),e.schema=9),t<10&&(zU(e),e.schema=10),t<11&&(FU(e),e.schema=11),t<12&&(Cb(e),e.schema=12),t<13&&(NU(e),e.schema=13),t<14&&(UU(e),e.schema=14),t<15&&(jU(e),e.schema=15),t<16&&(GU(e),e.schema=16),t<17&&(Vn(e,Tb),Gn(e,Tb),e.schema=17),t<18&&(Vn(e,Eb),Gn(e,Eb),e.schema=18),t<19&&(CU(e),e.schema=19),t<20&&(VU(e),WU(e),e.schema=20),t<21&&(qU(e),XU(e),e.schema=21),t<22&&(Ib(e),e.schema=22),t<23&&(YU(e),e.schema=23),t<24&&(QU(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(kU(e),t<25&&(e.schema=25)),t<26&&(OU(e),e.schema=26),t<27&&(RU(e),e.schema=27),t<28&&(Ib(e),e.schema=28),t<29&&(BU(e),e.schema=29),t<30&&(ZU(e),e.schema=30),t<31&&(KU(e),e.schema=31),t<33&&(JU(e),e.schema=33),t<34&&($U(e),e.schema=34),t<35&&(e6(e),e.schema=35),t<36&&(t6(e),e.schema=36),t<37&&(i6(e),e.schema=37),t<38&&(Vn(e,Pb),Gn(e,Pb),e.schema=38),t<39&&(r6(e),e.schema=39),t<40&&(s6(e),e.schema=40),t<41&&(n6(e),e.schema=41),t<42&&(a6(e),e.schema=42),t<43&&(o6(e),e.schema=43),t<99){Vn(e,Ob),Gn(e,Ob),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=ql);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Yh,r.insertBefore(null,null,[{id:Yh,data:{...Tl.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:xn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:xn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...El.defaultData,...xn(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Tl.defaultData.camera,name:"Scene"},children:[]}]);for(let a of i)a.id!==al.TRASH_CAN_ID&&r.move(Yh,a.fi,a.id);let s=0,n=0;e.shared.penumbraSize&&e.scene.objects.traverse((a,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(n,1)],n+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,Ml.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function Rb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function h6(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var Da=104;function t2(e){let t=e.schema??0;t!==Da&&(console.warn("updating from ",t,"to ",Da),l6(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Ha.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Vn(e,Rb),Gn(e,Rb),e.schema=101),t<102&&(h6(e),e.schema=102),t<104&&(e.shared.catelogs=new ot,e.shared.lib=yc.defaultData(),e.schema=104))}var Ju;(e=>{e.defaultData={schema:Da,scene:al.defaultData,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:{...un.emptyData(),colors:un.defaultColors()}},e.emptyDataForImports=function(s){let n=al.emptyDataWithPage(s);return{schema:Da,scene:n,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:{...un.emptyData(),colors:un.defaultColors(),images:un.defaultImages(s)}}},e.emptyData=function(){return{schema:Da,scene:al.emptyDataWithPage(),frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:un.emptyData()}},e.collabHelper={...dg,updateSchema(s){return(s.schema??0)<Da?mc(s,t2):(s.schema??0)-Da}};function t(s){let n=e.collabHelper.updateSchema(s);return typeof n=="number"?n===0?s:null:n.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:yc.defaultData()}}}e.withoutLib=i;function r(s,n){let a=s.scene.objects.get(n);if(a&&a.data.type==="Component")return a;{let o=s.shared.lib.components[n];if(o)return o.asset}}e.getComponentData=r})(Ju||(Ju={}));function za(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new qe,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in n){let c=Bb(n[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in a){let c=a[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let g=0;g<a[u].length;++g)p.push(a[u][g][d]);let f=Bb(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function Bb(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new Ye(n,i,r)}var c6=Math.pow(2,-24),Md=class{constructor(){}};function Ps(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function zb(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Fb(e,t){t.set(e)}function Nb(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Ed(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function mh(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function d6(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Ye(s,1));for(let n=0;n<i;n++)s[n]=n}}function u6(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function Vf(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],_=e[y+1],A=b-_,S=b+_;A<n&&(n=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let w=e[y+2],M=e[y+3],C=w-M,T=w+M;C<a&&(a=C),T>h&&(h=T),v&&w<d&&(d=w),v&&w>g&&(g=w);let D=e[y+4],P=e[y+5],L=D-P,B=D+P;L<o&&(o=L),B>u&&(u=B),v&&D<p&&(p=D),v&&D>m&&(m=D)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=u,v&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function p6(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<n&&(n=p),p>l&&(l=p);let f=e[u+4];f<a&&(a=f),f>h&&(h=f)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function f6(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let u=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=u;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let d=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=d}n++,a--}else return n}}var an=32,m6=(e,t)=>e.candidate-t.candidate,Ln=new Array(an).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Cd=new Float32Array(6);function g6(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=zb(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=zb(e),a!==-1&&(o=v6(i,r,s,a));else if(n===2){let l=mh(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/an;if(s<an/4){let g=[...Ln];g.length=s;let m=0;for(let y=u;y<c;y+=6,m++){let x=g[m];x.candidate=i[y+2*d],x.count=0;let{bounds:b,leftCacheBounds:_,rightCacheBounds:A}=x;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0,b[S]=1/0,b[S+3]=-1/0;Ed(y,i,b)}g.sort(m6);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let x=i[y+2*d];for(let b=0;b<v;b++){let _=g[b];x>=_.candidate?Ed(y,i,_.rightCacheBounds):(Ed(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],b=x.count,_=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,w=0;b!==0&&(w=mh(A)/l);let M=0;_!==0&&(M=mh(S)/l);let C=1+1.25*(w*b+M*_);C<h&&(a=d,h=C,o=x.candidate)}}else{for(let v=0;v<an;v++){let y=Ln[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=an&&(y=an-1);let x=Ln[y];x.count++,Ed(v,i,x.bounds)}let g=Ln[an-1];Fb(g.bounds,g.rightCacheBounds);for(let v=an-2;v>=0;v--){let y=Ln[v],x=Ln[v+1];Nb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<an-1;v++){let y=Ln[v],x=y.count,b=y.bounds,_=Ln[v+1].rightCacheBounds;x!==0&&(m===0?Fb(b,Cd):Nb(b,Cd,Cd)),m+=x;let A=0,S=0;m!==0&&(A=mh(Cd)/l);let w=s-m;w!==0&&(S=mh(_)/l);let M=1+1.25*(A*m+S*w);M<h&&(a=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function v6(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function y6(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,n=new Float32Array(s*6),a=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,g,m;a?(f=r[d+0],g=r[d+1],m=r[d+2]):(f=r[d+0]*h+l,g=r[d+1]*h+l,m=r[d+2]*h+l);for(let v=0;v<3;v++){let y,x,b;a?(y=i[u[v]](f),x=i[u[v]](g),b=i[u[v]](m)):(y=o[f+v],x=o[g+v],b=o[m+v]);let _=y;x<_&&(_=x),b<_&&(_=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-_)/2,w=v*2;n[p+w+0]=_+S,n[p+w+1]=S+(Math.abs(_)+S)*c6,_<t[v]&&(t[v]=_),A>t[v+3]&&(t[v+3]=A)}}return n}function x6(e,t){function i(v){d&&d(v/p)}function r(v,y,x,b=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=u||_>=l)return i(y+x),v.offset=y,v.count=x,v;let A=g6(v.boundingData,b,a,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=f6(o,a,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let w=new Md,M=y,C=S-y;v.left=w,w.boundingData=new Float32Array(6),Vf(a,M,C,w.boundingData,n),r(w,M,C,n,_+1);let T=new Md,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Vf(a,D,P,T.boundingData,n),r(T,D,P,n,_+1)}return v}d6(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=y6(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=u6(e);if(m.length===1){let v=m[0],y=new Md;y.boundingData=s,p6(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new Md;y.boundingData=new Float32Array(6),Vf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function b6(e,t){let i=x6(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,g=c.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=c.offset,v=c.count;return s[d+6]=m,n[p+14]=v,n[p+15]=65535,u+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(u+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=x/4,x=h(x,v),s[d+7]=y,x}}}var Ns=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Ns.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let u=t.dot(e);n=Math.min(u,n),a=Math.max(u,a)}this.min=n,this.max=a}}();var tX=function(){let e=new Ns;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=n[h],c=s[h];if(e.setFromPoints(c,a),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),w6=function(){let e=new E,t=new E,i=new E;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,g,m;f!==0?g=(u*c-p*d)/f:g=0,m=(u+g*c)/d,n.x=g,n.y=m}}(),A0=function(){let e=new k,t=new E,i=new E;return function(r,s,n,a){w6(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){n.copy(c),a.copy(u);return}else{n.copy(h),a.copy(d);return}}}}(),_6=function(){let e=new E,t=new E,i=new xr,r=new kr;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:u}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let d=c.projectPoint(o,t);if(n.containsPoint(d))return!0}return!1}}(),S6=1e-15;function Mo(e){return Math.abs(e)<S6}var Sn=class extends Ri{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Ns),this.points=[this.a,this.b,this.c],this.sphere=new Sr,this.plane=new xr,this.needsUpdate=!0}intersectsSphere(e){return _6(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=n[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=n[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};Sn.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new kr;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),A0(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(u)}}();Sn.prototype.intersectsTriangle=function(){let e=new Sn,t=new Array(3),i=new Array(3),r=new Ns,s=new Ns,n=new E,a=new E,o=new E,l=new E,h=new kr,u=new kr,c=new kr;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let g=this.plane,m=d.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let _=0;_<4;_++){let A=v[_],S=y[_];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let A=x[_],S=b[_];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let _=0;_<4;_++){let A=y[_];for(let S=0;S<4;S++){let w=b[S];if(n.crossVectors(A,w),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let L=v[P],B=v[(P+1)%3];h.start.copy(L),h.end.copy(B),h.delta(a);let V=y?u.start:u.end,U=Mo(m.distanceToPoint(L));if(Mo(m.normal.dot(a))&&U){u.copy(h),x=2;break}if((m.intersectLine(h,V)||U)&&!Mo(V.distanceTo(B))){if(x++,y)break;y=!0}}if(x===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(x!==2)return!1;let b=d.points,_=!1,A=0;for(let P=0;P<3;P++){let L=b[P],B=b[(P+1)%3];h.start.copy(L),h.end.copy(B),h.delta(o);let V=_?c.start:c.end,U=Mo(g.distanceToPoint(L));if(Mo(g.normal.dot(o))&&U){c.copy(h),A=2;break}if((g.intersectLine(h,V)||U)&&!Mo(V.distanceTo(B))){if(A++,_)break;_=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(u.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=u.start.dot(a),w=u.end.dot(a),M=c.start.dot(a),C=c.end.dot(a),T=w<M,D=S<C;return S!==C&&M!==w&&T===D?!1:(p&&(l.subVectors(u.start,c.start),l.dot(a)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(a)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();Sn.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Sn.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new kr,s=new kr;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=n[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let f=this[d];n.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,a&&a.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(n[f],n[g]),A0(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var ks=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new fe,this.invMatrix=new fe,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Ns),this.alignedSatBounds=new Array(3).fill().map(()=>new Ns),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};ks.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],u=s[l],c=1<<l,d=r[c];h.subVectors(a,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ks.prototype.intersectsBox=function(){let e=new Ns;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();ks.prototype.intersectsTriangle=function(){let e=new Sn,t=new Array(3),i=new Ns,r=new Ns,s=new E;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let d=a[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();ks.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();ks.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ks.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new kr),i=new Array(12).fill().map(()=>new kr),r=new E,s=new E;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,u=n.min,c=n.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(u,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,b=m<<y|v<<x,_=1<<g|m<<y|v<<x,A=d[b],S=d[_];t[f].set(A,S);let w=e[g],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[w]=u[w],D[M]=m?u[M]:c[M],D[C]=v?u[C]:c[M],P[w]=c[w],P[M]=m?u[M]:c[M],P[C]=v?u[C]:c[M],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:u.x,s.y=m?c.y:u.y,s.z=v?c.z:u.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];A0(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Eo=new E,Co=new E,To=new E,Td=new k,Pd=new k,Dd=new k,kb=new E,Ub=new E,jb=new E,Id=new E;function A6(e,t,i,r,s,n){let a;return n===xi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==br,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function M6(e,t,i,r,s,n,a,o,l){Eo.fromBufferAttribute(t,n),Co.fromBufferAttribute(t,a),To.fromBufferAttribute(t,o);let h=A6(e,Eo,Co,To,Id,l);if(h){r&&(Td.fromBufferAttribute(r,n),Pd.fromBufferAttribute(r,a),Dd.fromBufferAttribute(r,o),h.uv=Ri.getInterpolation(Id,Eo,Co,To,Td,Pd,Dd,new k)),s&&(Td.fromBufferAttribute(s,n),Pd.fromBufferAttribute(s,a),Dd.fromBufferAttribute(s,o),h.uv1=Ri.getInterpolation(Id,Eo,Co,To,Td,Pd,Dd,new k)),i&&(kb.fromBufferAttribute(i,n),Ub.fromBufferAttribute(i,a),jb.fromBufferAttribute(i,o),h.normal=Ri.getInterpolation(Id,Eo,Co,To,kb,Ub,jb,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a:n,b:a,c:o,normal:new E,materialIndex:0};Ri.getNormal(Eo,Co,To,u.normal),h.face=u,h.faceIndex=n}return h}function i2(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),{position:h,normal:u,uv:c,uv1:d}=e.attributes,p=M6(i,h,u,c,d,a,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function E6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)i2(e,t,i,a,n)}function C6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=i2(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function Ms(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function Gb(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(Ms(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var r2=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Hn(e,t){return t[e+15]===65535}function ol(e,t){return t[e+6]}function xc(e,t){return t[e+14]}function bc(e){return e+8}function wc(e,t){return t[e+6]}function T6(e,t){return t[e+7]}var Jo=new Jt,$u=new E,P6=["x","y","z"];function Wg(e,t,i,r,s){let n=e*2,a=Xl,o=ia,l=ra;if(Hn(n,o)){let h=ol(e,l),u=xc(n,o);E6(t,i,r,h,u,s)}else{let h=bc(e);ep(h,a,r,$u)&&Wg(h,t,i,r,s);let u=wc(e,l);ep(u,a,r,$u)&&Wg(u,t,i,r,s)}}function qg(e,t,i,r){let s=e*2,n=Xl,a=ia,o=ra;if(Hn(s,a)){let l=ol(e,o),h=xc(s,a);return C6(t,i,r,l,h)}else{let l=T6(e,o),h=P6[l],u=r.direction[h]>=0,c,d;u?(c=bc(e),d=wc(e,o)):(c=wc(e,o),d=bc(e));let p=ep(c,n,r,$u)?qg(c,t,i,r):null;if(p){let g=p.point[h];if(u?g<=n[d+l]:g>=n[d+l+3])return p}let f=ep(d,n,r,$u)?qg(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var D6=function(){let e,t,i=[],r=new r2(()=>new Jt);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,u=0,c=0){function d(y){let x=y*2,b=ia,_=ra;for(;!Hn(x,b);)y=bc(y),x=y*2;return ol(y,_)}function p(y){let x=y*2,b=ia,_=ra;for(;!Hn(x,b);)y=wc(y,_),x=y*2;return ol(y,_)+xc(x,b)}let f=n*2,g=Xl,m=ia,v=ra;if(Hn(f,m)){let y=ol(n,v),x=xc(f,m);return Ps(n,g,e),l(y,x,!1,c,u+n,e)}else{let y=bc(n),x=wc(n,v),b=y,_=x,A,S,w,M;if(h&&(w=e,M=t,Ps(b,g,w),Ps(_,g,M),A=h(w),S=h(M),S<A)){b=x,_=y;let V=A;A=S,S=V,w=M}w||(w=e,Ps(b,g,w));let C=Hn(b*2,m),T=o(w,C,A,c+1,u+b),D;if(T===2){let V=d(b),U=p(b)-V;D=l(V,U,!0,c+1,u+b,w)}else D=T&&s(b,a,o,l,h,u,c+1);if(D)return!0;M=t,Ps(_,g,M);let P=Hn(_*2,m),L=o(M,P,S,c+1,u+_),B;if(L===2){let V=d(_),U=p(_)-V;B=l(V,U,!0,c+1,u+_,M)}else B=L&&s(_,a,o,l,h,u,c+1);return!!B}}}(),I6=function(){let e=new Sn,t=new Sn,i=new fe,r=new ks,s=new ks;return function n(a,o,l,h,u=null){let c=a*2,d=Xl,p=ia,f=ra;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),Hn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,b=ol(a,f),_=xc(c,p);if(i.copy(h).invert(),l.boundsTree)return Ps(a,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,w=(_+b)*3;S<w;S+=3)if(Ms(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=_+b*3;A<S;A+=3){Ms(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let w=0,M=y.count;w<M;w+=3)if(Ms(t,w,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return Ps(g,d,Jo),!!(u.intersectsBox(Jo)&&n(g,o,l,h,u)||(Ps(m,d,Jo),u.intersectsBox(Jo)&&n(m,o,l,h,u)))}}}();function ep(e,t,i,r){return Ps(e,t,Jo),i.intersectBox(Jo,r)}var Xg=[],uu,Xl,ia,ra;function Fh(e){uu&&Xg.push(uu),uu=e,Xl=new Float32Array(e),ia=new Uint16Array(e),ra=new Uint32Array(e)}function Ld(){uu=null,Xl=null,ia=null,ra=null,Xg.length&&Fh(Xg.pop())}var Hf=Symbol("skip tree generation"),Wf=new Jt,qf=new Jt,Po=new fe,wa=new ks,gh=new ks,vh=new E,Od=new E,L6=new E,O6=new E,R6=new E,Vb=new Jt,ps=new r2(()=>new Sn),Zh=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Zh.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Zh.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new Zh(t,{...i,[Hf]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Ye(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Hf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Hf]||(this._roots=b6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Jt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,n,a,o,l=0,h=this._roots;for(let c=0,d=h.length;c<d;c++)s=h[c],n=new Uint32Array(s),a=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(a[f+15]===65535){let g=n[c+6],m=a[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,_=-1/0,A=-1/0;for(let S=3*g,w=3*(g+m);S<w;S++){let M=i[S],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>_&&(_=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==_||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=_,o[c+5]=A,!0):!1}else{let g=c+8,m=n[c+6],v=g+d,y=m+d,x=p,b=!1,_=!1;e?x||(b=e.has(v),_=e.has(y),x=!b&&!_):(b=!0,_=!0);let A=x||b,S=x||_,w=!1;A&&(w=u(g,d,x));let M=!1;S&&(M=u(m,d,x));let C=w||M;if(C)for(let T=0;T<3;T++){let D=g+T,P=m+T,L=o[D],B=o[D+3],V=o[P],U=o[P+3];o[c+T]=L<V?L:V,o[c+T+3]=B>U?B:U}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let u=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),u,c)}else{let u=a+8,c=r[a+6],d=r[a+7];e(o,h,new Float32Array(i,a*4,6),d)||(n(u,o+1),n(c,o+1))}}}raycast(e,t=ns){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l,d=s.length;if(Fh(i[h]),Wg(0,r,c,e,s),Ld(),a){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ns){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l;Fh(i[h]);let d=qg(0,r,c,e);Ld(),d!=null&&(a==null||d.distance<a.distance)&&(a=d,n&&(d.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Fh(s),r=I6(0,i,e,t),Ld(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,g)=>{let m=p*3;return c(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ps.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,g,m)=>c(d,p,f,g,m)?!0:Gb(d,p,r,l,f,g,s)}else o||(l?o=(c,d,p,f)=>Gb(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Fh(c),h=D6(0,r,a,o,n,u),Ld(),h)break;u+=c.byteLength}return ps.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Po.copy(t).invert();let h=ps.getPrimitive(),u=ps.getPrimitive();if(s){let d=function(p,f,g,m,v,y,x,b){for(let _=g,A=g+m;_<A;_++){Ms(u,_*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let S=p,w=p+f;S<w;S++)if(Ms(h,S*3,n,a),h.needsUpdate=!0,s(h,u,S,_,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,b,_){return p(f,g,m,v,y,x,b,_)?!0:d(f,g,m,v,y,x,b,_)}}else r=d}e.getBoundingBox(qf),qf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>qf.intersectsBox(d),intersectsRange:(d,p,f,g,m,v)=>(Wf.copy(v),Wf.applyMatrix4(Po),e.shapecast({intersectsBounds:y=>Wf.intersectsBox(y),intersectsRange:(y,x,b,_,A)=>r(d,p,y,x,g,m,_,A)}))});return ps.releasePrimitive(h),ps.releasePrimitive(u),c}intersectsBox(e,t){return wa.set(e.min,e.max,t),wa.needsUpdate=!0,this.shapecast({intersectsBounds:i=>wa.intersectsBox(i),intersectsTriangle:i=>wa.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),wa.set(e.boundingBox.min,e.boundingBox.max,t),wa.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,u=e.index,c=ps.getPrimitive(),d=ps.getPrimitive(),p=Od,f=L6,g=null,m=null;r&&(g=O6,m=R6);let v=1/0,y=null,x=null;return Po.copy(t).invert(),gh.matrix.copy(Po),this.shapecast({boundsTraverseOrder:b=>wa.distanceToBox(b),intersectsBounds:(b,_,A)=>A<v&&A<n?(_&&(gh.min.copy(b.min),gh.max.copy(b.max),gh.needsUpdate=!0),!0):!1,intersectsRange:(b,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>gh.distanceToBox(A),intersectsBounds:(A,S,w)=>w<v&&w<n,intersectsRange:(A,S)=>{for(let w=A*3,M=(A+S)*3;w<M;w+=3){Ms(d,w,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=b*3,T=(b+_)*3;C<T;C+=3){Ms(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(d,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=w/3),D<s)return!0}}}});{let A=u?u.count:h.count;for(let S=0,w=A;S<w;S+=3){Ms(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=b*3,C=(b+_)*3;M<C;M+=3){Ms(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=M/3,x=S/3),T<s)return!0}}}}}),ps.releasePrimitive(c),ps.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Po),f.applyMatrix4(Po),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(vh.copy(e).clamp(h.min,h.max),vh.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<a&&c<n,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,vh);let c=e.distanceToSquared(vh);return c<a&&(Od.copy(vh),a=c,o=u),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Od):t.point=Od.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ps(0,new Float32Array(t),Vb),e.union(Vb)}),e}},yh=Ll(KE()),B6=.5*(Math.sqrt(3)-1),xh=(3-Math.sqrt(3))/6,z6=1/3,fs=1/6,iX=(Math.sqrt(5)-1)/4,rX=(5-Math.sqrt(5))/20,Kh=e=>Math.floor(e)|0,Hb=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Xf=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function Yf(e=Math.random){let t=s2(e),i=new Float64Array(t).map(s=>Hb[s%12*2]),r=new Float64Array(t).map(s=>Hb[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*B6,u=Kh(s+h),c=Kh(n+h),d=(u+c)*xh,p=u-d,f=c-d,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+xh,b=m-y+xh,_=g-1+2*xh,A=m-1+2*xh,S=u&255,w=c&255,M=.5-g*g-m*m;if(M>=0){let D=S+t[w],P=i[D],L=r[D];M*=M,a=M*M*(P*g+L*m)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[w+y],P=i[D],L=r[D];C*=C,o=C*C*(P*x+L*b)}let T=.5-_*_-A*A;if(T>=0){let D=S+1+t[w+1],P=i[D],L=r[D];T*=T,l=T*T*(P*_+L*A)}return 70*(a+o+l)}}function F6(e=Math.random){let t=s2(e),i=new Float64Array(t).map(n=>Xf[n%12*3]),r=new Float64Array(t).map(n=>Xf[n%12*3+1]),s=new Float64Array(t).map(n=>Xf[n%12*3+2]);return function(n,a,o){let l,h,u,c,d=(n+a+o)*z6,p=Kh(n+d),f=Kh(a+d),g=Kh(o+d),m=(p+f+g)*fs,v=p-m,y=f-m,x=g-m,b=n-v,_=a-y,A=o-x,S,w,M,C,T,D;b>=_?_>=A?(S=1,w=0,M=0,C=1,T=1,D=0):b>=A?(S=1,w=0,M=0,C=1,T=0,D=1):(S=0,w=0,M=1,C=1,T=0,D=1):_<A?(S=0,w=0,M=1,C=0,T=1,D=1):b<A?(S=0,w=1,M=0,C=0,T=1,D=1):(S=0,w=1,M=0,C=1,T=1,D=0);let P=b-S+fs,L=_-w+fs,B=A-M+fs,V=b-C+2*fs,U=_-T+2*fs,z=A-D+2*fs,X=b-1+3*fs,H=_-1+3*fs,G=A-1+3*fs,F=p&255,q=f&255,j=g&255,W=.6-b*b-_*_-A*A;if(W<0)l=0;else{let re=F+t[q+t[j]];W*=W,l=W*W*(i[re]*b+r[re]*_+s[re]*A)}let N=.6-P*P-L*L-B*B;if(N<0)h=0;else{let re=F+S+t[q+w+t[j+M]];N*=N,h=N*N*(i[re]*P+r[re]*L+s[re]*B)}let ie=.6-V*V-U*U-z*z;if(ie<0)u=0;else{let re=F+C+t[q+T+t[j+D]];ie*=ie,u=ie*ie*(i[re]*V+r[re]*U+s[re]*z)}let Q=.6-X*X-H*H-G*G;if(Q<0)c=0;else{let re=F+1+t[q+1+t[j+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*G)}return 32*(l+h+u+c)}}function s2(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Xr=new Ri,N6=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Xr.a.fromBufferAttribute(e,r),Xr.b.fromBufferAttribute(e,r+1),Xr.c.fromBufferAttribute(e,r+2),s*=Xr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Xr.a.fromBufferAttribute(this.positionAttribute,e*3),Xr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Xr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Xr.a,r).addScaledVector(Xr.b,s).addScaledVector(Xr.c,1-(r+s)),Xr.getNormal(i),this}},k6=Ll(W_()),U6=new fe,j6=new fe,G6=new fe,_c;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(_c||(_c={}));var M0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new fe,this.copyPreviousMatrix=!0,this.hiddenMatrix=new fe,this.matrixWorldRigid=new fe,this.shearScale=new fe,this.shearScaleInv=new fe}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Et&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)_c.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,k6.SVD)(i),a=U6.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=j6.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=G6.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new fe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof fe?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},V6=class extends M0(Et){},H6=e=>e.type==="Mesh",Bi=class extends V6{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Bi(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return H6(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},Ia=new E,La=new E,ll=new fe,n2=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],W6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],q6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Wb=(e,t,i)=>{e.updateEntityBoxSize(Ia,La),ll.copy(t).multiply(e.matrixWorld),La.x===0&&La.y===0&&La.z===0?i.push(new E(Ia.x,Ia.y,Ia.z).applyMatrix4(ll)):n2.forEach(r=>{i.push(r.clone().multiply(La).add(Ia).applyMatrix4(ll))})},qb=class extends Jt{constructor(){super(...arguments),this.matrix=new fe,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new fe().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Wb(s,t,r)}}):Wb(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ll.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(La).multiplyScalar(.5),this.getCenter(Ia),ll.copy(this.matrix).setPosition(Ia),this.vertices=n2.map(e=>e.clone().multiply(La).applyMatrix4(ll))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=W6.map(([e,t])=>new kr(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=q6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Zn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},X6=class extends xS{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Yg=.001;function Qg(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Yg}function Qf(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),n=new E(...t.position);return Qg(i,r,n)&&Qg(i,s,n)}function a2(e){let t=e.points.map(u=>new E(...u.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)Qg(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let u=0;u<a;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),g={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===a-1)){o[u]={...g,removedLength:0};continue}let m=s&&u==0?a-1:u-1,v=s&&u==a-1?0:u+1,y=i[m].data,x=i[v].data,b=new E(...y.position),_=new E(...x.position),A=b.clone().sub(d).normalize(),S=_.clone().sub(d).normalize();Object.assign(g,{prevDir:A,nextDir:S});let w=Qf(y,c),M=Qf(c,x);if(!w||!M)o[u]={...g,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[u]={...g,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d],g=null;if(!Qf(i[c].data,i[d].data))p.position.distanceTo(f.position)>Yg&&(g=new ou(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Yg&&(g=new ou(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*u+1]=g}for(let u=0;u<a;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),b=m.clone().multiplyScalar(-g).add(x),_=d.distanceTo(b)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(_*d.distanceTo(p)).add(d),S=A.clone().lerp(b,2),w=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*u]=new ou(p,w,M,f)}let h=new X6;return l.forEach(u=>{u&&h.add(u)}),h}var pt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(pt||(pt={}));var pn=e=>pt.is(e),Y6={type:"completeState",isfromEntity:!0},E0=e=>class extends M0(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new qb,this._recursiveBBox=new qb,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(pt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(pt.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(pt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Ba.toOps(this.data,s.data).forEach(n=>{let a=cg.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Ba.patch(this.data,s),Ba.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{pn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(pt.is(i[r]))return i[r];if(pt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&pt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)pn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{pt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)pn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)pn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)pn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>pn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return hg(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Sl.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)pt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{pt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return hg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Fr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=Os.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=Os.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Ba.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fr(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(ea.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=Os.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=Yu.resolve(i.overrides,l),u.updateByOp(t,Xi.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Qn.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Qn.rootOverrideProps)if(Fr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=ea.filterOp(h.overrideData,l);u&&h.updateByOp(u,Xi.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=ea.filterOp(h.overrideData,t);if(u){let c;n===h.data&&t===u?c=i:c=Xi.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ja.is(t.props.type)&&Zn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Zn.changeEntityProptotype(this,i,r);for(let s of this.children)pt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fr(t.path,["cloner"])!==null){let s=Xi.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=a2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new fe;a.updateMatrixWorld();let d=new fe().multiplyMatrices(c.clone().invert(),a.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new fe().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(u),m=new fe().lookAt(u,g,new E(0,1,0)),v=new yi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(Y6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Zn.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Zn.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},o2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return c||p?f=new l2(h,u,r,s,n,a,o,l*Math.PI/180,c,c,d,p):f=new Gv(h,u,r,s,n,a,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function On(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Xb(e){return new k(e.y,-e.x)}var l2=class extends qe{constructor(e,t,i,r,s,n,a,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,x=new E,b=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let _=new k(e,y),A=new k(t,-y),S=null,w=null,M=null,C=null,T=_.clone().sub(A),D=0,P=0,L=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,L=t-D);let B=_.clone();B.x-=D;let V=Math.PI-T.angle(),U=T.angle(),z=Math.tan(U/2),X=Math.tan(V/2),H=z+X,G=c?H:X,F=c?H:z;if(l=Math.min(l,(e-P)/G,T.length()/H),h=Math.min(h,(t-L)/F,T.length()/H),l>0){let Q=l/z;S=_.clone().sub(new k(Q,l)),c&&(M=S.clone(),M.x-=D-H*l),_.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;w=A.clone().sub(new k(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=w.clone(),C.x-=D-H*h,B.sub(T.clone().setLength(Q)))}T=_.clone().sub(A);let q=T.length()<.5,j=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,ue=Z*o+a,ae=new k(Math.sin(ue),Math.cos(ue));C&&w?(W(re,Z,ae,V,h,C,-1,!0),W(re,Z,ae,U,h,w,-1,!1)):w?(N(re,ae,w.x,0,-1),W(re,Z,ae,U,h,w,-1,!1)):n||N(re,ae,t,L,-1);let se=Xb(T).normalize();if(On(se,ae,x),!q)for(let Ae=0;Ae<=s;Ae++){let Se=Ae/s,Me=T.clone().multiplyScalar(Se).add(A);On(Me,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}if(M&&S?(W(re,Z,ae,V,l,S,1,!1),W(re,Z,ae,U,l,M,1,!0)):S?(W(re,Z,ae,V,l,S,1,!1),N(re,ae,S.x,0,1)):n||N(re,ae,e,P,1),c&&!q){let Ae=Xb(T).multiplyScalar(-1).normalize();On(Ae,ae,x);for(let Se=0;Se<=s;Se++){let Me=Se/s,Pe=T.clone().multiplyScalar(-Me).add(B);On(Pe,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}}c&&!n&&re.push(re[0]),j.push(re)}for(let Q=0;Q<j.length-1;Q++)for(let re=0;re<j[0].length-1;re++){if(n&&c&&re==s)continue;let Z=j[Q][re],ue=j[Q+1][re],ae=j[Q+1][re+1],se=j[Q][re+1],Ae=f[ae*3+0],Se=f[ae*3+2];p.push(Z,ue,se),(Ae!=0||Se!=0)&&p.push(ue,ae,se)}o<Math.PI*2&&(ie(-1,j[0],a),ie(1,j[j.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Le(f,3)),this.setAttribute("normal",new Le(g,3)),this.setAttribute("uv",new Le(m,2));function W(Q,re,Z,ue,ae,se,Ae,Se){for(let Me=0;Me<u+1;Me++){let Pe=Me/u,xe=Ae<0?Pe:1-Pe;Se&&(xe-=1),xe*=ue;let ve=new k(Math.sin(xe),Math.cos(xe)*Ae),Be=ve.clone().multiplyScalar(ae).add(se);On(Be,Z,b),f.push(b.x,b.y,b.z),On(ve,Z,x),g.push(x.x,x.y,x.z),m.push(re,.5+b.y/i),Q.push(v++)}}function N(Q,re,Z,ue,ae){let se=new E,Ae=new k,Se=[Z,ue];ae<0&&Se.reverse();for(let Me of Se)Ae.set(Me,y*ae),On(Ae,re,se),f.push(se.x,se.y,se.z),g.push(0,ae,0),m.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let ue=new k(Math.sin(Z),Math.cos(Z)),ae=new k(-Math.cos(Z),Math.sin(Z)),se=new E,Ae=Q<0?(Pe,xe,ve)=>p.push(Pe,xe,ve):(Pe,xe,ve)=>p.push(Pe,ve,xe),Se=new k((e+t+P+L)/4,0);On(Se,ue,se),f.push(se.x,se.y,se.z),g.push(ae.x,0,ae.y),m.push(.5,.5);let Me=v++;for(let Pe of re){let xe=f.slice(Pe*3,Pe*3+3);f.push(...xe),g.push(ae.x,0,ae.y);let ve=m.slice(Pe*2,Pe*2+2);m.push(...ve),v++}for(let Pe=Me+1;Pe<v-1;Pe++)Ae(Me,Pe,Pe+1);Ae(Me,v-1,Me+1)}}},Q6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return h>0||u>0||l<360?d=new l2(0,t/2,r,s,n,a,o,l*Math.PI/180,h,u,c,0,!0):d=new wS(t/2,r,s,n,a),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},Z6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new zs(t,i,r,s,n,a):h=new K6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Zf=Math.PI/2,K6=class extends qe{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Le(u,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(d,2));function g(y,x,b,_,A,S,w,M,C,T,D){let P=(S-2*a)/C,L=(w-2*a)/T,B=S/2-a,V=w/2-a,U=M/2,z=C+1,X=T+1,H=0,G=0,F=new E;for(let q=0;q<X;q++){let j=q*L-V;for(let W=0;W<z;W++){let N=W*P-B;F[y]=N*_,F[x]=j*A,F[b]=U,u.push(F.x,F.y,F.z),F[y]=0,F[x]=0,F[b]=M>0?1:-1,c.push(F.x,F.y,F.z),d.push(W/C),d.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let j=0;j<C;j++){let W=p+j+z*q,N=p+j+z*(q+1),ie=p+(j+1)+z*(q+1),Q=p+(j+1)+z*q;h.push(W,N,Q),h.push(N,ie,Q),G+=6}l.addGroup(f,G,D),f+=G,p+=H}function m(y,x,b,_,A,S,w,M,C,T,D){let P=(w-2*a)/T,L=w/2-a,B=M/2-a,V=C/2,U=T+1,z=0,X=0,H=new E,G=new E;for(let F=0;F<o+1;F++){let q=F/o*Zf,j=Math.sin(q)*a,W=(1-Math.cos(q))*a,N=Math.sin(q),ie=Math.cos(q);H[x]=(B+j)*A,H[b]=(V-W)*S,G[y]=0,G[x]=N*Math.sign(H[x]),G[b]=ie*Math.sign(H[b]);for(let Q=0;Q<U;Q++){let re=Q*P-L;H[y]=re*_,u.push(H.x,H.y,H.z),c.push(G.x,G.y,G.z),d.push(Q/T),d.push(0),z+=1}}for(let F=0;F<o;F++)for(let q=0;q<T;q++){let j=p+q+U*F,W=p+q+U*(F+1),N=p+(q+1)+U*(F+1),ie=p+(q+1)+U*F;h.push(j,W,ie),h.push(W,N,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let _=new E,A=new E(e/2,t/2,i/2);A.subScalar(a);let S=[],w=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Zf*(1-C/o),P=Math.cos(D),L=Math.sin(D),B=0;for(let V=0;V<=C;V++){let U=Math.cos(B),z=Math.sin(B);_.x=P*U,_.y=L,_.z=P*z;let X=A.clone().addScaledVector(_,a);u.push(y*X.x,x*X.y,b*X.z),c.push(y*_.x,x*_.y,b*_.z),d.push(0,0),T.push(p++),B+=Zf/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],D=S[C+1],P=T.length-1;w(T[0],D[1],D[0]);for(let L=1;L<=P;L++)w(T[L-1],T[L],D[L]),w(T[L],D[L+1],D[L])}}}},C0=class extends qe{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),u(),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new Ri,g=s*r,m=r-g,v=n+1,y=new E,x=(U,z)=>y.subVectors(U,z).normalize(),b=(U,z)=>Array(U).fill(void 0).map(z),_=b(e.length/3,(U,z)=>new E().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let U=0;U<_.length;U++){let z=_[U],X=[],H,G,F,q=1e10,j=-1;for(;(j=t.indexOf(U,j+1))!=-1;){let Q=j-j%3;H=t[Q+(j+1)%3],G=t[Q+(j+2)%3],F=z.distanceToSquared(_[H]),q=Math.min(q,F),X.push([H,G,F])}q+=1e-6;let W=[],N=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,G,F]=X[N];let re=A[H]?.includes(U)==!0;F<=q&&W.push(H+ +re*S),N=X.findIndex(Z=>Z[0]==G)}A.push(W)}let w=[];{let U=0,z=0,X,H,G=c==3;for(let F=0;F<=n;F++){X=F*(F+1)/2,H=(F+1)*(F+2)/2;for(let q=0;q<n-F;q++)[U,z]=[X+q+F+2,H+q+F+3],w.push(X,H,...G?[z,X]:[U,H],z,U),[X,H]=[U,z];w.push(X,H,X+n+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),D=d.clone(),P=d.clone(),L=[],B=b(_.length,()=>b(c,()=>d.clone()));for(let U=0;U<_.length;U++){d.copy(_[U]).normalize(),M.copy(d).multiplyScalar(m);let z=A[U];for(let W=0;W<z.length;W++){let N=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(_,U,N%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,B[U][W])}let X=[],H=[],G=[],F=new E;n==0&&[...B[U]].reduce((W,N)=>W.add(N),F).multiplyScalar(1/c);for(let W=0;W<c;W++){let N=[],ie=(W-1+c)%c,Q=B[U][ie],re=B[U][W];d.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(d),ue=d.angleTo(p),ae=Math.cos(Z)*g;n==0?C.copy(F):C.copy(M).setLength(m+ae),H.push(ae);let se=[C,Q,re];for(let Ae=0;Ae<2;Ae++){let Se=se[Ae],Me=se[Ae+1];D.subVectors(Se,M),P.subVectors(Me,M),T.crossVectors(D,P).normalize();for(let Pe=0;Pe<v;Pe++){let xe=[Z,ue][Ae]*Pe/v;d.copy(D).applyAxisAngle(T,xe).add(M),X.push(d.clone()),Ae&&(x(d,M),N.push([Pe==0?Se:d.clone(),y.clone()]))}Ae&&(x(Me,M),N.push([Me,y.clone()]))}G.push(N)}L.push(G);let q=2*v,j=2;for(let W=0;W<c;W++){let N=q*W,ie=q*((W+1)%c),Q=[X[N]];for(let Z=1;Z<v;Z++){D=X[N+Z],P=X[ie+Z],Q.push(D);for(let ue=1,ae=Z-j+1;ue<=ae;ue++)d.lerpVectors(D,P,ue/(ae+1)),d.sub(M).setLength(H[W]).add(M),Q.push(d.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+N]);Q.push(X[ie+v]);let re=w.map(Z=>Q[Z]);a.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let V=[];for(let U=0;U<A.length;U++)for(let z=0;z<c;z++){let X=A[U][z];if(X<S){let H=A[X].findIndex(q=>q%S==U),G=L[U][z],F=L[X][H];for(let q=0;q<v;q++){let j=G[q],W=F[v-q],N=G[q+1],ie=F[v-(q+1)];[j,W,N,N,W,ie].forEach(Q=>{a.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}V.push(G[0][0],F[v][0],G[v][0],F[0][0])}}for(;V.length;){let U,z,X,H;[U,z]=V.splice(0,2);let G=[U];for(;U!=z;)G.push(z),X=V.indexOf(z),H=X%2,z=V.splice(X-H,2)[1-H];y.subVectors(G[0],G[1]).cross(d.subVectors(G[0],G[2])).normalize();let F=y.dot(G[0])<0;F&&y.negate();for(let q=1;q<=G.length-2;q++)[G[q+ +F],G[q+1-+F],G[0]].forEach(j=>{a.push(j.x,j.y,j.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let A=0;A<a.length;A+=3){c.x=a[A+0],c.y=a[A+1],c.z=a[A+2];let S=b(c)/2/Math.PI+.5,w=_(c)/Math.PI+.5;o.push(S,1-w)}let d=new E,p=new E,f=new E,g=new E,m=new k,v=new k,y=new k,x=(A,S,w,M)=>{M<0&&A.x===1&&(o[S]=A.x-1),w.x===0&&w.z===0&&(o[S]=M/2/Math.PI+.5)};for(let A=0,S=0;A<a.length;A+=9,S+=6){d.set(a[A+0],a[A+1],a[A+2]),p.set(a[A+3],a[A+4],a[A+5]),f.set(a[A+6],a[A+7],a[A+8]),m.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),g.copy(d).add(p).add(f).divideScalar(3);let w=b(g);x(m,S+0,d,w),x(v,S+2,p,w),x(y,S+4,f,w)}for(let A=0;A<o.length;A+=6){let S=o[A+0],w=o[A+2],M=o[A+4],C=Math.max(S,w,M),T=Math.min(S,w,M);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),w<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function b(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new C0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},J6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new h2(t*.5,n,a):new _S(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},h2=class extends C0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new h2(e.radius,e.corner,e.cornerSides)}},bh=1e-12,T0=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=st.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new T0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Zg=class extends T0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Zg(this.parent).copy(this)}},hl=class extends T0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Zg(this),new Zg(this))}static create(e,t){let i=new hl(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new hl(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(Yb(i,e),Yb(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Yb(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var P0=e=>e,Yl=new k,Pp=new k,$6=new k,e8=new k,t8=new k,i8=new k,c2=new E,d2=new E;function r8(e){let t=new k;t.addVectors(e.v0,Yl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Pp.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new $r(e.v0,t,i,e.v2)}function Nh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function s8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function n8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function u2(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function a8(e,t,i){return Zb(e,t)&&Zb(t,i)&&Kg(e.position,t.position,i.position)}function Kg(e,t,i){return Yl.copy(t).sub(e).cross(Pp.copy(i).sub(e))===0}function o8(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function l8(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function h8(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return u2(t,e,i)>Math.PI&&(u*=-1),Nh(h,o)?c=(o+h)*(r/u-.5)*8/3/(a-l):c=(a+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function Qb(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Zb(e,t){return Kg(e.position,e.controls[1].position,t.position)&&Kg(e.position,t.controls[0].position,t.position)}function c8(e,t,i,r,s=.5){let n=Yl.subVectors(t,e).multiplyScalar(s).add(e),a=Pp.subVectors(i,t).multiplyScalar(s).add(t),o=$6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=e8.subVectors(a,n).multiplyScalar(s).add(n),u=t8.subVectors(o,a).multiplyScalar(s).add(a),c=o,d=i8.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function d8(e,t,i=12,r=!0){let s=d2.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=P0(t[l]),u=Yl,c=Wa(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof $r||h instanceof na||h instanceof ss){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),n!==void 0&&n8(n,s))continue;n===void 0&&(n=c2),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function u8(e,t,i,r=12,s=!0){let n=d2.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=P0(t[l]),c=Yl,d=Wa(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof $r||u instanceof na||u instanceof ss){if(u.getPoint(p/d,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=c2:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function Kb(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Wa(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Wa(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Wa(e[0].roundedCurveCorner,t)*.5),r}function Wa(e,t=12){return e&&e instanceof pp?t*2:e&&(e instanceof ss||e instanceof yS)?1:e&&e instanceof jv?t*e.points.length:t}function p8(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=P0(t[a]),l=Wa(o,i),h=Yl;for(let u=0;u<=l;u++)if(o instanceof $r||o instanceof na||o instanceof ss){if(o.getPoint(u/l,h),s!==void 0&&s8(s,h,bh))continue;s===void 0&&(s=Pp),s.copy(h),e.push(h.x,h.y),n++}}return Nh(e[0],e[e.length-2],bh)&&Nh(e[1],e[e.length-1],bh)&&(e.pop(),e.pop()),r&&n>1&&!(Nh(e[n-1],e[1],bh)&&Nh(e[n-2],e[0],bh))&&(e.push(e[0],e[1]),n++),e}var Kf=new k,f8=new k,m8=new k,g8=new k,v8=new k,y8=new k,Ht=class extends Mu{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new xr(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Ht;return r.isClosed=e.isClosed,r.points=e.points.map(s=>hl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Ht.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Kf.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=st.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new hl(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return d8(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Kb(this.points,e,!1),this.roundedCurveDivisions=Kb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return u8(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),p8(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Wa(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(Qb(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Kf.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Qb(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&a8(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,b=h.getPointAt(y,Kf),_=u.getPointAt(x,f8);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(u,d,x,void 0,_);let A;if(this.useCubicForRoundedCorners){let S=u2(b,s.position,_)/2,w=Math.tan(S)*b.distanceTo(s.position),[M,C]=o8(b,_,w,m8,g8),T=l8(M,C,s.position),[D,P]=h8(T,b,_,w,v8,y8);A=new $r(b.clone(),D.clone(),P.clone(),_.clone())}else A=new na(b.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof ss)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=c8(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Ht(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],c=new hl(st.generateUUID(),new k(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Ht;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof $r&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof na&&(r[n]=r8(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],u=n>0?r[n-1]:null,c;h instanceof $r?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof ss&&(c=this.createPoint(h.v1)),c!==void 0&&(u!==null&&t(c,u),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof $r?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof ss&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Mu&&(this.shapeHoles=e.holes.map(r=>{let s=new Ht;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Jg=Math.PI*2;function Jf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function x8(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function Jb(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function b8(e,t,i,r,s,n,a,o,l,h){let u=Math.pow(s,2),c=Math.pow(n,2),d=Math.pow(a,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,x=(a-g)/s,b=(o-m)/n,_=(-a-g)/s,A=(-o-m)/n,S=Jb(1,0,x,b),w=Jb(x,b,_,A);return!h&&w>0&&(w-=Jg),h&&w<0&&(w+=Jg),{centerx:v,centery:y,ang1:S,ang2:w}}function w8({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let d=b8(e,t,i,r,s,n,h,u,a,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,v=Math.abs(f)/(Jg/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(x8(p,f)),p+=f;return l.map(x=>{let{x:b,y:_}=Jf(x[0],s,n,g,m),{x:A,y:S}=Jf(x[1],s,n,g,m),{x:w,y:M}=Jf(x[2],s,n,g,m);return{x1:b,y1:_,x2:A,y2:S,x:w,y:M}})}var At;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(At||(At={}));var ri;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ri||(ri={}));function He(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){He(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){He(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){He(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){He(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),wh=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Rd=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Vo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),$b=function(){function e(){var t=new Vo,i=new wh,r=new Rd(0),s=new Rd(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new Rd(0),r=new Rd(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;He(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;He(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new Vo,i=new Vo,r=new wh,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new Vo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new wh;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new wh;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Vo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new wh;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Fe.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){He(s.prev===n),l=s.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(He(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){He(a.prev===o),l=a.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(He(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)He(l.Sym.next===h.Sym),He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Org!==null),He(l.Dst!==null),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l);He(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),ew=function(){function e(){this.handle=null}return e}(),tw=function(){function e(){this.key=null,this.node=0}return e}(),_8=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new ew,this.handles[r]=new tw;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,He(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new ew;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new tw}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;He(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),$f=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),iw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),S8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new iw,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new iw;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),A8=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Fe.vertLeq(n.Org,a.Org)?Fe.edgeSign(a.Dst,n.Org,a.Org)<=0:Fe.edgeSign(n.Dst,a.Org,n.Org)>=0:Fe.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Fe.edgeSign(n.Dst,s,n.Org)>=0;var o=Fe.edgeEval(n.Dst,s,n.Org),l=Fe.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&He(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){He(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new $f;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case At.ODD:return(i&1)!==0;case At.NONZERO:return i!==0;case At.POSITIVE:return i>0;case At.NEGATIVE:return i<0;case At.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,u,c=!0;h=r;do He(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,u=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,He(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),n=Fe.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Fe.vertLeq(s.Org,n.Org)){if(Fe.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Fe.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(He(!Fe.vertEq(s.Dst,n.Dst)),Fe.vertLeq(s.Dst,n.Dst)){if(Fe.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Fe.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,u,c,d=new Vo,p,f;if(He(!Fe.vertEq(h,l)),He(Fe.edgeSign(l,t.event,a)<=0),He(Fe.edgeSign(h,t.event,o)>=0),He(a!==t.event&&o!==t.event),He(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(u=Math.min(a.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(Fe.vertLeq(a,o)){if(Fe.edgeSign(h,a,o)>0)return!1}else if(Fe.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Fe.intersect(l,a,h,o,d),He(Math.min(a.t,l.t)<=d.t),He(d.t<=Math.max(o.t,h.t)),He(Math.min(h.s,l.s)<=d.s),He(d.s<=Math.max(o.s,a.s)),Fe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Fe.vertLeq(a,o)?a:o,Fe.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Fe.vertEq(d,a)||Fe.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,d)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,f,!0),!0):(Fe.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Fe.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Fe.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){He(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}He(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(He(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Fe.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new $f;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Fe.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Fe.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);He(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new $f,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new S8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(He(i.fixUpperEdge),He(++r===1)),He(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Fe.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new _8(n,Fe.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,He(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Fe.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),M8=function(){function e(){this.mesh=new $b,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=At.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,f[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>o&&(o=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,i===ri.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){n=u.anEdge,l=0;do{var h=n.Org;this.elements[d++]=h.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===ri.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,u=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[u++]=n,this.elements[u++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new $b),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=At.ODD),i===void 0&&(i=ri.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),A8.computeInterior(this,a);var o=this.mesh;return i===ri.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ri.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Kn(e){var t=e.windingRule,i=t===void 0?At.ODD:t,r=e.elementType,s=r===void 0?ri.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new M8;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(i,s,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var sX=At.ODD,nX=At.NONZERO,aX=At.POSITIVE,oX=At.NEGATIVE,lX=At.ABS_GEQ_TWO,hX=ri.POLYGONS,cX=ri.CONNECTED_POLYGONS,dX=ri.BOUNDARY_CONTOURS,$g=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*$g.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*$g.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);t?(a.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},p2=$g;p2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var E8=Ll($E()),D0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},f2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},m2={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},em=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),I0=class extends qe{constructor(e,t,i=0,r=12,s=3,n=At.ODD,a=!1){super(),this.forPathBevel=a,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],L=C[D-0];T.push(P,L)}return T}),h=[],u=[];for(let M=0;M<o.length;M+=2)u.push([o[M],o[M+1]]);h.push(u);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c=h[0].length?(0,E8.default)(h).distance:i;i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=Kn({windingRule:n,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=D0}let p;try{p=Kn({windingRule:At.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=f2}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?d.vertexCount:0;d.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=d.vertexCount;d.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];d.vertices.push(C)}}let g=1/0,m=-1/0,v=1/0,y=-1/0;for(let M=0,C=d.vertexCount;M<C;M++){let T=M*2,D=d.vertices[T+0],P=d.vertices[T+1];D<g&&(g=D),D>m&&(m=D),P<v&&(v=P),P>y&&(y=P)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new p2(this._computeBufferEstimatedSize(d));let x=[],b=[];for(let M=d.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=d.elements[T+0],P=d.elements[T+1],L=D+P,B={start:D,count:P,normals:[],continuous:[],concave:[]},V=D,U=L-1,z=D+1,X=this._shape.roundedCurves.length;do{let j=V-D,W=d.vertices[U*2+0],N=d.vertices[U*2+1],ie=d.vertices[V*2+0],Q=d.vertices[V*2+1],re=d.vertices[z*2+0],Z=d.vertices[z*2+1],ue=ie-W,ae=Q-N,se=Math.sqrt(ue*ue+ae*ae);ue/=se,ae/=se;let Ae=ie-re,Se=Q-Z,Me=Math.sqrt(Ae*Ae+Se*Se);Ae/=Me,Se/=Me,B.normals[j*2+0]=-Se,B.normals[j*2+1]=Ae,B.concave[j]=ue*Se-ae*Ae>0;let Pe=d.vertexIndices[V];if(Array.isArray(Pe))B.continuous[j]=!1;else{let[xe,ve]=this._shape.getCurveIndexFromVertexId(Pe-1,!0);if(ve>0&&ve<1)B.continuous[j]=!0;else{let Be=ve===1?xe+1:xe-1;Be=(Be+X)%X;let Ze=ve===1?0:1,R=this._shape.roundedCurves[xe].getTangent(ve),I=this._shape.roundedCurves[Be].getTangent(Ze);B.continuous[j]=R.dot(I)>.95}}C&&(B.normals[j*2+0]*=-1,B.normals[j*2+1]*=-1),[U,V,z]=[V,z,z+1],z>=L&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(D*2,L*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((j,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(D*2,L*2)});let G=0;for(let j=1;j<=this._bevelSegments;j++){let W=j/this._bevelSegments*Math.PI/2,N=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],ue=0;for(let se=0;se<P;se++){let Ae=se*2,Se=(se-1+P)%P*2,Me=d.vertices[B.start*2+Ae+0],Pe=d.vertices[B.start*2+Ae+1],xe=-B.normals[Se+0]*N,ve=-B.normals[Se+1]*N,Be=-B.normals[Ae+0]*N,Ze=-B.normals[Ae+1]*N;if(B.concave[se]||!B.concave[se]&&C){let R=Math.atan2(ve,xe),I=Math.atan2(Ze,Be);I>R&&(I-=Math.PI*2);let $=I-R;if(B.continuous[se]||C){let me=R+$/2,ce=Math.cos(me)*N,ye=Math.sin(me)*N;ie[2*ue+0]=Me+ce*(C?-1:1),ie[2*ue+1]=Pe+ye*(C?-1:1),Z[ue]=se,ue++}else{let me=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let ce=0;ce<=me;ce++){let ye=R+$*(ce/me),Oe=Math.cos(ye)*N,Ee=Math.sin(ye)*N;ie[2*ue+0]=Me+Oe,ie[2*ue+1]=Pe+Ee,Z[ue]=se,ue++}}}else ie[2*ue+0]=Me+xe,ie[2*ue+1]=Pe+ve,Z[ue]=se,Q[se]=ue,ue++,ie[2*ue+0]=Me,ie[2*ue+1]=Pe,Z[ue]=se,ue++,ie[2*ue+0]=Me+Be,ie[2*ue+1]=Pe+Ze,Z[ue]=se,re[se]=ue,ue++}let ae=Kn({windingRule:At.POSITIVE,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:se=>{let Ae=se.Org.idx,Se=Z[Ae],Me=Z[(Ae+1)%Z.length];se.idx=[Se,Me],se.Sym.idx=[Me,Se]},vertexIdCallback:se=>{let Ae=se.Lprev.idx;return[Ae?Ae[1]:0,se.idx?se.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!ae.vertexCount){let se=(j-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(se))*this._bevel;break}for(let se=0;se<ae.vertexIndices.length;se++){let[Ae,Se]=ae.vertexIndices[se];if(Ae===Se)continue;let Me=Se;Se<Ae&&(Me+=P);for(let Pe=Ae;Pe<Me;Pe++){let xe=Pe%P,ve=(Pe+1)%P;if(!B.continuous[xe]||!B.continuous[ve]){ae.vertexIndices[se]=[Ae,xe],ae.vertexIndices.splice(se+1,0,[ve,Se]),ae.vertices.splice((se+1)*2,0,ae.vertices[se*2],ae.vertices[se*2+1]);break}}}H.push({bevelI:j,angle:W,size:N,boundary:ae,reverseMap:Z,insetPoints:ie})}let F=(j,W,N)=>{let ie=0,Q=j.boundary.vertexIndices.length;for(;ie<Q&&N(j.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let j=1;j<H.length;j++){let W=H[j-1],N=H[j],ie=W.boundary.vertexIndices.length,Q=N.boundary.vertexIndices.length;if(!ie||!Q)break;let re=B.concave.length,Z=0,ue=em(Z,P);for(;!W.boundary.vertexIndices.filter(ue).length||!N.boundary.vertexIndices.filter(ue).length;)Z++,ue=em(Z,P);let ae=W.boundary.vertexIndices.findIndex(ue),se=N.boundary.vertexIndices.findIndex(ue);do ae=(ae+1)%ie;while(ue(W.boundary.vertexIndices[ae]));do se=(se+1)%Q;while(ue(N.boundary.vertexIndices[se]));Z=(Z+1)%P;let Ae=Z,Se=0,Me=this._buildBevelVert(B,W,(ae-1+ie)%ie,void 0,Se),Pe=this._buildBevelVert(B,N,(se-1+Q)%Q,void 0,Se),xe=Me,ve=Pe,Be,Ze,R=!1;do{Se=(Z||re)/re,ue=em(Z,P);let I=F(W,ae,ue),$=F(N,se,ue),me=R;if(R=!1,I&&!$){for(let ce=0;ce<I;ce++)Be=this._buildBevelVert(B,W,(ae+ce)%ie,ce/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be;R=!0}else if(!I&&$)for(let ce=0;ce<$;ce++)Ze=this._buildBevelVert(B,N,(se+ce)%Q,ce/($-1),Se),x.push(ve.topN,xe.topP,Ze.topP),a===!1&&x.push(xe.bottomP,ve.bottomN,Ze.bottomP),ve=Ze;else if(I&&$)if(Be=this._buildBevelVert(B,W,ae,0,Se),Ze=this._buildBevelVert(B,N,se,0,Se),me?(x.push(xe.topN,Ze.topP,ve.topN),x.push(xe.topN,Be.topP,Ze.topP),a===!1&&(x.push(Ze.bottomP,xe.bottomN,ve.bottomN),x.push(Ze.bottomP,Be.bottomP,xe.bottomN))):(x.push(ve.topN,xe.topN,Be.topP),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&(x.push(Be.bottomP,xe.bottomN,ve.bottomN),x.push(Be.bottomP,ve.bottomN,Ze.bottomP))),xe=Be,ve=Ze,I===$)for(let ce=1;ce<I;ce++)Be=this._buildBevelVert(B,W,(ae+ce)%ie,ce/(I-1),Se),Ze=this._buildBevelVert(B,N,(se+ce)%Q,ce/($-1),Se),x.push(xe.topN,Be.topP,ve.topN),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&(x.push(Be.bottomP,xe.bottomN,ve.bottomN),x.push(Be.bottomP,ve.bottomN,Ze.bottomP)),xe=Be,ve=Ze;else if(I>$){let ce=I/$,ye=0;for(let Oe=1;Oe<I;Oe++)Be=this._buildBevelVert(B,W,(ae+Oe)%ie,Oe/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be,Oe>(ye+1)*ce&&(ye++,Ze=this._buildBevelVert(B,N,(se+ye)%Q,ye/($-1),Se),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&x.push(Be.bottomP,ve.bottomN,Ze.bottomP),ve=Ze)}else{let ce=$/I,ye=0;for(let Oe=1;Oe<$;Oe++)Ze=this._buildBevelVert(B,N,(se+Oe)%Q,Oe/($-1),Se),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&x.push(Be.bottomP,ve.bottomN,Ze.bottomP),ve=Ze,Oe>(ye+1)*ce&&(ye++,Be=this._buildBevelVert(B,W,(ae+ye)%ie,ye/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be)}ae=(ae+I)%ie,se=(se+$)%Q,Z=(Z+1)%re}while(Z!==Ae)}if(a===!1&&this._depth>this._bevel*2&&this._buildWall(H,B,x),C){let j=[];for(let W=x.length-1;W>=q+2;W-=3){let N=x[W-2],ie=x[W-1],Q=x[W-0];j.push(Q,ie,N)}x.splice(q,x.length-q,...j)}if(C){let j=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let N=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];j.push(N,ie)}b.push(j)}if(!C){let j=H[H.length-1],W;try{W=Kn({windingRule:H.length>1?At.POSITIVE:At.ODD,elementType:ri.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...b]})}catch{W=m2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let N=0;N<W.elementCount*3;N+=3){let ie=this._buildSurfaceVert(W,W.elements[N+0],G),Q=this._buildSurfaceVert(W,W.elements[N+1],G),re=this._buildSurfaceVert(W,W.elements[N+2],G);x.push(ie.top,Q.top,re.top),a===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ye(Uint32Array.from(x),1),A=new Ye(this._buffer.positions,3),S=new Ye(this._buffer.normals,3),w=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",w),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],n=e.vertices[t*2+1],a=(s-this._minX)/this._width,o=(n-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,u=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=n,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=n,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let n=`${t.bevelI}:${i}`;if(n in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[n].pathBevelUCoord))return this.vertexCache[n];let[a,o]=t.boundary.vertexIndices[i],l,h,u,c;a!==o?(h=a,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=a,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),_=1);let A=e.normals[g+0],S=e.normals[g+1],w=e.normals[m+0],M=e.normals[m+1];if(c){let L=w-A,B=M-S;A=A+L*(1-r),S=S+B*(1-r);let V=Math.sqrt(A*A+S*S);A/=V,S/=V}let C=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=S*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=S*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b),u||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=w*d,this._buffer.normals[T+1]=M*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=w*d,this._buffer.normals[T+4]=M*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b)),this.vertexCache[n]=P,P}clone(){let e=new I0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_p(this.userData),e}},g2=class extends qe{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=At.ODD,this.elementType=ri.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:At.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=Kn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=D0}let u=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Ye(new Float32Array(u*3),3),this._normalAttribute=new Ye(new Float32Array(u*3),3),this._uvAttribute=new Ye(new Float32Array(u*2),2),this._indexAttribute=new Ye(new Uint32Array(c*3),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,x=u;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1];_<d&&(d=_),_>p&&(p=_),A<f&&(f=A),A>g&&(g=A)}let m=p-d,v=g-f;for(let y=0,x=u;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1],S=(_-d)/m,w=(A-f)/v;this._positionAttribute.setXYZ(y,_,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,w)}for(let y=0,x=c;y<x;y++){let b=y*3,_=n.elements[b+0],A=n.elements[b+1],S=n.elements[b+2];this._indexAttribute.setX(b+0,_),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new g2(this._shape,this._curveSegments);return e.userData=_p(this.userData),e}},v2=class extends I0{constructor(e,t,i=0,r=12,s=3,n=At.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new v2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_p(this.userData),e}},ro=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:At.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Ht?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Ht(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Ht(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new g2(e.shape,s,{windingRule:a}):o=new v2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},y2=Math.PI*2,L0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=C8(h,u,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=ro.create({shape:h,parameters:{subdivisions:d,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function C8(e,t,i,r,s,n){if(r>=y2)return s>30||s%4===0?(P8(e,t,i,n),Math.round(s/4)):rw(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=w8({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?T8(e,a.x,a.y,h,s,t,i,n):rw(e,r,s,t,i,n)}function T8(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(cl(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=cl(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?x2(e,n,a,o):e.addPoint(cl(0,0)),l}function rw(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(cl(h,u))}return t<y2?n>0?x2(e,r,s,n):e.addPoint(cl(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&b2(e,r,s,n)),1}function P8(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Bd(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Bd(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Bd(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Bd(s,n-i,s+o,n-i,s-o,n-i)),r>0&&b2(e,t,i,r)}function cl(e,t){return new hl(st.generateUUID(),new k(e,t))}function Bd(e,t,i,r,s,n){let a=cl(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function x2(e,t,i,r){w2(e,t,i,r).forEach(s=>e.addPoint(s))}function b2(e,t,i,r){let s=w2(e,t,i,r),n=new Ht;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function w2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new k(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var D8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new _2(!1,t,i,r,s,n,a,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},tm=new tl([0,0,0],1),_2=class extends qe{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,c=1){if(super(),n===0)return;let d=e&&n===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new E,f=new E,g=p(),m=p(),v=p(),y,x,b,_,A,S,w,M,C=p(),T=p(),D=p(),P=p(),L=p(),B=p(),V=p(),U=p(),z=i-2*o+.001,X=z/n,H=Math.ceil(a*n),G=H+1,F=z/H,q=-z/2,j=h+1,W=2*Math.PI/h,N=Math.PI/2/c,ie=.01,Q=Math.min((1-u/100)*o,o-ie),re=o-Q,Z=0,ue=2,ae=c*ue+ue,se=j*ae/ue,Ae=se+j*G,Se=j*(G+ae),[Me,Pe,xe]=[3,3,2].map(De=>Array(Se*De).fill(0)),ve=[],Be=s-o;function Ze(De,Re){let Ie=Math.PI/2;S=Re*F,M=2*Math.PI*(S%X)/X+Ie,S+=q,w=Math.sin(M)*Be,A=Math.cos(M)*Be,e?De.set(A,w,S):De.set(A,S,w)}Ze(f,-1e-10),Ze(g,0),C.copy(f),Ze(f,1);let R=f.distanceTo(g),I=d?0:re+Q,$=R*H+2*I,me=Q,ce=$-I;for(let De=0;De<=H;De++){Ze(m,De),U.subVectors(m,C).normalize(),C.copy(m),B.copy(m).setComponent(+e+1,0).normalize(),V.crossVectors(U,B).normalize();let Re=De===0,Ie=De===H,Xe=Re?3*Math.PI/2:N,Ne=Re?me:ce,ft=Re?j:Ae,Rt=Re?0:Se-j,$t=U.clone().multiplyScalar(Re?-re:re).add(m),Y=U.clone().multiplyScalar(Re?-1:1).normalize();for(let ne=0;ne<j;ne++){let ge=ne*W;if(T.addVectors(f.copy(B).multiplyScalar(o*Math.cos(ge)),g.copy(V).multiplyScalar(o*Math.sin(ge))),D.copy(T).normalize(),Re||Ie){d||(Z=Rt+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=$t.getComponent(we),Pe[Z*3+we]=Y.getComponent(we)}),xe[Z*2]=+Ie,xe[Z*2+1]=ne/h),g.copy(D).multiplyScalar(Q),v.addVectors(m,g);for(let we=0;we<c;we++){let Ge=we*N+Xe;P.addVectors(f.copy(U).multiplyScalar(re*Math.sin(Ge)),g.copy(D).multiplyScalar(re*Math.cos(Ge))),L.copy(P).normalize(),g.addVectors(v,P),P.normalize(),Z=ft+we*j+ne,[0,1,2].forEach(kt=>{Me[Z*3+kt]=g.getComponent(kt),Pe[Z*3+kt]=L.getComponent(kt)});let vt=+Re+Math.sin(Ge);xe[Z*2]=(Ne+re*vt)/$,xe[Z*2+1]=ne/h}}g.addVectors(m,T),Z=se+De*j+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=g.getComponent(we),Pe[Z*3+we]=D.getComponent(we)}),xe[Z*2]=(I+De*R)/$,xe[Z*2+1]=ne/h}}let ye=G+2*c+ue,Oe=1,[Ee,de]=[+d,ye-1];for(let De=Ee;De<=de-1;De++){let Re=d&&De===de-1;for(let Ie=0;Ie<j-1;Ie++)y=De*j+Ie,x=y+1,b=(Re?Ie:y)+j,_=(Re?Ie+1:x)+j,De===0?ve.push(x,_,b):De===ye-2?ve.push(y,x,b):ve.push(y,x,b,x,_,b)}this.setIndex(ve),this.setAttribute("position",new Le(Me,3)),this.setAttribute("normal",new Le(Pe,3)),this.setAttribute("uv",new Le(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(u?c:s)+i,o=(u?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,tm.array=r,tm.count=r.length,tm}},I8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new S2(t*.5,n,a):new CS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},S2=class extends C0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new S2(e.radius,e.corner,e.cornerSides)}},L8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Mu;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new bS(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ms=new fe,im=new Et,zd=new E,tp=class extends Ti{constructor(){super(),this.uuid=st.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new bi().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ms.makeRotationX(e),this.applyMatrix4(ms),this}rotateY(e){return ms.makeRotationY(e),this.applyMatrix4(ms),this}rotateZ(e){return ms.makeRotationZ(e),this.applyMatrix4(ms),this}translate(e,t,i){return ms.makeTranslation(e,t,i),this.applyMatrix4(ms),this}scale(e,t,i){return ms.makeScale(e,t,i),this.applyMatrix4(ms),this}lookAt(e){return im.lookAt(e),im.updateMatrix(),this.applyMatrix4(im.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new E().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new je().fromBufferAttribute(a,c));function h(c,d,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],m=n===void 0?[]:[new E().fromBufferAttribute(n,c),new E().fromBufferAttribute(n,d),new E().fromBufferAttribute(n,p)],v=new ev(c,d,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,d),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,d),new k().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zd).negate(),this.translate(zd.x,zd.y,zd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new fe;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new E,t=new E;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new E;if(e){let i=new E,r=new E;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new tp;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new bi().getNormalMatrix(t));for(let c=0,d=a.length;c<d;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,g,m=p.vertexNormals,v=p.vertexColors,y=new ev(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=m.length;x<b;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)g=v[x],y.vertexColors.push(g.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new E(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,g),A=h(A,2,m),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,_),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(d(S[0]),d(S[1]),d(S[2]))}if(y&&i.push(u(f.normal)),x){let S=f.vertexNormals;i.push(u(S[0]),u(S[1]),u(S[2]))}if(b&&i.push(c(f.color)),_){let S=f.vertexColors;i.push(c(S[0]),c(S[1]),c(S[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return a[f]!==void 0||(a[f]=n.length,n.push(p.getHex())),a[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new tp().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let b=m[y];v.push(b.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,d=n.length;c<d;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;f++)p.faceNormals.push(n[c].faceNormals[f].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,d=a.length;c<d;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new O8().fromGeometry(this),t=new qe,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Fd.call(new Ye(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Fd.call(new Ye(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",sw.call(new Ye(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",nw.call(new Ye(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",nw.call(new Ye(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new Le(l.data.length*3,3);h.name=l.name,s.push(Fd.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Le(e.skinIndices.length*4,4);t.setAttribute("skinIndex",aw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Le(e.skinWeights.length*4,4);t.setAttribute("skinWeight",aw.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new qe,i=e.geometry;if(e.isPoints||e.isLine){let r=new Le(i.vertices.length*3,3),s=new Le(i.colors.length*3,3);if(t.setAttribute("position",Fd.call(r,i.vertices)),t.setAttribute("color",sw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Le(i.lineDistances.length,1);t.setAttribute("lineDistance",R8.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};tp.prototype.isGeometry=!0;var O8=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let m=0;m<u;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][m];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new k,new k,new k))}if(n===!0){let b=r[1][m];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new k,new k,new k))}for(let b=0;b<o;b++){let _=a[b].vertices;l[b].data.push(_[v.a],_[v.b],_[v.c])}for(let b=0;b<u;b++){let _=h[b].vertexNormals[m];c[b].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},ev=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new E,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new je,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function R8(e){return this.array.set(e),this}function sw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new je),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function nw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new k),t[i++]=n.x,t[i++]=n.y}return this}function Fd(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new E),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function aw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new et),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var B8=["a","b","c"];function z8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function rm(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function sm(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[a],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function F8(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],sm(a.a,a.b,e,r,a,i),sm(a.b,a.c,e,r,a,i),sm(a.c,a.a,e,r,a,i)}function Nd(e,t,i,r,s){e.push(new ev(t,i,r,void 0,void 0,s))}function Do(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function kd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var N8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof qe?e=new tp().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new E,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;F8(o,l,c,d);let p=[],f,g,m,v,y,x,b;for(let ie of Array.from(d.keys())){for(g=d.get(ie),m=new E,y=3/8,x=1/8,b=g.faces.length,b!=2&&(y=.5,x=0,b!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<b;n++){for(v=g.faces[n],a=0;a<3&&(f=o[z8(v,B8[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,A,S,w,M,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?_=3/16:i>3&&(_=3/(8*i)),A=1-i*Number(_),S=_,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),n=0;n<i;n++)w=M[n],f=w.a!==C?w.a:w.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),L=D.length,B,V,U,z=[],X=[],H,G,F,q,j=new k,W=new k,N=new k;for(r=0,s=l.length;r<s;r++)v=l[r],B=Number(rm(v.a,v.b,d).newEdge)+L,V=Number(rm(v.b,v.c,d).newEdge)+L,U=Number(rm(v.c,v.a,d).newEdge)+L,Nd(z,B,V,U,v.materialIndex),Nd(z,v.a,B,U,v.materialIndex),Nd(z,v.b,V,B,v.materialIndex),Nd(z,v.c,U,V,v.materialIndex),u&&(H=h[r],G=H[0],F=H[1],q=H[2],j.set(Do(G.x,F.x),Do(G.y,F.y)),W.set(Do(F.x,q.x),Do(F.y,q.y)),N.set(Do(G.x,q.x),Do(G.y,q.y)),kd(X,j,W,N),kd(X,G,j,N),kd(X,F,W,j),kd(X,q,N,W));e.vertices=P,e.faces=z,u&&(e.faceVertexUvs[0]=X)}},ai=new E,k8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new qe().copy(new zs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new qe().copy(new zs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new N8(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new RS(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},A2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=d+Math.cos(m)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=ro.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},U8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new G8(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function _h(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function nm(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function j8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var G8=class extends qe{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new E(0,-d,0),x=new E(0,d,0),b=new k(e,-d),_=new k(f,-d),A=new k(0,x.y).sub(_),S=new k(0,x.y).sub(b),w=new k(A.y,-A.x).normalize(),M=new k(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new E(w.x,w.y,0),X=new E(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(X)}let D=n/Math.tan((Math.PI-A.angle())/2),P=n/Math.tan((Math.PI-T)/2),L=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let z=c++,X=[],H=b.clone(),G=D/Math.cos(Math.PI/i);H.x-=G;for(let F=0;F<i;F++){let q=F/i*Math.PI*2+p,j=new k(Math.sin(q),Math.cos(q));_h(H,j,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),u.push(0,0),X.push(c++)}for(let F=0;F<X.length;F++)o.push(X[F],z,X[(F+1)%X.length])}let B=[];{let z=new E,X=new E,H=new E,G=new E,F=new E,q=new E;for(let j=0;j<i;j++){let W=j/i*Math.PI*2+p,N=(j+.5)/i*Math.PI*2+p,ie=(j+1)/i*Math.PI*2+p,Q=new k(Math.sin(W),Math.cos(W)),re=new k(Math.sin(N),Math.cos(N)),Z=new k(Math.sin(ie),Math.cos(ie));_h(b,Q,X),_h(b,Z,H),_h(w,re,z),nm(x,X,H,P,P,G),l.push(G.x,G.y,G.z),nm(X,x,H,P,D,F),l.push(F.x,F.y,F.z),nm(H,X,x,D,P,q),l.push(q.x,q.y,q.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),u.push(0,0),u.push(0,0),u.push(0,0);let ue=c++,ae=c++,se=c++;if(o.push(ue,ae,se),n>0){{let Me=X.clone().add(H).multiplyScalar(.5),Pe=x.clone().sub(Me).normalize(),xe=y.clone().sub(Me).normalize().add(Pe).normalize().multiplyScalar(-1),ve=q.clone().sub(F);V(Me,ve,xe,A.angle())}let Ae,Se;{let Me=new E;_h(M,Z,Me);let Pe=q.clone().add(G).multiplyScalar(.5);Pe=j8(Pe,H,x);let xe=q.clone().sub(G);[Ae,Se]=V(Pe,xe,Me,T,G.y)}{let Me=Ae,Pe=Me.clone().setY(0).normalize(),xe=new E(0,-1,0),ve=Pe.clone().cross(xe);U(Me,Pe,xe,ve)}B.concat(Se);{let Me=A.angle(),Pe=Math.PI-Me,xe=x.clone();xe.y-=n/Math.sin(Me-Math.PI/2);let ve=new E,Be=[];for(let R=0;R<a;R++){let I=[],$=Math.PI/2-Pe*R/a,me=Math.cos($),ce=Math.sin($),ye=N;for(let Oe=0;Oe<=R;Oe++){let Ee=Math.cos(ye),de=Math.sin(ye);z.x=me*de,z.y=ce,z.z=me*Ee,ve.copy(xe).addScaledVector(z,n),l.push(ve.x,ve.y,ve.z),h.push(z.x,z.y,z.z),u.push(0,0),I.push(c++),ye+=Math.PI*2/R/i}Be.push(I)}Se.reverse(),Be.push(Se);let Ze=Be.length-1;for(let R=0;R<Ze;R++){let I=Be[R],$=Be[R+1],me=I.length-1;o.push($[1],I[0],$[0]);for(let ce=1;ce<=me;ce++)o.push(I[ce],I[ce-1],$[ce]),o.push($[ce+1],I[ce],$[ce])}}}}}this.setIndex(o),this.setAttribute("position",new Le(l,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(u,2));function V(z,X,H,G,F){let q=-G/2,j=(Math.PI-G)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-n/Math.sin(j));let N=new E,ie=new E,Q=1,re=c,Z=[];for(let ue=0;ue<=a;ue++){let ae=q+ue/a*G;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(ae)),ie.addScaledVector(H,Math.cos(ae));for(let se=0;se<=Q;se++){let Ae=se/Q-.5;if(N.copy(z),N.addScaledVector(X,Ae),N.addScaledVector(ie,n),F!=null){let Se=Math.max(0,N.y-F);N.addScaledVector(X,-Se/X.y)}l.push(N.x,N.y,N.z),h.push(ie.x,ie.y,ie.z),u.push(0,0),se===0&&Z.push(c),c++}}for(let ue=0;ue<a;ue++)for(let ae=0;ae<Q;ae++){let se=re+ae+(Q+1)*ue,Ae=se+(Q+1),Se=Ae+1,Me=se+1;o.push(se,Ae,Me),o.push(Ae,Se,Me)}return[z.clone().addScaledVector(X,.5),Z]}function U(z,X,H,G){let F=Math.PI/2,q=S.angle()-F,j=[],W=new E,N=new E;for(let Q=0;Q<=a;Q++){let re=[],Z=Q/a;for(let ue=0;ue<=Q;ue++){let ae=((Q?ue/Q:0)-.5)*v,se=Math.cos(ae),Ae=Math.sin(ae),Se=Math.atan(Math.tan(q)*se),Me=(F+Se)*Z,Pe=Math.cos(Me),xe=Math.sin(Me);W.set(0,0,0),W.addScaledVector(X,xe*se),W.addScaledVector(H,Pe),W.addScaledVector(G,xe*Ae),N.copy(z).addScaledVector(W,n),l.push(N.x,N.y,N.z),h.push(W.x,W.y,W.z),u.push(0,0),re.push(c++)}j.push(re)}let ie=j.length-1;for(let Q=0;Q<ie;Q++){let re=j[Q],Z=j[Q+1],ue=re.length-1;o.push(re[0],Z[1],Z[0]);for(let ae=1;ae<=ue;ae++)o.push(re[ae-1],re[ae],Z[ae]),o.push(re[ae],Z[ae+1],Z[ae])}}}},M2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(b,_,A){return _>i&&A>r?Math.min(b*i/_,b*r/A):_>i?b*i/_:A>r?b*r/A:b}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,g=c.x,m=c.y,v=u.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,_=t.points.length;b<_;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=ro.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},V8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u=new Hv(.5*t,s,n,a,o,l,h);return u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},H8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new dp(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},W8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new q8(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},q8=class extends qe{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=d(),f=d(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[b,_,A]=[d(y,-g,+v),d(y,-g,-v),d(y,+g,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),w=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-g;let M=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):_.z=Math.min(_.z-M-v,b.z-h),p.subVectors(b,_),f.subVectors(A,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(P).add(_);p.set(0,S(r,!0),w(r,!0)),u.push([A,p.clone()]);let B=(Math.PI-r)/n;for(let ie=0;ie<=n;ie++){let Q=c+r+ie*B;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(L),f.set(0,S(Q),w(Q)),u.push([p.clone(),f.clone()])}u.push([b,d(0,1,0)]);let V=Math.sin(B/2)*D*2,U=u.length-1,z=u[0][0].distanceTo(u[1][0]),X=u[U-1][0].distanceTo(u[U][0]),H=z+V*n+X;u[0].push(1);for(let ie=0;ie<=n;ie++)u[ie+1].push(1-(z+ie*V)/H);u[U].push(0);let[G,F,q]=u[0],j,W,N;for(let ie=1;ie<u.length;ie++)[j,W,N]=u[ie],a.push(y,G.y,G.z,y,j.y,j.z,x,G.y,G.z,x,G.y,G.z,y,j.y,j.z,x,j.y,j.z),o.push(0,F.y,F.z,0,W.y,W.z,0,F.y,F.z,0,F.y,F.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,N,1,q,1,q,0,N,1,N),[G,F,q]=[j,W,N];this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(o,3)),this.setAttribute("uv",new Le(l,2))}},E2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let b=0;b<s;b++){let _=g*b,A=p+Math.sin(_)*c,S=f+Math.cos(_)*d;u.addPoint(u.createPoint(A,S))}}else for(let b=0;b<s;b++){let _=p+Math.cos(m)*c,A=f+Math.sin(m)*d;u.addPoint(u.createPoint(_,A)),m+=g,_=p+Math.cos(m)*v,A=f+Math.sin(m)*y,b<=s,u.addPoint(u.createPoint(_,A)),m+=g}u.isClosed=!0;for(let b=0,_=u.points.length;b<_;b++)u.points[b].roundness=n;u.roundness=n,u.update();let x=ro.create({shape:u,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},X8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new dp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},Y8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=Q8(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function Q8(e,t,i,r,s,n,a,o,l,h,u){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new _2(!0,e,t,i,r,s,n,a,o,l,h,u)}var Z8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new TS(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},K8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=ro.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function J8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var $8=new fe,ej=new fe;function tj(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=st.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new fe().makeBasis(r[0],r[1],r[2])}var ij=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??L0.create({parameters:JA}).userData.shape;return{path:e.path??Wu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...$A,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new rj(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new qe,{userData:{...e,type:"PathGeometry"}})}},rj=class extends qe{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!J8(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let U=0;U<o;U++){let z=this.inputs.path.isClosed?(U+n)%e.length:Math.min(U+n,e.length-1);l.push(e[z].clone()),h.push(t[z].clone())}let u=(U,z,X)=>{l[U]=l[U].clone().lerp(l[z],X),h[U]=tj(h[U],h[z],X)},c=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(c=d,u(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,u(l.length-1,l.length-2,1-p)),i===0){let U=l.length-1;l[U].copy(l[0]),h[U].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:_}=this._computeShapePoints(y),A=0,S;v==="round"&&(S=new I0(this.inputs.shapeData,2*g,g,y,m,void 0,!0),A=S.getAttribute("position").count);let w=0,M=0;b.sort((U,z)=>U.start-z.start),b.forEach(U=>{U.verticesStart=w,U.verticesCount=U.continuous.reduce((z,X,H)=>z+(H===0||!X?2:1),0),M+=U.verticesCount,w=M});let C=M*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=Kn({windingRule:At.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=m2}D=T.vertexCount}let P=C+2*D+A*2,L=C+2*D,B={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},V=[];if(b.forEach(U=>{this._extrudeRegion(U,_,h,l,B,V,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,V,B,h[0],l[0],!1),this._closeEnd(T,C+D,V,B,h[h.length-1],l[l.length-1],!0)),S){B.positions.set(S.getAttribute("position").array,L*3),B.normals.set(S.getAttribute("normal").array,L*3),B.uvs.set(S.getAttribute("uv").array,L*2);let U=V.length;V.push(...S.getIndex().array.map(H=>H+L)),L+=A,B.positions.set(S.getAttribute("position").array,L*3),B.normals.set(S.getAttribute("normal").array,L*3),B.uvs.set(S.getAttribute("uv").array,L*2);let z=V.length;V.push(...S.getIndex().array.map(H=>H+L)),this.setAttribute("position",new Ye(B.positions,3)),this.setAttribute("normal",new Ye(B.normals,3)),this.setAttribute("uv",new Ye(B.uvs,2)),this.setIndex(V);let X=$8;X.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(X,L,P),X.copy(h[0]).setPosition(l[0]).multiply(ej.makeScale(1,1,-1)),this.applyMatrix4OnRange(X,L-A,L),this.reverseIndicesOnRange(U,z)}else this.setAttribute("position",new Ye(B.positions,3)),this.setAttribute("normal",new Ye(B.normals,3)),this.setAttribute("uv",new Ye(B.uvs,2)),this.setIndex(V)}_extractPathPoints(){let e=a2(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,n=new E,a=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),b=y.clone().add(x).normalize();a.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(b).normalize(),A=b.clone().cross(_).normalize();l.copy(A),o.copy(_),f===0&&(s.copy(A),n.copy(b));let S=new fe().makeBasis(_,A,b);t.push(S)}let h=r?n:a,u=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),d=Math.acos(u.dot(c));if(isNaN(d))return t;let p=u.clone().cross(c);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let g=new fe().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new fe,h=new fe;return e.forEach((u,c)=>{let d=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(st.lerp(s,s+n,d));let p=st.lerp(a,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=At.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=Kn({windingRule:t,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=D0}let a;try{a=Kn({windingRule:At.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=f2}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let f=a.elements[p],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}for(let p=0;p<a.vertices.length;p++){let f=a.vertices[p];n.vertices.push(f)}}let l=1/0,h=-1/0,u=1/0,c=-1/0;for(let p=0,f=n.vertexCount;p<f;p++){let g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<u&&(u=v),v>c&&(c=v)}let d=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,x={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(x);let b=m,_=y-1,A=m+1,S=i.roundedCurves.length;do{let w=b-m,M=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[b*2+0],D=n.vertices[b*2+1],P=n.vertices[A*2+0],L=n.vertices[A*2+1],B=T-M,V=D-C,U=Math.sqrt(B*B+V*V);B/=U,V/=U;let z=T-P,X=D-L,H=Math.sqrt(z*z+X*X);z/=H,X/=H,x.normals[w*2+0]=-X,x.normals[w*2+1]=z;let G=n.vertexIndices[b];if(Array.isArray(G))x.continuous[w]=!1;else{let[F,q]=i.getCurveIndexFromVertexId(G-1,!0);if(q>0&&q<1)x.continuous[w]=!0;else{let j=q===1?F+1:F-1;j=(j+S)%S;let W=q===1?0:1,N=i.roundedCurves[F].getTangent(q),ie=i.roundedCurves[j].getTangent(W);x.continuous[w]=N.dot(ie)>.95}}f&&(x.normals[w*2+0]*=-1,x.normals[w*2+1]*=-1),[_,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==m+1)}return{regions:[r,...s],infos:d,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new E,l=new E,h=new E,u=new E,c=new k;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[v])u.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v===0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),u.copy(o).sub(l),u.set(-u.y,u.x,0),e.isHole||u.negate()}if(u.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,m,h,u,c),m++,!e.continuous[v]||v===0){if(v===0)u.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),u.copy(l).sub(o),u.set(-u.y,u.x,0),e.isHole||u.negate()}u.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,u,c),m++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,b=f+y,_=g+y,A=g+m;e.isHole?n.push(x,_,b,x,A,_):n.push(x,b,_,x,_,A),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new E(0,0,a?-1:1).applyMatrix4(s),h=new E,u=new k;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+d,h,l,u)}let c=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=c[p+0]+t,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new bi().getNormalMatrix(e).elements,n,a,o,l,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let c=h.array,d=u.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;n=c[f+0],a=c[f+1],o=c[f+2],l=1/(r[3]*n+r[7]*a+r[11]*o+r[15]),c[f+0]=(r[0]*n+r[4]*a+r[8]*o+r[12])*l,c[f+1]=(r[1]*n+r[5]*a+r[9]*o+r[13])*l,c[f+2]=(r[2]*n+r[6]*a+r[10]*o+r[14])*l,n=d[f+0],a=d[f+1],o=d[f+2],d[f+0]=s[0]*n+s[3]*a+s[6]*o,d[f+1]=s[1]*n+s[4]*a+s[7]*o,d[f+2]=s[2]*n+s[5]*a+s[8]*o}h.needsUpdate=!0,u.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),n=i.getX(r+1),a=i.getX(r+2);i.setXYZ(r,a,n,s)}i.needsUpdate=!0}}};function C2(){let e=new qe;return e.setAttribute("position",new Ye(new Float32Array([]),3)),e.setIndex(new Ye(new Uint16Array([]),1)),e}var sj=C2().attributes,nj=12,aj=1,T2=class extends qe{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,sj),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,u=oj(e,t,h),{shapes:c,charWidths:d,charCoords:p}=t.generateShapes(u,e),f=i*.5,g=r*.5,m=c.map(x=>new Ht().fromShape(x));this.vectorShapes=m;let v=m.map(x=>ro.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?At.NONZERO:At.ODD,subdivisions:this.isLowResolution&&s>0?aj:nj}})),y=v.length?za(v):C2();y.translate(-f,g,0),this.dispose(),this.wrappedText=u,this.charCoords=p,this.charWidths=d,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,b])=>{this.setAttribute(x,b)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Ka(new qe,T2.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function oj(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3138
|
+
}`;function ZI(e,t,i){let r=new zv,s=new k,n=new k,a=new et,o=new fS({depthPacking:eS}),l=new XI,h={},u=i.maxTextureSize,c={[ns]:xi,[xi]:ns,[br]:br},d=new Ot({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:YI,fragmentShader:QI}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new qe;f.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new nr(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Dv,this.render=function(b,_,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),w=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(si),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],L=P.shadow;if(L===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(L.autoUpdate===!1&&L.needsUpdate===!1)continue;s.copy(L.mapSize);let B=L.getFrameExtents();if(s.multiply(B),n.copy(L.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(n.x=Math.floor(u/B.x),s.x=n.x*B.x,L.mapSize.x=n.x),s.y>u&&(n.y=Math.floor(u/B.y),s.y=n.y*B.y,L.mapSize.y=n.y)),L.map===null){let U=this.type!==Rh?{minFilter:Lt,magFilter:Lt}:{};L.map=new Mt(s.x,s.y,U),L.map.texture.name=P.name+".shadowMap",L.camera.updateProjectionMatrix()}e.setRenderTarget(L.map),e.clear();let V=L.getViewportCount();for(let U=0;U<V;U++){let z=L.getViewport(U);a.set(n.x*z.x,n.y*z.y,n.x*z.z,n.y*z.w),C.viewport(a),L.updateMatrices(P,U),r=L.getFrustum(),x(_,A,L.camera,P,this.type)}L.isPointLightShadow!==!0&&this.type===Rh&&v(L,A),L.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,w,M)};function v(b,_){let A=t.update(g);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Mt(s.x,s.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(_,null,A,d,g,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(_,null,A,p,g,null)}function y(b,_,A,S,w,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&_.clipShadows===!0&&Array.isArray(_.clippingPlanes)&&_.clippingPlanes.length!==0||_.displacementMap&&_.displacementScale!==0||_.alphaMap&&_.alphaTest>0||_.map&&_.alphaTest>0){let D=C.uuid,P=_.uuid,L=h[D];L===void 0&&(L={},h[D]=L);let B=L[P];B===void 0&&(B=C.clone(),L[P]=B),C=B}return C.visible=_.visible,C.wireframe=_.wireframe,M===Rh?C.side=_.shadowSide!==null?_.shadowSide:_.side:C.side=_.shadowSide!==null?_.shadowSide:c[_.side],C.alphaMap=_.alphaMap,C.alphaTest=_.alphaTest,C.map=_.map,C.clipShadows=_.clipShadows,C.clippingPlanes=_.clippingPlanes,C.clipIntersection=_.clipIntersection,C.displacementMap=_.displacementMap,C.displacementScale=_.displacementScale,C.displacementBias=_.displacementBias,C.wireframeLinewidth=_.wireframeLinewidth,C.linewidth=_.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=w),C}function x(b,_,A,S,w){if(b.visible===!1)return;if(b.layers.test(_.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&w===Rh)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,L=D.length;P<L;P++){let B=D[P],V=T[B.materialIndex];if(V&&V.visible){let U=y(b,V,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,U,b,B)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,w);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],_,A,S,w)}}function KI(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new et,ge=null,we=new et(0,0,0,0);return{setMask:function(Ge){ge!==Ge&&!Y&&(e.colorMask(Ge,Ge,Ge,Ge),ge=Ge)},setLocked:function(Ge){Y=Ge},setClear:function(Ge,vt,kt,Pi,pa){pa===!0&&(Ge*=Pi,vt*=Pi,kt*=Pi),ne.set(Ge,vt,kt,Pi),we.equals(ne)===!1&&(e.clearColor(Ge,vt,kt,Pi),we.copy(ne))},reset:function(){Y=!1,ge=null,we.set(-1,0,0,0)}}}function n(){let Y=!1,ne=null,ge=null,we=null;return{setTest:function(Ge){Ge?ie(2929):Q(2929)},setMask:function(Ge){ne!==Ge&&!Y&&(e.depthMask(Ge),ne=Ge)},setFunc:function(Ge){if(ge!==Ge){switch(Ge){case vC:e.depthFunc(512);break;case yC:e.depthFunc(519);break;case xC:e.depthFunc(513);break;case Gm:e.depthFunc(515);break;case bC:e.depthFunc(514);break;case wC:e.depthFunc(518);break;case _C:e.depthFunc(516);break;case SC:e.depthFunc(517);break;default:e.depthFunc(515)}ge=Ge}},setLocked:function(Ge){Y=Ge},setClear:function(Ge){we!==Ge&&(e.clearDepth(Ge),we=Ge)},reset:function(){Y=!1,ne=null,ge=null,we=null}}}function a(){let Y=!1,ne=null,ge=null,we=null,Ge=null,vt=null,kt=null,Pi=null,pa=null;return{setTest:function(Nt){Y||(Nt?ie(2960):Q(2960))},setMask:function(Nt){ne!==Nt&&!Y&&(e.stencilMask(Nt),ne=Nt)},setFunc:function(Nt,Ws,Mr){(ge!==Nt||we!==Ws||Ge!==Mr)&&(e.stencilFunc(Nt,Ws,Mr),ge=Nt,we=Ws,Ge=Mr)},setOp:function(Nt,Ws,Mr){(vt!==Nt||kt!==Ws||Pi!==Mr)&&(e.stencilOp(Nt,Ws,Mr),vt=Nt,kt=Ws,Pi=Mr)},setLocked:function(Nt){Y=Nt},setClear:function(Nt){pa!==Nt&&(e.clearStencil(Nt),pa=Nt)},reset:function(){Y=!1,ne=null,ge=null,we=null,Ge=null,vt=null,kt=null,Pi=null,pa=null}}}let o=new s,l=new n,h=new a,u=new WeakMap,c=new WeakMap,d={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,M=!1,C=null,T=null,D=null,P=null,L=null,B=e.getParameter(35661),V=!1,U=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(U=parseFloat(/^WebGL (\d)/.exec(z)[1]),V=U>=1):z.indexOf("OpenGL ES")!==-1&&(U=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),V=U>=2);let X=null,H={},G=e.getParameter(3088),F=e.getParameter(2978),q=new et().fromArray(G),j=new et().fromArray(F);function W(Y,ne,ge){let we=new Uint8Array(4),Ge=e.createTexture();e.bindTexture(Y,Ge),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let vt=0;vt<ge;vt++)e.texImage2D(ne+vt,0,6408,1,1,0,6408,5121,we);return Ge}let N={};N[3553]=W(3553,3553,1),N[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(Gm),Me(!1),Pe(Iy),ie(2884),Ae(si);function ie(Y){d[Y]!==!0&&(e.enable(Y),d[Y]=!0)}function Q(Y){d[Y]!==!1&&(e.disable(Y),d[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ge=g,we=!1;if(Y)if(ge=f.get(ne),ge===void 0&&(ge=[],f.set(ne,ge)),Y.isWebGLMultipleRenderTargets){let Ge=Y.texture;if(ge.length!==Ge.length||ge[0]!==36064){for(let vt=0,kt=Ge.length;vt<kt;vt++)ge[vt]=36064+vt;ge.length=Ge.length,we=!0}}else ge[0]!==36064&&(ge[0]=36064,we=!0);else ge[0]!==1029&&(ge[0]=1029,we=!0);we&&(i.isWebGL2?e.drawBuffers(ge):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ge))}function ue(Y){return m!==Y?(e.useProgram(Y),m=Y,!0):!1}let ae={[jo]:32774,[aC]:32778,[oC]:32779};if(r)ae[By]=32775,ae[zy]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(ae[By]=Y.MIN_EXT,ae[zy]=Y.MAX_EXT)}let se={[lC]:0,[hC]:1,[cC]:768,[q_]:770,[gC]:776,[fC]:774,[uC]:772,[dC]:769,[X_]:771,[mC]:775,[pC]:773};function Ae(Y,ne,ge,we,Ge,vt,kt,Pi){if(Y===si){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==nC){if(Y!==y||Pi!==M){if((x!==jo||A!==jo)&&(e.blendEquation(32774),x=jo,A=jo),Pi)switch(Y){case el:e.blendFuncSeparate(1,771,1,771);break;case Ly:e.blendFunc(1,1);break;case Oy:e.blendFuncSeparate(0,769,0,1);break;case Ry:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case el:e.blendFuncSeparate(770,771,1,771);break;case Ly:e.blendFunc(770,1);break;case Oy:e.blendFuncSeparate(0,769,0,1);break;case Ry:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,_=null,S=null,w=null,y=Y,M=Pi}return}Ge=Ge||ne,vt=vt||ge,kt=kt||we,(ne!==x||Ge!==A)&&(e.blendEquationSeparate(ae[ne],ae[Ge]),x=ne,A=Ge),(ge!==b||we!==_||vt!==S||kt!==w)&&(e.blendFuncSeparate(se[ge],se[we],se[vt],se[kt]),b=ge,_=we,S=vt,w=kt),y=Y,M=!1}function Se(Y,ne){Y.side===br?Q(2884):ie(2884);let ge=Y.side===xi;ne&&(ge=!ge),Me(ge),Y.blending===el&&Y.transparent===!1?Ae(si):Ae(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let we=Y.stencilWrite;h.setTest(we),we&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ve(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Me(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Pe(Y){Y!==iC?(ie(2884),Y!==T&&(Y===Iy?e.cullFace(1029):Y===rC?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function xe(Y){Y!==D&&(V&&e.lineWidth(Y),D=Y)}function ve(Y,ne,ge){Y?(ie(32823),(P!==ne||L!==ge)&&(e.polygonOffset(ne,ge),P=ne,L=ge)):Q(32823)}function Be(Y){Y?ie(3089):Q(3089)}function Ze(Y){Y===void 0&&(Y=33984+B-1),X!==Y&&(e.activeTexture(Y),X=Y)}function R(Y,ne,ge){ge===void 0&&(X===null?ge=33984+B-1:ge=X);let we=H[ge];we===void 0&&(we={type:void 0,texture:void 0},H[ge]=we),(we.type!==Y||we.texture!==ne)&&(X!==ge&&(e.activeTexture(ge),X=ge),e.bindTexture(Y,ne||N[Y]),we.type=Y,we.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function me(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ce(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ye(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ee(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function De(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Re(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ie(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Xe(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ne(Y){j.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),j.copy(Y))}function ft(Y,ne){let ge=c.get(ne);ge===void 0&&(ge=new WeakMap,c.set(ne,ge));let we=ge.get(Y);we===void 0&&(we=e.getUniformBlockIndex(ne,Y.name),ge.set(Y,we))}function Rt(Y,ne){let ge=c.get(ne).get(Y);u.get(ne)!==ge&&(e.uniformBlockBinding(ne,ge,Y.__bindingPointIndex),u.set(ne,ge))}function $t(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),r===!0&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},X=null,H={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,x=null,b=null,_=null,A=null,S=null,w=null,M=!1,C=null,T=null,D=null,P=null,L=null,q.set(0,0,e.canvas.width,e.canvas.height),j.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:ue,setBlending:Ae,setMaterial:Se,setFlipSided:Me,setCullFace:Pe,setLineWidth:xe,setPolygonOffset:ve,setScissorTest:Be,activeTexture:Ze,bindTexture:R,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:me,texImage2D:Re,texImage3D:Ie,updateUBOMapping:ft,uniformBlockBinding:Rt,texStorage2D:de,texStorage3D:De,texSubImage2D:ce,texSubImage3D:ye,compressedTexSubImage2D:Oe,compressedTexSubImage3D:Ee,scissor:Xe,viewport:Ne,reset:$t}}function JI(e,t,i,r,s,n,a){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,u=s.maxTextureSize,c=s.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap,g,m=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):wu("canvas")}function x(R,I,$,me){let ce=1;if((R.width>me||R.height>me)&&(ce=me/Math.max(R.width,R.height)),ce<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let ye=I?bu:Math.floor,Oe=ye(ce*R.width),Ee=ye(ce*R.height);g===void 0&&(g=y(Oe,Ee));let de=$?y(Oe,Ee):g;return de.width=Oe,de.height=Ee,de.getContext("2d").drawImage(R,0,0,Oe,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Oe+"x"+Ee+")."),de}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Ym(R.width)&&Ym(R.height)}function _(R){return o?!1:R.wrapS!==Qt||R.wrapT!==Qt||R.minFilter!==Lt&&R.minFilter!==nt}function A(R,I){return R.generateMipmaps&&I&&R.minFilter!==Lt&&R.minFilter!==nt}function S(R){e.generateMipmap(R)}function w(R,I,$,me,ce=!1){if(o===!1)return I;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let ye=I;return I===6403&&($===5126&&(ye=33326),$===5131&&(ye=33325),$===5121&&(ye=33321)),I===33319&&($===5126&&(ye=33328),$===5131&&(ye=33327),$===5121&&(ye=33323)),I===6408&&($===5126&&(ye=34836),$===5131&&(ye=34842),$===5121&&(ye=me===$e&&ce===!1?35907:32856),$===32819&&(ye=32854),$===32820&&(ye=32855)),(ye===33325||ye===33326||ye===33327||ye===33328||ye===34842||ye===34836)&&t.get("EXT_color_buffer_float"),ye}function M(R,I,$){return A(R,$)===!0||R.isFramebufferTexture&&R.minFilter!==Lt&&R.minFilter!==nt?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function C(R){return R===Lt||R===Fy||R===Yp?9728:9729}function T(R){let I=R.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function P(R){let I=r.get(R);if(I.__webglInit===void 0)return;let $=R.source,me=m.get($);if(me){let ce=me[I.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&L(R),Object.keys(me).length===0&&m.delete($)}r.remove(R)}function L(R){let I=r.get(R);e.deleteTexture(I.__webglTexture);let $=R.source,me=m.get($);delete me[I.__cacheKey],a.memory.textures--}function B(R){let I=R.texture,$=r.get(R),me=r.get(I);if(me.__webglTexture!==void 0&&(e.deleteTexture(me.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let ce=0;ce<6;ce++)e.deleteFramebuffer($.__webglFramebuffer[ce]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[ce]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let ce=0;ce<$.__webglColorRenderbuffer.length;ce++)$.__webglColorRenderbuffer[ce]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[ce]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let ce=0,ye=I.length;ce<ye;ce++){let Oe=r.get(I[ce]);Oe.__webglTexture&&(e.deleteTexture(Oe.__webglTexture),a.memory.textures--),r.remove(I[ce])}r.remove(I),r.remove(R)}let V=0;function U(){V=0}function z(){let R=V;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),V+=1,R}function X(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function H(R,I){let $=r.get(R);if(R.isVideoTexture&&Be(R),R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){let me=R.image;if(me===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(me.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,R,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function G(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function F(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){re($,R,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let j={[gn]:10497,[Qt]:33071,[Wm]:33648},W={[Lt]:9728,[Fy]:9984,[Yp]:9986,[nt]:9729,[IC]:9985,[gl]:9987};function N(R,I,$){if($?(e.texParameteri(R,10242,j[I.wrapS]),e.texParameteri(R,10243,j[I.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,j[I.wrapR]),e.texParameteri(R,10240,W[I.magFilter]),e.texParameteri(R,10241,W[I.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(I.wrapS!==Qt||I.wrapT!==Qt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(I.magFilter)),e.texParameteri(R,10241,C(I.minFilter)),I.minFilter!==Lt&&I.minFilter!==nt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),t.has("EXT_texture_filter_anisotropic")===!0){let me=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Lt||I.minFilter!==Yp&&I.minFilter!==gl||I.type===wr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===vl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(R,me.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(R,I){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",T));let me=I.source,ce=m.get(me);ce===void 0&&(ce={},m.set(me,ce));let ye=X(I);if(ye!==R.__cacheKey){ce[ye]===void 0&&(ce[ye]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,$=!0),ce[ye].usedTimes++;let Oe=ce[R.__cacheKey];Oe!==void 0&&(ce[R.__cacheKey].usedTimes--,Oe.usedTimes===0&&L(I)),R.__cacheKey=ye,R.__webglTexture=ce[ye].texture}return $}function Q(R,I,$){let me=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(me=35866),I.isData3DTexture&&(me=32879);let ce=ie(R,I),ye=I.source;i.bindTexture(me,R.__webglTexture,33984+$);let Oe=r.get(ye);if(ye.version!==Oe.__version||ce===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ee=_(I)&&b(I.image)===!1,de=x(I.image,Ee,!1,u);de=Ze(I,de);let De=b(de)||o,Re=n.convert(I.format,I.encoding),Ie=n.convert(I.type),Xe=w(I.internalFormat,Re,Ie,I.encoding,I.isVideoTexture);N(me,I,De);let Ne,ft=I.mipmaps,Rt=o&&I.isVideoTexture!==!0,$t=Oe.__version===void 0||ce===!0,Y=M(I,de,De);if(I.isDepthTexture)Xe=6402,o?I.type===wr?Xe=36012:I.type===Wn?Xe=33190:I.type===Ua?Xe=35056:Xe=33189:I.type===wr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===ja&&Xe===6402&&I.type!==Z_&&I.type!==Wn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Wn,Ie=n.convert(I.type)),I.format===Qa&&Xe===6402&&(Xe=34041,I.type!==Ua&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Ua,Ie=n.convert(I.type))),$t&&(Rt?i.texStorage2D(3553,1,Xe,de.width,de.height):i.texImage2D(3553,0,Xe,de.width,de.height,0,Re,Ie,null));else if(I.isDataTexture)if(ft.length>0&&De){Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],Rt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ie,Ne.data):i.texImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Re,Ie,Ne.data);I.generateMipmaps=!1}else Rt?($t&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,de.width,de.height,Re,Ie,de.data)):i.texImage2D(3553,0,Xe,de.width,de.height,0,Re,Ie,de.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){Rt&&$t&&i.texStorage3D(35866,Y,Xe,ft[0].width,ft[0].height,de.depth);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],I.format!==zr?Re!==null?Rt?i.compressedTexSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,de.depth,Re,Ne.data,0,0):i.compressedTexImage3D(35866,ne,Xe,Ne.width,Ne.height,de.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Rt?i.texSubImage3D(35866,ne,0,0,0,Ne.width,Ne.height,de.depth,Re,Ie,Ne.data):i.texImage3D(35866,ne,Xe,Ne.width,Ne.height,de.depth,0,Re,Ie,Ne.data)}else{Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],I.format!==zr?Re!==null?Rt?i.compressedTexSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ne.data):i.compressedTexImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Rt?i.texSubImage2D(3553,ne,0,0,Ne.width,Ne.height,Re,Ie,Ne.data):i.texImage2D(3553,ne,Xe,Ne.width,Ne.height,0,Re,Ie,Ne.data)}else if(I.isDataArrayTexture)Rt?($t&&i.texStorage3D(35866,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(35866,0,0,0,0,de.width,de.height,de.depth,Re,Ie,de.data)):i.texImage3D(35866,0,Xe,de.width,de.height,de.depth,0,Re,Ie,de.data);else if(I.isData3DTexture)Rt?($t&&i.texStorage3D(32879,Y,Xe,de.width,de.height,de.depth),i.texSubImage3D(32879,0,0,0,0,de.width,de.height,de.depth,Re,Ie,de.data)):i.texImage3D(32879,0,Xe,de.width,de.height,de.depth,0,Re,Ie,de.data);else if(I.isFramebufferTexture){if($t)if(Rt)i.texStorage2D(3553,Y,Xe,de.width,de.height);else{let ne=de.width,ge=de.height;for(let we=0;we<Y;we++)i.texImage2D(3553,we,Xe,ne,ge,0,Re,Ie,null),ne>>=1,ge>>=1}}else if(ft.length>0&&De){Rt&&$t&&i.texStorage2D(3553,Y,Xe,ft[0].width,ft[0].height);for(let ne=0,ge=ft.length;ne<ge;ne++)Ne=ft[ne],Rt?i.texSubImage2D(3553,ne,0,0,Re,Ie,Ne):i.texImage2D(3553,ne,Xe,Re,Ie,Ne);I.generateMipmaps=!1}else Rt?($t&&i.texStorage2D(3553,Y,Xe,de.width,de.height),i.texSubImage2D(3553,0,0,0,Re,Ie,de)):i.texImage2D(3553,0,Xe,Re,Ie,de);A(I,De)&&S(me),Oe.__version=ye.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function re(R,I,$){if(I.image.length!==6)return;let me=ie(R,I),ce=I.source;i.bindTexture(34067,R.__webglTexture,33984+$);let ye=r.get(ce);if(ce.version!==ye.__version||me===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Oe=I.isCompressedTexture||I.image[0].isCompressedTexture,Ee=I.image[0]&&I.image[0].isDataTexture,de=[];for(let ne=0;ne<6;ne++)!Oe&&!Ee?de[ne]=x(I.image[ne],!1,!0,h):de[ne]=Ee?I.image[ne].image:I.image[ne],de[ne]=Ze(I,de[ne]);let De=de[0],Re=b(De)||o,Ie=n.convert(I.format,I.encoding),Xe=n.convert(I.type),Ne=w(I.internalFormat,Ie,Xe,I.encoding),ft=o&&I.isVideoTexture!==!0,Rt=ye.__version===void 0||me===!0,$t=M(I,De,Re);N(34067,I,Re);let Y;if(Oe){ft&&Rt&&i.texStorage2D(34067,$t,Ne,De.width,De.height);for(let ne=0;ne<6;ne++){Y=de[ne].mipmaps;for(let ge=0;ge<Y.length;ge++){let we=Y[ge];I.format!==zr?Ie!==null?ft?i.compressedTexSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,we.data):i.compressedTexImage2D(34069+ne,ge,Ne,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ft?i.texSubImage2D(34069+ne,ge,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge,Ne,we.width,we.height,0,Ie,Xe,we.data)}}}else{Y=I.mipmaps,ft&&Rt&&(Y.length>0&&$t++,i.texStorage2D(34067,$t,Ne,de[0].width,de[0].height));for(let ne=0;ne<6;ne++)if(Ee){ft?i.texSubImage2D(34069+ne,0,0,0,de[ne].width,de[ne].height,Ie,Xe,de[ne].data):i.texImage2D(34069+ne,0,Ne,de[ne].width,de[ne].height,0,Ie,Xe,de[ne].data);for(let ge=0;ge<Y.length;ge++){let we=Y[ge].image[ne].image;ft?i.texSubImage2D(34069+ne,ge+1,0,0,we.width,we.height,Ie,Xe,we.data):i.texImage2D(34069+ne,ge+1,Ne,we.width,we.height,0,Ie,Xe,we.data)}}else{ft?i.texSubImage2D(34069+ne,0,0,0,Ie,Xe,de[ne]):i.texImage2D(34069+ne,0,Ne,Ie,Xe,de[ne]);for(let ge=0;ge<Y.length;ge++){let we=Y[ge];ft?i.texSubImage2D(34069+ne,ge+1,0,0,Ie,Xe,we.image[ne]):i.texImage2D(34069+ne,ge+1,Ne,Ie,Xe,we.image[ne])}}}A(I,Re)&&S(34067),ye.__version=ce.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,$,me,ce){let ye=n.convert($.format,$.encoding),Oe=n.convert($.type),Ee=w($.internalFormat,ye,Oe,$.encoding);r.get(I).__hasExternalTextures||(ce===32879||ce===35866?i.texImage3D(ce,0,Ee,I.width,I.height,I.depth,0,ye,Oe,null):i.texImage2D(ce,0,Ee,I.width,I.height,0,ye,Oe,null)),i.bindFramebuffer(36160,R),ve(I)?d.framebufferTexture2DMultisampleEXT(36160,me,ce,r.get($).__webglTexture,0,xe(I)):(ce===3553||ce>=34069&&ce<=34074)&&e.framebufferTexture2D(36160,me,ce,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function ue(R,I,$){if(e.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let me=33189;if($||ve(I)){let ce=I.depthTexture;ce&&ce.isDepthTexture&&(ce.type===wr?me=36012:ce.type===Wn&&(me=33190));let ye=xe(I);ve(I)?d.renderbufferStorageMultisampleEXT(36161,ye,me,I.width,I.height):e.renderbufferStorageMultisample(36161,ye,me,I.width,I.height)}else e.renderbufferStorage(36161,me,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let me=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,me,35056,I.width,I.height):ve(I)?d.renderbufferStorageMultisampleEXT(36161,me,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let me=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let ce=0;ce<me.length;ce++){let ye=me[ce],Oe=n.convert(ye.format,ye.encoding),Ee=n.convert(ye.type),de=w(ye.internalFormat,Oe,Ee,ye.encoding),De=xe(I);$&&ve(I)===!1?e.renderbufferStorageMultisample(36161,De,de,I.width,I.height):ve(I)?d.renderbufferStorageMultisampleEXT(36161,De,de,I.width,I.height):e.renderbufferStorage(36161,de,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function ae(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,me=xe(I);if(I.depthTexture.format===ja)ve(I)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,me):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===Qa)ve(I)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,me):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function se(R){let I=r.get(R),$=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");ae(I.__webglFramebuffer,R)}else if($){I.__webglDepthbuffer=[];for(let me=0;me<6;me++)i.bindFramebuffer(36160,I.__webglFramebuffer[me]),I.__webglDepthbuffer[me]=e.createRenderbuffer(),ue(I.__webglDepthbuffer[me],R,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),ue(I.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function Ae(R,I,$){let me=r.get(R);I!==void 0&&Z(me.__webglFramebuffer,R,R.texture,36064,3553),$!==void 0&&se(R)}function Se(R){let I=R.texture,$=r.get(R),me=r.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(me.__webglTexture===void 0&&(me.__webglTexture=e.createTexture()),me.__version=I.version,a.memory.textures++);let ce=R.isWebGLCubeRenderTarget===!0,ye=R.isWebGLMultipleRenderTargets===!0,Oe=b(R)||o;if(ce){$.__webglFramebuffer=[];for(let Ee=0;Ee<6;Ee++)$.__webglFramebuffer[Ee]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),ye)if(s.drawBuffers){let Ee=R.texture;for(let de=0,De=Ee.length;de<De;de++){let Re=r.get(Ee[de]);Re.__webglTexture===void 0&&(Re.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&ve(R)===!1){let Ee=ye?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let de=0;de<Ee.length;de++){let De=Ee[de];$.__webglColorRenderbuffer[de]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[de]);let Re=n.convert(De.format,De.encoding),Ie=n.convert(De.type),Xe=w(De.internalFormat,Re,Ie,De.encoding,R.isXRRenderTarget===!0),Ne=xe(R);e.renderbufferStorageMultisample(36161,Ne,Xe,R.width,R.height),e.framebufferRenderbuffer(36160,36064+de,36161,$.__webglColorRenderbuffer[de])}e.bindRenderbuffer(36161,null),R.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),ue($.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(ce){i.bindTexture(34067,me.__webglTexture),N(34067,I,Oe);for(let Ee=0;Ee<6;Ee++)Z($.__webglFramebuffer[Ee],R,I,36064,34069+Ee);A(I,Oe)&&S(34067),i.unbindTexture()}else if(ye){let Ee=R.texture;for(let de=0,De=Ee.length;de<De;de++){let Re=Ee[de],Ie=r.get(Re);i.bindTexture(3553,Ie.__webglTexture),N(3553,Re,Oe),Z($.__webglFramebuffer,R,Re,36064+de,3553),A(Re,Oe)&&S(3553)}i.unbindTexture()}else{let Ee=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Ee=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ee,me.__webglTexture),N(Ee,I,Oe),Z($.__webglFramebuffer,R,I,36064,Ee),A(I,Oe)&&S(Ee),i.unbindTexture()}R.depthBuffer&&se(R)}function Me(R){let I=b(R)||o,$=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let me=0,ce=$.length;me<ce;me++){let ye=$[me];if(A(ye,I)){let Oe=R.isWebGLCubeRenderTarget?34067:3553,Ee=r.get(ye).__webglTexture;i.bindTexture(Oe,Ee),S(Oe),i.unbindTexture()}}}function Pe(R){if(o&&R.samples>0&&ve(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],$=R.width,me=R.height,ce=16384,ye=[],Oe=R.stencilBuffer?33306:36096,Ee=r.get(R),de=R.isWebGLMultipleRenderTargets===!0;if(de)for(let De=0;De<I.length;De++)i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,null),i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,null,0);i.bindFramebuffer(36008,Ee.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ee.__webglFramebuffer);for(let De=0;De<I.length;De++){ye.push(36064+De),R.depthBuffer&&ye.push(Oe);let Re=Ee.__ignoreDepthValues!==void 0?Ee.__ignoreDepthValues:!1;if(Re===!1&&(R.depthBuffer&&(ce|=256),R.stencilBuffer&&(ce|=1024)),de&&e.framebufferRenderbuffer(36008,36064,36161,Ee.__webglColorRenderbuffer[De]),Re===!0&&(e.invalidateFramebuffer(36008,[Oe]),e.invalidateFramebuffer(36009,[Oe])),de){let Ie=r.get(I[De]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Ie,0)}e.blitFramebuffer(0,0,$,me,0,0,$,me,ce,9728),p&&e.invalidateFramebuffer(36008,ye)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),de)for(let De=0;De<I.length;De++){i.bindFramebuffer(36160,Ee.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+De,36161,Ee.__webglColorRenderbuffer[De]);let Re=r.get(I[De]).__webglTexture;i.bindFramebuffer(36160,Ee.__webglFramebuffer),e.framebufferTexture2D(36009,36064+De,3553,Re,0)}i.bindFramebuffer(36009,Ee.__webglMultisampledFramebuffer)}}function xe(R){return Math.min(c,R.samples)}function ve(R){let I=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Be(R){let I=a.render.frame;f.get(R)!==I&&(f.set(R,I),R.update())}function Ze(R,I){let $=R.encoding,me=R.format,ce=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Xm||$!==Bs&&($===$e?o===!1?t.has("EXT_sRGB")===!0&&me===zr?(R.format=Xm,R.minFilter=nt,R.generateMipmaps=!1):I=sS.sRGBToLinear(I):(me!==zr||ce!==Ni)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=U,this.setTexture2D=H,this.setTexture2DArray=G,this.setTexture3D=F,this.setTextureCube=q,this.rebindTextures=Ae,this.setupRenderTarget=Se,this.updateRenderTargetMipmap=Me,this.updateMultisampleRenderTarget=Pe,this.setupDepthRenderbuffer=se,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ve}function $I(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Ni)return 5121;if(n===BC)return 32819;if(n===zC)return 32820;if(n===LC)return 5120;if(n===OC)return 5122;if(n===Z_)return 5123;if(n===RC)return 5124;if(n===Wn)return 5125;if(n===wr)return 5126;if(n===vl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===FC)return 6406;if(n===zr)return 6408;if(n===NC)return 6409;if(n===kC)return 6410;if(n===ja)return 6402;if(n===Qa)return 34041;if(n===Xm)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===UC)return 6403;if(n===jC)return 36244;if(n===K_)return 33319;if(n===GC)return 33320;if(n===VC)return 36249;if(n===Qp||n===Zp||n===Kp||n===Jp)if(a===$e)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Qp)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Zp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Kp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Jp)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Qp)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Zp)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Kp)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Jp)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ny||n===ky||n===Uy||n===jy)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Ny)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ky)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Uy)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===jy)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===HC)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Gy||n===Vy)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===Gy)return a===$e?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Vy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Hy||n===Wy||n===qy||n===Xy||n===Yy||n===Qy||n===Zy||n===Ky||n===Jy||n===$y||n===e1||n===t1||n===i1||n===r1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Hy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Wy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Xy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Yy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Qy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Zy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ky)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Jy)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===$y)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===e1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===t1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===i1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===r1)return a===$e?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===$p)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===$p)return a===$e?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===WC||n===s1||n===n1||n===a1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===$p)return o.COMPRESSED_RED_RGTC1_EXT;if(n===s1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===n1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===a1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ua?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[n]!==void 0?e[n]:null}return{convert:s}}var eL=class extends Oi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Qo=class extends Et{constructor(){super(),this.isGroup=!0,this.type="Group"}},tL={type:"move"},Ef=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Qo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,n=null,a=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){n=!0;for(let f of e.hand.values()){let g=t.getJointPose(f,i),m=this._getHandJoint(l,f);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],c=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&c>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else o!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(tL)))}return a!==null&&(a.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=n!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new Qo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},xl=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:ja,h!==ja&&h!==Qa)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===ja&&(i=Wn),i===void 0&&h===Qa&&(i=Ua),super(null,r,s,n,a,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Lt,this.minFilter=o!==void 0?o:Lt,this.flipY=!1,this.generateMipmaps=!1}},iL=class extends Ti{constructor(e,t){super();let i=this,r=null,s=1,n=null,a="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),g=null,m=null,v=[],y=[],x=new Set,b=new Map,_=new Oi;_.layers.enable(1),_.viewport=new et;let A=new Oi;A.layers.enable(2),A.viewport=new et;let S=[_,A],w=new eL;w.layers.enable(1),w.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getTargetRaySpace()},this.getControllerGrip=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getGripSpace()},this.getHand=function(G){let F=v[G];return F===void 0&&(F=new Ef,v[G]=F),F.getHandSpace()};function T(G){let F=y.indexOf(G.inputSource);if(F===-1)return;let q=v[F];q!==void 0&&q.dispatchEvent({type:G.type,data:G.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",P);for(let G=0;G<v.length;G++){let F=y[G];F!==null&&(y[G]=null,v[G].disconnect(F))}M=null,C=null,e.setRenderTarget(g),d=null,c=null,u=null,r=null,m=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){s=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(G){l=G},this.getBaseLayer=function(){return c!==null?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(G){if(r=G,r!==null){if(g=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let F={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,F),r.updateRenderState({baseLayer:d}),m=new Mt(d.framebufferWidth,d.framebufferHeight,{format:zr,type:Ni,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let F=null,q=null,j=null;f.depth&&(j=f.stencil?35056:33190,F=f.stencil?Qa:ja,q=f.stencil?Ua:Wn);let W={colorFormat:32856,depthFormat:j,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(W),r.updateRenderState({layers:[c]}),m=new Mt(c.textureWidth,c.textureHeight,{format:zr,type:Ni,depthTexture:new xl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,F),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let N=e.properties.get(m);N.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(G){for(let F=0;F<G.removed.length;F++){let q=G.removed[F],j=y.indexOf(q);j>=0&&(y[j]=null,v[j].disconnect(q))}for(let F=0;F<G.added.length;F++){let q=G.added[F],j=y.indexOf(q);if(j===-1){for(let N=0;N<v.length;N++)if(N>=y.length){y.push(q),j=N;break}else if(y[N]===null){y[N]=q,j=N;break}if(j===-1)break}let W=v[j];W&&W.connect(q)}}let L=new E,B=new E;function V(G,F,q){L.setFromMatrixPosition(F.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let j=L.distanceTo(B),W=F.projectionMatrix.elements,N=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],ue=(W[8]-1)/W[0],ae=(N[8]+1)/N[0],se=ie*ue,Ae=ie*ae,Se=j/(-ue+ae),Me=Se*-ue;F.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(Me),G.translateZ(Se),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert();let Pe=ie+Se,xe=Q+Se,ve=se-Me,Be=Ae+(j-Me),Ze=re*Q/xe*Pe,R=Z*Q/xe*Pe;G.projectionMatrix.makePerspective(ve,Be,Ze,R,Pe,xe)}function U(G,F){F===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(F.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(r===null)return;w.near=A.near=_.near=G.near,w.far=A.far=_.far=G.far,(M!==w.near||C!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),M=w.near,C=w.far);let F=G.parent,q=w.cameras;U(w,F);for(let W=0;W<q.length;W++)U(q[W],F);w.matrixWorld.decompose(w.position,w.quaternion,w.scale),G.matrix.copy(w.matrix),G.matrix.decompose(G.position,G.quaternion,G.scale);let j=G.children;for(let W=0,N=j.length;W<N;W++)j[W].updateMatrixWorld(!0);q.length===2?V(w,_,A):w.projectionMatrix.copy(_.projectionMatrix)},this.getCamera=function(){return w},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(G){o=G,c!==null&&(c.fixedFoveation=G),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=G)},this.getPlanes=function(){return x};let z=null;function X(G,F){if(h=F.getViewerPose(l||n),p=F,h!==null){let q=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let j=!1;q.length!==w.cameras.length&&(w.cameras.length=0,j=!0);for(let W=0;W<q.length;W++){let N=q[W],ie=null;if(d!==null)ie=d.getViewport(N);else{let re=u.getViewSubImage(c,N);ie=re.viewport,W===0&&(e.setRenderTargetTextures(m,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(m))}let Q=S[W];Q===void 0&&(Q=new Oi,Q.layers.enable(W),Q.viewport=new et,S[W]=Q),Q.matrix.fromArray(N.transform.matrix),Q.projectionMatrix.fromArray(N.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&w.matrix.copy(Q.matrix),j===!0&&w.cameras.push(Q)}}for(let q=0;q<v.length;q++){let j=y[q],W=v[q];j!==null&&W!==void 0&&W.update(j,F,l||n)}if(z&&z(G,F),F.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:F.detectedPlanes});let q=null;for(let j of x)F.detectedPlanes.has(j)||(q===null&&(q=[]),q.push(j));if(q!==null)for(let j of q)x.delete(j),b.delete(j),i.dispatchEvent({type:"planeremoved",data:j});for(let j of F.detectedPlanes)if(!x.has(j))x.add(j),b.set(j,F.lastChangedTime),i.dispatchEvent({type:"planeadded",data:j});else{let W=b.get(j);j.lastChangedTime>W&&(b.set(j,j.lastChangedTime),i.dispatchEvent({type:"planechanged",data:j}))}}p=null}let H=new hS;H.setAnimationLoop(X),this.setAnimationLoop=function(G){z=G},this.dispose=function(){}}};function rL(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,lS(e)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function r(g,m,v,y,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?s(g,m):m.isMeshToonMaterial?(s(g,m),u(g,m)):m.isMeshPhongMaterial?(s(g,m),h(g,m)):m.isMeshStandardMaterial?(s(g,m),c(g,m),m.isMeshPhysicalMaterial&&d(g,m,x)):m.isMeshMatcapMaterial?(s(g,m),p(g,m)):m.isMeshDepthMaterial?s(g,m):m.isMeshDistanceMaterial?(s(g,m),f(g,m)):m.isMeshNormalMaterial?s(g,m):m.isLineBasicMaterial?(n(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?o(g,m,v,y):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function s(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.bumpMap&&(g.bumpMap.value=m.bumpMap,g.bumpScale.value=m.bumpScale,m.side===xi&&(g.bumpScale.value*=-1)),m.displacementMap&&(g.displacementMap.value=m.displacementMap,g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap),m.normalMap&&(g.normalMap.value=m.normalMap,g.normalScale.value.copy(m.normalScale),m.side===xi&&g.normalScale.value.negate()),m.specularMap&&(g.specularMap.value=m.specularMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v=t.get(m).envMap;if(v&&(g.envMap.value=v,g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*b}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity);let y;m.map?y=m.map:m.specularMap?y=m.specularMap:m.displacementMap?y=m.displacementMap:m.normalMap?y=m.normalMap:m.bumpMap?y=m.bumpMap:m.roughnessMap?y=m.roughnessMap:m.metalnessMap?y=m.metalnessMap:m.alphaMap?y=m.alphaMap:m.emissiveMap?y=m.emissiveMap:m.clearcoatMap?y=m.clearcoatMap:m.clearcoatNormalMap?y=m.clearcoatNormalMap:m.clearcoatRoughnessMap?y=m.clearcoatRoughnessMap:m.iridescenceMap?y=m.iridescenceMap:m.iridescenceThicknessMap?y=m.iridescenceThicknessMap:m.specularIntensityMap?y=m.specularIntensityMap:m.specularColorMap?y=m.specularColorMap:m.transmissionMap?y=m.transmissionMap:m.thicknessMap?y=m.thicknessMap:m.sheenColorMap?y=m.sheenColorMap:m.sheenRoughnessMap&&(y=m.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),g.uvTransform.value.copy(y.matrix));let x;m.aoMap?x=m.aoMap:m.lightMap&&(x=m.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uv2Transform.value.copy(x.matrix))}function n(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function o(g,m,v,y){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*v,g.scale.value=y*.5,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let x;m.map?x=m.map:m.alphaMap&&(x=m.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),g.uvTransform.value.copy(x.matrix))}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map),m.alphaMap&&(g.alphaMap.value=m.alphaMap),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);let v;m.map?v=m.map:m.alphaMap&&(v=m.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),g.uvTransform.value.copy(v.matrix))}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function c(g,m){g.roughness.value=m.roughness,g.metalness.value=m.metalness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap),m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap),t.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,v){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap)),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap),m.clearcoatNormalMap&&(g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),g.clearcoatNormalMap.value=m.clearcoatNormalMap,m.side===xi&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap)),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap)}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function f(g,m){g.referencePosition.value.copy(m.referencePosition),g.nearDistance.value=m.nearDistance,g.farDistance.value=m.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function sL(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=u(y),s[y.id]=b,y.addEventListener("dispose",m));let _=x.program;r.updateUBOMapping(y,_);let A=t.render.frame;n[y.id]!==A&&(d(y),n[y.id]=A)}function u(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),_=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,_,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){let x=s[y.id],b=y.uniforms,_=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let w=b[A];if(p(w,A,_)===!0){let M=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],L=g(P);typeof P=="number"?(w.__data[0]=P,e.bufferSubData(35345,M+T,w.__data)):P.isMatrix3?(w.__data[0]=P.elements[0],w.__data[1]=P.elements[1],w.__data[2]=P.elements[2],w.__data[3]=P.elements[0],w.__data[4]=P.elements[3],w.__data[5]=P.elements[4],w.__data[6]=P.elements[5],w.__data[7]=P.elements[0],w.__data[8]=P.elements[6],w.__data[9]=P.elements[7],w.__data[10]=P.elements[8],w.__data[11]=P.elements[0]):(P.toArray(w.__data,T),T+=L.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,w.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let _=y.value;if(b[x]===void 0){if(typeof _=="number")b[x]=_;else{let A=Array.isArray(_)?_:[_],S=[];for(let w=0;w<A.length;w++)S.push(A[w].clone());b[x]=S}return!0}else if(typeof _=="number"){if(b[x]!==_)return b[x]=_,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],S=Array.isArray(_)?_:[_];for(let w=0;w<A.length;w++){let M=A[w];if(M.equals(S[w])===!1)return M.copy(S[w]),!0}}return!1}function f(y){let x=y.uniforms,b=0,_=16,A=0;for(let S=0,w=x.length;S<w;S++){let M=x[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let L=T[D],B=g(L);C.boundary+=B.boundary,C.storage+=B.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,S>0){A=b%_;let D=_-A;A!==0&&D-C.boundary<0&&(b+=_-A,M.__offset=b)}b+=C.storage}return A=b%_,A>0&&(b+=_-A),y.__size=b,y.__cache={},this}function g(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function m(y){let x=y.target;x.removeEventListener("dispose",m);let b=a.indexOf(x.__bindingPointIndex);a.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete n[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function nL(){let e=wu("canvas");return e.style.display="block",e}function mS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:nL(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,n=e.antialias!==void 0?e.antialias:!1,a=e.premultipliedAlpha!==void 0?e.premultipliedAlpha:!0,o=e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1,l=e.powerPreference!==void 0?e.powerPreference:"default",h=e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,u;i!==null?u=i.getContextAttributes().alpha:u=e.alpha!==void 0?e.alpha:!1;let c=null,d=null,p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Bs,this.physicallyCorrectLights=!1,this.toneMapping=yn,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,x=null,b=-1,_=null,A=new et,S=new et,w=null,M=t.width,C=t.height,T=1,D=null,P=null,L=new et(0,0,M,C),B=new et(0,0,M,C),V=!1,U=new zv,z=!1,X=!1,H=null,G=new fe,F=new k,q=new E,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let N=i;function ie(O,ee){for(let oe=0;oe<O.length;oe++){let J=O[oe],le=t.getContext(J,ee);if(le!==null)return le}return null}try{let O={alpha:!0,depth:r,stencil:s,antialias:n,premultipliedAlpha:a,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ol}`),t.addEventListener("webglcontextlost",Xe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",ft,!1),N===null){let ee=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&ee.shift(),N=ie(ee,O),N===null)throw ie(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}N.getShaderPrecisionFormat===void 0&&(N.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(O){throw console.error("THREE.WebGLRenderer: "+O.message),O}let Q,re,Z,ue,ae,se,Ae,Se,Me,Pe,xe,ve,Be,Ze,R,I,$,me,ce,ye,Oe,Ee,de,De;function Re(){Q=new yD(N),re=new uD(N,Q,e),Q.init(re),Ee=new $I(N,Q,re),Z=new KI(N,Q,re),ue=new wD,ae=new NI,se=new JI(N,Q,Z,ae,re,Ee,ue),Ae=new fD(g),Se=new vD(g),Me=new DT(N,re),de=new cD(N,Q,Me,re),Pe=new xD(N,Me,ue,de),xe=new MD(N,Pe,Me,ue),ce=new AD(N,re,se),I=new pD(ae),ve=new FI(g,Ae,Se,Q,re,de,I),Be=new rL(g,ae),Ze=new UI,R=new qI(Q,re),me=new hD(g,Ae,Se,Z,xe,u,a),$=new ZI(g,xe,re),De=new sL(N,ue,re,Z),ye=new dD(N,Q,ue,re),Oe=new bD(N,Q,ue,re),ue.programs=ve.programs,g.capabilities=re,g.extensions=Q,g.properties=ae,g.renderLists=Ze,g.shadowMap=$,g.state=Z,g.info=ue}Re();let Ie=new iL(g,N);this.xr=Ie,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let O=Q.get("WEBGL_lose_context");O&&O.loseContext()},this.forceContextRestore=function(){let O=Q.get("WEBGL_lose_context");O&&O.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(O){O!==void 0&&(T=O,this.setSize(M,C,!1))},this.getSize=function(O){return O.set(M,C)},this.setSize=function(O,ee,oe){if(Ie.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=O,C=ee,t.width=Math.floor(O*T),t.height=Math.floor(ee*T),oe!==!1&&(t.style.width=O+"px",t.style.height=ee+"px"),this.setViewport(0,0,O,ee)},this.getDrawingBufferSize=function(O){return O.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(O,ee,oe){M=O,C=ee,T=oe,t.width=Math.floor(O*oe),t.height=Math.floor(ee*oe),this.setViewport(0,0,O,ee)},this.getCurrentViewport=function(O){return O.copy(A)},this.getViewport=function(O){return O.copy(L)},this.setViewport=function(O,ee,oe,J){O.isVector4?L.set(O.x,O.y,O.z,O.w):L.set(O,ee,oe,J),Z.viewport(A.copy(L).multiplyScalar(T).floor())},this.getScissor=function(O){return O.copy(B)},this.setScissor=function(O,ee,oe,J){O.isVector4?B.set(O.x,O.y,O.z,O.w):B.set(O,ee,oe,J),Z.scissor(S.copy(B).multiplyScalar(T).floor())},this.getScissorTest=function(){return V},this.setScissorTest=function(O){Z.setScissorTest(V=O)},this.setOpaqueSort=function(O){D=O},this.setTransparentSort=function(O){P=O},this.getClearColor=function(O){return O.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(O=!0,ee=!0,oe=!0){let J=0;O&&(J|=16384),ee&&(J|=256),oe&&(J|=1024),N.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Xe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",ft,!1),Ze.dispose(),R.dispose(),ae.dispose(),Ae.dispose(),Se.dispose(),xe.dispose(),de.dispose(),De.dispose(),ve.dispose(),Ie.dispose(),Ie.removeEventListener("sessionstart",we),Ie.removeEventListener("sessionend",Ge),H&&(H.dispose(),H=null),vt.stop()};function Xe(O){O.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let O=ue.autoReset,ee=$.enabled,oe=$.autoUpdate,J=$.needsUpdate,le=$.type;Re(),ue.autoReset=O,$.enabled=ee,$.autoUpdate=oe,$.needsUpdate=J,$.type=le}function ft(O){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",O.statusMessage)}function Rt(O){let ee=O.target;ee.removeEventListener("dispose",Rt),$t(ee)}function $t(O){Y(O),ae.remove(O)}function Y(O){let ee=ae.get(O).programs;ee!==void 0&&(ee.forEach(function(oe){ve.releaseProgram(oe)}),O.isShaderMaterial&&ve.releaseShaderCache(O))}this.renderBufferDirect=function(O,ee,oe,J,le,ze){ee===null&&(ee=j);let rt=le.isMesh&&le.matrixWorld.determinant()<0,lt=RE(O,ee,oe,J,le);Z.setMaterial(J,rt);let ct=oe.index,Dt=1;J.wireframe===!0&&(ct=Pe.getWireframeAttribute(oe),Dt=2);let yt=oe.drawRange,mt=oe.attributes.position,Di=yt.start*Dt,pr=(yt.start+yt.count)*Dt;ze!==null&&(Di=Math.max(Di,ze.start*Dt),pr=Math.min(pr,(ze.start+ze.count)*Dt)),ct!==null?(Di=Math.max(Di,0),pr=Math.min(pr,ct.count)):mt!=null&&(Di=Math.max(Di,0),pr=Math.min(pr,mt.count));let qs=pr-Di;if(qs<0||qs===1/0)return;de.setup(le,J,lt,oe,ct);let fa,ei=ye;if(ct!==null&&(fa=Me.get(ct),ei=Oe,ei.setIndex(fa)),le.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),ei.setMode(1)):ei.setMode(4);else if(le.isLine){let gt=J.linewidth;gt===void 0&&(gt=1),Z.setLineWidth(gt*W()),le.isLineSegments?ei.setMode(1):le.isLineLoop?ei.setMode(2):ei.setMode(3)}else le.isPoints?ei.setMode(0):le.isSprite&&ei.setMode(4);if(le.isInstancedMesh)ei.renderInstances(Di,qs,le.count);else if(oe.isInstancedBufferGeometry){let gt=oe._maxInstanceCount!==void 0?oe._maxInstanceCount:1/0,Vp=Math.min(oe.instanceCount,gt);ei.renderInstances(Di,qs,Vp)}else ei.render(Di,qs)},this.compile=function(O,ee){function oe(J,le,ze){J.transparent===!0&&J.side===br&&J.forceSinglePass===!1?(J.side=xi,J.needsUpdate=!0,Mr(J,le,ze),J.side=ns,J.needsUpdate=!0,Mr(J,le,ze),J.side=br):Mr(J,le,ze)}d=R.get(O),d.init(),f.push(d),O.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(d.pushLight(J),J.castShadow&&d.pushShadow(J))}),d.setupLights(g.physicallyCorrectLights),O.traverse(function(J){let le=J.material;if(le)if(Array.isArray(le))for(let ze=0;ze<le.length;ze++){let rt=le[ze];oe(rt,O,J)}else oe(le,O,J)}),f.pop(),d=null};let ne=null;function ge(O){ne&&ne(O)}function we(){vt.stop()}function Ge(){vt.start()}let vt=new hS;vt.setAnimationLoop(ge),typeof self<"u"&&vt.setContext(self),this.setAnimationLoop=function(O){ne=O,Ie.setAnimationLoop(O),O===null?vt.stop():vt.start()},Ie.addEventListener("sessionstart",we),Ie.addEventListener("sessionend",Ge),this.render=function(O,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(ee),ee=Ie.getCamera()),O.isScene===!0&&O.onBeforeRender(g,O,ee,x),d=R.get(O,f.length),d.init(),f.push(d),G.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),U.setFromProjectionMatrix(G),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Ze.get(O,p.length),c.init(),p.push(c),kt(O,ee,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let oe=d.state.shadowsArray;if($.render(oe,O,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),me.render(c,O),d.setupLights(g.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let le=0,ze=J.length;le<ze;le++){let rt=J[le];Pi(c,O,rt,rt.viewport)}}else Pi(c,O,ee);x!==null&&(se.updateMultisampleRenderTarget(x),se.updateRenderTargetMipmap(x)),O.isScene===!0&&O.onAfterRender(g,O,ee),de.resetDefaultState(),b=-1,_=null,f.pop(),f.length>0?d=f[f.length-1]:d=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function kt(O,ee,oe,J){if(O.visible===!1)return;if(O.layers.test(ee.layers)){if(O.isGroup)oe=O.renderOrder;else if(O.isLOD)O.autoUpdate===!0&&O.update(ee);else if(O.isLight)d.pushLight(O),O.castShadow&&d.pushShadow(O);else if(O.isSprite){if(!O.frustumCulled||U.intersectsSprite(O)){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}else if((O.isMesh||O.isLine||O.isPoints)&&(O.isSkinnedMesh&&O.skeleton.frame!==ue.render.frame&&(O.skeleton.update(),O.skeleton.frame=ue.render.frame),!O.frustumCulled||U.intersectsObject(O))){J&&q.setFromMatrixPosition(O.matrixWorld).applyMatrix4(G);let ze=xe.update(O),rt=O.material;if(Array.isArray(rt)){let lt=ze.groups;for(let ct=0,Dt=lt.length;ct<Dt;ct++){let yt=lt[ct],mt=rt[yt.materialIndex];mt&&mt.visible&&c.push(O,ze,mt,oe,q.z,yt)}}else rt.visible&&c.push(O,ze,rt,oe,q.z,null)}}let le=O.children;for(let ze=0,rt=le.length;ze<rt;ze++)kt(le[ze],ee,oe,J)}function Pi(O,ee,oe,J){let le=O.opaque,ze=O.transmissive,rt=O.transparent;d.setupLightsView(oe),z===!0&&I.setGlobalState(g.clippingPlanes,oe),ze.length>0&&pa(le,ee,oe),J&&Z.viewport(A.copy(J)),le.length>0&&Nt(le,ee,oe),ze.length>0&&Nt(ze,ee,oe),rt.length>0&&Nt(rt,ee,oe),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function pa(O,ee,oe){let J=re.isWebGL2;H===null&&(H=new Mt(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?vl:Ni,minFilter:gl,samples:J&&n===!0?4:0})),g.getDrawingBufferSize(F),J?H.setSize(F.x,F.y):H.setSize(bu(F.x),bu(F.y));let le=g.getRenderTarget();g.setRenderTarget(H),g.clear();let ze=g.toneMapping;g.toneMapping=yn,Nt(O,ee,oe),g.toneMapping=ze,se.updateMultisampleRenderTarget(H),se.updateRenderTargetMipmap(H),g.setRenderTarget(le)}function Nt(O,ee,oe){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let le=0,ze=O.length;le<ze;le++){let rt=O[le],lt=rt.object,ct=rt.geometry,Dt=J===null?rt.material:J,yt=rt.group;lt.layers.test(oe.layers)&&Ws(lt,ee,oe,ct,Dt,yt)}}function Ws(O,ee,oe,J,le,ze){O.onBeforeRender(g,ee,oe,J,le,ze),O.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,O.matrixWorld),O.normalMatrix.getNormalMatrix(O.modelViewMatrix),le.onBeforeRender(g,ee,oe,J,O,ze),le.transparent===!0&&le.side===br&&le.forceSinglePass===!1?(le.side=xi,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=ns,le.needsUpdate=!0,g.renderBufferDirect(oe,ee,J,le,O,ze),le.side=br):g.renderBufferDirect(oe,ee,J,le,O,ze),O.onAfterRender(g,ee,oe,J,le,ze)}function Mr(O,ee,oe){ee.isScene!==!0&&(ee=j);let J=ae.get(O),le=d.state.lights,ze=d.state.shadowsArray,rt=le.state.version,lt=ve.getParameters(O,le.state,ze,ee,oe),ct=ve.getProgramCacheKey(lt),Dt=J.programs;J.environment=O.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(O.isMeshStandardMaterial?Se:Ae).get(O.envMap||J.environment),Dt===void 0&&(O.addEventListener("dispose",Rt),Dt=new Map,J.programs=Dt);let yt=Dt.get(ct);if(yt!==void 0){if(J.currentProgram===yt&&J.lightsStateVersion===rt)return Ey(O,lt),yt}else lt.uniforms=ve.getUniforms(O),O.onBuild(oe,lt,g),O.onBeforeCompile(lt,g),yt=ve.acquireProgram(lt,ct),Dt.set(ct,yt),J.uniforms=lt.uniforms;let mt=J.uniforms;(!O.isShaderMaterial&&!O.isRawShaderMaterial||O.clipping===!0)&&(mt.clippingPlanes=I.uniform),Ey(O,lt),J.needsLights=zE(O),J.lightsStateVersion=rt,J.needsLights&&(mt.ambientLightColor.value=le.state.ambient,mt.lightProbe.value=le.state.probe,mt.directionalLights.value=le.state.directional,mt.directionalLightShadows.value=le.state.directionalShadow,mt.spotLights.value=le.state.spot,mt.spotLightShadows.value=le.state.spotShadow,mt.rectAreaLights.value=le.state.rectArea,mt.ltc_1.value=le.state.rectAreaLTC1,mt.ltc_2.value=le.state.rectAreaLTC2,mt.pointLights.value=le.state.point,mt.pointLightShadows.value=le.state.pointShadow,mt.hemisphereLights.value=le.state.hemi,mt.directionalShadowMap.value=le.state.directionalShadowMap,mt.directionalShadowMatrix.value=le.state.directionalShadowMatrix,mt.spotShadowMap.value=le.state.spotShadowMap,mt.spotLightMatrix.value=le.state.spotLightMatrix,mt.spotLightMap.value=le.state.spotLightMap,mt.pointShadowMap.value=le.state.pointShadowMap,mt.pointShadowMatrix.value=le.state.pointShadowMatrix);let Di=yt.getUniforms(),pr=au.seqWithValue(Di.seq,mt);return J.currentProgram=yt,J.uniformsList=pr,yt}function Ey(O,ee){let oe=ae.get(O);oe.outputEncoding=ee.outputEncoding,oe.instancing=ee.instancing,oe.skinning=ee.skinning,oe.morphTargets=ee.morphTargets,oe.morphNormals=ee.morphNormals,oe.morphColors=ee.morphColors,oe.morphTargetsCount=ee.morphTargetsCount,oe.numClippingPlanes=ee.numClippingPlanes,oe.numIntersection=ee.numClipIntersection,oe.vertexAlphas=ee.vertexAlphas,oe.vertexTangents=ee.vertexTangents,oe.toneMapping=ee.toneMapping}function RE(O,ee,oe,J,le){ee.isScene!==!0&&(ee=j),se.resetTextureUnits();let ze=ee.fog,rt=J.isMeshStandardMaterial?ee.environment:null,lt=x===null?g.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Bs,ct=(J.isMeshStandardMaterial?Se:Ae).get(J.envMap||rt),Dt=J.vertexColors===!0&&!!oe.attributes.color&&oe.attributes.color.itemSize===4,yt=!!J.normalMap&&!!oe.attributes.tangent,mt=!!oe.morphAttributes.position,Di=!!oe.morphAttributes.normal,pr=!!oe.morphAttributes.color,qs=J.toneMapped?g.toneMapping:yn,fa=oe.morphAttributes.position||oe.morphAttributes.normal||oe.morphAttributes.color,ei=fa!==void 0?fa.length:0,gt=ae.get(J),Vp=d.state.lights;if(z===!0&&(X===!0||O!==_)){let fr=O===_&&J.id===b;I.setState(J,O,fr)}let Hp=!1;J.version===gt.__version?(gt.needsLights&>.lightsStateVersion!==Vp.state.version||gt.outputEncoding!==lt||le.isInstancedMesh&>.instancing===!1||!le.isInstancedMesh&>.instancing===!0||le.isSkinnedMesh&>.skinning===!1||!le.isSkinnedMesh&>.skinning===!0||gt.envMap!==ct||J.fog===!0&>.fog!==ze||gt.numClippingPlanes!==void 0&&(gt.numClippingPlanes!==I.numPlanes||gt.numIntersection!==I.numIntersection)||gt.vertexAlphas!==Dt||gt.vertexTangents!==yt||gt.morphTargets!==mt||gt.morphNormals!==Di||gt.morphColors!==pr||gt.toneMapping!==qs||re.isWebGL2===!0&>.morphTargetsCount!==ei)&&(Hp=!0):(Hp=!0,gt.__version=J.version);let ma=gt.currentProgram;Hp===!0&&(ma=Mr(J,ee,le));let Cy=!1,th=!1,Wp=!1,Ai=ma.getUniforms(),ga=gt.uniforms;if(Z.useProgram(ma.program)&&(Cy=!0,th=!0,Wp=!0),J.id!==b&&(b=J.id,th=!0),Cy||_!==O){if(Ai.setValue(N,"projectionMatrix",O.projectionMatrix),re.logarithmicDepthBuffer&&Ai.setValue(N,"logDepthBufFC",2/(Math.log(O.far+1)/Math.LN2)),_!==O&&(_=O,th=!0,Wp=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let fr=Ai.map.cameraPosition;fr!==void 0&&fr.setValue(N,q.setFromMatrixPosition(O.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ai.setValue(N,"isOrthographic",O.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||le.isSkinnedMesh)&&Ai.setValue(N,"viewMatrix",O.matrixWorldInverse)}if(le.isSkinnedMesh){Ai.setOptional(N,le,"bindMatrix"),Ai.setOptional(N,le,"bindMatrixInverse");let fr=le.skeleton;fr&&(re.floatVertexTextures?(fr.boneTexture===null&&fr.computeBoneTexture(),Ai.setValue(N,"boneTexture",fr.boneTexture,se),Ai.setValue(N,"boneTextureSize",fr.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let qp=oe.morphAttributes;if((qp.position!==void 0||qp.normal!==void 0||qp.color!==void 0&&re.isWebGL2===!0)&&ce.update(le,oe,J,ma),(th||gt.receiveShadow!==le.receiveShadow)&&(gt.receiveShadow=le.receiveShadow,Ai.setValue(N,"receiveShadow",le.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(ga.envMap.value=ct,ga.flipEnvMap.value=ct.isCubeTexture&&ct.isRenderTargetTexture===!1?-1:1),th&&(Ai.setValue(N,"toneMappingExposure",g.toneMappingExposure),gt.needsLights&&BE(ga,Wp),ze&&J.fog===!0&&Be.refreshFogUniforms(ga,ze),Be.refreshMaterialUniforms(ga,J,T,C,H),au.upload(N,gt.uniformsList,ga,se)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(au.upload(N,gt.uniformsList,ga,se),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ai.setValue(N,"center",le.center),Ai.setValue(N,"modelViewMatrix",le.modelViewMatrix),Ai.setValue(N,"normalMatrix",le.normalMatrix),Ai.setValue(N,"modelMatrix",le.matrixWorld),le.previousModelViewMatrix&&Ai.setValue(N,"previousModelViewMatrix",le.previousModelViewMatrix),O.previousProjectionMatrix&&Ai.setValue(N,"previousProjectionMatrix",O.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let fr=J.uniformsGroups;for(let Xp=0,FE=fr.length;Xp<FE;Xp++)if(re.isWebGL2){let Ty=fr[Xp];De.update(Ty,ma),De.bind(Ty,ma)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return ma}function BE(O,ee){O.ambientLightColor.needsUpdate=ee,O.lightProbe.needsUpdate=ee,O.directionalLights.needsUpdate=ee,O.directionalLightShadows.needsUpdate=ee,O.pointLights.needsUpdate=ee,O.pointLightShadows.needsUpdate=ee,O.spotLights.needsUpdate=ee,O.spotLightShadows.needsUpdate=ee,O.rectAreaLights.needsUpdate=ee,O.hemisphereLights.needsUpdate=ee}function zE(O){return O.isMeshLambertMaterial||O.isMeshToonMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isShadowMaterial||O.isShaderMaterial&&O.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(O,ee,oe){ae.get(O.texture).__webglTexture=ee,ae.get(O.depthTexture).__webglTexture=oe;let J=ae.get(O);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=oe===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(O,ee){let oe=ae.get(O);oe.__webglFramebuffer=ee,oe.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(O,ee=0,oe=0){x=O,v=ee,y=oe;let J=!0,le=null,ze=!1,rt=!1;if(O){let lt=ae.get(O);lt.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):lt.__webglFramebuffer===void 0?se.setupRenderTarget(O):lt.__hasExternalTextures&&se.rebindTextures(O,ae.get(O.texture).__webglTexture,ae.get(O.depthTexture).__webglTexture);let ct=O.texture;(ct.isData3DTexture||ct.isDataArrayTexture||ct.isCompressedArrayTexture)&&(rt=!0);let Dt=ae.get(O).__webglFramebuffer;O.isWebGLCubeRenderTarget?(le=Dt[ee],ze=!0):re.isWebGL2&&O.samples>0&&se.useMultisampledRTT(O)===!1?le=ae.get(O).__webglMultisampledFramebuffer:le=Dt,A.copy(O.viewport),S.copy(O.scissor),w=O.scissorTest}else A.copy(L).multiplyScalar(T).floor(),S.copy(B).multiplyScalar(T).floor(),w=V;if(Z.bindFramebuffer(36160,le)&&re.drawBuffers&&J&&Z.drawBuffers(O,le),Z.viewport(A),Z.scissor(S),Z.setScissorTest(w),ze){let lt=ae.get(O.texture);N.framebufferTexture2D(36160,36064,34069+ee,lt.__webglTexture,oe)}else if(rt){let lt=ae.get(O.texture),ct=ee||0;N.framebufferTextureLayer(36160,36064,lt.__webglTexture,oe||0,ct)}b=-1},this.readRenderTargetPixels=function(O,ee,oe,J,le,ze,rt){if(!(O&&O.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let lt=ae.get(O).__webglFramebuffer;if(O.isWebGLCubeRenderTarget&&rt!==void 0&&(lt=lt[rt]),lt){Z.bindFramebuffer(36160,lt);try{let ct=O.texture,Dt=ct.format,yt=ct.type;if(Dt!==zr&&Ee.convert(Dt)!==N.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let mt=yt===vl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(yt!==Ni&&Ee.convert(yt)!==N.getParameter(35738)&&!(yt===wr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!mt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=O.width-J&&oe>=0&&oe<=O.height-le&&N.readPixels(ee,oe,J,le,Ee.convert(Dt),Ee.convert(yt),ze)}finally{let ct=x!==null?ae.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,ct)}}},this.copyFramebufferToTexture=function(O,ee,oe=0){let J=Math.pow(2,-oe),le=Math.floor(ee.image.width*J),ze=Math.floor(ee.image.height*J);se.setTexture2D(ee,0),N.copyTexSubImage2D(3553,oe,0,0,O.x,O.y,le,ze),Z.unbindTexture()},this.copyTextureToTexture=function(O,ee,oe,J=0){let le=ee.image.width,ze=ee.image.height,rt=Ee.convert(oe.format),lt=Ee.convert(oe.type);se.setTexture2D(oe,0),N.pixelStorei(37440,oe.flipY),N.pixelStorei(37441,oe.premultiplyAlpha),N.pixelStorei(3317,oe.unpackAlignment),ee.isDataTexture?N.texSubImage2D(3553,J,O.x,O.y,le,ze,rt,lt,ee.image.data):ee.isCompressedTexture?N.compressedTexSubImage2D(3553,J,O.x,O.y,ee.mipmaps[0].width,ee.mipmaps[0].height,rt,ee.mipmaps[0].data):N.texSubImage2D(3553,J,O.x,O.y,rt,lt,ee.image),J===0&&oe.generateMipmaps&&N.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(O,ee,oe,J,le=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ze=O.max.x-O.min.x+1,rt=O.max.y-O.min.y+1,lt=O.max.z-O.min.z+1,ct=Ee.convert(J.format),Dt=Ee.convert(J.type),yt;if(J.isData3DTexture)se.setTexture3D(J,0),yt=32879;else if(J.isDataArrayTexture)se.setTexture2DArray(J,0),yt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(37440,J.flipY),N.pixelStorei(37441,J.premultiplyAlpha),N.pixelStorei(3317,J.unpackAlignment);let mt=N.getParameter(3314),Di=N.getParameter(32878),pr=N.getParameter(3316),qs=N.getParameter(3315),fa=N.getParameter(32877),ei=oe.isCompressedTexture?oe.mipmaps[0]:oe.image;N.pixelStorei(3314,ei.width),N.pixelStorei(32878,ei.height),N.pixelStorei(3316,O.min.x),N.pixelStorei(3315,O.min.y),N.pixelStorei(32877,O.min.z),oe.isDataTexture||oe.isData3DTexture?N.texSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,Dt,ei.data):oe.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,ei.data)):N.texSubImage3D(yt,le,ee.x,ee.y,ee.z,ze,rt,lt,ct,Dt,ei),N.pixelStorei(3314,mt),N.pixelStorei(32878,Di),N.pixelStorei(3316,pr),N.pixelStorei(3315,qs),N.pixelStorei(32877,fa),le===0&&J.generateMipmaps&&N.generateMipmap(yt),Z.unbindTexture()},this.initTexture=function(O){O.isCubeTexture?se.setTextureCube(O,0):O.isData3DTexture?se.setTexture3D(O,0):O.isDataArrayTexture||O.isCompressedArrayTexture?se.setTexture2DArray(O,0):se.setTexture2D(O,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),de.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var aL=class extends mS{};aL.prototype.isWebGL1Renderer=!0;var gS=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new je(e),this.near=t,this.far=i}clone(){return new gS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},$n=class extends Et{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}},oL=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=qm,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Nr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Nr()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},Ui=new E,Zm=class{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyMatrix4(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.applyNormalMatrix(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ui.fromBufferAttribute(this,t),Ui.transformDirection(e),this.setXYZ(t,Ui.x,Ui.y,Ui.z);return this}setX(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=It(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=vn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=vn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=vn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=vn(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array),r=It(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=It(t,this.array),i=It(i,this.array),r=It(r,this.array),s=It(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Ye(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Zm(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let i=0;i<this.count;i++){let r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},vS=class extends Et{constructor(){super(),this.isBone=!0,this.type="Bone"}},_u=class extends ci{constructor(e=null,t=1,i=1,r,s,n,a,o,l=Lt,h=Lt,u,c){super(null,n,a,o,l,h,r,s,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},j1=new fe,lL=new fe,kv=class{constructor(e=[],t=[]){this.uuid=Nr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new fe;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,n=e.length;s<n;s++){let a=e[s]?e[s].matrixWorld:lL;j1.multiplyMatrices(a,t[s]),j1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new kv(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=tS(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new _u(t,e,e,zr,wr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],n=t[s];n===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),n=new vS),this.bones.push(n),this.boneInverses.push(new fe().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let n=t[r];e.bones.push(n.uuid);let a=i[r];e.boneInverses.push(a.toArray())}return e}},hL=class extends Ye{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},la=class extends Cc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new je(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},G1=new E,V1=new E,H1=new fe,Cf=new Rl,hd=new Sr,Su=class extends Et{constructor(e=new qe,t=new la){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)G1.fromBufferAttribute(t,r-1),V1.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=G1.distanceTo(V1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,n=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),hd.copy(i.boundingSphere),hd.applyMatrix4(r),hd.radius+=s,e.ray.intersectsSphere(hd)===!1)return;H1.copy(r).invert(),Cf.copy(e.ray).applyMatrix4(H1);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=a*a,l=new E,h=new E,u=new E,c=new E,d=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let g=Math.max(0,n.start),m=Math.min(p.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),Cf.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(c);_<e.near||_>e.far||t.push({distance:_,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let g=Math.max(0,n.start),m=Math.min(f.count,n.start+n.count);for(let v=g,y=m-1;v<y;v+=d){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Cf.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,s=i.length;r<s;r++){let n=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=r}}}}},W1=new E,q1=new E,Pc=class extends Su{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)W1.fromBufferAttribute(t,r),q1.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+W1.distanceTo(q1);e.setAttribute("lineDistance",new Le(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},cL=class extends ci{constructor(e,t,i,r,s,n,a,o,l){super(e,t,i,r,s,n,a,o,l),this.isVideoTexture=!0,this.minFilter=n!==void 0?n:nt,this.magFilter=s!==void 0?s:nt,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!("requestVideoFrameCallback"in e)&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},js=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],i,r=this.getPoint(0),s=0;t.push(0);for(let n=1;n<=e;n++)i=this.getPoint(n/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i=this.getLengths(),r=0,s=i.length,n;t?n=t:n=e*i[s-1];let a=0,o=s-1,l;for(;a<=o;)if(r=Math.floor(a+(o-a)/2),l=i[r]-n,l<0)a=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===n)return r/(s-1);let h=i[r],u=i[r+1]-h,c=(n-h)/u;return(r+c)/(s-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);let s=this.getPoint(i),n=this.getPoint(r),a=t||(s.isVector2?new k:new E);return a.copy(n).sub(s).normalize(),a}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],n=[],a=new E,o=new fe;for(let d=0;d<=e;d++){let p=d/e;r[d]=this.getTangentAt(p,new E)}s[0]=new E,n[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),u=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),c<=l&&i.set(0,0,1),a.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],a),n[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),n[d]=n[d-1].clone(),a.crossVectors(r[d-1],r[d]),a.length()>Number.EPSILON){a.normalize();let p=Math.acos(hi(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(o.makeRotationAxis(a,p))}n[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(hi(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(d=-d);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],d*p)),n[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:n}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},pp=class extends js{constructor(e=0,t=0,i=1,r=1,s=0,n=Math.PI*2,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(n?s=0:s=r),this.aClockwise===!0&&!n&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),c=o-this.aX,d=l-this.aY;o=c*h-d*u+this.aX,l=c*u+d*h+this.aY}return i.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},dL=class extends pp{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function Uv(){let e=0,t=0,i=0,r=0;function s(n,a,o,l){e=n,t=o,i=-3*n+3*a-2*o-l,r=2*n-2*a+o+l}return{initCatmullRom:function(n,a,o,l,h){s(a,o,h*(o-n),h*(l-a))},initNonuniformCatmullRom:function(n,a,o,l,h,u,c){let d=(a-n)/h-(o-n)/(h+u)+(o-a)/u,p=(o-a)/u-(l-a)/(u+c)+(l-o)/c;d*=u,p*=u,s(a,o,d,p)},calc:function(n){let a=n*n,o=a*n;return e+t*n+i*a+r*o}}}var cd=new E,Tf=new Uv,Pf=new Uv,Df=new Uv,uL=class extends js{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new E){let i=t,r=this.points,s=r.length,n=(s-(this.closed?0:1))*e,a=Math.floor(n),o=n-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:o===0&&a===s-1&&(a=s-2,o=1);let l,h;this.closed||a>0?l=r[(a-1)%s]:(cd.subVectors(r[0],r[1]).add(r[0]),l=cd);let u=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(cd.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=cd),this.curveType==="centripetal"||this.curveType==="chordal"){let d=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(u),d),f=Math.pow(u.distanceToSquared(c),d),g=Math.pow(c.distanceToSquared(h),d);f<1e-4&&(f=1),p<1e-4&&(p=f),g<1e-4&&(g=f),Tf.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,g),Pf.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,g),Df.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(Tf.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Pf.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Df.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Tf.calc(o),Pf.calc(o),Df.calc(o)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new E().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function X1(e,t,i,r,s){let n=(r-t)*.5,a=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+n+a)*l+(-3*i+3*r-2*n-a)*o+n*e+i}function pL(e,t){let i=1-e;return i*i*t}function fL(e,t){return 2*(1-e)*e*t}function mL(e,t){return e*e*t}function Wh(e,t,i,r){return pL(e,t)+fL(e,i)+mL(e,r)}function gL(e,t){let i=1-e;return i*i*i*t}function vL(e,t){let i=1-e;return 3*i*i*e*t}function yL(e,t){return 3*(1-e)*e*e*t}function xL(e,t){return e*e*e*t}function qh(e,t,i,r,s){return gL(e,t)+vL(e,i)+yL(e,r)+xL(e,s)}var $r=class extends js{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qh(e,r.x,s.x,n.x,a.x),qh(e,r.y,s.y,n.y,a.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ou=class extends js{constructor(e=new E,t=new E,i=new E,r=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set(qh(e,r.x,s.x,n.x,a.x),qh(e,r.y,s.y,n.y,a.y),qh(e,r.z,s.z,n.z,a.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},ss=class extends js{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},yS=class extends js{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},na=class extends js{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Wh(e,r.x,s.x,n.x),Wh(e,r.y,s.y,n.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},bL=class extends js{constructor(e=new E,t=new E,i=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new E){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Wh(e,r.x,s.x,n.x),Wh(e,r.y,s.y,n.y),Wh(e,r.z,s.z,n.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},jv=class extends js{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,n=Math.floor(s),a=s-n,o=r[n===0?n:n-1],l=r[n],h=r[n>r.length-2?r.length-1:n+1],u=r[n>r.length-3?r.length-1:n+2];return i.set(X1(a,o.x,l.x,h.x,u.x),X1(a,o.y,l.y,h.y,u.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},wL=Object.freeze({__proto__:null,ArcCurve:dL,CatmullRomCurve3:uL,CubicBezierCurve:$r,CubicBezierCurve3:ou,EllipseCurve:pp,LineCurve:ss,LineCurve3:yS,QuadraticBezierCurve:na,QuadraticBezierCurve3:bL,SplineCurve:jv}),xS=class extends js{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new ss(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let n=r[s]-i,a=this.curves[s],o=a.getLength(),l=o===0?0:1-n/o;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],i;for(let r=0,s=this.curves;r<s.length;r++){let n=s[r],a=n.isEllipseCurve?e*2:n.isLineCurve||n.isLineCurve3?1:n.isSplineCurve?e*n.points.length:e,o=n.getPoints(a);for(let l=0;l<o.length;l++){let h=o[l];i&&i.equals(h)||(t.push(h),i=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let r=e.curves[t];this.curves.push(new wL[r.type]().fromJSON(r))}return this}},Au=class extends xS{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ss(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new na(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new $r(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new jv(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,n){let a=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+a,t+o,i,r,s,n),this}absarc(e,t,i,r,s,n){return this.absellipse(e,t,i,i,r,s,n),this}ellipse(e,t,i,r,s,n,a,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,n,a,o),this}absellipse(e,t,i,r,s,n,a,o){let l=new pp(e,t,i,r,s,n,a,o);if(this.curves.length>0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},bS=class extends qe{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=hi(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,u=new E,c=new k,d=new E,p=new E,f=new E,g=0,m=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:g=e[v+1].x-e[v].x,m=e[v+1].y-e[v].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),b=Math.cos(y);for(let _=0;_<=e.length-1;_++){u.x=e[_].x*x,u.y=e[_].y,u.z=e[_].x*b,n.push(u.x,u.y,u.z),c.x=v/t,c.y=_/(e.length-1),a.push(c.x,c.y);let A=o[3*_+0]*x,S=o[3*_+1],w=o[3*_+0]*b;l.push(A,S,w)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,_=x+e.length,A=x+e.length+1,S=x+1;s.push(b,_,S),s.push(A,S,_)}this.setIndex(s),this.setAttribute("position",new Le(n,3)),this.setAttribute("uv",new Le(a,2)),this.setAttribute("normal",new Le(l,3))}static fromJSON(e){return new bS(e.points,e.segments,e.phiStart,e.phiLength)}},Gv=class extends qe{constructor(e=1,t=1,i=1,r=32,s=1,n=!1,a=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],u=[],c=[],d=[],p=0,f=[],g=i/2,m=0;v(),n===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Le(u,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(d,2));function v(){let x=new E,b=new E,_=0,A=(t-e)/i;for(let S=0;S<=s;S++){let w=[],M=S/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let D=T/r,P=D*o+a,L=Math.sin(P),B=Math.cos(P);b.x=C*L,b.y=-M*i+g,b.z=C*B,u.push(b.x,b.y,b.z),x.set(L,A,B).normalize(),c.push(x.x,x.y,x.z),d.push(D,1-M),w.push(p++)}f.push(w)}for(let S=0;S<r;S++)for(let w=0;w<s;w++){let M=f[w][S],C=f[w+1][S],T=f[w+1][S+1],D=f[w][S+1];h.push(M,C,D),h.push(C,T,D),_+=6}l.addGroup(m,_,0),m+=_}function y(x){let b=p,_=new k,A=new E,S=0,w=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)u.push(0,g*M,0),c.push(0,M,0),d.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+a,P=Math.cos(D),L=Math.sin(D);A.x=w*L,A.y=g*M,A.z=w*P,u.push(A.x,A.y,A.z),c.push(0,M,0),_.x=P*.5+.5,_.y=L*.5*M+.5,d.push(_.x,_.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(m,S,x===!0?1:2),m+=S}}static fromJSON(e){return new Gv(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},wS=class extends Gv{constructor(e=1,t=1,i=32,r=1,s=!1,n=0,a=Math.PI*2){super(0,e,t,i,r,s,n,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:n,thetaLength:a}}static fromJSON(e){return new wS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Vv=class extends qe{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],n=[];a(r),l(i),h(),this.setAttribute("position",new Le(s,3)),this.setAttribute("normal",new Le(s.slice(),3)),this.setAttribute("uv",new Le(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,x=new E,b=new E;for(let _=0;_<t.length;_+=3)d(t[_+0],y),d(t[_+1],x),d(t[_+2],b),o(y,x,b,v)}function o(v,y,x,b){let _=b+1,A=[];for(let S=0;S<=_;S++){A[S]=[];let w=v.clone().lerp(x,S/_),M=y.clone().lerp(x,S/_),C=_-S;for(let T=0;T<=C;T++)T===0&&S===_?A[S][T]=w:A[S][T]=w.clone().lerp(M,T/C)}for(let S=0;S<_;S++)for(let w=0;w<2*(_-S)-1;w++){let M=Math.floor(w/2);w%2===0?(c(A[S][M+1]),c(A[S+1][M]),c(A[S][M])):(c(A[S][M+1]),c(A[S+1][M+1]),c(A[S+1][M]))}}function l(v){let y=new E;for(let x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=g(v)/2/Math.PI+.5,b=m(v)/Math.PI+.5;n.push(x,1-b)}p(),u()}function u(){for(let v=0;v<n.length;v+=6){let y=n[v+0],x=n[v+2],b=n[v+4],_=Math.max(y,x,b),A=Math.min(y,x,b);_>.9&&A<.1&&(y<.2&&(n[v+0]+=1),x<.2&&(n[v+2]+=1),b<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,_=new k,A=new k,S=new k;for(let w=0,M=0;w<s.length;w+=9,M+=6){v.set(s[w+0],s[w+1],s[w+2]),y.set(s[w+3],s[w+4],s[w+5]),x.set(s[w+6],s[w+7],s[w+8]),_.set(n[M+0],n[M+1]),A.set(n[M+2],n[M+3]),S.set(n[M+4],n[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=g(b);f(_,M+0,v,C),f(A,M+2,y,C),f(S,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(n[y]=v.x-1),x.x===0&&x.z===0&&(n[y]=b/2/Math.PI+.5)}function g(v){return Math.atan2(v.z,-v.x)}function m(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new Vv(e.vertices,e.indices,e.radius,e.details)}},_S=class extends Vv{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=1/i,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],n=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,n,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new _S(e.radius,e.detail)}},Mu=class extends Au{constructor(e){super(e),this.uuid=Nr(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let r=e.holes[t];this.holes.push(new Au().fromJSON(r))}return this}},_L={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=SS(e,0,s,i,!0),a=[];if(!n||n.next===n.prev)return a;let o,l,h,u,c,d,p;if(r&&(n=CL(e,t,n,i)),e.length>80*i){o=h=e[0],l=u=e[1];for(let f=i;f<s;f+=i)c=e[f],d=e[f+1],c<o&&(o=c),d<l&&(l=d),c>h&&(h=c),d>u&&(u=d);p=Math.max(h-o,u-l),p=p!==0?32767/p:0}return oc(n,a,i,o,l,p,0),a}};function SS(e,t,i,r,s){let n,a;if(s===NL(e,t,i,r)>0)for(n=t;n<i;n+=r)a=Y1(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=Y1(n,e[n],e[n+1],a);return a&&fp(a,a.next)&&(hc(a),a=a.next),a}function Za(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(fp(i,i.next)||Ut(i.prev,i,i.next)===0)){if(hc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function oc(e,t,i,r,s,n,a){if(!e)return;!a&&n&&LL(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?AL(e,r,s,n):SL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),hc(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=ML(Za(e),t,i),oc(e,t,i,r,s,n,2)):a===2&&EL(e,t,i,r,s,n):oc(Za(e),t,i,r,s,n,1);break}}}function SL(e){let t=e.prev,i=e,r=e.next;if(Ut(t,i,r)>=0)return!1;let s=t.x,n=i.x,a=r.x,o=t.y,l=i.y,h=r.y,u=s<n?s<a?s:a:n<a?n:a,c=o<l?o<h?o:h:l<h?l:h,d=s>n?s>a?s:a:n>a?n:a,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Zo(s,o,n,l,a,h,f.x,f.y)&&Ut(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function AL(e,t,i,r){let s=e.prev,n=e,a=e.next;if(Ut(s,n,a)>=0)return!1;let o=s.x,l=n.x,h=a.x,u=s.y,c=n.y,d=a.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,g=o>l?o>h?o:h:l>h?l:h,m=u>c?u>d?u:d:c>d?c:d,v=Km(p,f,t,i,r),y=Km(g,m,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Zo(o,u,l,c,h,d,x.x,x.y)&&Ut(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Zo(o,u,l,c,h,d,b.x,b.y)&&Ut(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&Zo(o,u,l,c,h,d,x.x,x.y)&&Ut(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&Zo(o,u,l,c,h,d,b.x,b.y)&&Ut(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ML(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!fp(s,n)&&AS(s,r,r.next,n)&&lc(s,n)&&lc(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),hc(r),hc(r.next),r=e=n),r=r.next}while(r!==e);return Za(r)}function EL(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&BL(a,o)){let l=MS(a,o);a=Za(a,a.next),l=Za(l,l.next),oc(a,t,i,r,s,n,0),oc(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function CL(e,t,i,r){let s=[],n,a,o,l,h;for(n=0,a=t.length;n<a;n++)o=t[n]*r,l=n<a-1?t[n+1]*r:e.length,h=SS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(RL(h));for(s.sort(TL),n=0;n<s.length;n++)i=PL(s[n],i);return i}function TL(e,t){return e.x-t.x}function PL(e,t){let i=DL(e,t);if(!i)return t;let r=MS(i,e);return Za(r,r.next),Za(i,i.next)}function DL(e,t){let i=t,r=-1/0,s,n=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){let d=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(d<=n&&d>r&&(r=d,s=i.x<i.next.x?i:i.next,d===n))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,u=1/0,c;i=s;do n>=i.x&&i.x>=l&&n!==i.x&&Zo(a<h?n:r,a,l,h,a<h?r:n,a,i.x,i.y)&&(c=Math.abs(a-i.y)/(n-i.x),lc(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&IL(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function IL(e,t){return Ut(e.prev,e,t.prev)<0&&Ut(t.next,e,e.next)<0}function LL(e,t,i,r){let s=e;do s.z===0&&(s.z=Km(s.x,s.y,t,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,OL(s)}function OL(e){let t,i,r,s,n,a,o,l,h=1;do{for(i=e,e=null,n=null,a=0;i;){for(a++,r=i,o=0,t=0;t<h&&(o++,r=r.nextZ,!!r);t++);for(l=h;o>0||l>0&&r;)o!==0&&(l===0||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:e=s,s.prevZ=n,n=s;i=r}n.nextZ=null,h*=2}while(a>1);return e}function Km(e,t,i,r,s){return e=(e-i)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function RL(e){let t=e,i=e;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==e);return i}function Zo(e,t,i,r,s,n,a,o){return(s-a)*(t-o)>=(e-a)*(n-o)&&(e-a)*(r-o)>=(i-a)*(t-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function BL(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!zL(e,t)&&(lc(e,t)&&lc(t,e)&&FL(e,t)&&(Ut(e.prev,e,t.prev)||Ut(e,t.prev,t))||fp(e,t)&&Ut(e.prev,e,e.next)>0&&Ut(t.prev,t,t.next)>0)}function Ut(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function fp(e,t){return e.x===t.x&&e.y===t.y}function AS(e,t,i,r){let s=ud(Ut(e,t,i)),n=ud(Ut(e,t,r)),a=ud(Ut(i,r,e)),o=ud(Ut(i,r,t));return!!(s!==n&&a!==o||s===0&&dd(e,i,t)||n===0&&dd(e,r,t)||a===0&&dd(i,e,r)||o===0&&dd(i,t,r))}function dd(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function ud(e){return e>0?1:e<0?-1:0}function zL(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&AS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function lc(e,t){return Ut(e.prev,e,e.next)<0?Ut(e,t,e.next)>=0&&Ut(e,e.prev,t)>=0:Ut(e,t,e.prev)<0||Ut(e,e.next,t)<0}function FL(e,t){let i=e,r=!1,s=(e.x+t.x)/2,n=(e.y+t.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function MS(e,t){let i=new Jm(e.i,e.x,e.y),r=new Jm(t.i,t.x,t.y),s=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Y1(e,t,i,r){let s=new Jm(e,t,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function hc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Jm(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function NL(e,t,i,r){let s=0;for(let n=t,a=i-r;n<i;n+=r)s+=(e[a]-e[n])*(e[n+1]+e[a+1]),a=n;return s}var ES=class{static area(e){let t=e.length,i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return ES.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];Q1(e),Z1(i,e);let n=e.length;t.forEach(Q1);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,Z1(i,t[o]);let a=_L.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function Q1(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Z1(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var CS=class extends Vv{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new CS(e.radius,e.detail)}},Hv=class extends qe{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,n=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:n,thetaLength:a},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(n+a,Math.PI),l=0,h=[],u=new E,c=new E,d=[],p=[],f=[],g=[];for(let m=0;m<=i;m++){let v=[],y=m/i,x=0;m==0&&n==0?x=.5/t:m==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let _=b/t;u.x=-e*Math.cos(r+_*s)*Math.sin(n+y*a),u.y=e*Math.cos(n+y*a),u.z=e*Math.sin(r+_*s)*Math.sin(n+y*a),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.z),g.push(_+x,1-y),v.push(l++)}h.push(v)}for(let m=0;m<i;m++)for(let v=0;v<t;v++){let y=h[m][v+1],x=h[m][v],b=h[m+1][v],_=h[m+1][v+1];(m!==0||n>0)&&d.push(y,x,_),(m!==i-1||o<Math.PI)&&d.push(x,b,_)}this.setIndex(d),this.setAttribute("position",new Le(p,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(g,2))}static fromJSON(e){return new Hv(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},TS=class extends qe{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:n},i=Math.floor(i),r=Math.floor(r);let a=[],o=[],l=[],h=[],u=new E,c=new E,d=new E,p=new E,f=new E,g=new E,m=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,n,e,d),v(x+.01,s,n,e,p),g.subVectors(p,d),m.addVectors(p,d),f.crossVectors(g,m),m.crossVectors(f,g),f.normalize(),m.normalize();for(let b=0;b<=r;++b){let _=b/r*Math.PI*2,A=-t*Math.cos(_),S=t*Math.sin(_);u.x=d.x+(A*m.x+S*f.x),u.y=d.y+(A*m.y+S*f.y),u.z=d.z+(A*m.z+S*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),_=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;a.push(b,_,S),a.push(_,A,S)}this.setIndex(a),this.setAttribute("position",new Le(o,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(h,2));function v(y,x,b,_,A){let S=Math.cos(y),w=Math.sin(y),M=b/x*y,C=Math.cos(M);A.x=_*(2+C)*.5*S,A.y=_*(2+C)*w*.5,A.z=_*Math.sin(M)*.5}}static fromJSON(e){return new TS(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function In(e,t,i){return PS(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function pd(e,t,i){return!e||!i&&e.constructor===t?e:typeof t.BYTES_PER_ELEMENT=="number"?new t(e):Array.prototype.slice.call(e)}function PS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function kL(e){function t(s,n){return e[s]-e[n]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function K1(e,t,i){let r=e.length,s=new e.constructor(r);for(let n=0,a=0;a!==r;++n){let o=i[n]*t;for(let l=0;l!==t;++l)s[a++]=e[o+l]}return s}function DS(e,t,i,r){let s=1,n=e[0];for(;n!==void 0&&n[r]===void 0;)n=e[s++];if(n===void 0)return;let a=n[r];if(a!==void 0)if(Array.isArray(a))do a=n[r],a!==void 0&&(t.push(n.time),i.push.apply(i,a)),n=e[s++];while(n!==void 0);else if(a.toArray!==void 0)do a=n[r],a!==void 0&&(t.push(n.time),a.toArray(i,i.length)),n=e[s++];while(n!==void 0);else do a=n[r],a!==void 0&&(t.push(n.time),i.push(a)),n=e[s++];while(n!==void 0)}var mp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let n;i:{r:if(!(e<r)){for(let a=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=r,r=t[++i],e<r)break t}n=t.length;break i}if(!(e>=s)){let a=t[1];e<a&&(i=2,s=a);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}n=i,i=0;break i}break e}for(;i<n;){let a=i+n>>>1;e<t[a]?n=a:i=a+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let n=0;n!==r;++n)t[n]=i[s+n];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},UL=class extends mp{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:qo,endingEnd:qo}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,n=e+1,a=r[s],o=r[n];if(a===void 0)switch(this.getSettings_().endingStart){case Xo:s=e,a=2*t-i;break;case yu:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=i}if(o===void 0)switch(this.getSettings_().endingEnd){case Xo:n=e,o=2*i-t;break;case yu:n=1,o=i+r[1]-r[0];break;default:n=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=n*h}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=this._offsetPrev,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(i-t)/(r-t),f=p*p,g=f*p,m=-c*g+2*c*f-c*p,v=(1+c)*g+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*g+(1.5+d)*f+.5*p,x=d*g-d*f;for(let b=0;b!==a;++b)s[b]=m*n[h+b]+v*n[l+b]+y*n[o+b]+x*n[u+b];return s}},IS=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=e*a,l=o-a,h=(i-t)/(r-t),u=1-h;for(let c=0;c!==a;++c)s[c]=n[l+c]*u+n[o+c]*h;return s}},jL=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Gs=class{constructor(e,t,i,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=pd(t,this.TimeBufferType),this.values=pd(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:pd(e.times,Array),values:pd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new jL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new IS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new UL(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case gu:t=this.InterpolantFactoryMethodDiscrete;break;case vu:t=this.InterpolantFactoryMethodLinear;break;case ef:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gu;case this.InterpolantFactoryMethodLinear:return vu;case this.InterpolantFactoryMethodSmooth:return ef}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){let i=this.times,r=i.length,s=0,n=r-1;for(;s!==r&&i[s]<e;)++s;for(;n!==-1&&i[n]>t;)--n;if(++n,s!==0||n!==r){s>=n&&(n=Math.max(n,1),s=n-1);let a=this.getValueSize();this.times=In(i,s,n),this.values=In(this.values,s*a,n*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let a=0;a!==s;a++){let o=i[a];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,o),e=!1;break}if(n!==null&&n>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,o,n),e=!1;break}n=o}if(r!==void 0&&PS(r))for(let a=0,o=r.length;a!==o;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=In(this.times),t=In(this.values),i=this.getValueSize(),r=this.getInterpolation()===ef,s=e.length-1,n=1;for(let a=1;a<s;++a){let o=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(r)o=!0;else{let u=a*i,c=u-i,d=u+i;for(let p=0;p!==i;++p){let f=t[u+p];if(f!==t[c+p]||f!==t[d+p]){o=!0;break}}}if(o){if(a!==n){e[n]=e[a];let u=a*i,c=n*i;for(let d=0;d!==i;++d)t[c+d]=t[u+d]}++n}}if(s>0){e[n]=e[s];for(let a=s*i,o=n*i,l=0;l!==i;++l)t[o+l]=t[a+l];++n}return n!==e.length?(this.times=In(e,0,n),this.values=In(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=In(this.times,0),t=In(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Gs.prototype.TimeBufferType=Float32Array;Gs.prototype.ValueBufferType=Float32Array;Gs.prototype.DefaultInterpolation=vu;var Nl=class extends Gs{};Nl.prototype.ValueTypeName="bool";Nl.prototype.ValueBufferType=Array;Nl.prototype.DefaultInterpolation=gu;Nl.prototype.InterpolantFactoryMethodLinear=void 0;Nl.prototype.InterpolantFactoryMethodSmooth=void 0;var LS=class extends Gs{};LS.prototype.ValueTypeName="color";var Eu=class extends Gs{};Eu.prototype.ValueTypeName="number";var GL=class extends mp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-t)/(r-t),l=e*a;for(let h=l+a;l!==h;l+=4)it.slerpFlat(s,0,n,l-a,n,l,o);return s}},Dc=class extends Gs{InterpolantFactoryMethodLinear(e){return new GL(this.times,this.values,this.getValueSize(),e)}};Dc.prototype.ValueTypeName="quaternion";Dc.prototype.DefaultInterpolation=vu;Dc.prototype.InterpolantFactoryMethodSmooth=void 0;var kl=class extends Gs{};kl.prototype.ValueTypeName="string";kl.prototype.ValueBufferType=Array;kl.prototype.DefaultInterpolation=gu;kl.prototype.InterpolantFactoryMethodLinear=void 0;kl.prototype.InterpolantFactoryMethodSmooth=void 0;var Cu=class extends Gs{};Cu.prototype.ValueTypeName="vector";var $m=class{constructor(e,t=-1,i,r=Lv){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Nr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let n=0,a=i.length;n!==a;++n)t.push(HL(i[n]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,n=i.length;s!==n;++s)t.push(Gs.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,n=[];for(let a=0;a<s;a++){let o=[],l=[];o.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let h=kL(o);o=K1(o,1,h),l=K1(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),n.push(new Eu(".morphTargetInfluences["+t[a].name+"]",o,l).scale(1/i))}return new this(e,-1,n)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,o=e.length;a<o;a++){let l=e[a],h=l.name.match(s);if(h&&h.length>1){let u=h[1],c=r[u];c||(r[u]=c=[]),c.push(l)}}let n=[];for(let a in r)n.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,u,c,d,p){if(c.length!==0){let f=[],g=[];DS(c,f,g,d),f.length!==0&&p.push(new h(u,f,g))}},r=[],s=e.name||"default",n=e.fps||30,a=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let u=l[h].keys;if(!(!u||u.length===0))if(u[0].morphTargets){let c={},d;for(d=0;d<u.length;d++)if(u[d].morphTargets)for(let p=0;p<u[d].morphTargets.length;p++)c[u[d].morphTargets[p]]=-1;for(let p in c){let f=[],g=[];for(let m=0;m!==u[d].morphTargets.length;++m){let v=u[d];f.push(v.time),g.push(v.morphTarget===p?1:0)}r.push(new Eu(".morphTargetInfluence["+p+"]",f,g))}o=c.length*n}else{let c=".bones["+t[h].name+"]";i(Cu,c+".position",u,"pos",r),i(Dc,c+".quaternion",u,"rot",r),i(Cu,c+".scale",u,"scl",r)}}return r.length===0?null:new this(s,o,r,a)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function VL(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Eu;case"vector":case"vector2":case"vector3":case"vector4":return Cu;case"color":return LS;case"quaternion":return Dc;case"bool":case"boolean":return Nl;case"string":return kl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function HL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=VL(e.type);if(e.times===void 0){let i=[],r=[];DS(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var J1={enabled:!1,files:{},add:function(e,t){this.enabled!==!1&&(this.files[e]=t)},get:function(e){if(this.enabled!==!1)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},OS=class{constructor(e,t,i){let r=this,s=!1,n=0,a=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){a++,s===!1&&r.onStart!==void 0&&r.onStart(h,n,a),s=!0},this.itemEnd=function(h){n++,r.onProgress!==void 0&&r.onProgress(h,n,a),n===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return o?o(h):h},this.setURLModifier=function(h){return o=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,c=l.length;u<c;u+=2){let d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}},WL=new OS,Wv=class{constructor(e){this.manager=e!==void 0?e:WL,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise(function(r,s){i.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},Js={},qL=class extends Error{constructor(e,t){super(e),this.response=t}},eg=class extends Wv{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=J1.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Js[e]!==void 0){Js[e].push({onLoad:t,onProgress:i,onError:r});return}Js[e]=[],Js[e].push({onLoad:t,onProgress:i,onError:r});let n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(n).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Js[e],u=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=c?parseInt(c):0,p=d!==0,f=0,g=new ReadableStream({start(m){v();function v(){u.read().then(({done:y,value:x})=>{if(y)m.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let _=0,A=h.length;_<A;_++){let S=h[_];S.onProgress&&S.onProgress(b)}m.enqueue(x),v()}})}}});return new Response(g)}else throw new qL(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(o){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),u=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(u);return l.arrayBuffer().then(d=>c.decode(d))}}}).then(l=>{J1.add(e,l);let h=Js[e];delete Js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=Js[e];if(h===void 0)throw this.manager.itemError(e),l;delete Js[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Ic=class extends Et{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new je(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},XL=class extends Ic{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.groundColor=new je(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},If=new fe,$1=new E,ex=new E,qv=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zv,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new et(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;$1.setFromMatrixPosition(e.matrixWorld),t.position.copy($1),ex.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ex),t.updateMatrixWorld(),If.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(If),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(If)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},YL=class extends qv{constructor(){super(new Oi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=ac*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},QL=class extends Ic{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new YL}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},tx=new fe,dh=new E,Lf=new E,ZL=class extends qv{constructor(){super(new Oi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new et(2,1,1,1),new et(0,1,1,1),new et(3,1,1,1),new et(1,1,1,1),new et(3,0,1,1),new et(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),dh.setFromMatrixPosition(e.matrixWorld),i.position.copy(dh),Lf.copy(i.position),Lf.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Lf),i.updateMatrixWorld(),r.makeTranslation(-dh.x,-dh.y,-dh.z),tx.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tx)}},KL=class extends Ic{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new ZL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},JL=class extends qv{constructor(){super(new Fv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},$L=class extends Ic{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Et.DEFAULT_UP),this.updateMatrix(),this.target=new Et,this.shadow=new JL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},eO=class extends qe{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},RS=class extends Wv{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new eg(s.manager);n.setPath(s.path),n.setRequestHeader(s.requestHeader),n.setWithCredentials(s.withCredentials),n.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,d){if(t[d]!==void 0)return t[d];let p=c.interleavedBuffers[d],f=s(c,p.buffer),g=Hc(p.type,f),m=new oL(g,p.stride);return m.uuid=p.uuid,t[d]=m,m}function s(c,d){if(i[d]!==void 0)return i[d];let p=c.arrayBuffers[d],f=new Uint32Array(p).buffer;return i[d]=f,f}let n=e.isInstancedBufferGeometry?new eO:new qe,a=e.data.index;if(a!==void 0){let c=Hc(a.type,a.array);n.setIndex(new Ye(c,1))}let o=e.data.attributes;for(let c in o){let d=o[c],p;if(d.isInterleavedBufferAttribute){let f=r(e.data,d.data);p=new Zm(f,d.itemSize,d.offset,d.normalized)}else{let f=Hc(d.type,d.array),g=d.isInstancedBufferAttribute?hL:Ye;p=new g(f,d.itemSize,d.normalized)}d.name!==void 0&&(p.name=d.name),d.usage!==void 0&&p.setUsage(d.usage),d.updateRange!==void 0&&(p.updateRange.offset=d.updateRange.offset,p.updateRange.count=d.updateRange.count),n.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let d=l[c],p=[];for(let f=0,g=d.length;f<g;f++){let m=d[f],v;if(m.isInterleavedBufferAttribute){let y=r(e.data,m.data);v=new Zm(y,m.itemSize,m.offset,m.normalized)}else{let y=Hc(m.type,m.array);v=new Ye(y,m.itemSize,m.normalized)}m.name!==void 0&&(v.name=m.name),p.push(v)}n.morphAttributes[c]=p}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,d=h.length;c!==d;++c){let p=h[c];n.addGroup(p.start,p.count,p.materialIndex)}let u=e.data.boundingSphere;if(u!==void 0){let c=new E;u.center!==void 0&&c.fromArray(u.center),n.boundingSphere=new Sr(c,u.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},tO=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=ix(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=ix();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function ix(){return(typeof performance>"u"?Date:performance).now()}var iO=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,n;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,n=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,n=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,n=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=n,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,n=this.cumulativeWeight;if(n===0){for(let a=0;a!==r;++a)i[s+a]=i[a];n=t}else{n+=t;let a=t/n;this._mixBufferRegion(i,s,0,a,r)}this.cumulativeWeight=n}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,n=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}n>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){a.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,n=r;s!==n;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let n=0;n!==s;++n)e[t+n]=e[i+n]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let n=this._workIndex*s;it.multiplyQuaternionsFlat(e,n,e,t,e,i),it.slerpFlat(e,t,e,t,e,n,r)}_lerp(e,t,i,r,s){let n=1-r;for(let a=0;a!==s;++a){let o=t+a;e[o]=e[o]*n+e[i+a]*r}}_lerpAdditive(e,t,i,r,s){for(let n=0;n!==s;++n){let a=t+n;e[a]=e[a]+e[i+n]*r}}},Xv="\\[\\]\\.:\\/",rO=new RegExp("["+Xv+"]","g"),Yv="[^"+Xv+"]",sO="[^"+Xv.replace("\\.","")+"]",nO=/((?:WC+[\/:])*)/.source.replace("WC",Yv),aO=/(WCOD+)?/.source.replace("WCOD",sO),oO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yv),lO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yv),hO=new RegExp("^"+nO+aO+oO+lO+"$"),cO=["material","materials","bones","map"],dO=class{constructor(e,t,i){let r=i||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Tt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,i):new Tt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(rO,"")}static parseTrackName(e){let t=hO.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=i.nodeName.substring(r+1);cO.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){let i=function(s){for(let n=0;n<s.length;n++){let a=s[n];if(a.name===t||a.uuid===t)return a;let o=i(a.children);if(o)return o}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,i=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(i){let l=t.objectIndex;switch(i){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let n=e[r];if(n===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let o=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}o=this.BindingType.ArrayElement,this.resolvedProperty=n,this.propertyIndex=s}else n.fromArray!==void 0&&n.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=n):Array.isArray(n)?(o=this.BindingType.EntireArray,this.resolvedProperty=n):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Tt.Composite=dO;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var uO=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,n=s.length,a=new Array(n),o={endingStart:qo,endingEnd:qo};for(let l=0;l!==n;++l){let h=s[l].createInterpolant(null);a[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=$_,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,n=s/r,a=r/s;e.warp(1,n,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,n=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,l=a.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/n,l[1]=t/n,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let n=this._updateTime(t),a=this._updateWeight(e);if(a>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case qC:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(n),l[h].accumulateAdditive(a);break;case Lv:default:for(let h=0,u=o.length;h!==u;++h)o[h].evaluate(n),l[h].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,n=i===Iv;if(e===0)return s===-1?r:n&&(s&1)===1?t-r:r;if(i===J_){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,n)}else this._setEndings(!1,!1,n);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(n&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=Xo,r.endingEnd=Xo):(e?r.endingStart=this.zeroSlopeAtStart?Xo:qo:r.endingStart=yu,t?r.endingEnd=this.zeroSlopeAtEnd?Xo:qo:r.endingEnd=yu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,n=this._weightInterpolant;n===null&&(n=r._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=s,o[0]=t,a[1]=s+e,o[1]=i,this}},pO=new Float32Array(1),fO=class extends Ti{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,n=e._propertyBindings,a=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let u=0;u!==s;++u){let c=r[u],d=c.name,p=h[d];if(p!==void 0)++p.referenceCount,n[u]=p;else{if(p=n[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,d));continue}let f=t&&t._propertyBindings[u].binding.parsedPath;p=new iO(Tt.create(i,d,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,d),n[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,n=s[t];if(n===void 0)n={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=n;else{let a=n.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),n.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,n=this._actionsByClip,a=n[s],o=a.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,c=(e._localRoot||this._root).uuid;delete u[c],o.length===0&&delete n[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,n=r[t];n===void 0&&(n={},r[t]=n),n[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,n=this._bindingsByRootAndName,a=n[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete a[s],Object.keys(a).length===0&&delete n[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new IS(new Float32Array(2),new Float32Array(2),1,pO),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,n=typeof e=="string"?$m.findByName(r,e):e,a=n!==null?n.uuid:e,o=this._actionsByClip[a],l=null;if(i===void 0&&(n!==null?i=n.blendMode:i=Lv),o!==void 0){let u=o.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=o.knownActions[0],n===null&&(n=l._clip)}if(n===null)return null;let h=new uO(this,n,t,i);return this._bindAction(h,l),this._addInactiveAction(h,a,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?$m.findByName(i,e):e,n=s?s.uuid:e,a=this._actionsByClip[n];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),n=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,n);let a=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)a[l].apply(n);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let n=s.knownActions;for(let a=0,o=n.length;a!==o;++a){let l=n[a];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let n in i){let a=i[n].actionByRoot,o=a[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let n in s){let a=s[n];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},pe=class{constructor(e){this.value=e}clone(){return new pe(this.value.clone===void 0?this.value:this.value.clone())}},BS=class{constructor(e,t,i=0,r=1/0){this.ray=new Rl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Rv,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return tg(e,this,i,t),i.sort(rx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)tg(e[r],this,i,t);return i.sort(rx),i}};function rx(e,t){return e.distance-t.distance}function tg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let n=0,a=s.length;n<a;n++)tg(s[n],t,i,!0)}}var sx=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(hi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},nx=new k,mO=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=nx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return nx.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ax=new E,fd=new E,kr=class{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){ax.subVectors(e,this.start),fd.subVectors(this.end,this.start);let i=fd.dot(fd),r=fd.dot(ax)/i;return t&&(r=hi(r,0,1)),r}closestPointToPoint(e,t,i){let r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},ox=new E,gO=class extends Et{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new qe,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let n=0,a=1,o=32;n<o;n++,a++){let l=n/o*Math.PI*2,h=a/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Le(r,3));let s=new la({fog:!1,toneMapped:!1});this.cone=new Pc(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ox.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ox),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},vO=class extends nr{constructor(e,t,i){let r=new Hv(t,4,2),s=new Tc({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},lx=new E,md=new E,hx=new E,yO=class extends Et{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new qe;r.setAttribute("position",new Le([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new la({fog:!1,toneMapped:!1});this.lightPlane=new Su(r,s),this.add(this.lightPlane),r=new qe,r.setAttribute("position",new Le([0,0,0,0,0,1],3)),this.targetLine=new Su(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),lx.setFromMatrixPosition(this.light.matrixWorld),md.setFromMatrixPosition(this.light.target.matrixWorld),hx.subVectors(md,lx),this.lightPlane.lookAt(md),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(md),this.targetLine.scale.z=hx.length()}},gd=new E,jt=new zl,Tu=class extends Pc{constructor(e){let t=new qe,i=new la({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],n={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),n[p]===void 0&&(n[p]=[]),n[p].push(r.length/3-1)}t.setAttribute("position",new Le(r,3)),t.setAttribute("color",new Le(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update();let l=new je(16755200),h=new je(16711680),u=new je(43775),c=new je(16777215),d=new je(3355443);this.setColors(l,h,u,c,d)}setColors(e,t,i,r,s){let n=this.geometry.getAttribute("color");n.setXYZ(0,e.r,e.g,e.b),n.setXYZ(1,e.r,e.g,e.b),n.setXYZ(2,e.r,e.g,e.b),n.setXYZ(3,e.r,e.g,e.b),n.setXYZ(4,e.r,e.g,e.b),n.setXYZ(5,e.r,e.g,e.b),n.setXYZ(6,e.r,e.g,e.b),n.setXYZ(7,e.r,e.g,e.b),n.setXYZ(8,e.r,e.g,e.b),n.setXYZ(9,e.r,e.g,e.b),n.setXYZ(10,e.r,e.g,e.b),n.setXYZ(11,e.r,e.g,e.b),n.setXYZ(12,e.r,e.g,e.b),n.setXYZ(13,e.r,e.g,e.b),n.setXYZ(14,e.r,e.g,e.b),n.setXYZ(15,e.r,e.g,e.b),n.setXYZ(16,e.r,e.g,e.b),n.setXYZ(17,e.r,e.g,e.b),n.setXYZ(18,e.r,e.g,e.b),n.setXYZ(19,e.r,e.g,e.b),n.setXYZ(20,e.r,e.g,e.b),n.setXYZ(21,e.r,e.g,e.b),n.setXYZ(22,e.r,e.g,e.b),n.setXYZ(23,e.r,e.g,e.b),n.setXYZ(24,t.r,t.g,t.b),n.setXYZ(25,t.r,t.g,t.b),n.setXYZ(26,t.r,t.g,t.b),n.setXYZ(27,t.r,t.g,t.b),n.setXYZ(28,t.r,t.g,t.b),n.setXYZ(29,t.r,t.g,t.b),n.setXYZ(30,t.r,t.g,t.b),n.setXYZ(31,t.r,t.g,t.b),n.setXYZ(32,i.r,i.g,i.b),n.setXYZ(33,i.r,i.g,i.b),n.setXYZ(34,i.r,i.g,i.b),n.setXYZ(35,i.r,i.g,i.b),n.setXYZ(36,i.r,i.g,i.b),n.setXYZ(37,i.r,i.g,i.b),n.setXYZ(38,r.r,r.g,r.b),n.setXYZ(39,r.r,r.g,r.b),n.setXYZ(40,s.r,s.g,s.b),n.setXYZ(41,s.r,s.g,s.b),n.setXYZ(42,s.r,s.g,s.b),n.setXYZ(43,s.r,s.g,s.b),n.setXYZ(44,s.r,s.g,s.b),n.setXYZ(45,s.r,s.g,s.b),n.setXYZ(46,s.r,s.g,s.b),n.setXYZ(47,s.r,s.g,s.b),n.setXYZ(48,s.r,s.g,s.b),n.setXYZ(49,s.r,s.g,s.b),n.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;jt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),qt("c",t,e,jt,0,0,-1),qt("t",t,e,jt,0,0,1),qt("n1",t,e,jt,-i,-r,-1),qt("n2",t,e,jt,i,-r,-1),qt("n3",t,e,jt,-i,r,-1),qt("n4",t,e,jt,i,r,-1),qt("f1",t,e,jt,-i,-r,1),qt("f2",t,e,jt,i,-r,1),qt("f3",t,e,jt,-i,r,1),qt("f4",t,e,jt,i,r,1),qt("u1",t,e,jt,i*.7,r*1.1,-1),qt("u2",t,e,jt,-i*.7,r*1.1,-1),qt("u3",t,e,jt,0,r*2,-1),qt("cf1",t,e,jt,-i,0,1),qt("cf2",t,e,jt,i,0,1),qt("cf3",t,e,jt,0,-r,1),qt("cf4",t,e,jt,0,r,1),qt("cn1",t,e,jt,-i,0,-1),qt("cn2",t,e,jt,i,0,-1),qt("cn3",t,e,jt,0,-r,-1),qt("cn4",t,e,jt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function qt(e,t,i,r,s,n,a){gd.set(s,n,a).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,u=o.length;h<u;h++)l.setXYZ(o[h],gd.x,gd.y,gd.z)}}var Pu=class extends Pc{constructor(e,t=16776960){let i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new qe;s.setIndex(new Ye(i,1)),s.setAttribute("position",new Le(r,3)),super(s,new la({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},xO=class extends Pc{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new qe;r.setAttribute("position",new Le(t,3)),r.setAttribute("color",new Le(i,3));let s=new la({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new je,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ol}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ol);var uh=".",Qv=Symbol("target"),zS=Symbol("unsubscribe");function ig(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function bO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var Cs=Array.isArray;function Zv(e){return typeof e=="symbol"}var wO={after:(e,t)=>Cs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>Cs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=uh),Zv(t)?e+t.toString():e+t):e,initial:e=>{if(Cs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(uh);return t===-1?"":e.slice(0,t)},last:e=>{if(Cs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(uh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(Cs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(uh);if(r===-1)t(e);else for(;i<e.length;)r===-1&&(r=e.length),t(e.slice(i,r)),i=r+1,r=e.indexOf(uh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Or=wO;function _O(e){return typeof e=="object"&&typeof e.next=="function"}function SO(e,t,i,r,s){let n=e.next;if(t.name==="entries")e.next=function(){let a=n.call(this);return a.done===!1&&(a.value[0]=s(a.value[0],t,a.value[0],r),a.value[1]=s(a.value[1],t,a.value[0],r)),a};else if(t.name==="values"){let a=i[Qv].keys();e.next=function(){let o=n.call(this);return o.done===!1&&(o.value=s(o.value,t,a.next().value,r)),o}}else e.next=function(){let a=n.call(this);return a.done===!1&&(a.value=s(a.value,t,a.value,r)),a};return e}function cx(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&Zv(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var AO=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),i=t.get(e);return i===void 0&&(i={},t.set(e,i)),i}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let i=this._getProperties(e),r=i[t];return r===void 0&&(r=Reflect.getOwnPropertyDescriptor(e,t),i[t]=r),r}getProxy(e,t,i,r){if(this.isUnsubscribed)return e;let s=e[r],n=s||e;this._pathCache.set(n,t);let a=this._proxyCache.get(n);return a===void 0&&(a=s===void 0?new Proxy(e,i):e,this._proxyCache.set(n,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Or.get(t,this.getPath(e)))}defineProperty(e,t,i){return Reflect.defineProperty(e,t,i)?(this.isUnsubscribed||(this._getProperties(e)[t]=i),!0):!1}setProperty(e,t,i,r,s){if(!this._equals(s,i)||!(t in e)){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&"set"in n?Reflect.set(e,t,i,r):Reflect.set(e,t,i)}return!0}deleteProperty(e,t,i){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let r=this._getDescriptorCache().get(e);r&&(delete r[t],this._pathCache.delete(i))}return!0}return!1}isSameDescriptor(e,t,i){let r=this._getOwnPropertyDescriptor(t,i);return e!==void 0&&r!==void 0&&Object.is(e.value,r.value)&&(e.writable||!1)===(r.writable||!1)&&(e.enumerable||!1)===(r.enumerable||!1)&&(e.configurable||!1)===(r.configurable||!1)&&e.get===r.get&&e.set===r.set}isGetInvariant(e,t){let i=this._getOwnPropertyDescriptor(e,t);return i!==void 0&&i.configurable!==!0&&i.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function rg(e){return toString.call(e)==="[object Object]"}function vd(){return!0}function Ao(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var FS=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),MO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),NS={push:vd,pop:vd,shift:vd,unshift:vd,copyWithin:Ao,reverse:Ao,sort:Ao,splice:Ao,flat:Ao,fill:Ao},EO=new Set([...FS,...MO,...Object.keys(NS)]);function yd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var kS=["keys","values","entries"],US=new Set(["has","toString"]),jS={add:yd,clear:yd,delete:yd,forEach:yd},CO=new Set([...US,...Object.keys(jS),...kS]);function xd(e,t){if(e.size!==t.size)return!0;let i;for(let[r,s]of e)if(i=t.get(r),i!==s||i===void 0&&!t.has(r))return!0;return!1}var TO=new Set([...US,"get"]),GS={set:xd,clear:xd,delete:xd,forEach:xd},PO=new Set([...TO,...Object.keys(GS),...kS]),aa=class{constructor(e,t,i,r){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=r,this._changes=r?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return FS.has(e)}_shallowClone(e){let t=e;if(rg(e))t={...e};else if(Cs(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(i=>this._shallowClone(i)));else if(e instanceof Map){t=new Map;for(let[i,r]of e.entries())t.set(i,this._shallowClone(r))}return this._clonedCache.add(t),t}preferredThisArg(e,t,i,r){return e?(Cs(r)?this._onIsChanged=NS[t]:r instanceof Set?this._onIsChanged=jS[t]:r instanceof Map&&(this._onIsChanged=GS[t]),r):i}update(e,t,i){let r=Or.after(e,this._path);if(t!=="length"){let s=this.clone;Or.walk(r,n=>{s&&s[n]&&(this._clonedCache.has(s[n])||(s[n]=this._shallowClone(s[n])),s=s[n])}),this._hasOnValidate&&this._changes.push({path:r,property:t,previous:i}),s&&s[t]&&(s[t]=i)}this._isChanged=!0}undo(e){let t;for(let i=this._changes.length-1;i!==-1;i--)t=this._changes[i],Or.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},dx=class extends aa{static isHandledMethod(e){return EO.has(e)}},DO=class extends aa{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},ux=class extends aa{static isHandledMethod(e){return CO.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}},px=class extends aa{static isHandledMethod(e){return PO.has(e)}undo(e){for(let[t,i]of this.clone.entries())e.set(t,i);for(let t of e.keys())this.clone.has(t)||e.delete(t)}},IO=class extends aa{constructor(e,t,i,r){super(void 0,t,i,r),this._arg1=i[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}},LO=class extends aa{constructor(e,t,i,r){super(void 0,t,i,r),this._weakKey=i[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}},Go=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return rg(e)||Cs(e)||ig(e)}static isHandledMethod(e,t){return rg(e)?aa.isHandledMethod(t):Cs(e)?dx.isHandledMethod(t):e instanceof Set?ux.isHandledMethod(t):e instanceof Map?px.isHandledMethod(t):ig(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=aa;Cs(e)?r=dx:e instanceof Date?r=DO:e instanceof Set?r=ux:e instanceof Map?r=px:e instanceof WeakSet?r=IO:e instanceof WeakMap&&(r=LO),this._stack.push(new r(e,t,i,this._hasOnValidate))}update(e,t,i){this._stack[this._stack.length-1].update(e,t,i)}preferredThisArg(e,t,i){let{name:r}=e,s=Go.isHandledMethod(i,r);return this._stack[this._stack.length-1].preferredThisArg(s,r,t,i)}isChanged(e,t,i){return this._stack[this._stack.length-1].isChanged(e,t,i)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}},OO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Kv=(e,t,i={})=>{i={...OO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new AO(s),h=typeof i.onValidate=="function",u=new Go(h),c=(y,x,b,_,A)=>!h||u.isCloning||i.onValidate(Or.concat(l.getPath(y),x),b,_,A)===!0,d=(y,x,b,_)=>{!cx(l,i,x)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),x,b,_)},p=(y,x,b,_,A)=>{u.isCloning?u.update(y,x,_):t(Or.concat(y,x),b,_,A)},f=y=>y&&(y[r]||y),g=(y,x,b,_)=>bO(y)||b==="constructor"||n&&!Go.isHandledMethod(x,b)||cx(l,i,b)||l.isGetInvariant(x,b)||a&&l.isDetached(x,e)?y:(_===void 0&&(_=l.getPath(x)),l.getProxy(y,Or.concat(_,b),m,r)),m={get(y,x,b){if(Zv(x)){if(x===r||x===Qv)return y;if(x===zS&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let _=ig(y)?Reflect.get(y,x):Reflect.get(y,x,b);return g(_,y,x)},set(y,x,b,_){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let w=c(y,x,b,S);return w&&l.setProperty(A,x,b,_,S)?(d(y,x,y[x],S),!0):!w},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let _=y[x];c(y,x,b.value,_)&&l.defineProperty(y,x,b,_)&&d(y,x,b.value,_)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),_=c(y,x,void 0,b);return _&&l.deleteProperty(y,x,b)?(d(y,x,void 0,b),!0):!_},apply(y,x,b){let _=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,_,b);if((o===!1||o!==!0&&!o.includes(y.name))&&Go.isHandledType(_)){let A=Or.initial(l.getPath(y)),S=Go.isHandledMethod(_,y.name);u.start(_,A,b);let w=Reflect.apply(y,u.preferredThisArg(y,x,_),S?b.map(T=>f(T)):b),M=u.isChanged(_,s),C=u.stop();if(Go.isHandledType(w)&&S&&(x instanceof Map&&y.name==="get"&&(A=Or.concat(A,b[0])),w=l.getProxy(w,A,m)),M){let T={name:y.name,args:b,result:w},D=u.isCloning?Or.initial(A):A,P=u.isCloning?Or.last(A):"";c(Or.get(e,D),P,_,C,T)?p(D,P,_,C,T):u.undo(_)}return(x instanceof Map||x instanceof Set)&&_O(w)?SO(w,y,x,A,g):w}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};Kv.target=e=>e&&e[Qv]||e;Kv.unsubscribe=e=>e[zS]||e;var fx=Kv,RO=typeof global=="object"&&global&&global.Object===Object&&global,VS=RO,BO=typeof self=="object"&&self&&self.Object===Object&&self,zO=VS||BO||Function("return this")(),os=zO,FO=os.Symbol,jr=FO,HS=Object.prototype,NO=HS.hasOwnProperty,kO=HS.toString,ph=jr?jr.toStringTag:void 0;function UO(e){var t=NO.call(e,ph),i=e[ph];try{e[ph]=void 0;var r=!0}catch{}var s=kO.call(e);return r&&(t?e[ph]=i:delete e[ph]),s}var jO=UO,GO=Object.prototype,VO=GO.toString;function HO(e){return VO.call(e)}var WO=HO,qO="[object Null]",XO="[object Undefined]",mx=jr?jr.toStringTag:void 0;function YO(e){return e==null?e===void 0?XO:qO:mx&&mx in Object(e)?jO(e):WO(e)}var eo=YO;function QO(e){return e!=null&&typeof e=="object"}var _n=QO,ZO="[object Symbol]";function KO(e){return typeof e=="symbol"||_n(e)&&eo(e)==ZO}var gp=KO;function JO(e,t){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=t(e[i],i,e);return s}var WS=JO,$O=Array.isArray,Fs=$O,e4=1/0,gx=jr?jr.prototype:void 0,vx=gx?gx.toString:void 0;function qS(e){if(typeof e=="string")return e;if(Fs(e))return WS(e,qS)+"";if(gp(e))return vx?vx.call(e):"";var t=e+"";return t=="0"&&1/e==-e4?"-0":t}var t4=qS,i4=/\s/;function r4(e){for(var t=e.length;t--&&i4.test(e.charAt(t)););return t}var s4=r4,n4=/^\s+/;function a4(e){return e&&e.slice(0,s4(e)+1).replace(n4,"")}var o4=a4;function l4(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var as=l4,yx=0/0,h4=/^[-+]0x[0-9a-f]+$/i,c4=/^0b[01]+$/i,d4=/^0o[0-7]+$/i,u4=parseInt;function p4(e){if(typeof e=="number")return e;if(gp(e))return yx;if(as(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=as(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=o4(e);var i=c4.test(e);return i||d4.test(e)?u4(e.slice(2),i?2:8):h4.test(e)?yx:+e}var xx=p4;function f4(e){return e}var m4=f4,g4="[object AsyncFunction]",v4="[object Function]",y4="[object GeneratorFunction]",x4="[object Proxy]";function b4(e){if(!as(e))return!1;var t=eo(e);return t==v4||t==y4||t==g4||t==x4}var XS=b4,w4=os["__core-js_shared__"],Of=w4,bx=function(){var e=/[^.]+$/.exec(Of&&Of.keys&&Of.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function _4(e){return!!bx&&bx in e}var S4=_4,A4=Function.prototype,M4=A4.toString;function E4(e){if(e!=null){try{return M4.call(e)}catch{}try{return e+""}catch{}}return""}var to=E4,C4=/[\\^$.*+?()[\]{}|]/g,T4=/^\[object .+?Constructor\]$/,P4=Function.prototype,D4=Object.prototype,I4=P4.toString,L4=D4.hasOwnProperty,O4=RegExp("^"+I4.call(L4).replace(C4,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R4(e){if(!as(e)||S4(e))return!1;var t=XS(e)?O4:T4;return t.test(to(e))}var B4=R4;function z4(e,t){return e?.[t]}var F4=z4;function N4(e,t){var i=F4(e,t);return B4(i)?i:void 0}var io=N4,k4=io(os,"WeakMap"),sg=k4,wx=Object.create,U4=function(){function e(){}return function(t){if(!as(t))return{};if(wx)return wx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),j4=U4;function G4(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}var V4=G4;function H4(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var W4=H4,q4=800,X4=16,Y4=Date.now;function Q4(e){var t=0,i=0;return function(){var r=Y4(),s=X4-(r-i);if(i=r,s>0){if(++t>=q4)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Z4=Q4;function K4(e){return function(){return e}}var J4=K4,$4=function(){try{var e=io(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Du=$4,eR=Du?function(e,t){return Du(e,"toString",{configurable:!0,enumerable:!1,value:J4(t),writable:!0})}:m4,tR=eR,iR=Z4(tR),rR=iR;function sR(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var nR=sR,aR=9007199254740991,oR=/^(?:0|[1-9]\d*)$/;function lR(e,t){var i=typeof e;return t=t??aR,!!t&&(i=="number"||i!="symbol"&&oR.test(e))&&e>-1&&e%1==0&&e<t}var Jv=lR;function hR(e,t,i){t=="__proto__"&&Du?Du(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var YS=hR;function cR(e,t){return e===t||e!==e&&t!==t}var $v=cR,dR=Object.prototype,uR=dR.hasOwnProperty;function pR(e,t,i){var r=e[t];(!(uR.call(e,t)&&$v(r,i))||i===void 0&&!(t in e))&&YS(e,t,i)}var e0=pR;function fR(e,t,i,r){var s=!i;i||(i={});for(var n=-1,a=t.length;++n<a;){var o=t[n],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?YS(i,o,l):e0(i,o,l)}return i}var Lc=fR,_x=Math.max;function mR(e,t,i){return t=_x(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=_x(r.length-t,0),a=Array(n);++s<n;)a[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(a),V4(e,this,o)}}var gR=mR,vR=9007199254740991;function yR(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=vR}var t0=yR;function xR(e){return e!=null&&t0(e.length)&&!XS(e)}var QS=xR,bR=Object.prototype;function wR(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||bR;return e===i}var i0=wR;function _R(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var SR=_R,AR="[object Arguments]";function MR(e){return _n(e)&&eo(e)==AR}var Sx=MR,ZS=Object.prototype,ER=ZS.hasOwnProperty,CR=ZS.propertyIsEnumerable,TR=Sx(function(){return arguments}())?Sx:function(e){return _n(e)&&ER.call(e,"callee")&&!CR.call(e,"callee")},r0=TR;function PR(){return!1}var DR=PR,KS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ax=KS&&typeof module=="object"&&module&&!module.nodeType&&module,IR=Ax&&Ax.exports===KS,Mx=IR?os.Buffer:void 0,LR=Mx?Mx.isBuffer:void 0,OR=LR||DR,Iu=OR,RR="[object Arguments]",BR="[object Array]",zR="[object Boolean]",FR="[object Date]",NR="[object Error]",kR="[object Function]",UR="[object Map]",jR="[object Number]",GR="[object Object]",VR="[object RegExp]",HR="[object Set]",WR="[object String]",qR="[object WeakMap]",XR="[object ArrayBuffer]",YR="[object DataView]",QR="[object Float32Array]",ZR="[object Float64Array]",KR="[object Int8Array]",JR="[object Int16Array]",$R="[object Int32Array]",eB="[object Uint8Array]",tB="[object Uint8ClampedArray]",iB="[object Uint16Array]",rB="[object Uint32Array]",Ft={};Ft[QR]=Ft[ZR]=Ft[KR]=Ft[JR]=Ft[$R]=Ft[eB]=Ft[tB]=Ft[iB]=Ft[rB]=!0;Ft[RR]=Ft[BR]=Ft[XR]=Ft[zR]=Ft[YR]=Ft[FR]=Ft[NR]=Ft[kR]=Ft[UR]=Ft[jR]=Ft[GR]=Ft[VR]=Ft[HR]=Ft[WR]=Ft[qR]=!1;function sB(e){return _n(e)&&t0(e.length)&&!!Ft[eo(e)]}var nB=sB;function aB(e){return function(t){return e(t)}}var s0=aB,JS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Xh=JS&&typeof module=="object"&&module&&!module.nodeType&&module,oB=Xh&&Xh.exports===JS,Rf=oB&&VS.process,lB=function(){try{var e=Xh&&Xh.require&&Xh.require("util").types;return e||Rf&&Rf.binding&&Rf.binding("util")}catch{}}(),bl=lB,Ex=bl&&bl.isTypedArray,hB=Ex?s0(Ex):nB,$S=hB,cB=Object.prototype,dB=cB.hasOwnProperty;function uB(e,t){var i=Fs(e),r=!i&&r0(e),s=!i&&!r&&Iu(e),n=!i&&!r&&!s&&$S(e),a=i||r||s||n,o=a?SR(e.length,String):[],l=o.length;for(var h in e)(t||dB.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Jv(h,l)))&&o.push(h);return o}var eA=uB;function pB(e,t){return function(i){return e(t(i))}}var tA=pB,fB=tA(Object.keys,Object),mB=fB,gB=Object.prototype,vB=gB.hasOwnProperty;function yB(e){if(!i0(e))return mB(e);var t=[];for(var i in Object(e))vB.call(e,i)&&i!="constructor"&&t.push(i);return t}var xB=yB;function bB(e){return QS(e)?eA(e):xB(e)}var n0=bB;function wB(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var _B=wB,SB=Object.prototype,AB=SB.hasOwnProperty;function MB(e){if(!as(e))return _B(e);var t=i0(e),i=[];for(var r in e)r=="constructor"&&(t||!AB.call(e,r))||i.push(r);return i}var EB=MB;function CB(e){return QS(e)?eA(e,!0):EB(e)}var a0=CB,TB=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,PB=/^\w*$/;function DB(e,t){if(Fs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||gp(e)?!0:PB.test(e)||!TB.test(e)||t!=null&&e in Object(t)}var IB=DB,LB=io(Object,"create"),cc=LB;function OB(){this.__data__=cc?cc(null):{},this.size=0}var RB=OB;function BB(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var zB=BB,FB="__lodash_hash_undefined__",NB=Object.prototype,kB=NB.hasOwnProperty;function UB(e){var t=this.__data__;if(cc){var i=t[e];return i===FB?void 0:i}return kB.call(t,e)?t[e]:void 0}var jB=UB,GB=Object.prototype,VB=GB.hasOwnProperty;function HB(e){var t=this.__data__;return cc?t[e]!==void 0:VB.call(t,e)}var WB=HB,qB="__lodash_hash_undefined__";function XB(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=cc&&t===void 0?qB:t,this}var YB=XB;function Ul(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Ul.prototype.clear=RB;Ul.prototype.delete=zB;Ul.prototype.get=jB;Ul.prototype.has=WB;Ul.prototype.set=YB;var Cx=Ul;function QB(){this.__data__=[],this.size=0}var ZB=QB;function KB(e,t){for(var i=e.length;i--;)if($v(e[i][0],t))return i;return-1}var vp=KB,JB=Array.prototype,$B=JB.splice;function ez(e){var t=this.__data__,i=vp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():$B.call(t,i,1),--this.size,!0}var tz=ez;function iz(e){var t=this.__data__,i=vp(t,e);return i<0?void 0:t[i][1]}var rz=iz;function sz(e){return vp(this.__data__,e)>-1}var nz=sz;function az(e,t){var i=this.__data__,r=vp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var oz=az;function jl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}jl.prototype.clear=ZB;jl.prototype.delete=tz;jl.prototype.get=rz;jl.prototype.has=nz;jl.prototype.set=oz;var yp=jl,lz=io(os,"Map"),dc=lz;function hz(){this.size=0,this.__data__={hash:new Cx,map:new(dc||yp),string:new Cx}}var cz=hz;function dz(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var uz=dz;function pz(e,t){var i=e.__data__;return uz(t)?i[typeof t=="string"?"string":"hash"]:i.map}var xp=pz;function fz(e){var t=xp(this,e).delete(e);return this.size-=t?1:0,t}var mz=fz;function gz(e){return xp(this,e).get(e)}var vz=gz;function yz(e){return xp(this,e).has(e)}var xz=yz;function bz(e,t){var i=xp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var wz=bz;function Gl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Gl.prototype.clear=cz;Gl.prototype.delete=mz;Gl.prototype.get=vz;Gl.prototype.has=xz;Gl.prototype.set=wz;var bp=Gl,_z="Expected a function";function o0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(_z);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],n=i.cache;if(n.has(s))return n.get(s);var a=e.apply(this,r);return i.cache=n.set(s,a)||n,a};return i.cache=new(o0.Cache||bp),i}o0.Cache=bp;var Sz=o0,Az=500;function Mz(e){var t=Sz(e,function(r){return i.size===Az&&i.clear(),r}),i=t.cache;return t}var Ez=Mz,Cz=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tz=/\\(\\)?/g,Pz=Ez(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Cz,function(i,r,s,n){t.push(s?n.replace(Tz,"$1"):r||i)}),t}),Dz=Pz;function Iz(e){return e==null?"":t4(e)}var Lz=Iz;function Oz(e,t){return Fs(e)?e:IB(e,t)?[e]:Dz(Lz(e))}var Vl=Oz,Rz=1/0;function Bz(e){if(typeof e=="string"||gp(e))return e;var t=e+"";return t=="0"&&1/e==-Rz?"-0":t}var wp=Bz;function zz(e,t){t=Vl(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[wp(t[i++])];return i&&i==r?e:void 0}var iA=zz;function Fz(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var l0=Fz,Tx=jr?jr.isConcatSpreadable:void 0;function Nz(e){return Fs(e)||r0(e)||!!(Tx&&e&&e[Tx])}var kz=Nz;function rA(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=kz),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?rA(o,t-1,i,r,s):l0(s,o):r||(s[s.length]=o)}return s}var Uz=rA;function jz(e){var t=e==null?0:e.length;return t?Uz(e,1):[]}var Gz=jz;function Vz(e){return rR(gR(e,void 0,Gz),e+"")}var sA=Vz,Hz=tA(Object.getPrototypeOf,Object),h0=Hz,Wz="[object Object]",qz=Function.prototype,Xz=Object.prototype,nA=qz.toString,Yz=Xz.hasOwnProperty,Qz=nA.call(Object);function Zz(e){if(!_n(e)||eo(e)!=Wz)return!1;var t=h0(e);if(t===null)return!0;var i=Yz.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&nA.call(i)==Qz}var Kz=Zz;function Jz(e,t,i){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),i=i>s?s:i,i<0&&(i+=s),s=t>i?0:i-t>>>0,t>>>=0;for(var n=Array(s);++r<s;)n[r]=e[r+t];return n}var $z=Jz;function e5(){this.__data__=new yp,this.size=0}var t5=e5;function i5(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var r5=i5;function s5(e){return this.__data__.get(e)}var n5=s5;function a5(e){return this.__data__.has(e)}var o5=a5,l5=200;function h5(e,t){var i=this.__data__;if(i instanceof yp){var r=i.__data__;if(!dc||r.length<l5-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new bp(r)}return i.set(e,t),this.size=i.size,this}var c5=h5;function Hl(e){var t=this.__data__=new yp(e);this.size=t.size}Hl.prototype.clear=t5;Hl.prototype.delete=r5;Hl.prototype.get=n5;Hl.prototype.has=o5;Hl.prototype.set=c5;var lu=Hl;function d5(e,t){return e&&Lc(t,n0(t),e)}var u5=d5;function p5(e,t){return e&&Lc(t,a0(t),e)}var f5=p5,aA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Px=aA&&typeof module=="object"&&module&&!module.nodeType&&module,m5=Px&&Px.exports===aA,Dx=m5?os.Buffer:void 0,Ix=Dx?Dx.allocUnsafe:void 0;function g5(e,t){if(t)return e.slice();var i=e.length,r=Ix?Ix(i):new e.constructor(i);return e.copy(r),r}var v5=g5;function y5(e,t){for(var i=-1,r=e==null?0:e.length,s=0,n=[];++i<r;){var a=e[i];t(a,i,e)&&(n[s++]=a)}return n}var x5=y5;function b5(){return[]}var oA=b5,w5=Object.prototype,_5=w5.propertyIsEnumerable,Lx=Object.getOwnPropertySymbols,S5=Lx?function(e){return e==null?[]:(e=Object(e),x5(Lx(e),function(t){return _5.call(e,t)}))}:oA,c0=S5;function A5(e,t){return Lc(e,c0(e),t)}var M5=A5,E5=Object.getOwnPropertySymbols,C5=E5?function(e){for(var t=[];e;)l0(t,c0(e)),e=h0(e);return t}:oA,lA=C5;function T5(e,t){return Lc(e,lA(e),t)}var P5=T5;function D5(e,t,i){var r=t(e);return Fs(e)?r:l0(r,i(e))}var hA=D5;function I5(e){return hA(e,n0,c0)}var ng=I5;function L5(e){return hA(e,a0,lA)}var cA=L5,O5=io(os,"DataView"),ag=O5,R5=io(os,"Promise"),og=R5,B5=io(os,"Set"),lg=B5,Ox="[object Map]",z5="[object Object]",Rx="[object Promise]",Bx="[object Set]",zx="[object WeakMap]",Fx="[object DataView]",F5=to(ag),N5=to(dc),k5=to(og),U5=to(lg),j5=to(sg),Ea=eo;(ag&&Ea(new ag(new ArrayBuffer(1)))!=Fx||dc&&Ea(new dc)!=Ox||og&&Ea(og.resolve())!=Rx||lg&&Ea(new lg)!=Bx||sg&&Ea(new sg)!=zx)&&(Ea=function(e){var t=eo(e),i=t==z5?e.constructor:void 0,r=i?to(i):"";if(r)switch(r){case F5:return Fx;case N5:return Ox;case k5:return Rx;case U5:return Bx;case j5:return zx}return t});var uc=Ea,G5=Object.prototype,V5=G5.hasOwnProperty;function H5(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&V5.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var W5=H5,q5=os.Uint8Array,Lu=q5;function X5(e){var t=new e.constructor(e.byteLength);return new Lu(t).set(new Lu(e)),t}var d0=X5;function Y5(e,t){var i=t?d0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var Q5=Y5,Z5=/\w*$/;function K5(e){var t=new e.constructor(e.source,Z5.exec(e));return t.lastIndex=e.lastIndex,t}var J5=K5,Nx=jr?jr.prototype:void 0,kx=Nx?Nx.valueOf:void 0;function $5(e){return kx?Object(kx.call(e)):{}}var eF=$5;function tF(e,t){var i=t?d0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var iF=tF,rF="[object Boolean]",sF="[object Date]",nF="[object Map]",aF="[object Number]",oF="[object RegExp]",lF="[object Set]",hF="[object String]",cF="[object Symbol]",dF="[object ArrayBuffer]",uF="[object DataView]",pF="[object Float32Array]",fF="[object Float64Array]",mF="[object Int8Array]",gF="[object Int16Array]",vF="[object Int32Array]",yF="[object Uint8Array]",xF="[object Uint8ClampedArray]",bF="[object Uint16Array]",wF="[object Uint32Array]";function _F(e,t,i){var r=e.constructor;switch(t){case dF:return d0(e);case rF:case sF:return new r(+e);case uF:return Q5(e,i);case pF:case fF:case mF:case gF:case vF:case yF:case xF:case bF:case wF:return iF(e,i);case nF:return new r;case aF:case hF:return new r(e);case oF:return J5(e);case lF:return new r;case cF:return eF(e)}}var SF=_F;function AF(e){return typeof e.constructor=="function"&&!i0(e)?j4(h0(e)):{}}var MF=AF,EF="[object Map]";function CF(e){return _n(e)&&uc(e)==EF}var TF=CF,Ux=bl&&bl.isMap,PF=Ux?s0(Ux):TF,DF=PF,IF="[object Set]";function LF(e){return _n(e)&&uc(e)==IF}var OF=LF,jx=bl&&bl.isSet,RF=jx?s0(jx):OF,BF=RF,zF=1,FF=2,NF=4,dA="[object Arguments]",kF="[object Array]",UF="[object Boolean]",jF="[object Date]",GF="[object Error]",uA="[object Function]",VF="[object GeneratorFunction]",HF="[object Map]",WF="[object Number]",pA="[object Object]",qF="[object RegExp]",XF="[object Set]",YF="[object String]",QF="[object Symbol]",ZF="[object WeakMap]",KF="[object ArrayBuffer]",JF="[object DataView]",$F="[object Float32Array]",eN="[object Float64Array]",tN="[object Int8Array]",iN="[object Int16Array]",rN="[object Int32Array]",sN="[object Uint8Array]",nN="[object Uint8ClampedArray]",aN="[object Uint16Array]",oN="[object Uint32Array]",Bt={};Bt[dA]=Bt[kF]=Bt[KF]=Bt[JF]=Bt[UF]=Bt[jF]=Bt[$F]=Bt[eN]=Bt[tN]=Bt[iN]=Bt[rN]=Bt[HF]=Bt[WF]=Bt[pA]=Bt[qF]=Bt[XF]=Bt[YF]=Bt[QF]=Bt[sN]=Bt[nN]=Bt[aN]=Bt[oN]=!0;Bt[GF]=Bt[uA]=Bt[ZF]=!1;function hu(e,t,i,r,s,n){var a,o=t&zF,l=t&FF,h=t&NF;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!as(e))return e;var u=Fs(e);if(u){if(a=W5(e),!o)return W4(e,a)}else{var c=uc(e),d=c==uA||c==VF;if(Iu(e))return v5(e,o);if(c==pA||c==dA||d&&!s){if(a=l||d?{}:MF(e),!o)return l?P5(e,f5(a,e)):M5(e,u5(a,e))}else{if(!Bt[c])return s?e:{};a=SF(e,c,o)}}n||(n=new lu);var p=n.get(e);if(p)return p;n.set(e,a),BF(e)?e.forEach(function(m){a.add(hu(m,t,i,m,e,n))}):DF(e)&&e.forEach(function(m,v){a.set(v,hu(m,t,i,v,e,n))});var f=h?l?cA:ng:l?a0:n0,g=u?void 0:f(e);return nR(g||e,function(m,v){g&&(v=m,m=e[v]),e0(a,v,hu(m,t,i,v,e,n))}),a}var fA=hu,lN=1,hN=4;function cN(e){return fA(e,lN|hN)}var _p=cN,dN="__lodash_hash_undefined__";function uN(e){return this.__data__.set(e,dN),this}var pN=uN;function fN(e){return this.__data__.has(e)}var mN=fN;function Ou(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new bp;++t<i;)this.add(e[t])}Ou.prototype.add=Ou.prototype.push=pN;Ou.prototype.has=mN;var gN=Ou;function vN(e,t){for(var i=-1,r=e==null?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var yN=vN;function xN(e,t){return e.has(t)}var bN=xN,wN=1,_N=2;function SN(e,t,i,r,s,n){var a=i&wN,o=e.length,l=t.length;if(o!=l&&!(a&&l>o))return!1;var h=n.get(e),u=n.get(t);if(h&&u)return h==t&&u==e;var c=-1,d=!0,p=i&_N?new gN:void 0;for(n.set(e,t),n.set(t,e);++c<o;){var f=e[c],g=t[c];if(r)var m=a?r(g,f,c,t,e,n):r(f,g,c,e,t,n);if(m!==void 0){if(m)continue;d=!1;break}if(p){if(!yN(t,function(v,y){if(!bN(p,y)&&(f===v||s(f,v,i,r,n)))return p.push(y)})){d=!1;break}}else if(!(f===g||s(f,g,i,r,n))){d=!1;break}}return n.delete(e),n.delete(t),d}var mA=SN;function AN(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var MN=AN;function EN(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var CN=EN,TN=1,PN=2,DN="[object Boolean]",IN="[object Date]",LN="[object Error]",ON="[object Map]",RN="[object Number]",BN="[object RegExp]",zN="[object Set]",FN="[object String]",NN="[object Symbol]",kN="[object ArrayBuffer]",UN="[object DataView]",Gx=jr?jr.prototype:void 0,Bf=Gx?Gx.valueOf:void 0;function jN(e,t,i,r,s,n,a){switch(i){case UN:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case kN:return!(e.byteLength!=t.byteLength||!n(new Lu(e),new Lu(t)));case DN:case IN:case RN:return $v(+e,+t);case LN:return e.name==t.name&&e.message==t.message;case BN:case FN:return e==t+"";case ON:var o=MN;case zN:var l=r&TN;if(o||(o=CN),e.size!=t.size&&!l)return!1;var h=a.get(e);if(h)return h==t;r|=PN,a.set(e,t);var u=mA(o(e),o(t),r,s,n,a);return a.delete(e),u;case NN:if(Bf)return Bf.call(e)==Bf.call(t)}return!1}var GN=jN,VN=1,HN=Object.prototype,WN=HN.hasOwnProperty;function qN(e,t,i,r,s,n){var a=i&VN,o=ng(e),l=o.length,h=ng(t),u=h.length;if(l!=u&&!a)return!1;for(var c=l;c--;){var d=o[c];if(!(a?d in t:WN.call(t,d)))return!1}var p=n.get(e),f=n.get(t);if(p&&f)return p==t&&f==e;var g=!0;n.set(e,t),n.set(t,e);for(var m=a;++c<l;){d=o[c];var v=e[d],y=t[d];if(r)var x=a?r(y,v,d,t,e,n):r(v,y,d,e,t,n);if(!(x===void 0?v===y||s(v,y,i,r,n):x)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var b=e.constructor,_=t.constructor;b!=_&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof _=="function"&&_ instanceof _)&&(g=!1)}return n.delete(e),n.delete(t),g}var XN=qN,YN=1,Vx="[object Arguments]",Hx="[object Array]",bd="[object Object]",QN=Object.prototype,Wx=QN.hasOwnProperty;function ZN(e,t,i,r,s,n){var a=Fs(e),o=Fs(t),l=a?Hx:uc(e),h=o?Hx:uc(t);l=l==Vx?bd:l,h=h==Vx?bd:h;var u=l==bd,c=h==bd,d=l==h;if(d&&Iu(e)){if(!Iu(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new lu),a||$S(e)?mA(e,t,i,r,s,n):GN(e,t,l,i,r,s,n);if(!(i&YN)){var p=u&&Wx.call(e,"__wrapped__"),f=c&&Wx.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new lu),s(g,m,i,r,n)}}return d?(n||(n=new lu),XN(e,t,i,r,s,n)):!1}var KN=ZN;function gA(e,t,i,r,s){return e===t?!0:e==null||t==null||!_n(e)&&!_n(t)?e!==e&&t!==t:KN(e,t,i,r,gA,s)}var JN=gA;function $N(e,t){return e!=null&&t in Object(e)}var ek=$N;function tk(e,t,i){t=Vl(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=wp(t[r]);if(!(n=e!=null&&i(e,a)))break;e=e[a]}return n||++r!=s?n:(s=e==null?0:e.length,!!s&&t0(s)&&Jv(a,s)&&(Fs(e)||r0(e)))}var ik=tk;function rk(e,t){return e!=null&&ik(e,t,ek)}var sk=rk,nk=function(){return os.Date.now()},zf=nk,ak="Expected a function",ok=Math.max,lk=Math.min;function hk(e,t,i){var r,s,n,a,o,l,h=0,u=!1,c=!1,d=!0;if(typeof e!="function")throw new TypeError(ak);t=xx(t)||0,as(i)&&(u=!!i.leading,c="maxWait"in i,n=c?ok(xx(i.maxWait)||0,t):n,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,w=s;return r=s=void 0,h=A,a=e.apply(w,S),a}function f(A){return h=A,o=setTimeout(v,t),u?p(A):a}function g(A){var S=A-l,w=A-h,M=t-S;return c?lk(M,n-w):M}function m(A){var S=A-l,w=A-h;return l===void 0||S>=t||S<0||c&&w>=n}function v(){var A=zf();if(m(A))return y(A);o=setTimeout(v,g(A))}function y(A){return o=void 0,d&&r?p(A):(r=s=void 0,a)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?a:y(zf())}function _(){var A=zf(),S=m(A);if(r=arguments,s=this,l=A,S){if(o===void 0)return f(l);if(c)return clearTimeout(o),o=setTimeout(v,t),p(l)}return o===void 0&&(o=setTimeout(v,t)),a}return _.cancel=x,_.flush=b,_}var u0=hk;function ck(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var dk=ck;function uk(e,t){return t.length<2?e:iA(e,$z(t,0,-1))}var pk=uk;function fk(e,t){return JN(e,t)}var p0=fk;function mk(e,t){return t=Vl(t,e),e=pk(e,t),e==null||delete e[wp(dk(t))]}var gk=mk;function vk(e){return Kz(e)?void 0:e}var yk=vk,xk=1,bk=2,wk=4,_k=sA(function(e,t){var i={};if(e==null)return i;var r=!1;t=WS(t,function(n){return n=Vl(n,e),r||(r=n.length>1),n}),Lc(e,cA(e),i),r&&(i=fA(i,xk|bk|wk,yk));for(var s=t.length;s--;)gk(i,t[s]);return i}),hg=_k;function Sk(e,t,i,r){if(!as(e))return e;t=Vl(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=wp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=a){var u=o[l];h=r?r(u,l,o):void 0,h===void 0&&(h=as(u)?u:Jv(t[s+1])?[]:{})}e0(o,l,h),o=o[l]}return e}var Ak=Sk;function Mk(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=iA(e,a);i(o,a)&&Ak(n,Vl(a,e),o)}return n}var Ek=Mk;function Ck(e,t){return Ek(e,t,function(i,r){return sk(e,r)})}var Tk=Ck,Pk=sA(function(e,t){return e==null?{}:Tk(e,t)}),xn=Pk,Dk="Expected a function";function Ik(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(Dk);return as(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),u0(e,t,{leading:r,maxWait:t,trailing:s})}var Lk=Ik;function Ok(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ka(e,t){return Object.setPrototypeOf(e,t),e}var Rk=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),Bk=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),zk=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Sp&&"ontouchend"in document,Fk=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Nk=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,kk=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},Uk=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},jk=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},Gk=Rk(),Hq=Gk?jk():void 0,Sp=Bk(),vA=zk(),Vk=Fk(),_r=Nk(),qx=kk(),Xx=Number(Uk());function yA(e){return Array.isArray(e)?e:[e]}function Hk(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}function wd(e){return Sp?e.metaKey:e.ctrlKey}var Ve=[],Ru={},zh={},cu={};function xA(e){Ve.includes(e)||Ve.push(e)}function il(e){delete Ru[e.pointerId];for(let t=0;t<Ve.length;t++)if(Ve[t].pointerId===e.pointerId){Ve.splice(t,1);break}}function Wk(){Ve.splice(0,Ve.length)}function Bu(e){if(e.pointerType!=="touch")return;let t=Ru[e.pointerId];t===void 0&&(t={x:0,y:0},Ru[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Ff(e){let t=e.pointerId===Ve[0].pointerId?Ve[1]:Ve[0];return Ru[t.pointerId]}function bA(e){zh[e.key]=!0,cu[e.key]=cu[e.key]===void 0?1:cu[e.key]+1}function wA(e){if(Sp&&zh.Meta)for(let t in zh)zh[t]=!1;else zh[e.key]=!1;cu={}}function qk(e){e.addEventListener("pointerdown",xA,!0),e.addEventListener("pointerdown",Bu,!0),e.addEventListener("pointermove",Bu,!0),e.addEventListener("pointerup",il,!0),e.addEventListener("pointercancel",il,!0),e.addEventListener("pointerleave",il,!0),window.addEventListener("keydown",bA,!0),window.addEventListener("keyup",wA,!0)}function Xk(e){e.removeEventListener("pointerdown",xA,!0),e.removeEventListener("pointerdown",Bu,!0),e.removeEventListener("pointermove",Bu,!0),e.removeEventListener("pointerup",il,!0),e.removeEventListener("pointercancel",il,!0),e.removeEventListener("pointerleave",il,!0),window.removeEventListener("keydown",bA,!0),window.removeEventListener("keyup",wA,!0)}var _A,Yk=new Promise(e=>{_A=e}),_d;function Qk(){if(_d)return _d;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.455/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});_A(a)}return _d=e(),_d}var SA,Zk=new Promise(e=>{SA=e}),Sd;function Kk(){if(Sd)return Sd;async function e(){let t=await import("./physics.js");await t.init(),SA(t)}return Sd=e(),Sd}var ot=class{modifyById(e,t){let i=this;if(i[e]===void 0)throw new Error("not expected");{let r={...i,[e]:t};return Object.setPrototypeOf(r,ot.prototype),r}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let i=t[e.id],r;i===void 0?r={type:2,id:e.id}:r={type:1,id:e.id,data:i};let{id:s,data:n}=e,a={...t,[s]:n};return Object.setPrototypeOf(a,ot.prototype),{data:a,actual:e,reverse:r}}else if(e.type===2){let{id:i}=e,r=t[i];if(r===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,ot.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function f0(e){if(e.deepFreeze!==void 0){e.deepFreeze(e);return}let t=Object.getOwnPropertyNames(e);for(let i of t){let r=e[i];r&&typeof r=="object"&&f0(r)}return Object.freeze(e)}function Jk(e,t){let i=0;for(;i<e.length&&i<t.length;){if(e[i]<t[i])return-1;if(e[i]>t[i])return 1;i+=1}return i!==t.length?-1:i!==e.length?1:0}var AA=class extends Error{};function Nf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function qn(e,t,i){if(e===void 0?t===void 0?(e=0,t=10):e=t-10:t===void 0&&(t=e+10),e>t){let n=e;e=t,t=n}let r=[],s=1/(i+1);for(let n=0;n<i;n++){let a=e+(t-e)*(n+.75+Math.random()*.5)*s;r.push(a)}return r}function m0(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array}function $k(){return typeof process<"u"}function MA(e,t){for(let i of e)t(i.id,i.data)!==!0&&MA(i.children,t)}function EA(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)EA(i,t)}var lr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,lr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)f0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&EA(i,t)}}traverse(e){MA(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),r=this.childrenArray(i),s=r.findIndex(a=>a.id===e);if(s<0)throw new Error("not expected");let n=r[s];return r=[...r],r[s]={...n,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let n=r,a=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===a);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:n}}Object.setPrototypeOf(r,lr.prototype);let s=r;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:t}){if(this.get(e)!==void 0)return!0;for(let i of t)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:t,fi:i,id:r,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let a=t,o=this.childrenArray(a),l={fi:i,id:r,data:s,children:n};return o=[...o,l],o.sort((h,u)=>h.fi-u.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(a,o),actual:e,reverse:{type:8,id:r}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let i=this.parent(t);if(i===void 0)return null;let r=this.childrenArray(i),s=r.findIndex(a=>a.id===t);e.localIndex=s,r=[...r];let n=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...n,parent:i}}}}moveOp(e){let{parent:t,fi:i,id:r}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:8,id:r});if(t!==null){let c=t;for(;c!==null;){if(c===void 0)throw new Error;if(c===r)throw new AA("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let n=s,a=this.childrenArray(s),o=a.findIndex(c=>c.id===r);a=[...a];let l=a.splice(o,1)[0],h=this.modifyArrayBy(s,a);s=t,a=h.childrenArray(s);let u=l.fi;return l={...l,fi:i},a=[...a,l],a.sort((c,d)=>c.fi-d.fi),e.localIndex=a.indexOf(l),h=h.modifyArrayBy(s,a),{data:h,actual:e,reverse:{type:9,parent:n,fi:u,id:r}}}previous(e,t){if(t===null){let r=this.childrenArray(e);return r.length===0?null:r[r.length-1].id}let i=null;for(let r of this.childrenArray(e)){if(r.id===t)return i;i=r.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)+1;if(r<i.length)return i[r].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let i=this.childrenArray(t),r=i.findIndex(s=>s.id===e)-1;return r>=0?this.traverseSortPrevious(i[r].id):t}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push({...i,...r})}t.sort((i,r)=>Jk(i.sortKey,r.sortKey));for(let i of t)delete i.sortKey;return t}getWithSortKey(e){var t=e;let i=[],r=this.get(t),s=r;if(r!==void 0){for(;t;)i.splice(0,0,r.fi),t=this.parent(t),t!==null&&(r=this.get(t));return{...s,sortKey:i}}}insertBeforeHelper(e,t,i){return this.insertAfterHelper(e,this.previous(e,t),i)}insertAfterHelper(e,t,i){let r=this.childrenArray(e);if(t===null){if(r.length===0)return qn(0,i,i);{let s=r[0].fi;return qn(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=r.find(a=>a.fi>s.fi);if(n===void 0){let a=r[r.length-1].fi;return qn(a,a+i,i)}else return qn(s.fi,n.fi,i)}}},zu;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,n={},a=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");n[l]=a[h],a[h]=s[l],o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let s=r.props,n={},a={...i},o=!1;if(s)for(let l of Object.keys(s)){n[l]=a[l];let h=s[l];h===void 0?delete a[l]:a[l]=h,o=!0}return o?{data:a,actual:r,reverse:{type:0,props:n}}:null}}e.runOp=t})(zu||(zu={}));var Qe=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,Qe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)f0(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this,r=i.findIndex(n=>n.id===e);if(r<0)throw new Error("not expected");let s=i[r];return i=[...i],i[r]={...s,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Qe.prototype);let t=e;return $k()||t.fillCaches(),t}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:t,id:i,data:r}=e,s=this,n={fi:t,id:i,data:r};return s=[...s,n],s.sort((a,o)=>a.fi-o.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(n=>n.id===t);if(r===-1)return null;e.localIndex=r,i=[...i];let s=i.splice(r,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:i}=e,r=this;r=[...r];let s=r.findIndex(o=>o.id===i);if(s===-1)return null;let n=r[s].fi,a={...r[s],fi:t};return r[s]=a,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(a),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:n,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let i of this){if(i.id===e)return t;t=i.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let i=this;if(e===null){if(i.length===0)return qn(0,t,t);{let r=i[0].fi;return qn(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(n=>n.fi>r.fi);if(s===void 0){let n=i[i.length-1].fi;return qn(n,n+t,t)}else return qn(r.fi,s.fi,t)}}};function wl(e){return e&&typeof e=="object"&&e instanceof di}var di=class{unusedFunOverridesTable(e){}runOp(e){let t=[],i=this,r=0,s={};for(;r<e.path.length;){if(t.push(i),i=i===void 0?void 0:i[e.path[r]],i!==void 0&&!wl(i))return null;r+=1}i=i?Nf(i):new di;for(let[o,l]of Object.entries(e.props)){let h=i[o];s[o]=h,l===void 0?delete i[o]:i[o]=l}for(;r>0;){if(Object.keys(i).length===0){let o=t[r-1];o&&(i=Nf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Nf(o);l[e.path[r-1]]=i,i=l}else{let l=new di;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,di.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},ea;(e=>{function t(s,n){return pc(s,n)??s}e.apply=t;function i(s,n){return v0(s,n)}e.merge=i;function r(s,n){let a=0,o=n.path,l=s;for(;a<o.length&&l!==void 0;){if(l=Os.zoomOnce(l,o[a]),l===void 0)return n;if(!wl(l))return;a+=1}if(l===void 0)return n;if(wl(l))if(n.type===0){let h={...n.props};for(let u of Object.keys(l))delete h[u];return{...n,props:h}}else if(n.type===1||n.type===4||n.type===7){let h=g0([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(ea||(ea={}));function g0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=pc(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=g0(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:n,data:a,children:o}}else return{...s,id:n,data:a}});if(i)return r}function eU(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=pc(s.data,t[n]);return i=i||a!==void 0,a===void 0&&(a=s.data),{...s,id:n,data:a}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function pc(e,t){if(!wl(t))return t;if(e instanceof lr){let i=g0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof Qe)return eU(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=pc(s,t[n]);return i=i||a!==void 0,a===void 0&&(a=s),a});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof di)return v0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=pc(n,t[s]);r=r||a!==void 0,a===void 0&&(a=n),i[s]=a}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function v0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!wl(t))return t;if(!wl(e))return ea.apply(e,t);let i=new Set;for(let s of Object.keys(e))i.add(s);for(let s of Object.keys(t))i.add(s);let r=new di;for(let s of i){let n=v0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function tU(e,t){let i={cur:[],result:[],len:0};return e=fc(e,t,i)??e,[e,i.result]}function Fu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Nu(e){e&&(e.len-=1)}function iU(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function CA(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=fc(n.data,t,Fu(i,a));Nu(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=CA(n.children,t,i);return h!==void 0?r=!0:h=n.children,{...n,id:a,data:l,children:h}});if(r)return s}function rU(e,t,i){let r=!1,s=e.map(n=>{let a=n.id,o=t[a];if(o!==void 0&&typeof o=="string"&&(r=!0,a=o,i!==null))throw new Error("not supported");let l=fc(n.data,t,Fu(i,a));return Nu(i),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function fc(e,t,i){if(e instanceof lr){let r=CA(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof Qe)return rU(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=fc(n,t,Fu(i,a));return Nu(i),r=r||o!==void 0,o===void 0&&(o=n),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!m0(e)){let r={},s=!1;for(let[n,a]of Object.entries(e))if(n!=="name"&&n!=="text"){let o=t[n];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,n=o}let l=fc(a,t,Fu(i,n));Nu(i),s=s||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&iU(i),r}else return}}var cg;(e=>{function t(i,r){let s=Os.zoom(r,i.path);if(typeof s=="object"){let n={};for(let a of Object.keys(i.props))n[a]=s[a];return{...i,props:n}}else return{...i,props:{}}}e.replaceProps=t})(cg||(cg={}));var Xi;(e=>{function t(l,h){return{...l,path:l.path.slice(h)}}e.drop=t;function i(l,h){return r(l,h)?.data??l}e.applySimple=i;function r(l,h){let u=h.path;for(var c=[];;){let d;if(l instanceof di&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),d===void 0&&c.length===u.length&&(l instanceof lr||l instanceof Qe||l instanceof ot?d=l.runOp(h):d=zu.runOp(l,h)),d!==void 0)if(d!==null){let g=d.data;for(let m=c.length-1;m>=0;m--){let v=u[m],y=c[m];if(y instanceof lr){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof Qe){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof ot){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof di){let x={...y,[v]:g};g=Object.setPrototypeOf(x,di.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let x=g;g=[...y],g[v]=x}else g={...y,[v]:g};else return null}return{data:g,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let p=u[c.length],f;if(l instanceof lr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof Qe){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else l!==null&&(f=l[p]);if(f!==void 0)c.push(l),l=f;else return null}}e.apply=r;function s(l,h){for(let u=0;u<l.length&&u<h.length;u++)if(l[u]!==h[u])return!0;return!1}e.pathDisjoint=s;function n(l,h){if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==h[u])return!1;return!0}e.pathEq=n;function a(l,h){return s(l.path,h.path)}e.commutative=a;function o(l,h){return l.type===0&&h.type===0&&n(l.path,h.path)?Object.keys(l.props).every(u=>h.props[u]!==void 0):!1}e.subsumed=o})(Xi||(Xi={}));var dg;(e=>{function t(){return[]}e.empty=t;function i(h,u){let c=[];for(let d of h){let[p,...f]=d.path;p===u&&c.push({...d,path:f})}return c}e.removePrefix=i;function r(h,u){return h.map(c=>({...c,path:[u,...c.path]}))}e.addPrefix=r;function s(h,u){return[...h,...u]}e.concat=s;function n(h,u){return[...h.filter(c=>!u.some(d=>Xi.subsumed(c,d))),...u]}e.compress=n;function a(h,u){return h.every(c=>u.every(d=>Xi.commutative(c,d)))}e.commutative=a;function o(h,u){for(let c of u){let d=l(h,c);d!==null&&(h=d.data)}return h}e.applyAll=o;function l(h,u){var c=h;let d=[],p=[];for(let f of u)try{if(f.type===3){let g=Os.zoom(c,[...f.path,f.id]),m=Xi.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=tU(c,{[f.id]:g});c=v;for(let x of y){let b=x[x.length-1];x.splice(x.length-1,1),d.push({type:0,path:x,props:{[b]:g}}),p.push({type:0,path:x,props:{[b]:f.id}})}p.push(m.reverse),d.push(m.actual)}}else{let g=Xi.apply(c,f);g!==null&&(d.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof AA)return null;throw g}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(dg||(dg={}));var TA=Symbol(),sU=Symbol(),Ap=Symbol(),Oc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof DA);){let n=r._path,a=r._current;if(n!==""&&s.splice(0,0,n),r=r._parent,r===null)return;r.update(n,a)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Ap];i&&i(),delete this._children[e]}}}},nU=class extends Oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,zu.runOp(this._current,e),e.path)}},aU=class extends Oc{constructor(e,t,i){super(),this._parent=e,this._path=t,this._current=i}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,ot.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},PA={get(e,t){if(t===Ap)return()=>{e._parent=null};if(t===TA)return e._current;if(t===sU)return e;let{_current:i,_children:r}=e;if(t==="push"&&Array.isArray(i))throw new Error("not supported to expand array");let s=r===void 0?void 0:r[t];if(s!==void 0)return s;let n=i[t],a=Mp(e,t,n);return a!==n?(r===void 0&&(r={},e._children=r),r[t]=a,a):n},has(e,t){return t in e._current},ownKeys(e){return Reflect.ownKeys(e._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(e){return Object.getPrototypeOf(e._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(e,t){let i=e._current,r=Reflect.getOwnPropertyDescriptor(i,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:i[t]}}},oU={...PA,set(e,t,i){let r={type:0,props:{[t]:wi(i)??i}};return e.deleteChildren(t),e.runOp(r),!0},deleteProperty(e,t){let i={type:0,props:{[t]:void 0}};return e.deleteChildren(t),e.runOp(i),!0}},lU={...PA,set(e,t,i){return i===void 0?this.deleteProperty(e,t):(e.deleteChildren(t),e.runOp({type:1,id:t,data:i})),!0},deleteProperty(e,t){return e.runOp({type:2,id:t}),!0}},y0=class extends Oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ap]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,i)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Mp(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}add(e,t,i,r,s){this.runOp({type:7,parent:e,fi:t,id:i,data:r,children:s})}move(e,t,i){this.runOp({type:9,parent:e,fi:t,id:i})}insertAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.add(e,r[s],n.id,n.data,n.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let n=i[s];this.move(e,r[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},x0=class extends Oc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Ap]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id,s=this._current[i].fi;e(this.data(this._current[i].id),r,s)}}find(e){let t=this.length;for(let i=0;i<t;i++){let r=this._current[i].id;if(e(this.data(r),r))return this.get(r)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:i}=this,r=i===void 0?void 0:i[e];if(r!==void 0)return r;let s=t.get(e)?.data,n=Mp(this,e,s);return n!==s?(i===void 0&&(i={},this._children=i),i[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,i){this.runOp({type:4,fi:e,id:t,data:i})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}insertBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.add(i[r],s.id,s.data)}}moveAfter(e,t){let i=this._current.insertAfterHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}moveBefore(e,t){let i=this._current.insertBeforeHelper(e,t.length);for(let r=0;r<t.length;r++){let s=t[r];this.move(i[r],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function kf(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Os.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var DA=class extends Oc{constructor(e){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,i,r){kf(this.ts,t,e),kf(this.actual,i,e),kf(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Mp(e,t,i){return i instanceof lr?new y0(e,t,i):i instanceof Qe?new x0(e,t,i):i instanceof ot?new Proxy(new aU(e,t,i),lU):i!==null&&typeof i=="object"?m0(i)?i:new Proxy(new nU(e,t,i),oU):i}function IA(e){let t=new DA(e);return[Mp(t,"",e),t]}function mc(e,t){let[i,r]=IA(e);return t(i),r.result()}function wi(e){return e instanceof y0||e instanceof x0?e._current:e!==null&&typeof e=="object"?e[TA]:e}var Os;(e=>{function t(n,a){if(a.length===n.length)for(var o=0;o<n.length;){if(n[o]!==a[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(n,a,o){let l=s(o,n);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...a};return Object.keys(l).forEach(u=>{delete h[u]}),h}else return a}e.removeOverridden=i;function r(n,a){if((n instanceof lr||n instanceof y0)&&typeof a=="string"||(n instanceof Qe||n instanceof x0)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n)||typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}e.zoomOnce=r;function s(n,a,o=0){for(;o<a.length&&n!==void 0;)n=r(n,a[o]),o+=1;return n}e.zoom=s})(Os||(Os={}));function hU(e,t){let i=[];if(t.length===e.length)for(var r=0;r<e.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}function Fr(e,t){let i=[];if(t.length<=e.length)for(var r=0;r<t.length;){if(t[r]==="*")i.push(e[r]);else if(e[r]!==t[r])return null;r+=1}else return null;return i}var LA=class{},Yx=class extends LA{constructor(e){super(),this.id=e}},Qx=class extends LA{constructor(e){super(),this.data=e}},ug;try{ug=new TextDecoder}catch{}var Te,ta,K=0,OA=[],pg=OA,fg=0,rr={},xt,Xn,Rr=0,Ts=0,yr,bn,Ki=[],wt,Zx={useRecords:!1,mapsAsObjects:!0},RA=class{},BA=new RA;BA.name="MessagePack 0xC1";var _l=!1,ku=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Te)return jA(()=>(gg(),this?this.unpack(e,t):ku.prototype.unpack.call(Zx,e,t)));ta=t>-1?t:e.length,K=0,fg=0,Ts=0,Xn=null,pg=OA,yr=null,Te=e;try{wt=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Te=null,e instanceof Uint8Array?i:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof ku){if(rr=this,this.structures)return xt=this.structures,Ad();(!xt||xt.length>0)&&(xt=[])}else rr=Zx,(!xt||xt.length>0)&&(xt=[]);return Ad()}unpackMultiple(e,t){let i,r=0;try{_l=!0;let s=e.length,n=this?this.unpack(e,s):Cp.unpack(e,s);if(t){for(t(n);K<s;)if(r=K,t(Ad())===!1)return}else{for(i=[n];K<s;)r=K,i.push(Ad());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{_l=!1,gg()}}_mergeStructures(e,t){e=e||[];for(let i=0,r=e.length;i<r;i++){let s=e[i];s&&(s.isShared=!0,i>=32&&(s.highByte=i-32>>5))}e.sharedLength=e.length;for(let i in t||[])if(i>=0){let r=e[i],s=t[i];s&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[i]=r),e[i]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Ad(){try{if(!rr.trusted&&!_l){let t=xt.sharedLength||0;t<xt.length&&(xt.length=t)}let e=Vt();if(K==ta)xt.restoreStructures&&Kx(),xt=null,Te=null,bn&&(bn=null);else if(K>ta){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!_l)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw xt.restoreStructures&&Kx(),gg(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function Kx(){for(let e in xt.restoreStructures)xt[e]=xt.restoreStructures[e];xt.restoreStructures=null}function Vt(){let e=Te[K++];if(e<160)if(e<128){if(e<64)return e;{let t=xt[e&63]||rr.getStructures&&zA()[e&63];return t?(t.read||(t.read=b0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,rr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NA()]=Vt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Vt(),Vt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vt();return t}else if(e<192){let t=e-160;if(Ts>=K)return Xn.slice(K-Rr,(K+=t)-Rr);if(Ts==0&&ta<140){let i=t<16?w0(t):FA(t);if(i!=null)return i}return mg(t)}else{let t;switch(e){case 192:return null;case 193:return yr?(t=Vt(),t>0?yr[1].slice(yr.position1,yr.position1+=t):yr[0].slice(yr.position0,yr.position0-=t)):BA;case 194:return!1;case 195:return!0;case 196:return Uf(Te[K++]);case 197:return t=wt.getUint16(K),K+=2,Uf(t);case 198:return t=wt.getUint32(K),K+=4,Uf(t);case 199:return ba(Te[K++]);case 200:return t=wt.getUint16(K),K+=2,ba(t);case 201:return t=wt.getUint32(K),K+=4,ba(t);case 202:if(t=wt.getFloat32(K),rr.useFloat32>2){let i=_0[(Te[K]&127)<<1|Te[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=wt.getFloat64(K),K+=8,t;case 204:return Te[K++];case 205:return t=wt.getUint16(K),K+=2,t;case 206:return t=wt.getUint32(K),K+=4,t;case 207:return rr.int64AsNumber?(t=wt.getUint32(K)*4294967296,t+=wt.getUint32(K+4)):t=wt.getBigUint64(K),K+=8,t;case 208:return wt.getInt8(K++);case 209:return t=wt.getInt16(K),K+=2,t;case 210:return t=wt.getInt32(K),K+=4,t;case 211:return rr.int64AsNumber?(t=wt.getInt32(K)*4294967296,t+=wt.getUint32(K+4)):t=wt.getBigInt64(K),K+=8,t;case 212:if(t=Te[K++],t==114)return ib(Te[K++]&63);{let i=Ki[t];if(i)return i.read?(K++,i.read(Vt())):i.noBuffer?(K++,i()):i(Te.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=Te[K],t==114?(K++,ib(Te[K++]&63,Te[K++])):ba(2);case 214:return ba(4);case 215:return ba(8);case 216:return ba(16);case 217:return t=Te[K++],Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):dU(t);case 218:return t=wt.getUint16(K),K+=2,Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):uU(t);case 219:return t=wt.getUint32(K),K+=4,Ts>=K?Xn.slice(K-Rr,(K+=t)-Rr):pU(t);case 220:return t=wt.getUint16(K),K+=2,$x(t);case 221:return t=wt.getUint32(K),K+=4,$x(t);case 222:return t=wt.getUint16(K),K+=2,eb(t);case 223:return t=wt.getUint32(K),K+=4,eb(t);default:if(e>=224)return e-256;if(e===void 0){let i=new Error("Unexpected end of MessagePack data");throw i.incomplete=!0,i}throw new Error("Unknown MessagePack token "+e)}}}var cU=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function b0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>cU.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Vt);return e.highByte===0&&(e.read=Jx(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Vt()}return r}return i.count=0,e.highByte===0?Jx(t,i):i}var Jx=(e,t)=>function(){let i=Te[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=xt[r]||zA()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=b0(s,e)),s.read()};function zA(){let e=jA(()=>(Te=null,rr.getStructures()));return xt=rr._mergeStructures(e,xt)}var mg=Ep,dU=Ep,uU=Ep,pU=Ep;function Ep(e){let t;if(e<16&&(t=w0(e)))return t;if(e>64&&ug)return ug.decode(Te.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=Te[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Te[K++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Te[K++]&63,a=Te[K++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Te[K++]&63,a=Te[K++]&63,o=Te[K++]&63,l=(s&7)<<18|n<<12|a<<6|o;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(s);r.length>=4096&&(t+=vi.apply(String,r),r.length=0)}return r.length>0&&(t+=vi.apply(String,r)),t}function $x(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Vt();return t}function eb(e){if(rr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[NA()]=Vt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Vt(),Vt());return t}}var vi=String.fromCharCode;function FA(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=Te[K++];if((s&128)>0){K=t;return}i[r]=s}return vi.apply(String,i)}function w0(e){if(e<4)if(e<2){if(e===0)return"";{let t=Te[K++];if((t&128)>1){K-=1;return}return vi(t)}}else{let t=Te[K++],i=Te[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return vi(t,i);let r=Te[K++];if((r&128)>0){K-=3;return}return vi(t,i,r)}else{let t=Te[K++],i=Te[K++],r=Te[K++],s=Te[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return vi(t,i,r,s);{let n=Te[K++];if((n&128)>0){K-=5;return}return vi(t,i,r,s,n)}}else if(e<8){let n=Te[K++],a=Te[K++];if((n&128)>0||(a&128)>0){K-=6;return}if(e<7)return vi(t,i,r,s,n,a);let o=Te[K++];if((o&128)>0){K-=7;return}return vi(t,i,r,s,n,a,o)}else{let n=Te[K++],a=Te[K++],o=Te[K++],l=Te[K++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return vi(t,i,r,s,n,a,o,l);{let h=Te[K++];if((h&128)>0){K-=9;return}return vi(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Te[K++],u=Te[K++];if((h&128)>0||(u&128)>0){K-=10;return}if(e<11)return vi(t,i,r,s,n,a,o,l,h,u);let c=Te[K++];if((c&128)>0){K-=11;return}return vi(t,i,r,s,n,a,o,l,h,u,c)}else{let h=Te[K++],u=Te[K++],c=Te[K++],d=Te[K++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){K-=12;return}if(e<14){if(e===12)return vi(t,i,r,s,n,a,o,l,h,u,c,d);{let p=Te[K++];if((p&128)>0){K-=13;return}return vi(t,i,r,s,n,a,o,l,h,u,c,d,p)}}else{let p=Te[K++],f=Te[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return vi(t,i,r,s,n,a,o,l,h,u,c,d,p,f);let g=Te[K++];if((g&128)>0){K-=15;return}return vi(t,i,r,s,n,a,o,l,h,u,c,d,p,f,g)}}}}}function Uf(e){return rr.copyBuffers?Uint8Array.prototype.slice.call(Te,K,K+=e):Te.subarray(K,K+=e)}function ba(e){let t=Te[K++];if(Ki[t])return Ki[t](Te.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var tb=new Array(4096);function NA(){let e=Te[K++];if(e>=160&&e<192){if(e=e-160,Ts>=K)return Xn.slice(K-Rr,(K+=e)-Rr);if(!(Ts==0&&ta<180))return mg(e)}else return K--,Vt();let t=(e<<5^(e>1?wt.getUint16(K):e>0?Te[K]:0))&4095,i=tb[t],r=K,s=K+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=wt.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Te[r++],n!=i[a++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],tb[t]=i,i.bytes=e;r<s;)n=wt.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Te[r++],i.push(n);let o=e<16?w0(e):FA(e);return o!=null?i.string=o:i.string=mg(e)}var ib=(e,t)=>{var i=Vt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=xt[e];return s&&s.isShared&&((xt.restoreStructures||(xt.restoreStructures=[]))[e]=s),xt[e]=i,i.read=b0(i,r),i.read()},kA=typeof self=="object"?self:global;Ki[0]=()=>{};Ki[0].noBuffer=!0;Ki[101]=()=>{let e=Vt();return(kA[e[0]]||Error)(e[1])};Ki[105]=e=>{let t=wt.getUint32(K-4);bn||(bn=new Map);let i=Te[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};bn.set(t,s);let n=Vt();return s.used?Object.assign(r,n):(s.target=n,n)};Ki[112]=e=>{let t=wt.getUint32(K-4),i=bn.get(t);return i.used=!0,i.target};Ki[115]=()=>new Set(Vt());var UA=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ki[116]=e=>{let t=e[0],i=UA[t];if(!i)throw new Error("Could not find typed array for code "+t);return new kA[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ki[120]=()=>{let e=Vt();return new RegExp(e[0],e[1])};Ki[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,yr=[Vt(),Vt()],yr.position0=0,yr.position1=0;let r=K;K=i;try{return Vt()}finally{K=r}};Ki[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function jA(e){let t=ta,i=K,r=fg,s=Rr,n=Ts,a=Xn,o=pg,l=bn,h=yr,u=new Uint8Array(Te.slice(0,ta)),c=xt,d=xt.slice(0,xt.length),p=rr,f=_l,g=e();return ta=t,K=i,fg=r,Rr=s,Ts=n,Xn=a,pg=o,bn=l,yr=h,Te=u,_l=f,xt=c,xt.splice(0,xt.length,...d),rr=p,wt=new DataView(Te.buffer,Te.byteOffset,Te.byteLength),g}function gg(){Te=null,bn=null,xt=null}function fU(e){e.unpack?Ki[e.type]=e.unpack:Ki[e.type]=e}var _0=new Array(147);for(let e=0;e<256;e++)_0[e]=+("1e"+Math.floor(45.15-e*.30103));var Cp=new ku({useRecords:!1}),Wq=Cp.unpack,qq=Cp.unpackMultiple,Xq=Cp.unpack,mU={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},gU=new Float32Array(1),Yq=new Uint8Array(gU.buffer,0,4),du;try{du=new TextEncoder}catch{}var Uu,S0,Tp=typeof Buffer<"u",jf=Tp?Buffer.allocUnsafeSlow:Uint8Array,GA=Tp?Buffer:Uint8Array,rb=Tp?4294967296:2144337920,he,Xt,te=0,cs,ds=null,vU=/[\u0080-\uFFFF]/,fh=Symbol("record-id"),VA=class extends ku{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=GA.prototype.utf8Write?function(S,w,M){return he.utf8Write(S,w,M)}:du&&du.encodeInto?function(S,w){return du.encodeInto(S,he.subarray(w)).written}:!1,h=this;e||(e={});let u=e&&e.sequential,c=e.structures||e.saveStructures,d=e.maxSharedStructures;if(d==null&&(d=c?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),u&&!e.saveStructures&&(this.structures=[]);let f=d>32||p+d>64,g=d+64,m=d+p+64;if(m>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,w){if(he||(he=new jf(8192),Xt=new DataView(he.buffer,0,8192),te=0),cs=he.length-10,cs-te<2048?(he=new jf(he.length),Xt=new DataView(he.buffer,0,he.length),cs=he.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(ds=["",""],he[te++]=214,he[te++]=98,ds.position=te-i,te+=4):ds=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let L=0,B=T.length;L<B;L++){let V=T[L];D=P[V],D||(D=P[V]=Object.create(null)),P=D}P[fh]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(b(S),ds){Xt.setUint32(ds.position+i,te-ds.position-i);let M=ds;ds=null,b(M[0]),b(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>cs&&A(te),h.offset=te;let M=xU(he.subarray(i,te),a.idsToInsert);return a=null,M}return w&bU?(he.start=i,he.end=te,he):he.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!u){for(let M=0,C=v.length;M<C;M++)v[M][fh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=he.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}w&wU&&(te=i)}};let b=S=>{te>cs&&(he=A(te));var w=typeof S,M;if(w==="string"){let C=S.length;if(ds&&C>=8&&C<4096){let P=vU.test(S);ds[P?0:1]+=S,he[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>cs&&(he=A(te+D)),C<64||!l){let P,L,B,V=te+T;for(P=0;P<C;P++)L=S.charCodeAt(P),L<128?he[V++]=L:L<2048?(he[V++]=L>>6|192,he[V++]=L&63|128):(L&64512)===55296&&((B=S.charCodeAt(P+1))&64512)===56320?(L=65536+((L&1023)<<10)+(B&1023),P++,he[V++]=L>>18|240,he[V++]=L>>12&63|128,he[V++]=L>>6&63|128,he[V++]=L&63|128):(he[V++]=L>>12|224,he[V++]=L>>6&63|128,he[V++]=L&63|128);M=V-te-T}else M=l(S,te+T,D);M<32?he[te++]=160|M:M<256?(T<2&&he.copyWithin(te+2,te+1,te+1+M),he[te++]=217,he[te++]=M):M<65536?(T<3&&he.copyWithin(te+3,te+2,te+2+M),he[te++]=218,he[te++]=M>>8,he[te++]=M&255):(T<5&&he.copyWithin(te+5,te+3,te+3+M),he[te++]=219,Xt.setUint32(te,M),te+=4),te+=M}else if(w==="number")if(S>>>0===S)S<64?he[te++]=S:S<256?(he[te++]=204,he[te++]=S):S<65536?(he[te++]=205,he[te++]=S>>8,he[te++]=S&255):(he[te++]=206,Xt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?he[te++]=256+S:S>=-128?(he[te++]=208,he[te++]=S+256):S>=-32768?(he[te++]=209,Xt.setInt16(te,S),te+=2):(he[te++]=210,Xt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){he[te++]=202,Xt.setFloat32(te,S);let T;if(C<4||(T=S*_0[(he[te]&127)<<1|he[te+1]>>7])>>0===T){te+=4;return}else te--}he[te++]=203,Xt.setFloat64(te,S),te+=8}else if(w==="object")if(!S)he[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let D=a.idsToInsert||(a.idsToInsert=[]);T.id=D.push(T)}he[te++]=214,he[te++]=112,Xt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)_(S,!0);else if(C===Array){M=S.length,M<16?he[te++]=144|M:M<65536?(he[te++]=220,he[te++]=M>>8,he[te++]=M&255):(he[te++]=221,Xt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(S[T])}else if(C===Map){M=S.size,M<16?he[te++]=128|M:M<65536?(he[te++]=222,he[te++]=M>>8,he[te++]=M&255):(he[te++]=223,Xt.setUint32(te,M),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Uu.length;T<D;T++){let P=S0[T];if(S instanceof P){let L=Uu[T];if(L.write){L.type&&(he[te++]=212,he[te++]=L.type,he[te++]=0),b(L.write.call(this,S));return}let B=he,V=Xt,U=te;he=null;let z;try{z=L.pack.call(this,S,X=>(he=B,B=null,te+=X,te>cs&&A(te),{target:he,targetView:Xt,position:te-X}),b)}finally{B&&(he=B,Xt=V,te=U,cs=he.length-10)}z&&(z.length+te>cs&&A(z.length+te),te=yU(z,he,te,L.type));return}}_(S,!S.hasOwnProperty)}}else if(w==="boolean")he[te++]=S?195:194;else if(w==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))he[te++]=211,Xt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)he[te++]=207,Xt.setBigUint64(te,S);else if(this.largeBigIntToFloat)he[te++]=203,Xt.setFloat64(te,Number(S));else throw new RangeError(S+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");te+=8}else if(w==="undefined")this.encodeUndefinedAsNil?he[te++]=192:(he[te++]=212,he[te++]=0,he[te++]=0);else if(w==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+w)},_=this.useRecords===!1?this.variableMapSize?S=>{let w=Object.keys(S),M=w.length;M<16?he[te++]=128|M:M<65536?(he[te++]=222,he[te++]=M>>8,he[te++]=M&255):(he[te++]=223,Xt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=w[T]),b(S[C])}:(S,w)=>{he[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(w||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);he[M+++i]=C>>8,he[M+i]=C&255}:S=>{let w=Object.keys(S),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let P=0,L=w.length;P<L;P++){let B=w[P];M=C[B],M||(M=C[B]=Object.create(null),T++),C=M}let D=C[fh];if(D)D>=96&&f?(he[te++]=((D-=96)&31)+96,he[te++]=D>>5):he[te++]=D;else{D=n.nextId,D||(D=64),D<g&&this.shouldShareStructure&&!this.shouldShareStructure(w)?(D=n.nextOwnId,D<m||(D=g),n.nextOwnId=D+1):(D>=m&&(D=g),n.nextId=D+1);let P=w.highByte=D>=96&&f?D-96>>5:-1;C[fh]=D,n[D-64]=w,D<g?(w.isShared=!0,n.sharedLength=D-63,s=!0,P>=0?(he[te++]=(D&31)+96,he[te++]=P):he[te++]=D):(P>=0?(he[te++]=213,he[te++]=114,he[te++]=(D&31)+96,he[te++]=P):(he[te++]=212,he[te++]=114,he[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[fh]=0),v.push(C),b(w))}for(let P=0,L=w.length;P<L;P++)b(S[w[P]])},A=S=>{let w;if(S>16777216){if(S-i>rb)throw new Error("Packed buffer would be larger than maximum buffer size");w=Math.min(rb,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else w=(Math.max(S-i<<2,he.length-1)>>12)+1<<12;let M=new jf(w);return Xt=new DataView(M.buffer,0,w),he.copy?he.copy(M,0,i,S):M.set(he.slice(i,S)),te-=i,i=0,cs=M.length-10,he=M}}useBuffer(e){he=e,Xt=new DataView(he.buffer,he.byteOffset,he.byteLength),te=0}};S0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,RA];Uu=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:n,position:a}=t(6);s[a++]=214,s[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:s,targetView:n,position:a}=t(10);s[a++]=215,s[a++]=255,n.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:n,position:a}=t(3);s[a++]=212,s[a++]=255,s[a++]=255}else{let{target:s,targetView:n,position:a}=t(15);s[a++]=199,s[a++]=12,s[a++]=255,n.setUint32(a,e.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(s[n++]=212,s[n++]=115,s[n++]=0),i(r)}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=101,r[s++]=0),i([e.name,e.message])}},{pack(e,t,i){let{target:r,position:s}=t(this.structuredClone?3:0);this.structuredClone&&(r[s++]=212,r[s++]=120,r[s++]=0),i([e.source,e.flags])}},{pack(e,t){this.structuredClone?sb(e,16,t):nb(Tp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==GA&&this.structuredClone?sb(e,UA.indexOf(i.name),t):nb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function sb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:n,position:a}=i(4+s);n[a++]=199,n[a++]=s+1}else if(s+1<65536){var{target:n,position:a}=i(5+s);n[a++]=200,n[a++]=s+1>>8,n[a++]=s+1&255}else{var{target:n,position:a,targetView:o}=i(7+s);n[a++]=201,o.setUint32(a,s+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a)}function nb(e,t){let i=e.byteLength;var r,s;if(i<256){var{target:r,position:s}=t(i+2);r[s++]=196,r[s++]=i}else if(i<65536){var{target:r,position:s}=t(i+3);r[s++]=197,r[s++]=i>>8,r[s++]=i&255}else{var{target:r,position:s,targetView:n}=t(i+5);r[s++]=198,n.setUint32(s,i),s+=4}r.set(e,s)}function yU(e,t,i,r){let s=e.length;switch(s){case 1:t[i++]=212;break;case 2:t[i++]=213;break;case 4:t[i++]=214;break;case 8:t[i++]=215;break;case 16:t[i++]=216;break;default:s<256?(t[i++]=199,t[i++]=s):s<65536?(t[i++]=200,t[i++]=s>>8,t[i++]=s&255):(t[i++]=201,t[i++]=s>>24,t[i++]=s>>16&255,t[i++]=s>>8&255,t[i++]=s&255)}return t[i++]=r,t.set(e,i),i+=s,i}function xU(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);i=t.pop();){let n=i.offset,a=i.id;e.copyWithin(n+r,n,s),r-=6;let o=n+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,s=n}return e}function Wl(e){if(e.Class){if(!e.pack&&!e.write)throw new Error("Extension has no pack or write function");if(e.pack&&!e.type)throw new Error("Extension has no type (numeric code to identify the extension)");S0.unshift(e.Class),Uu.unshift(e)}fU(e)}var HA=new VA({useRecords:!1}),Qq=HA.pack,Zq=HA.pack,{NEVER:Kq,ALWAYS:Jq,DECIMAL_ROUND:$q,DECIMAL_FIT:eX}=mU,bU=512,wU=1024,ab=new VA({structuredClone:!0});Wl({Class:ot.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,ot.prototype),e}});Wl({Class:Qe.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,Qe.prototype),e}});Wl({Class:lr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,lr.prototype),e}});Wl({Class:Yx.prototype.constructor,type:4,write(e){return e.id},read(e){return new Yx(e)}});Wl({Class:Qx.prototype.constructor,type:5,write(e){return e.data},read(e){return new Qx(e)}});Wl({Class:di.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,di.prototype),e}});function _U(e){var t=0;if(e.length===0)return t;for(let i=0;i<e.length;i++){let r=e[i];t=(t<<5)-t+r,t=t&t}return t}function vg(e){if(m0(e))return e;if(Array.isArray(e))return e.map(vg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=vg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var yg;(e=>{function t(s){return ab.pack(s)}e.serialize=t;function i(s){return ab.unpack(s)}e.deserialize=i;function r(s){return _U(t(vg(s))).toString()}e.checksum=r})(yg||(yg={}));var us={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition"],Scroll:["Transition","Animation","Create"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset"],GameControl:["Transition","Animation","Audio","Video","Create"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset"]},ob;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,toggle:!1,actions:new Qe}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new Qe}}e.defaultData=i})(ob||(ob={}));var ju;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(ju||(ju={}));var xg;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:ju.propertyDefaultData(s),rOperand:{...ju.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,n){return{type:"State",object:s??null,state:n??null}}e.stateDefaultData=r})(xg||(xg={}));var lb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new Qe,outActions:new Qe,condition:xg.distanceDefaultData(r)}}e.defaultData=i})(lb||(lb={}));var hb;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new Qe,drop:new Qe}})(hb||(hb={}));var bg;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new Qe})(bg||(bg={}));var wg;(e=>e.defaultData={type:"LookAt",disabled:!1,distance:1e3,dampingFactor:1,target:"cursor",tilt:"up",axis:"z",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledRotation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5})(wg||(wg={}));var cb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new Qe}}e.defaultData=i})(cb||(cb={}));var db;(e=>{function t(r){return r.type==="Scroll"}e.is=t;function i(){return{type:"Scroll",disabled:!1,steps:100,trigger:"load",startFrom:"enter",enterAnchor:"top",startOffset:0,endAfter:400,actions:new Qe}}e.defaultData=i})(db||(db={}));var ub;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new Qe}}e.defaultData=i})(ub||(ub={}));var pb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new Qe}}e.defaultData=i})(pb||(pb={}));var fb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,toggle:!1,target:"all",triggeringObjects:[],actions:new Qe,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(fb||(fb={}));var _g;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(a){return a.type==="Resize"}e.is=t;function i(a){return typeof a=="string"?a:"custom"}e.sizeToDevice=i;function r(a){return typeof a=="string"?[...e.defaultSizes[a]]:[...a]}e.deviceToSize=r;function s(){let a={size:"mobile",operator:"<",actions:new Qe},o={size:"tablet",operator:"<",actions:new Qe},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new Qe},h=new Qe;return h.push({id:st.generateUUID(),fi:0,data:a},{id:st.generateUUID(),fi:1,data:o},{id:st.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function n(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new Qe}}e.defaultBreakpointData=n})(_g||(_g={}));var ql="personal camera",Yh="a218fcc3-276b-49b9-b485-49037fd14f5f",SU=2960946,Gr=5526619,Ko;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n]}e.lerp=i})(Ko||(Ko={}));var Va;(e=>{function t(l,h){return l[0]===h[0]&&l[1]===h[1]&&l[2]===h[2]}e.isEqual=t;function i(l,h){return[l[0]+h[0],l[1]+h[1],l[2]+h[2]]}e.add=i;function r(l,h){return[l[0]-h[0],l[1]-h[1],l[2]-h[2]]}e.sub=r;function s(l,h){return[l[0]/h[0],l[1]/h[1],l[2]/h[2]]}e.div=s;function n(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=n;function a(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=a;function o(l,h,u){return[l[0]+(h[0]-l[0])*u,l[1]+(h[1]-l[1])*u,l[2]+(h[2]-l[2])*u]}e.lerp=o})(Va||(Va={}));var Gu;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]&&r[2]===s[2]&&r[3]===s[3]}e.isEqual=t;function i(r,s,n){return[r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]}e.lerp=i})(Gu||(Gu={}));var Sl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,n){for(let a=0;a<16;a++)if(s[a]!==n[a])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,n){let a=n.slice(0);for(var o=0,l=n.length;o<l;o+=3){let h=s[3]*n[o]+s[7]*n[o+1]+s[11]*n[o+2]+s[15];a[o]=(s[0]*n[o]+s[4]*n[o+1]+s[8]*n[o+2]+s[12])/h,a[o+1]=(s[1]*n[o]+s[5]*n[o+1]+s[9]*n[o+2]+s[13])/h,a[o+2]=(s[2]*n[o]+s[6]*n[o+1]+s[10]*n[o+2]+s[14])/h}return a}e.applyMatrix4=r})(Sl||(Sl={}));var Hi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function n(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=n;function a(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=a;function o(l,h,u){return{r:l.r+(h.r-l.r)*u,g:l.g+(h.g-l.g)*u,b:l.b+(h.b-l.b)*u}}e.lerp=o})(Hi||(Hi={}));var es;(e=>{e.white={...Hi.white,a:1},e.transparent={...Hi.white,a:0};function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}e.from0to1=t;function i(a,o){return{...Hi.fromHex(a),a:o}}e.fromHexAndA=i;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}e.toRgb255a1=r;function s(a,o){return Hi.equals(a,o)&&a.a===o.a}e.equals=s;function n(a,o,l){return{r:a.r+(o.r-a.r)*l,g:a.g+(o.g-a.g)*l,b:a.b+(o.b-a.b)*l,a:a.a+(o.a-a.a)*l}}e.lerp=n})(es||(es={}));var Sg;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Sg||(Sg={}));var mb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(mb||(mb={}));var gb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(gb||(gb={}));var jn;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(jn||(jn={}));var Ja;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(Ja||(Ja={}));var Al;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Al||(Al={}));var Yn;(e=>{function t(r,s=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*s,0,0]},grid:{count:[2,2,2],size:r.map(n=>n*(1+s)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}e.defaultData=t;function i(r,s){let n={...r};if(WA.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;qA.forEach(l=>{Object.assign(n.radial,{[l]:o[l]??a[l]})})}if(n.linear={...r.linear},s.linear){let a=r.linear,o=s.linear;XA.forEach(l=>{Object.assign(n.linear,{[l]:o[l]??a[l]})})}if(n.grid={...r.grid},s.grid){let a=r.grid,o=s.grid;YA.forEach(l=>{Object.assign(n.grid,{[l]:o[l]??a[l]})})}if(n.toObject={...r.toObject},s.toObject){let a=r.toObject,o=s.toObject;QA.forEach(l=>{Object.assign(n.toObject,{[l]:o[l]??a[l]})})}if(n.randomnessObject={...r.randomnessObject},s.randomnessObject){let a=r.randomnessObject,o=s.randomnessObject;ZA.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(Yn||(Yn={}));var Ag;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let n=[];r.count!==void 0&&n.push({type:0,path:s,props:{count:r.count}});for(let a of t){let o=r[a];o&&Object.keys(o).length>0&&n.push({type:0,path:[...s,a],props:o})}return n}e.toOps=i})(Ag||(Ag={}));var WA=["count"],qA=["radius","start","end","position","scale","rotation"],XA=["position","scale","rotation"],YA=["count","size"],QA=["count","position","scale","rotation"],ZA=["strength","scale","rotation","position","movement","seed","freqScale"],Mg;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Mg||(Mg={}));var Eg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:es.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:es.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Eg||(Eg={}));var Ml;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Ml||(Ml={}));var Cg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Cg||(Cg={}));var Tg;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(i,r){return i.flatShading===r.flatShading&&i.side===r.side&&i.wireframe===r.wireframe}e.equals=t})(Tg||(Tg={}));var Pg;(e=>e.defaultData={...Tg.defaultData,...Cg.defaultData})(Pg||(Pg={}));var vb;(e=>{function t(i,r){let s=[];if("material"in i){let n=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;n&&s.push(n)}else if("materials"in i)for(let n of i.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&s.push(a)}return s}e.getMaterialData=t})(vb||(vb={}));var Vu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Vu||(Vu={}));var yb;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(yb||(yb={}));function AU(e){return e.type!=="displace"}var xb;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(xb||(xb={}));var KA=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],MU=["wrapping","image","video","name"],tr;(e=>{function t(n,a){let{texture:o,...l}=a;if(Object.assign(n,l),o){let h=n.texture;h&&Object.assign(h,o)}}e.patch=t;function i(n,a){return n==="light"&&a?r(a):s(n)}e.defaultData=i;function r(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Vu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:Hi.fromHex(Gr)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Hi.fromHex(6710886),a:1},colorB:{...Hi.fromHex(6710886),a:1},colorC:{...Hi.fromHex(16777215),a:1},colorD:{...Hi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:es.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:es.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:es.fromHexAndA(0,1),contourColor:es.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Hi.fromHex(0),a:1},colorB:{...Hi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(tr||(tr={}));var zi;(e=>{function t(h){return!h.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}e.isMergable=t;function i(h){let u="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([d,p])=>{u+=`${d}${p}`,Array.isArray(p)?p.forEach(f=>u+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${p}`})}),u}e.getHash=i;function r(){return{layers:new Qe}}e.defaultEmptyData=r;function s(h="layer1",u="layer2"){return a("phong",h,u)}e.defaultData=s;function n(h,u){return{...h,name:u}}e.withName=n;function a(h,u="layer1",c="layer2"){let d=new Qe;return d.push({fi:0,data:tr.defaultData("light",h),id:u}),d.push({fi:1,data:tr.defaultData("color"),id:c}),{layers:d}}e.defaultTwoLayerData=a;function o(h,u="phong",c="layer1",d="layer2"){let p=tr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new Qe;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:tr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,u="phong",c="layer1",d="layer2"){let p=tr.defaultData("video");Object.assign(p.texture,{video:h});let f=new Qe;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:tr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(zi||(zi={}));var Hu;(e=>{function t(){return{points:new Qe,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Hu||(Hu={}));var Wu;(e=>{function t(){return{points:new Qe,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Wu||(Wu={}));var JA={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Dg;(e=>{function t(i,r){let s={...i};return e2.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(Dg||(Dg={}));var $A={shape:JA,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},e2=["depth","offset","angle","twist","startScale","endScale"],qu;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})(qu||(qu={}));var Ig;(e=>{function t(i,r){let s={...i};return Object.assign(s,r),s.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(s.extrusion={...i.extrusion},Object.assign(s.extrusion,Dg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Ig||(Ig={}));var rl;(e=>{function t(i){if(i==="RectangleGeometry")return{width:320,height:320,type:i,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="PathGeometry")return{type:i,width:1,height:1,depth:1,path:Wu.defaultData(),extrusion:$A};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Hu.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="BooleanGeometry")return{type:i,operation:2,width:0,height:0,depth:0,phongAngle:35};if(i==="TextGeometry")return{type:i,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:"",textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI};throw new Error("not implemented")}e.defaultData=t})(rl||(rl={}));var bb=["width","height","depth"],Lg;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Hi.white,near:.1,far:2e3})(Lg||(Lg={}));var Xu;(e=>{let t={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...t,blendFunction:16,granularity:15},bloom:{...t,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...t,offset:[2,2]},vignette:{...t,darkness:1,offset:0},hueSaturation:{...t,hue:3,saturation:0},brightnessContrast:{...t,brightness:.25,contrast:0},depthOfField:{...t,focalLength:2,focusDistance:2,bokehScale:2},noise:{...t,blendFunction:16}}})(Xu||(Xu={}));var Og;(e=>e.defaultData={softShadowQuality:"low"})(Og||(Og={}));var Rg;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Rg||(Rg={}));var Bg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Bg||(Bg={}));var El;(e=>e.defaultData={usePhysics:!1,gravity:-10})(El||(El={}));var zg;(e=>e.defaultData={playCamera:ql,gameControlObject:null})(zg||(zg={}));var Fg;(e=>e.defaultData={backgroundColor:es.fromHexAndA(SU,1),postprocessing:Xu.defaultData,fog:Lg.defaultData,globalPhysics:El.defaultData,ambient:Rg.defaultData,ao:Bg.defaultData,shadow:Og.defaultData,publish:zg.defaultData})(Fg||(Fg={}));var wb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(wb||(wb={}));var Cl;(e=>{e.identity={...Sg.identity,hiddenMatrix:Sl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,n){return{position:n?.position||s.position,rotation:n?.rotation||s.rotation,scale:n?.scale||s.scale,hiddenMatrix:n?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,n){return Ok({position:Va.isEqual(s.position,n.position)?void 0:n.position,rotation:Va.isEqual(s.rotation,n.rotation)?void 0:n.rotation,scale:Va.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Sl.isEqual(s.hiddenMatrix,n.hiddenMatrix)?void 0:n.hiddenMatrix})}e.diff=r})(Cl||(Cl={}));var Zi;(e=>e.defaultData={states:new Qe,events:new Qe,visible:!0,raycastLock:!1,physics:Ml.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Cl.identity,cloner:null})(Zi||(Zi={}));var Ng;(e=>e.defaultData={type:"Empty",...Zi.defaultData})(Ng||(Ng={}));var _b;(e=>e.defaultData={type:"Component",...Zi.defaultData})(_b||(_b={}));var sl;(e=>e.defaultData={type:"Mesh",...Zi.defaultData,...Pg.defaultData})(sl||(sl={}));var gc;(e=>e.defaultData={...Zi.defaultData,...Cl.identity,position:[0,0,Al.DefaultTargetOffset],...Al.defaultData})(gc||(gc={}));var kg;(e=>{function t(i){return{...Zi.defaultData,...Eg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(kg||(kg={}));var Yu;(e=>{function t(r,s,n=0){for(;n<s.length;){let a=r?r[s[n]]:void 0;if(s.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=t;function i(r,s,n=0){let a=t(r,s,n);if(a){let o=Object.keys(a);if(o.length===1&&o[0]==="descendants")return}return a}e.resolve=i})(Yu||(Yu={}));var Qn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Zi.defaultData,...s,component:r,overrides:new di,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=Cl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(Qn||(Qn={}));var Tl;(e=>e.defaultData={type:"Page",...Zi.defaultData,physics:{...Ml.defaultData,fusedBody:!1},...Fg.defaultData,camera:gc.defaultData})(Tl||(Tl={}));var Ug;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Sl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Ml.defaultData,states:new Qe,events:new Qe,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Al.defaultData},e.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},e.defaultMeshObject={name:"Rectangle",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("RectangleGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("BooleanGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Zi.defaultData,...sl.defaultData,geometry:rl.defaultData("TextGeometry"),material:zi.defaultTwoLayerData("phong","layer1","layer2")}))(Ug||(Ug={}));var Ba;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new di}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new di})))):Ja.is(n.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(n,a){if(a===void 0)return n;let o={...n};return"material"in o&&"material"in a&&a.material&&(o.material=mc(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&tr.patch(c,u)}}).data),o.materials&&a.materials&&(o.materials=mc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let u=a.materials[h];if(typeof u!="string")for(let[c,d]of Object.entries(u.layers)){let p=l[h]?.layers?.data(c);p&&tr.patch(p,d)}}}).data),o}function r(n,a){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function u(c,d){for(let[p,f]of Object.entries(d.layers)){let{texture:g,...m}=f;if(g!==void 0&&Object.keys(g).length>0){let v={path:[...c,"layers",p,"texture"],props:g,type:0};l.push(v)}if(Object.keys(m).length>0){let v={path:[...c,"layers",p],props:m,type:0};l.push(v)}}}for(let[c,d]of Object.entries(a))if(c!=="name")if(c==="cloner")l.push(...Ag.toOps(d,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:d.slide,offset:d.offset},type:0});else if(c==="material")u(["material"],d);else if(c==="materials")for(let[p,f]of Object.entries(d))u(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&d.extrusion!==void 0){let p={path:[c,"extrusion"],props:d.extrusion,type:0};l.push(p),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let p={path:[c],props:d,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=d;return l}e.toOps=r;function s(n,a){if(a===void 0)return n;let o={...n};if(Object.assign(o,Cl.merge(o,a)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:a.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??o.pathSnapping?.offset??0})}),Ja.is(n.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=a;l.orthographic?.zoom!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(o.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(o.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(o.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(o,{geometry:Ig.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Yn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:Yn.merge(o.cloner,a.cloner)});else if(Mg.is(n.type)){let l=a;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Hi.clone(l.color))}return o}e.patch=s})(Ba||(Ba={}));var Qu;(e=>e.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Qu||(Qu={}));var Ha;(e=>e.defaultData={orbitControls:Qu.defaultData,playPage:Yh,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Ha||(Ha={}));var jg;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(jg||(jg={}));var Gg;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Gg||(Gg={}));var nl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...jg.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Gg.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(nl||(nl={}));var vc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,n){r.scene.objects.traverseFrom(s,(a,o)=>{if(o.type==="Instance"){let l=Ju.getComponentData(r,o.component)?.data;l&&n(a,o,l.events)}else n(a,o,o.events)})}e.traverseModuleInstances=i})(vc||(vc={}));var al;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=[],a=Ug.defaultMeshObject;s.withLight===!0&&n.push({fi:-1,data:kg.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]});let o=new lr;return o.push({fi:1,id:Yh,data:{...Tl.defaultData,name:"Scene 1"},children:n}),o}e.defaultData={objects:t(),publish:Ha.defaultData,styles:nl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new lr,publish:Ha.defaultData,styles:nl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Ha.defaultData,styles:nl.defaultData()}};function i(s){return{...e.defaultData,objects:Ka(s,lr.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(al||(al={}));var Qh;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Qh||(Qh={}));var Zu;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Zu||(Zu={}));var Vg;(e=>e.all=["images","videos","colors","audios","fonts","materials"])(Vg||(Vg={}));var Sb;(e=>e.all=[...Vg.all,"components"])(Sb||(Sb={}));var Ab;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot}}e.defaultData=t})(Ab||(Ab={}));var yc;(e=>{function t(){return{images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,materials:new ot,components:new ot}}e.defaultData=t})(yc||(yc={}));var un;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ka(s,ot.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Zu.emptyImage,name:"AI generated image"}),Ka(n,ot.prototype)}e.defaultImages=i;function r(){return{catelogs:new ot,materials:new ot,images:new ot,videos:new ot,colors:new ot,audios:new ot,fonts:new ot,lib:yc.defaultData()}}e.emptyData=r})(un||(un={}));var Hg;(e=>e.list=["idle","move","jump","run"])(Hg||(Hg={}));var Ku;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Qe,move:new Qe,jump:new Qe,run:new Qe},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:es.fromHexAndA(3728051,1)}}))(Ku||(Ku={}));function Mb(e){e.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let i=t.colorA,r=t.colorB,s=[[i.r,i.g,i.b,i.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let o=2;o<10;o++)s.push(s[1]),n.push(1);let a={...xn(wi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...wi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Gn(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Vn(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,n)=>{s===void 0&&(r.materials[n]=zi.defaultData(),s=r.materials[n]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=zi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function EU(e){Object.assign(e.scene.publish,{orbitControls:{...Qu.defaultData,...wi(e.scene.publish.orbitControls)}})}function CU(e){Object.assign(e.scene.publish.settings,{video:{...Ha.defaultData.settings.video,...wi(e.scene.publish.settings.video)}})}function TU(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,n]of Object.entries(r))if((KA.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(MU.includes(a)||typeof o=="boolean")&&delete n[a]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let n=s;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function PU(e){e.scene.publish.withBackground=!0}function DU(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function IU(e){e.scene.objects.traverse((t,i)=>{let r=i.cloner;r&&(r.radial.scale=r.radial.scale.map(s=>s+1),r.linear.scale=r.linear.scale.map(s=>s+1))})}function LU(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function OU(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=wi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=wi(i).booleanExclude!==!0)}})}function RU(e){e.scene.objects.traverse((t,i)=>{if(i.type==="Mesh"){let r=i;i.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function BU(e){function t(r){Object.setPrototypeOf(r,di.prototype),r.texture&&Object.setPrototypeOf(r.texture,di.prototype)}function i(r){Object.setPrototypeOf(r,di.prototype);for(let s in r)t(r[s])}e.scene.objects.traverse((r,s)=>{s.states.forEach(n=>{let a=n;if(a.material){let o=wi(a.material).layers;i(o),a.material.layers=o}if(a.materials)for(let o=0;o<a.materials.length;o++){let l=a.materials[o],h=wi(l).layers;i(h),l.layers=h}})})}function Eb(e){e.layers===void 0&&Object.assign(e,zi.defaultTwoLayerData("lambert"))}function Gf(e){!e.layers||e.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let i=[...t.colors];i.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let s={...wi(t),colors:i,steps:r};Object.assign(t,s)}})}function zU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Cb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Gf(r)}):"material"in i&&typeof i.material!="string"&&Gf(i.material)}),Object.values(e.shared.materials).forEach(t=>Gf(t))}function FU(e){e.scene.environment.ambientLight.softShadows=!1,e.scene.environment.ambientLight.softShadowQuality="low",e.scene.objects.traverse((t,i)=>{(i.type==="DirectionalLight"||i.type==="SpotLight")&&(i.shadowResolution=1024,i.shadowRadius=1,i.depth=1e5)}),e.shared.penumbraSize=new Array(5).fill(.5)}function NU(e){e.shared.audios=Ka({},ot.prototype)}function kU(e){e.shared.videos=Ka({},ot.prototype)}function UU(e){let t=e.shared.materials;Object.entries(t).forEach(([i,r])=>{if(!r.layers){let s={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[i]:s})}})}function jU(e){Object.entries(wi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(wi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function GU(e){e.scene.publish.settings.web.preload=!1}function Tb(e){e.layers&&e.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function Pb(e){e.layers&&e.layers.forEach(t=>{AU(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function VU(e){e.shared.fonts=Ka({},ot.prototype)}function HU(e){return e.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function WU(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=zi.defaultTwoLayerData("phong"),a=typeof s.color=="string"?e.shared.colors[s.color]:s.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=s.alpha;let o=HU(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Zi.defaultData,...sl.defaultData,flatShading:!1,wireframe:!1,geometry:{...rl.defaultData("TextGeometry"),width:s.width,height:s.height,font:o,depth:0,horizontalAlign:s.horizontalAlign,verticalAlign:s.verticalAlign,fontSize:s.fontSize*1.40625,lineHeight:s.lineHeight/1.40625,letterSpacing:s.letterSpacing-1,text:s.text,textTransform:s.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:wi(s.states),events:wi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=wi(e.scene.objects).parent(i);e.scene.objects.insertAfter(h??null,i,[{id:i+"new",data:l,children:[]}]),t.push(i)}}),t.forEach(i=>{e.scene.objects.delete(i)})}function qU(e){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};e.scene.objects.traverse((i,r)=>{r.events.forEach(s=>{if(t[Number(s.type)])if(Object.assign(s,{type:t[Number(s.type)]}),s.type==="Audio"&&"audioEvent"in s&&(Object.assign(s,{playAudio:s.audioEvent}),delete s.audioEvent),s.type==="GameControl")Object.assign(s,{gameActions:{idle:new Qe,move:new Qe,jump:new Qe}});else{let n=new Qe;Object.assign(s,{actions:n}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&n.push({fi:0,id:st.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((a,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,xn(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let c={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...c,...u},p={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Qe({fi:0,id:st.generateUUID(),data:h},{fi:1,id:st.generateUUID(),data:d})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function XU(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new Qe,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...xn(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(c={...xn(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&a.push({fi:u,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),a.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):i.events.insertBefore(null,[{id:st.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Db(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=tr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Ib(e){Gn(e,Db),Vn(e,Db)}function YU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function QU(e){e.scene.objects.traverse((t,i)=>{(i.type==="Empty"||i.type==="Mesh")&&i.cloner&&!i.cloner.randomnessObject&&!i.cloner.toObject&&!i.cloner.randomness&&(i.cloner={...i.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function ZU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=zi.defaultTwoLayerData("phong"))})}function KU(e){e.scene.publish.orbitControls.autoZoom===void 0&&(e.scene.publish.orbitControls.autoZoom=!1),e.scene.objects.traverse((t,i)=>{(i.type==="OrthographicCamera"||i.type==="PerspectiveCamera")&&(i.orthographic.autoZoom===void 0&&(i.orthographic.autoZoom=!1),i.orthographic.autoZoomFrustumSize===void 0&&(i.orthographic.autoZoomFrustumSize=790))})}function JU(e){e.scene.objects.traverse((t,i)=>{i.pathSnapping===void 0&&(i.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),i.pathSnapping.offset===void 0&&(i.pathSnapping.offset=0)})}function $U(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function e6(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function t6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function i6(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function r6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Ku.defaultDataThirdPerson.navmesh)})})}function s6(e){e.scene.styles||(e.scene.styles=nl.defaultData())}function Lb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function n6(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Vn(e,Lb),Gn(e,Lb)}function a6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Qe})})})}function o6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Ob(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function l6(e,t){if(t<1&&(Vn(e,Mb),Gn(e,Mb),e.schema=1),t<2&&(EU(e),e.schema=2),t<3&&(TU(e),e.schema=3),t<4&&(PU(e),e.schema=4),t<5&&(DU(e),e.schema=5),t<6&&(IU(e),e.schema=6),t<7&&(LU(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Cb(e),e.schema=9),t<10&&(zU(e),e.schema=10),t<11&&(FU(e),e.schema=11),t<12&&(Cb(e),e.schema=12),t<13&&(NU(e),e.schema=13),t<14&&(UU(e),e.schema=14),t<15&&(jU(e),e.schema=15),t<16&&(GU(e),e.schema=16),t<17&&(Vn(e,Tb),Gn(e,Tb),e.schema=17),t<18&&(Vn(e,Eb),Gn(e,Eb),e.schema=18),t<19&&(CU(e),e.schema=19),t<20&&(VU(e),WU(e),e.schema=20),t<21&&(qU(e),XU(e),e.schema=21),t<22&&(Ib(e),e.schema=22),t<23&&(YU(e),e.schema=23),t<24&&(QU(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(kU(e),t<25&&(e.schema=25)),t<26&&(OU(e),e.schema=26),t<27&&(RU(e),e.schema=27),t<28&&(Ib(e),e.schema=28),t<29&&(BU(e),e.schema=29),t<30&&(ZU(e),e.schema=30),t<31&&(KU(e),e.schema=31),t<33&&(JU(e),e.schema=33),t<34&&($U(e),e.schema=34),t<35&&(e6(e),e.schema=35),t<36&&(t6(e),e.schema=36),t<37&&(i6(e),e.schema=37),t<38&&(Vn(e,Pb),Gn(e,Pb),e.schema=38),t<39&&(r6(e),e.schema=39),t<40&&(s6(e),e.schema=40),t<41&&(n6(e),e.schema=41),t<42&&(a6(e),e.schema=42),t<43&&(o6(e),e.schema=43),t<99){Vn(e,Ob),Gn(e,Ob),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=ql);let i=wi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=Yh,r.insertBefore(null,null,[{id:Yh,data:{...Tl.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:xn(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:xn(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...El.defaultData,...xn(e.scene.environment,"usePhysics","gravity")},camera:wi(e.scene.ownerCamera)??Tl.defaultData.camera,name:"Scene"},children:[]}]);for(let a of i)a.id!==al.TRASH_CAN_ID&&r.move(Yh,a.fi,a.id);let s=0,n=0;e.shared.penumbraSize&&e.scene.objects.traverse((a,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(n,1)],n+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,Ml.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function Rb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function h6(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var Da=104;function t2(e){let t=e.schema??0;t!==Da&&(console.warn("updating from ",t,"to ",Da),l6(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Ha.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Vn(e,Rb),Gn(e,Rb),e.schema=101),t<102&&(h6(e),e.schema=102),t<104&&(e.shared.catelogs=new ot,e.shared.lib=yc.defaultData(),e.schema=104))}var Ju;(e=>{e.defaultData={schema:Da,scene:al.defaultData,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:{...un.emptyData(),colors:un.defaultColors()}},e.emptyDataForImports=function(s){let n=al.emptyDataWithPage(s);return{schema:Da,scene:n,frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:{...un.emptyData(),colors:un.defaultColors(),images:un.defaultImages(s)}}},e.emptyData=function(){return{schema:Da,scene:al.emptyDataWithPage(),frames:new ot().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Qh.defaultData),shared:un.emptyData()}},e.collabHelper={...dg,updateSchema(s){return(s.schema??0)<Da?mc(s,t2):(s.schema??0)-Da}};function t(s){let n=e.collabHelper.updateSchema(s);return typeof n=="number"?n===0?s:null:n.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:yc.defaultData()}}}e.withoutLib=i;function r(s,n){let a=s.scene.objects.get(n);if(a&&a.data.type==="Component")return a;{let o=s.shared.lib.components[n];if(o)return o.asset}}e.getComponentData=r})(Ju||(Ju={}));function za(e,t=!1){let i=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),n={},a={},o=e[0].morphTargetsRelative,l=new qe,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in c.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;n[p]===void 0&&(n[p]=[]),n[p].push(c.attributes[p]),d++}if(d!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in c.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.morphAttributes[p])}if(t){let p;if(i)p=c.index.count;else if(c.attributes.position!==void 0)p=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(i){let u=0,c=[];for(let d=0;d<e.length;++d){let p=e[d].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+u);u+=e[d].attributes.position.count}l.setIndex(c)}for(let u in n){let c=Bb(n[u]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,c)}for(let u in a){let c=a[u][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let d=0;d<c;++d){let p=[];for(let g=0;g<a[u].length;++g)p.push(a[u][g][d]);let f=Bb(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(f)}}return l}function Bb(e){let t,i,r,s=0;for(let o=0;o<e.length;++o){let l=e[o];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(t===void 0&&(t=l.array.constructor),t!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(i===void 0&&(i=l.itemSize),i!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=l.normalized),r!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=l.array.length}let n=new t(s),a=0;for(let o=0;o<e.length;++o)n.set(e[o].array,a),a+=e[o].array.length;return new Ye(n,i,r)}var c6=Math.pow(2,-24),Md=class{constructor(){}};function Ps(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function zb(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Fb(e,t){t.set(e)}function Nb(e,t,i){let r,s;for(let n=0;n<3;n++){let a=n+3;r=e[n],s=t[n],i[n]=r<s?r:s,r=e[a],s=t[a],i[a]=r>s?r:s}}function Ed(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],n=t[e+2*r+1],a=s-n,o=s+n;a<i[r]&&(i[r]=a),o>i[r+3]&&(i[r+3]=o)}}function mh(e){let t=e[3]-e[0],i=e[4]-e[1],r=e[5]-e[2];return 2*(t*i+i*r+r*t)}function d6(e,t){if(!e.index){let i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;i>65535?s=new Uint32Array(new r(4*i)):s=new Uint16Array(new r(2*i)),e.setIndex(new Ye(s,1));for(let n=0;n<i;n++)s[n]=n}}function u6(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let s of e.groups)i.add(s.start),i.add(s.start+s.count);let r=Array.from(i.values()).sort((s,n)=>s-n);for(let s=0;s<r.length-1;s++){let n=r[s],a=r[s+1];t.push({offset:n/3,count:(a-n)/3})}return t}function Vf(e,t,i,r,s=null){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=1/0,d=1/0,p=1/0,f=-1/0,g=-1/0,m=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],_=e[y+1],A=b-_,S=b+_;A<n&&(n=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let w=e[y+2],M=e[y+3],C=w-M,T=w+M;C<a&&(a=C),T>h&&(h=T),v&&w<d&&(d=w),v&&w>g&&(g=w);let D=e[y+4],P=e[y+5],L=D-P,B=D+P;L<o&&(o=L),B>u&&(u=B),v&&D<p&&(p=D),v&&D>m&&(m=D)}r[0]=n,r[1]=a,r[2]=o,r[3]=l,r[4]=h,r[5]=u,v&&(s[0]=c,s[1]=d,s[2]=p,s[3]=f,s[4]=g,s[5]=m)}function p6(e,t,i,r){let s=1/0,n=1/0,a=1/0,o=-1/0,l=-1/0,h=-1/0;for(let u=t*6,c=(t+i)*6;u<c;u+=6){let d=e[u+0];d<s&&(s=d),d>o&&(o=d);let p=e[u+2];p<n&&(n=p),p>l&&(l=p);let f=e[u+4];f<a&&(a=f),f>h&&(h=f)}r[0]=s,r[1]=n,r[2]=a,r[3]=o,r[4]=l,r[5]=h}function f6(e,t,i,r,s){let n=i,a=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;n<=a&&t[n*6+l]<o;)n++;for(;n<=a&&t[a*6+l]>=o;)a--;if(n<a){for(let h=0;h<3;h++){let u=e[n*3+h];e[n*3+h]=e[a*3+h],e[a*3+h]=u;let c=t[n*6+h*2+0];t[n*6+h*2+0]=t[a*6+h*2+0],t[a*6+h*2+0]=c;let d=t[n*6+h*2+1];t[n*6+h*2+1]=t[a*6+h*2+1],t[a*6+h*2+1]=d}n++,a--}else return n}}var an=32,m6=(e,t)=>e.candidate-t.candidate,Ln=new Array(an).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Cd=new Float32Array(6);function g6(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=zb(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=zb(e),a!==-1&&(o=v6(i,r,s,a));else if(n===2){let l=mh(e),h=1.25*s,u=r*6,c=(r+s)*6;for(let d=0;d<3;d++){let p=t[d],f=(t[d+3]-p)/an;if(s<an/4){let g=[...Ln];g.length=s;let m=0;for(let y=u;y<c;y+=6,m++){let x=g[m];x.candidate=i[y+2*d],x.count=0;let{bounds:b,leftCacheBounds:_,rightCacheBounds:A}=x;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,_[S]=1/0,_[S+3]=-1/0,b[S]=1/0,b[S+3]=-1/0;Ed(y,i,b)}g.sort(m6);let v=s;for(let y=0;y<v;y++){let x=g[y];for(;y+1<v&&g[y+1].candidate===x.candidate;)g.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let x=i[y+2*d];for(let b=0;b<v;b++){let _=g[b];x>=_.candidate?Ed(y,i,_.rightCacheBounds):(Ed(y,i,_.leftCacheBounds),_.count++)}}for(let y=0;y<v;y++){let x=g[y],b=x.count,_=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,w=0;b!==0&&(w=mh(A)/l);let M=0;_!==0&&(M=mh(S)/l);let C=1+1.25*(w*b+M*_);C<h&&(a=d,h=C,o=x.candidate)}}else{for(let v=0;v<an;v++){let y=Ln[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=an&&(y=an-1);let x=Ln[y];x.count++,Ed(v,i,x.bounds)}let g=Ln[an-1];Fb(g.bounds,g.rightCacheBounds);for(let v=an-2;v>=0;v--){let y=Ln[v],x=Ln[v+1];Nb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<an-1;v++){let y=Ln[v],x=y.count,b=y.bounds,_=Ln[v+1].rightCacheBounds;x!==0&&(m===0?Fb(b,Cd):Nb(b,Cd,Cd)),m+=x;let A=0,S=0;m!==0&&(A=mh(Cd)/l);let w=s-m;w!==0&&(S=mh(_)/l);let M=1+1.25*(A*m+S*w);M<h&&(a=d,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:a,pos:o}}function v6(e,t,i,r){let s=0;for(let n=t,a=t+i;n<a;n++)s+=e[n*6+r*2];return s/i}function y6(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,n=new Float32Array(s*6),a=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let u=["getX","getY","getZ"];for(let c=0;c<s;c++){let d=c*3,p=c*6,f,g,m;a?(f=r[d+0],g=r[d+1],m=r[d+2]):(f=r[d+0]*h+l,g=r[d+1]*h+l,m=r[d+2]*h+l);for(let v=0;v<3;v++){let y,x,b;a?(y=i[u[v]](f),x=i[u[v]](g),b=i[u[v]](m)):(y=o[f+v],x=o[g+v],b=o[m+v]);let _=y;x<_&&(_=x),b<_&&(_=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-_)/2,w=v*2;n[p+w+0]=_+S,n[p+w+1]=S+(Math.abs(_)+S)*c6,_<t[v]&&(t[v]=_),A>t[v+3]&&(t[v+3]=A)}}return n}function x6(e,t){function i(v){d&&d(v/p)}function r(v,y,x,b=null,_=0){if(!f&&_>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),x<=u||_>=l)return i(y+x),v.offset=y,v.count=x,v;let A=g6(v.boundingData,b,a,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=f6(o,a,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let w=new Md,M=y,C=S-y;v.left=w,w.boundingData=new Float32Array(6),Vf(a,M,C,w.boundingData,n),r(w,M,C,n,_+1);let T=new Md,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Vf(a,D,P,T.boundingData,n),r(T,D,P,n,_+1)}return v}d6(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=y6(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,g=[],m=u6(e);if(m.length===1){let v=m[0],y=new Md;y.boundingData=s,p6(a,v.offset,v.count,n),r(y,v.offset,v.count,n),g.push(y)}else for(let v of m){let y=new Md;y.boundingData=new Float32Array(6),Vf(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function b6(e,t){let i=x6(e,t),r,s,n,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){let c=i[u],d=l(c),p=new o(32*d);r=new Float32Array(p),s=new Uint32Array(p),n=new Uint16Array(p),h(0,c),a.push(p)}return a;function l(u){return u.count?1:1+l(u.left)+l(u.right)}function h(u,c){let d=u/4,p=u/2,f=!!c.count,g=c.boundingData;for(let m=0;m<6;m++)r[d+m]=g[m];if(f){let m=c.offset,v=c.count;return s[d+6]=m,n[p+14]=v,n[p+15]=65535,u+32}else{let m=c.left,v=c.right,y=c.splitAxis,x;if(x=h(u+32,m),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=x/4,x=h(x,v),s[d+7]=y,x}}}var Ns=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,n=e.length;s<n;s++){let a=e[s][t];i=a<i?a:i,r=a>r?a:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,n=t.length;s<n;s++){let a=t[s],o=e.dot(a);i=o<i?o:i,r=o>r?o:r}this.min=i,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};Ns.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,n=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){e.x=r.x*o+s.x*(1-o),e.y=r.y*l+s.y*(1-l),e.z=r.z*h+s.z*(1-h);let u=t.dot(e);n=Math.min(u,n),a=Math.max(u,a)}this.min=n,this.max=a}}();var tX=function(){let e=new Ns;return function(t,i){let r=t.points,s=t.satAxes,n=t.satBounds,a=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let u=n[h],c=s[h];if(e.setFromPoints(c,a),u.isSeparated(e))return!1}for(let h=0;h<3;h++){let u=l[h],c=o[h];if(e.setFromPoints(c,r),u.isSeparated(e))return!1}}}(),w6=function(){let e=new E,t=new E,i=new E;return function(r,s,n){let a=r.start,o=e,l=s.start,h=t;i.subVectors(a,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let u=i.dot(h),c=h.dot(o),d=h.dot(h),p=i.dot(o),f=o.dot(o)*d-c*c,g,m;f!==0?g=(u*c-p*d)/f:g=0,m=(u+g*c)/d,n.x=g,n.y=m}}(),A0=function(){let e=new k,t=new E,i=new E;return function(r,s,n,a){w6(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,n),s.at(l,a);return}else if(o>=0&&o<=1){l<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,n);return}else if(l>=0&&l<=1){o<0?r.at(0,n):r.at(1,n),s.closestPointToPoint(n,!0,a);return}else{let h;o<0?h=r.start:h=r.end;let u;l<0?u=s.start:u=s.end;let c=t,d=i;if(r.closestPointToPoint(u,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(u)<=d.distanceToSquared(h)){n.copy(c),a.copy(u);return}else{n.copy(h),a.copy(d);return}}}}(),_6=function(){let e=new E,t=new E,i=new xr,r=new kr;return function(s,n){let{radius:a,center:o}=s,{a:l,b:h,c:u}=n;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a||(r.start=l,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a)||(r.start=h,r.end=u,r.closestPointToPoint(o,!0,e).distanceTo(o)<=a))return!0;let c=n.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=a){let d=c.projectPoint(o,t);if(n.containsPoint(d))return!0}return!1}}(),S6=1e-15;function Mo(e){return Math.abs(e)<S6}var Sn=class extends Ri{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new Ns),this.points=[this.a,this.b,this.c],this.sphere=new Sr,this.plane=new xr,this.needsUpdate=!0}intersectsSphere(e){return _6(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,n=this.satBounds,a=s[0],o=n[0];this.getNormal(a),o.setFromPoints(a,r);let l=s[1],h=n[1];l.subVectors(e,t),h.setFromPoints(l,r);let u=s[2],c=n[2];u.subVectors(t,i),c.setFromPoints(u,r);let d=s[3],p=n[3];d.subVectors(i,e),p.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};Sn.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new kr;return function(r,s=null,n=null){let{start:a,end:o}=r,l=this.points,h,u=1/0;for(let c=0;c<3;c++){let d=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[d]),A0(i,r,e,t),h=e.distanceToSquared(t),h<u&&(u=h,s&&s.copy(e),n&&n.copy(t))}return this.closestPointToPoint(a,e),h=a.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(a)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<u&&(u=h,s&&s.copy(e),n&&n.copy(o)),Math.sqrt(u)}}();Sn.prototype.intersectsTriangle=function(){let e=new Sn,t=new Array(3),i=new Array(3),r=new Ns,s=new Ns,n=new E,a=new E,o=new E,l=new E,h=new kr,u=new kr,c=new kr;return function(d,p=null,f=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let g=this.plane,m=d.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let _=0;_<4;_++){let A=v[_],S=y[_];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let _=0;_<4;_++){let A=x[_],S=b[_];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let _=0;_<4;_++){let A=y[_];for(let S=0;S<4;S++){let w=b[S];if(n.crossVectors(A,w),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let L=v[P],B=v[(P+1)%3];h.start.copy(L),h.end.copy(B),h.delta(a);let V=y?u.start:u.end,U=Mo(m.distanceToPoint(L));if(Mo(m.normal.dot(a))&&U){u.copy(h),x=2;break}if((m.intersectLine(h,V)||U)&&!Mo(V.distanceTo(B))){if(x++,y)break;y=!0}}if(x===1&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(x!==2)return!1;let b=d.points,_=!1,A=0;for(let P=0;P<3;P++){let L=b[P],B=b[(P+1)%3];h.start.copy(L),h.end.copy(B),h.delta(o);let V=_?c.start:c.end,U=Mo(g.distanceToPoint(L));if(Mo(g.normal.dot(o))&&U){c.copy(h),A=2;break}if((g.intersectLine(h,V)||U)&&!Mo(V.distanceTo(B))){if(A++,_)break;_=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(u.delta(a),c.delta(o),a.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=u.start.dot(a),w=u.end.dot(a),M=c.start.dot(a),C=c.end.dot(a),T=w<M,D=S<C;return S!==C&&M!==w&&T===D?!1:(p&&(l.subVectors(u.start,c.start),l.dot(a)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(a)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}();Sn.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Sn.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new kr,s=new kr;return function(n,a=null,o=null){let l=a||o?r:null;if(this.intersectsTriangle(n,l))return(a||o)&&(a&&l.getCenter(a),o&&l.getCenter(o)),0;let h=1/0;for(let u=0;u<3;u++){let c,d=i[u],p=n[d];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,a&&a.copy(e),o&&o.copy(p));let f=this[d];n.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,a&&a.copy(f),o&&o.copy(e))}for(let u=0;u<3;u++){let c=i[u],d=i[(u+1)%3];r.set(this[c],this[d]);for(let p=0;p<3;p++){let f=i[p],g=i[(p+1)%3];s.set(n[f],n[g]),A0(r,s,e,t);let m=e.distanceToSquared(t);m<h&&(h=m,a&&a.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var ks=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new fe,this.invMatrix=new fe,this.points=new Array(8).fill().map(()=>new E),this.satAxes=new Array(3).fill().map(()=>new E),this.satBounds=new Array(3).fill().map(()=>new Ns),this.alignedSatBounds=new Array(3).fill().map(()=>new Ns),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};ks.prototype.update=function(){return function(){let e=this.matrix,t=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){let c=1*l|2*h|4*u,d=r[c];d.x=l?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}let s=this.satBounds,n=this.satAxes,a=r[0];for(let l=0;l<3;l++){let h=n[l],u=s[l],c=1<<l,d=r[c];h.subVectors(a,d),u.setFromPoints(h,r)}let o=this.alignedSatBounds;o[0].setFromPointsField(r,"x"),o[1].setFromPointsField(r,"y"),o[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ks.prototype.intersectsBox=function(){let e=new Ns;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,n=this.satAxes,a=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,a[0].isSeparated(e)||(e.min=i.y,e.max=r.y,a[1].isSeparated(e))||(e.min=i.z,e.max=r.z,a[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=n[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();ks.prototype.intersectsTriangle=function(){let e=new Sn,t=new Array(3),i=new Ns,r=new Ns,s=new E;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);let a=this.satBounds,o=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let c=0;c<3;c++){let d=a[c],p=o[c];if(i.setFromPoints(p,t),d.isSeparated(i))return!1}let l=n.satBounds,h=n.satAxes,u=this.points;for(let c=0;c<3;c++){let d=l[c],p=h[c];if(i.setFromPoints(p,u),d.isSeparated(i))return!1}for(let c=0;c<3;c++){let d=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(d,f),i.setFromPoints(s,t),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}();ks.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();ks.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();ks.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new kr),i=new Array(12).fill().map(()=>new kr),r=new E,s=new E;return function(n,a=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(o||l)&&(n.getCenter(s),this.closestPointToPoint(s,r),n.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=a*a,u=n.min,c=n.max,d=this.points,p=1/0;for(let g=0;g<8;g++){let m=d[g];s.copy(m).clamp(u,c);let v=m.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(m),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let g=0;g<3;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){let y=(g+1)%3,x=(g+2)%3,b=m<<y|v<<x,_=1<<g|m<<y|v<<x,A=d[b],S=d[_];t[f].set(A,S);let w=e[g],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[w]=u[w],D[M]=m?u[M]:c[M],D[C]=v?u[C]:c[M],P[w]=c[w],P[M]=m?u[M]:c[M],P[C]=v?u[C]:c[M],f++}for(let g=0;g<=1;g++)for(let m=0;m<=1;m++)for(let v=0;v<=1;v++){s.x=g?c.x:u.x,s.y=m?c.y:u.y,s.z=v?c.z:u.z,this.closestPointToPoint(s,r);let y=s.distanceToSquared(r);if(y<p&&(p=y,o&&o.copy(r),l&&l.copy(s),y<h))return Math.sqrt(y)}for(let g=0;g<12;g++){let m=t[g];for(let v=0;v<12;v++){let y=i[v];A0(m,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Eo=new E,Co=new E,To=new E,Td=new k,Pd=new k,Dd=new k,kb=new E,Ub=new E,jb=new E,Id=new E;function A6(e,t,i,r,s,n){let a;return n===xi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==br,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function M6(e,t,i,r,s,n,a,o,l){Eo.fromBufferAttribute(t,n),Co.fromBufferAttribute(t,a),To.fromBufferAttribute(t,o);let h=A6(e,Eo,Co,To,Id,l);if(h){r&&(Td.fromBufferAttribute(r,n),Pd.fromBufferAttribute(r,a),Dd.fromBufferAttribute(r,o),h.uv=Ri.getInterpolation(Id,Eo,Co,To,Td,Pd,Dd,new k)),s&&(Td.fromBufferAttribute(s,n),Pd.fromBufferAttribute(s,a),Dd.fromBufferAttribute(s,o),h.uv1=Ri.getInterpolation(Id,Eo,Co,To,Td,Pd,Dd,new k)),i&&(kb.fromBufferAttribute(i,n),Ub.fromBufferAttribute(i,a),jb.fromBufferAttribute(i,o),h.normal=Ri.getInterpolation(Id,Eo,Co,To,kb,Ub,jb,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let u={a:n,b:a,c:o,normal:new E,materialIndex:0};Ri.getNormal(Eo,Co,To,u.normal),h.face=u,h.faceIndex=n}return h}function i2(e,t,i,r,s){let n=r*3,a=e.index.getX(n),o=e.index.getX(n+1),l=e.index.getX(n+2),{position:h,normal:u,uv:c,uv1:d}=e.attributes,p=M6(i,h,u,c,d,a,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function E6(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)i2(e,t,i,a,n)}function C6(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=i2(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function Ms(e,t,i,r){let s=e.a,n=e.b,a=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),s.x=r.getX(o),s.y=r.getY(o),s.z=r.getZ(o),n.x=r.getX(l),n.y=r.getY(l),n.z=r.getZ(l),a.x=r.getX(h),a.y=r.getY(h),a.z=r.getZ(h)}function Gb(e,t,i,r,s,n,a){let o=i.index,l=i.attributes.position;for(let h=e,u=t+e;h<u;h++)if(Ms(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var r2=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function Hn(e,t){return t[e+15]===65535}function ol(e,t){return t[e+6]}function xc(e,t){return t[e+14]}function bc(e){return e+8}function wc(e,t){return t[e+6]}function T6(e,t){return t[e+7]}var Jo=new Jt,$u=new E,P6=["x","y","z"];function Wg(e,t,i,r,s){let n=e*2,a=Xl,o=ia,l=ra;if(Hn(n,o)){let h=ol(e,l),u=xc(n,o);E6(t,i,r,h,u,s)}else{let h=bc(e);ep(h,a,r,$u)&&Wg(h,t,i,r,s);let u=wc(e,l);ep(u,a,r,$u)&&Wg(u,t,i,r,s)}}function qg(e,t,i,r){let s=e*2,n=Xl,a=ia,o=ra;if(Hn(s,a)){let l=ol(e,o),h=xc(s,a);return C6(t,i,r,l,h)}else{let l=T6(e,o),h=P6[l],u=r.direction[h]>=0,c,d;u?(c=bc(e),d=wc(e,o)):(c=wc(e,o),d=bc(e));let p=ep(c,n,r,$u)?qg(c,t,i,r):null;if(p){let g=p.point[h];if(u?g<=n[d+l]:g>=n[d+l+3])return p}let f=ep(d,n,r,$u)?qg(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var D6=function(){let e,t,i=[],r=new r2(()=>new Jt);return function(...n){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let a=s(...n);r.releasePrimitive(e),r.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),a};function s(n,a,o,l,h=null,u=0,c=0){function d(y){let x=y*2,b=ia,_=ra;for(;!Hn(x,b);)y=bc(y),x=y*2;return ol(y,_)}function p(y){let x=y*2,b=ia,_=ra;for(;!Hn(x,b);)y=wc(y,_),x=y*2;return ol(y,_)+xc(x,b)}let f=n*2,g=Xl,m=ia,v=ra;if(Hn(f,m)){let y=ol(n,v),x=xc(f,m);return Ps(n,g,e),l(y,x,!1,c,u+n,e)}else{let y=bc(n),x=wc(n,v),b=y,_=x,A,S,w,M;if(h&&(w=e,M=t,Ps(b,g,w),Ps(_,g,M),A=h(w),S=h(M),S<A)){b=x,_=y;let V=A;A=S,S=V,w=M}w||(w=e,Ps(b,g,w));let C=Hn(b*2,m),T=o(w,C,A,c+1,u+b),D;if(T===2){let V=d(b),U=p(b)-V;D=l(V,U,!0,c+1,u+b,w)}else D=T&&s(b,a,o,l,h,u,c+1);if(D)return!0;M=t,Ps(_,g,M);let P=Hn(_*2,m),L=o(M,P,S,c+1,u+_),B;if(L===2){let V=d(_),U=p(_)-V;B=l(V,U,!0,c+1,u+_,M)}else B=L&&s(_,a,o,l,h,u,c+1);return!!B}}}(),I6=function(){let e=new Sn,t=new Sn,i=new fe,r=new ks,s=new ks;return function n(a,o,l,h,u=null){let c=a*2,d=Xl,p=ia,f=ra;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),Hn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,x=l.attributes.position,b=ol(a,f),_=xc(c,p);if(i.copy(h).invert(),l.boundsTree)return Ps(a,d,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,w=(_+b)*3;S<w;S+=3)if(Ms(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=_+b*3;A<S;A+=3){Ms(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let w=0,M=y.count;w<M;w+=3)if(Ms(t,w,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return Ps(g,d,Jo),!!(u.intersectsBox(Jo)&&n(g,o,l,h,u)||(Ps(m,d,Jo),u.intersectsBox(Jo)&&n(m,o,l,h,u)))}}}();function ep(e,t,i,r){return Ps(e,t,Jo),i.intersectBox(Jo,r)}var Xg=[],uu,Xl,ia,ra;function Fh(e){uu&&Xg.push(uu),uu=e,Xl=new Float32Array(e),ia=new Uint16Array(e),ra=new Uint32Array(e)}function Ld(){uu=null,Xl=null,ia=null,ra=null,Xg.length&&Fh(Xg.pop())}var Hf=Symbol("skip tree generation"),Wf=new Jt,qf=new Jt,Po=new fe,wa=new ks,gh=new ks,vh=new E,Od=new E,L6=new E,O6=new E,R6=new E,Vb=new Jt,ps=new r2(()=>new Sn),Zh=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Zh.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let i=e.geometry,r=e._roots,s=i.getIndex(),n;return t.cloneBuffers?n={roots:r.map(a=>a.slice()),index:s.array.slice()}:n={roots:r,index:s.array},n}static deserialize(e,t,i={}){if(typeof i=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Zh.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,n=new Zh(t,{...i,[Hf]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Ye(e.index,1,!1);t.setIndex(o)}else a.array!==r&&(a.array.set(r),a.needsUpdate=!0)}return n}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Hf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Hf]||(this._roots=b6(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Jt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,i=t.index.array,r=t.attributes.position,s,n,a,o,l=0,h=this._roots;for(let c=0,d=h.length;c<d;c++)s=h[c],n=new Uint32Array(s),a=new Uint16Array(s),o=new Float32Array(s),u(0,l),l+=s.byteLength;function u(c,d,p=!1){let f=c*2;if(a[f+15]===65535){let g=n[c+6],m=a[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,_=-1/0,A=-1/0;for(let S=3*g,w=3*(g+m);S<w;S++){let M=i[S],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>_&&(_=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==_||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=_,o[c+5]=A,!0):!1}else{let g=c+8,m=n[c+6],v=g+d,y=m+d,x=p,b=!1,_=!1;e?x||(b=e.has(v),_=e.has(y),x=!b&&!_):(b=!0,_=!0);let A=x||b,S=x||_,w=!1;A&&(w=u(g,d,x));let M=!1;S&&(M=u(m,d,x));let C=w||M;if(C)for(let T=0;T<3;T++){let D=g+T,P=m+T,L=o[D],B=o[D+3],V=o[P],U=o[P+3];o[c+T]=L<V?L:V,o[c+T+3]=B>U?B:U}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);n(0);function n(a,o=0){let l=a*2,h=s[l+15]===65535;if(h){let u=r[a+6],c=s[l+14];e(o,h,new Float32Array(i,a*4,6),u,c)}else{let u=a+8,c=r[a+6],d=r[a+7];e(o,h,new Float32Array(i,a*4,6),d)||(n(u,o+1),n(c,o+1))}}}raycast(e,t=ns){let i=this._roots,r=this.geometry,s=[],n=t.isMaterial,a=Array.isArray(t),o=r.groups,l=n?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=a?t[o[h].materialIndex].side:l,d=s.length;if(Fh(i[h]),Wg(0,r,c,e,s),Ld(),a){let p=o[h].materialIndex;for(let f=d,g=s.length;f<g;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=ns){let i=this._roots,r=this.geometry,s=t.isMaterial,n=Array.isArray(t),a=null,o=r.groups,l=s?t.side:t;for(let h=0,u=i.length;h<u;h++){let c=n?t[o[h].materialIndex].side:l;Fh(i[h]);let d=qg(0,r,c,e);Ld(),d!=null&&(a==null||d.distance<a.distance)&&(a=d,n&&(d.face.materialIndex=o[h].materialIndex))}return a}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Fh(s),r=I6(0,i,e,t),Ld(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(d,p,f,g)=>{let m=p*3;return c(d,m,m+1,m+2,f,g)}}e={boundsTraverseOrder:i,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=ps.getPrimitive(),{boundsTraverseOrder:n,intersectsBounds:a,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(d,p,f,g,m)=>c(d,p,f,g,m)?!0:Gb(d,p,r,l,f,g,s)}else o||(l?o=(c,d,p,f)=>Gb(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Fh(c),h=D6(0,r,a,o,n,u),Ld(),h)break;u+=c.byteLength}return ps.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,n=this.geometry.index,a=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Po.copy(t).invert();let h=ps.getPrimitive(),u=ps.getPrimitive();if(s){let d=function(p,f,g,m,v,y,x,b){for(let _=g,A=g+m;_<A;_++){Ms(u,_*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let S=p,w=p+f;S<w;S++)if(Ms(h,S*3,n,a),h.needsUpdate=!0,s(h,u,S,_,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,x,b,_){return p(f,g,m,v,y,x,b,_)?!0:d(f,g,m,v,y,x,b,_)}}else r=d}e.getBoundingBox(qf),qf.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>qf.intersectsBox(d),intersectsRange:(d,p,f,g,m,v)=>(Wf.copy(v),Wf.applyMatrix4(Po),e.shapecast({intersectsBounds:y=>Wf.intersectsBox(y),intersectsRange:(y,x,b,_,A)=>r(d,p,y,x,g,m,_,A)}))});return ps.releasePrimitive(h),ps.releasePrimitive(u),c}intersectsBox(e,t){return wa.set(e.min,e.max,t),wa.needsUpdate=!0,this.shapecast({intersectsBounds:i=>wa.intersectsBox(i),intersectsTriangle:i=>wa.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,n=1/0){e.boundingBox||e.computeBoundingBox(),wa.set(e.boundingBox.min,e.boundingBox.max,t),wa.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,u=e.index,c=ps.getPrimitive(),d=ps.getPrimitive(),p=Od,f=L6,g=null,m=null;r&&(g=O6,m=R6);let v=1/0,y=null,x=null;return Po.copy(t).invert(),gh.matrix.copy(Po),this.shapecast({boundsTraverseOrder:b=>wa.distanceToBox(b),intersectsBounds:(b,_,A)=>A<v&&A<n?(_&&(gh.min.copy(b.min),gh.max.copy(b.max),gh.needsUpdate=!0),!0):!1,intersectsRange:(b,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>gh.distanceToBox(A),intersectsBounds:(A,S,w)=>w<v&&w<n,intersectsRange:(A,S)=>{for(let w=A*3,M=(A+S)*3;w<M;w+=3){Ms(d,w,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=b*3,T=(b+_)*3;C<T;C+=3){Ms(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(d,p,g);if(D<v&&(f.copy(p),m&&m.copy(g),v=D,y=C/3,x=w/3),D<s)return!0}}}});{let A=u?u.count:h.count;for(let S=0,w=A;S<w;S+=3){Ms(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=b*3,C=(b+_)*3;M<C;M+=3){Ms(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(d,p,g);if(T<v&&(f.copy(p),m&&m.copy(g),v=T,y=M/3,x=S/3),T<s)return!0}}}}}),ps.releasePrimitive(c),ps.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(Po),f.applyMatrix4(Po),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,n=r*r,a=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(vh.copy(e).clamp(h.min,h.max),vh.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<a&&c<n,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,vh);let c=e.distanceToSquared(vh);return c<a&&(Od.copy(vh),a=c,o=u),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Od):t.point=Od.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Ps(0,new Float32Array(t),Vb),e.union(Vb)}),e}},yh=Ll(KE()),B6=.5*(Math.sqrt(3)-1),xh=(3-Math.sqrt(3))/6,z6=1/3,fs=1/6,iX=(Math.sqrt(5)-1)/4,rX=(5-Math.sqrt(5))/20,Kh=e=>Math.floor(e)|0,Hb=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),Xf=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function Yf(e=Math.random){let t=s2(e),i=new Float64Array(t).map(s=>Hb[s%12*2]),r=new Float64Array(t).map(s=>Hb[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*B6,u=Kh(s+h),c=Kh(n+h),d=(u+c)*xh,p=u-d,f=c-d,g=s-p,m=n-f,v,y;g>m?(v=1,y=0):(v=0,y=1);let x=g-v+xh,b=m-y+xh,_=g-1+2*xh,A=m-1+2*xh,S=u&255,w=c&255,M=.5-g*g-m*m;if(M>=0){let D=S+t[w],P=i[D],L=r[D];M*=M,a=M*M*(P*g+L*m)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[w+y],P=i[D],L=r[D];C*=C,o=C*C*(P*x+L*b)}let T=.5-_*_-A*A;if(T>=0){let D=S+1+t[w+1],P=i[D],L=r[D];T*=T,l=T*T*(P*_+L*A)}return 70*(a+o+l)}}function F6(e=Math.random){let t=s2(e),i=new Float64Array(t).map(n=>Xf[n%12*3]),r=new Float64Array(t).map(n=>Xf[n%12*3+1]),s=new Float64Array(t).map(n=>Xf[n%12*3+2]);return function(n,a,o){let l,h,u,c,d=(n+a+o)*z6,p=Kh(n+d),f=Kh(a+d),g=Kh(o+d),m=(p+f+g)*fs,v=p-m,y=f-m,x=g-m,b=n-v,_=a-y,A=o-x,S,w,M,C,T,D;b>=_?_>=A?(S=1,w=0,M=0,C=1,T=1,D=0):b>=A?(S=1,w=0,M=0,C=1,T=0,D=1):(S=0,w=0,M=1,C=1,T=0,D=1):_<A?(S=0,w=0,M=1,C=0,T=1,D=1):b<A?(S=0,w=1,M=0,C=0,T=1,D=1):(S=0,w=1,M=0,C=1,T=1,D=0);let P=b-S+fs,L=_-w+fs,B=A-M+fs,V=b-C+2*fs,U=_-T+2*fs,z=A-D+2*fs,X=b-1+3*fs,H=_-1+3*fs,G=A-1+3*fs,F=p&255,q=f&255,j=g&255,W=.6-b*b-_*_-A*A;if(W<0)l=0;else{let re=F+t[q+t[j]];W*=W,l=W*W*(i[re]*b+r[re]*_+s[re]*A)}let N=.6-P*P-L*L-B*B;if(N<0)h=0;else{let re=F+S+t[q+w+t[j+M]];N*=N,h=N*N*(i[re]*P+r[re]*L+s[re]*B)}let ie=.6-V*V-U*U-z*z;if(ie<0)u=0;else{let re=F+C+t[q+T+t[j+D]];ie*=ie,u=ie*ie*(i[re]*V+r[re]*U+s[re]*z)}let Q=.6-X*X-H*H-G*G;if(Q<0)c=0;else{let re=F+1+t[q+1+t[j+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*G)}return 32*(l+h+u+c)}}function s2(e){let t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){let r=i+~~(e()*(256-i)),s=t[i];t[i]=t[r],t[r]=s}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var Xr=new Ri,N6=class{constructor(e){this.weightAttribute=null;let t=e.geometry;if(!t.isBufferGeometry||t.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");t.index&&(t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let e=this.positionAttribute,t=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;Xr.a.fromBufferAttribute(e,r),Xr.b.fromBufferAttribute(e,r+1),Xr.c.fromBufferAttribute(e,r+2),s*=Xr.getArea(),t[r/3]=s}this.distribution=new Float32Array(e.count/3);let i=0;for(let r=0;r<t.length;r++)i+=t[r],this.distribution[r]=i;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,e,t)}}binarySearch(e){if(!this.distribution)return 0;let t=this.distribution,i=0,r=t.length-1,s=-1;for(;i<=r;){let n=Math.ceil((i+r)/2);if(n===0||t[n-1]<=e&&t[n]>e){s=n;break}else e<t[n]?r=n-1:i=n+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Xr.a.fromBufferAttribute(this.positionAttribute,e*3),Xr.b.fromBufferAttribute(this.positionAttribute,e*3+1),Xr.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Xr.a,r).addScaledVector(Xr.b,s).addScaledVector(Xr.c,1-(r+s)),Xr.getNormal(i),this}},k6=Ll(W_()),U6=new fe,j6=new fe,G6=new fe,_c;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(_c||(_c={}));var M0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new fe,this.copyPreviousMatrix=!0,this.hiddenMatrix=new fe,this.matrixWorldRigid=new fe,this.shearScale=new fe,this.shearScaleInv=new fe}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Et&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)_c.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)_c.is(r)&&r.traverseObject(t,i+1)}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,i=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:r,v:s,q:n}=(0,k6.SVD)(i),a=U6.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),o=j6.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=G6.copy(o).transpose();this.shearScale.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,l).copyPosition(this.matrixWorld),n.every(h=>Math.abs(n[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new fe().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof fe?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,n,a){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},V6=class extends M0(Et){},H6=e=>e.type==="Mesh",Bi=class extends V6{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Bi(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return H6(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}},Ia=new E,La=new E,ll=new fe,n2=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],W6=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],q6=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Wb=(e,t,i)=>{e.updateEntityBoxSize(Ia,La),ll.copy(t).multiply(e.matrixWorld),La.x===0&&La.y===0&&La.z===0?i.push(new E(Ia.x,Ia.y,Ia.z).applyMatrix4(ll)):n2.forEach(r=>{i.push(r.clone().multiply(La).add(Ia).applyMatrix4(ll))})},qb=class extends Jt{constructor(){super(...arguments),this.matrix=new fe,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new fe().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}Wb(s,t,r)}}):Wb(e,t,r),this.setFromPoints(r)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(ll.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(La).multiplyScalar(.5),this.getCenter(Ia),ll.copy(this.matrix).setPosition(Ia),this.vertices=n2.map(e=>e.clone().multiply(La).applyMatrix4(ll))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=W6.map(([e,t])=>new kr(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new E))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=q6.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},Zn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},X6=class extends xS{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let n=0,a=this.curves;n<a.length;n++){let o=a[n],l=n===0?r[n]:r[n]-r[n-1],h=Math.ceil(e*l/s),u=o.getPoints(h);for(let c=0;c<u.length;c++){let d=u[c];i&&i.equals(d)||(t.push(d),i=d)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},Yg=.001;function Qg(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Yg}function Qf(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),n=new E(...t.position);return Qg(i,r,n)&&Qg(i,s,n)}function a2(e){let t=e.points.map(u=>new E(...u.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let u=0;u<e.points.length-1;u++)Qg(r,t[u],t[u+1])||(i.push(e.points[u]),r=t[u]);i.push(e.points[e.points.length-1]);let s=e.isClosed,n=i.length-(s?0:1),a=i.length,o=[];for(let u=0;u<a;u++){let c=i[u].data,d=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),g={position:d,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(u===0||u===a-1)){o[u]={...g,removedLength:0};continue}let m=s&&u==0?a-1:u-1,v=s&&u==a-1?0:u+1,y=i[m].data,x=i[v].data,b=new E(...y.position),_=new E(...x.position),A=b.clone().sub(d).normalize(),S=_.clone().sub(d).normalize();Object.assign(g,{prevDir:A,nextDir:S});let w=Qf(y,c),M=Qf(c,x);if(!w||!M)o[u]={...g,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[u]={...g,tan:T,removedLength:c.roundness/T}}}for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d];if(p.removedLength!==0||f.removedLength!==0){let g=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,g/2),f.removedLength=Math.min(f.removedLength,g/2)}}let l=[];for(let u=0;u<n;u++){let c=u,d=s&&u===a-1?0:u+1,p=o[c],f=o[d],g=null;if(!Qf(i[c].data,i[d].data))p.position.distanceTo(f.position)>Yg&&(g=new ou(p.position,p.controlNext,f.controlPrevious,f.position));else{let m=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&m.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),m.distanceTo(v)>Yg&&(g=new ou(m,m.clone().lerp(v,.3),v.clone().lerp(m,.3),v))}l[2*u+1]=g}for(let u=0;u<a;u++){let c=o[u];if(c.removedLength===0){l[2*u]=null;continue}let d=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(d),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(d),g=c.tan*c.removedLength,m=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),b=m.clone().multiplyScalar(-g).add(x),_=d.distanceTo(b)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(_*d.distanceTo(p)).add(d),S=A.clone().lerp(b,2),w=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*u]=new ou(p,w,M,f)}let h=new X6;return l.forEach(u=>{u&&h.add(u)}),h}var pt;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(pt||(pt={}));var pn=e=>pt.is(e),Y6={type:"completeState",isfromEntity:!0},E0=e=>class extends M0(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new qb,this._recursiveBBox=new qb,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(pt.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(pt.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(pt.is(i))t=i;else return}return t}forInstancesRec(t){this.instances.forEach(i=>{i.disposed||t(i),i.forInstancesRec(t)})}super_Entity(t,i){typeof t=="string"&&(this.uuid=t),this.identity=t,this.data=i,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(t,i,r=!1){if(!(this.data.states.length===0&&!r)){for(let s of this.data.states)Ba.toOps(this.data,s.data).forEach(n=>{let a=cg.replaceProps(n,this.data);this.dataPatched=this.data,this.updateByPatchedOp(a,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Ba.patch(this.data,s),Ba.toOps(this.data,s).forEach(n=>{this.updateByPatchedOp(n,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t,this.updatePathSnapping(this.dataPatched.pathSnapping)}}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}updateEntityBoxSize(t,i){t.setScalar(0),i.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{pn(t)&&t.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(t=>{t.resetBBoxNeedsUpdateSelf()})}find(t){let i;return this.traverseEntity(r=>{r.uuid===t&&(i=r)}),i}traverseSortNextHelper(){let t=this.parent;if(t){let i=t.children,r=i.indexOf(this)+1;if(pt.is(i[r]))return i[r];if(pt.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&pt.is(this.children[0])?t[0]:this.traverseSortNextHelper()}goUp(t){let i=this;for(;t>0&&i!==null;)i=i.parent,t-=1;return i}hasAnccestorOrSelf(t){return this===t||this.hasAnccestor(t)}hasAnccestor(t){let i=this.parent;for(;i;){if(t===i)return!0;i=i.parent}return!1}countToAccestor(t){let i=0,r=this;for(;r!==t;){if(r===null)return-1;r=r.parent,i+=1}return i}forEachEntity(t){for(let i of this.children)pn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{pt.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)pn(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)pn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)pn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>pn(t))}isAncestorOf(t){if(this.uuid===t)return!1;let i=!1;return this.traverseEntity(r=>{r.uuid===t&&(i=!0)}),i}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return hg(i,t)}updateTransformState(t){let i=!1;return t.position&&(this.position.fromArray(t.position),i=!0),t.rotation&&(this.rotation.fromArray(t.rotation),i=!0),t.scale&&(i=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Sl.identity)),i&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(r=>{r.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),i}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)pt.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{pt.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return hg(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=Fr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=Os.zoom(u,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(h[d]=c[d])}}a={...t,props:h,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:u,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:u,...c}=l;l=c}let h=Os.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,Ba.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Fr(t.path,["overrides"])){let l=[],h=[...t.path];for(l.push(h[1]),h.splice(0,2);h.length>0&&h[0]==="descendants";)l.push(h[1]),h.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let u of Object.keys(t.props)){l[l.length-1]=u;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[u],c.updateState(ea.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=Os.zoom(u.component.data,h);if(t={...t,path:h},t.type===0){let d=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(d===t.props&&(d={...t.props}),d[p]=c[p]);t={...t,props:d}}u.overrideData=Yu.resolve(i.overrides,l),u.updateByOp(t,Xi.applySimple(u.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let u of Qn.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of Qn.rootOverrideProps)if(Fr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=ea.filterOp(h.overrideData,l);u&&h.updateByOp(u,Xi.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=ea.filterOp(h.overrideData,t);if(u){let c;n===h.data&&t===u?c=i:c=Xi.applySimple(h.data,u),h.updateByOp(u,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!Ja.is(t.props.type)&&Zn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){Zn.changeEntityProptotype(this,i,r);for(let s of this.children)pt.is(s)&&s.updateVisible()}this.updateByPatchedOp(t,i,r)}updateByPatchedOp(t,i,r){if(t.path.length===0&&t.type===0&&this.updateState(t.props,r),Fr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Fr(t.path,["cloner"])!==null){let s=Xi.drop(t,1);s.path.length===0&&s.type===0&&s.props.disabled===!0?this.setFromClonerState(null,r):this.cloner?this.cloner.updateState(i.cloner,r.scene):(this.setFromClonerState(i.cloner,r),this.expandCloner(r.scene)),this.updateVisible()}}updatePathSnapping(t){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,n=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let a=t.find(i);if(!a||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=a.data;if(o.geometry.path.points.length<=1)return;let l=a2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let u=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new fe;a.updateMatrixWorld();let d=new fe().multiplyMatrices(c.clone().invert(),a.matrixWorld);u.applyMatrix4(d);let p={position:u.toArray(),rotation:o.rotation};if(n==="tangential"){let f=new fe().extractRotation(a.matrixWorld),g=l.getTangentAt(h).applyMatrix4(f).add(u),m=new fe().lookAt(u,g,new E(0,1,0)),v=new yi().setFromRotationMatrix(m);p={...p,rotation:[v.x,v.y,v.z]}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(Y6)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof Zn.Cloner&&t.parameters.type==="toObject")}setFromClonerState(t,i){this.disposed||(t===null||t.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new Zn.Cloner(this,t),i.scene.addPendingExpandCloner(this)):this.cloner.updateState(t,i.scene))}expandCloner(t){!this.disposed&&this.cloner&&this.cloner.expandClones(t)}invalidateClonerTransform(t){this.cloner&&this.cloner.invalidateTransform(t)}},o2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters),r=i.width/2,s=i.radiusTop??r,n=i.radiusBottom??r;return s===n?(s=r,n=r):s>n?(s=r,n=n*r/s):(s=s*r/n,n=r),{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),radiusTop:s,radiusBottom:n})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:u,cornerRadius:c,cornerSegments:d,hollow:p}=e.parameters,f;return c||p?f=new l2(h,u,r,s,n,a,o,l*Math.PI/180,c,c,d,p):f=new Gv(h,u,r,s,n,a,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function On(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function Xb(e){return new k(e.y,-e.x)}var l2=class extends qe{constructor(e,t,i,r,s,n,a,o,l,h,u,c,d=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,i=i||1,r=Math.floor(r)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,o=o!==void 0?o:Math.PI*2,n&&(l=0,h=0);let p=[],f=[],g=[],m=[],v=0,y=i/2,x=new E,b=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let _=new k(e,y),A=new k(t,-y),S=null,w=null,M=null,C=null,T=_.clone().sub(A),D=0,P=0,L=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,L=t-D);let B=_.clone();B.x-=D;let V=Math.PI-T.angle(),U=T.angle(),z=Math.tan(U/2),X=Math.tan(V/2),H=z+X,G=c?H:X,F=c?H:z;if(l=Math.min(l,(e-P)/G,T.length()/H),h=Math.min(h,(t-L)/F,T.length()/H),l>0){let Q=l/z;S=_.clone().sub(new k(Q,l)),c&&(M=S.clone(),M.x-=D-H*l),_.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;w=A.clone().sub(new k(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=w.clone(),C.x-=D-H*h,B.sub(T.clone().setLength(Q)))}T=_.clone().sub(A);let q=T.length()<.5,j=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,ue=Z*o+a,ae=new k(Math.sin(ue),Math.cos(ue));C&&w?(W(re,Z,ae,V,h,C,-1,!0),W(re,Z,ae,U,h,w,-1,!1)):w?(N(re,ae,w.x,0,-1),W(re,Z,ae,U,h,w,-1,!1)):n||N(re,ae,t,L,-1);let se=Xb(T).normalize();if(On(se,ae,x),!q)for(let Ae=0;Ae<=s;Ae++){let Se=Ae/s,Me=T.clone().multiplyScalar(Se).add(A);On(Me,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}if(M&&S?(W(re,Z,ae,V,l,S,1,!1),W(re,Z,ae,U,l,M,1,!0)):S?(W(re,Z,ae,V,l,S,1,!1),N(re,ae,S.x,0,1)):n||N(re,ae,e,P,1),c&&!q){let Ae=Xb(T).multiplyScalar(-1).normalize();On(Ae,ae,x);for(let Se=0;Se<=s;Se++){let Me=Se/s,Pe=T.clone().multiplyScalar(-Me).add(B);On(Pe,ae,b),f.push(b.x,b.y,b.z),g.push(x.x,x.y,x.z),m.push(Z,.5+b.y/i),re.push(v++)}}c&&!n&&re.push(re[0]),j.push(re)}for(let Q=0;Q<j.length-1;Q++)for(let re=0;re<j[0].length-1;re++){if(n&&c&&re==s)continue;let Z=j[Q][re],ue=j[Q+1][re],ae=j[Q+1][re+1],se=j[Q][re+1],Ae=f[ae*3+0],Se=f[ae*3+2];p.push(Z,ue,se),(Ae!=0||Se!=0)&&p.push(ue,ae,se)}o<Math.PI*2&&(ie(-1,j[0],a),ie(1,j[j.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Le(f,3)),this.setAttribute("normal",new Le(g,3)),this.setAttribute("uv",new Le(m,2));function W(Q,re,Z,ue,ae,se,Ae,Se){for(let Me=0;Me<u+1;Me++){let Pe=Me/u,xe=Ae<0?Pe:1-Pe;Se&&(xe-=1),xe*=ue;let ve=new k(Math.sin(xe),Math.cos(xe)*Ae),Be=ve.clone().multiplyScalar(ae).add(se);On(Be,Z,b),f.push(b.x,b.y,b.z),On(ve,Z,x),g.push(x.x,x.y,x.z),m.push(re,.5+b.y/i),Q.push(v++)}}function N(Q,re,Z,ue,ae){let se=new E,Ae=new k,Se=[Z,ue];ae<0&&Se.reverse();for(let Me of Se)Ae.set(Me,y*ae),On(Ae,re,se),f.push(se.x,se.y,se.z),g.push(0,ae,0),m.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let ue=new k(Math.sin(Z),Math.cos(Z)),ae=new k(-Math.cos(Z),Math.sin(Z)),se=new E,Ae=Q<0?(Pe,xe,ve)=>p.push(Pe,xe,ve):(Pe,xe,ve)=>p.push(Pe,ve,xe),Se=new k((e+t+P+L)/4,0);On(Se,ue,se),f.push(se.x,se.y,se.z),g.push(ae.x,0,ae.y),m.push(.5,.5);let Me=v++;for(let Pe of re){let xe=f.slice(Pe*3,Pe*3+3);f.push(...xe),g.push(ae.x,0,ae.y);let ve=m.slice(Pe*2,Pe*2+2);m.push(...ve),v++}for(let Pe=Me+1;Pe<v-1;Pe++)Ae(Me,Pe,Pe+1);Ae(Me,v-1,Me+1)}}},Q6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:n,openEnded:a,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:u,cornerSegments:c}=e.parameters,d;return h>0||u>0||l<360?d=new l2(0,t/2,r,s,n,a,o,l*Math.PI/180,h,u,c,0,!0):d=new wS(t/2,r,s,n,a),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},Z6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:n,depthSegments:a,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new zs(t,i,r,s,n,a):h=new K6(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Zf=Math.PI/2,K6=class extends qe{constructor(e=1,t=1,i=1,r=1,s=1,n=1,a=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),n=Math.floor(n),o=Math.floor(o),a=Math.min(a,e/2,t/2,i/2);let h=[],u=[],c=[],d=[],p=0,f=0;g("z","y","x",-1,-1,i,t,e,n,s,0),g("z","y","x",1,-1,i,t,-e,n,s,1),g("x","z","y",1,1,e,i,t,r,n,2),g("x","z","y",1,-1,e,i,-t,r,n,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),a>0&&(m("z","y","x",-1,-1,1,i,t,e,n,0),m("z","y","x",1,-1,-1,i,t,e,n,1),m("z","y","x",-1,1,-1,i,t,e,n,1),m("z","y","x",1,1,1,i,t,e,n,0),m("x","y","z",-1,-1,-1,e,t,i,r,0),m("x","y","z",1,-1,1,e,t,i,r,1),m("x","y","z",-1,1,1,e,t,i,r,0),m("x","y","z",1,1,-1,e,t,i,r,1),m("y","x","z",-1,-1,1,t,e,i,s,0),m("y","x","z",1,-1,-1,t,e,i,s,1),m("y","x","z",1,1,1,t,e,i,s,1),m("y","x","z",-1,1,-1,t,e,i,s,0),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(h),this.setAttribute("position",new Le(u,3)),this.setAttribute("normal",new Le(c,3)),this.setAttribute("uv",new Le(d,2));function g(y,x,b,_,A,S,w,M,C,T,D){let P=(S-2*a)/C,L=(w-2*a)/T,B=S/2-a,V=w/2-a,U=M/2,z=C+1,X=T+1,H=0,G=0,F=new E;for(let q=0;q<X;q++){let j=q*L-V;for(let W=0;W<z;W++){let N=W*P-B;F[y]=N*_,F[x]=j*A,F[b]=U,u.push(F.x,F.y,F.z),F[y]=0,F[x]=0,F[b]=M>0?1:-1,c.push(F.x,F.y,F.z),d.push(W/C),d.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let j=0;j<C;j++){let W=p+j+z*q,N=p+j+z*(q+1),ie=p+(j+1)+z*(q+1),Q=p+(j+1)+z*q;h.push(W,N,Q),h.push(N,ie,Q),G+=6}l.addGroup(f,G,D),f+=G,p+=H}function m(y,x,b,_,A,S,w,M,C,T,D){let P=(w-2*a)/T,L=w/2-a,B=M/2-a,V=C/2,U=T+1,z=0,X=0,H=new E,G=new E;for(let F=0;F<o+1;F++){let q=F/o*Zf,j=Math.sin(q)*a,W=(1-Math.cos(q))*a,N=Math.sin(q),ie=Math.cos(q);H[x]=(B+j)*A,H[b]=(V-W)*S,G[y]=0,G[x]=N*Math.sign(H[x]),G[b]=ie*Math.sign(H[b]);for(let Q=0;Q<U;Q++){let re=Q*P-L;H[y]=re*_,u.push(H.x,H.y,H.z),c.push(G.x,G.y,G.z),d.push(Q/T),d.push(0),z+=1}}for(let F=0;F<o;F++)for(let q=0;q<T;q++){let j=p+q+U*F,W=p+q+U*(F+1),N=p+(q+1)+U*(F+1),ie=p+(q+1)+U*F;h.push(j,W,ie),h.push(W,N,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let _=new E,A=new E(e/2,t/2,i/2);A.subScalar(a);let S=[],w=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=Zf*(1-C/o),P=Math.cos(D),L=Math.sin(D),B=0;for(let V=0;V<=C;V++){let U=Math.cos(B),z=Math.sin(B);_.x=P*U,_.y=L,_.z=P*z;let X=A.clone().addScaledVector(_,a);u.push(y*X.x,x*X.y,b*X.z),c.push(y*_.x,x*_.y,b*_.z),d.push(0,0),T.push(p++),B+=Zf/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],D=S[C+1],P=T.length-1;w(T[0],D[1],D[0]);for(let L=1;L<=P;L++)w(T[L-1],T[L],D[L]),w(T[L],D[L+1],D[L])}}}},C0=class extends qe{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),u(),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(l,3)),this.setAttribute("uv",new Le(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(n=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],d=new E,p=d.clone(),f=new Ri,g=s*r,m=r-g,v=n+1,y=new E,x=(U,z)=>y.subVectors(U,z).normalize(),b=(U,z)=>Array(U).fill(void 0).map(z),_=b(e.length/3,(U,z)=>new E().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let U=0;U<_.length;U++){let z=_[U],X=[],H,G,F,q=1e10,j=-1;for(;(j=t.indexOf(U,j+1))!=-1;){let Q=j-j%3;H=t[Q+(j+1)%3],G=t[Q+(j+2)%3],F=z.distanceToSquared(_[H]),q=Math.min(q,F),X.push([H,G,F])}q+=1e-6;let W=[],N=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,G,F]=X[N];let re=A[H]?.includes(U)==!0;F<=q&&W.push(H+ +re*S),N=X.findIndex(Z=>Z[0]==G)}A.push(W)}let w=[];{let U=0,z=0,X,H,G=c==3;for(let F=0;F<=n;F++){X=F*(F+1)/2,H=(F+1)*(F+2)/2;for(let q=0;q<n-F;q++)[U,z]=[X+q+F+2,H+q+F+3],w.push(X,H,...G?[z,X]:[U,H],z,U),[X,H]=[U,z];w.push(X,H,X+n+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),D=d.clone(),P=d.clone(),L=[],B=b(_.length,()=>b(c,()=>d.clone()));for(let U=0;U<_.length;U++){d.copy(_[U]).normalize(),M.copy(d).multiplyScalar(m);let z=A[U];for(let W=0;W<z.length;W++){let N=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(_,U,N%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,B[U][W])}let X=[],H=[],G=[],F=new E;n==0&&[...B[U]].reduce((W,N)=>W.add(N),F).multiplyScalar(1/c);for(let W=0;W<c;W++){let N=[],ie=(W-1+c)%c,Q=B[U][ie],re=B[U][W];d.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(d),ue=d.angleTo(p),ae=Math.cos(Z)*g;n==0?C.copy(F):C.copy(M).setLength(m+ae),H.push(ae);let se=[C,Q,re];for(let Ae=0;Ae<2;Ae++){let Se=se[Ae],Me=se[Ae+1];D.subVectors(Se,M),P.subVectors(Me,M),T.crossVectors(D,P).normalize();for(let Pe=0;Pe<v;Pe++){let xe=[Z,ue][Ae]*Pe/v;d.copy(D).applyAxisAngle(T,xe).add(M),X.push(d.clone()),Ae&&(x(d,M),N.push([Pe==0?Se:d.clone(),y.clone()]))}Ae&&(x(Me,M),N.push([Me,y.clone()]))}G.push(N)}L.push(G);let q=2*v,j=2;for(let W=0;W<c;W++){let N=q*W,ie=q*((W+1)%c),Q=[X[N]];for(let Z=1;Z<v;Z++){D=X[N+Z],P=X[ie+Z],Q.push(D);for(let ue=1,ae=Z-j+1;ue<=ae;ue++)d.lerpVectors(D,P,ue/(ae+1)),d.sub(M).setLength(H[W]).add(M),Q.push(d.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+N]);Q.push(X[ie+v]);let re=w.map(Z=>Q[Z]);a.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let V=[];for(let U=0;U<A.length;U++)for(let z=0;z<c;z++){let X=A[U][z];if(X<S){let H=A[X].findIndex(q=>q%S==U),G=L[U][z],F=L[X][H];for(let q=0;q<v;q++){let j=G[q],W=F[v-q],N=G[q+1],ie=F[v-(q+1)];[j,W,N,N,W,ie].forEach(Q=>{a.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}V.push(G[0][0],F[v][0],G[v][0],F[0][0])}}for(;V.length;){let U,z,X,H;[U,z]=V.splice(0,2);let G=[U];for(;U!=z;)G.push(z),X=V.indexOf(z),H=X%2,z=V.splice(X-H,2)[1-H];y.subVectors(G[0],G[1]).cross(d.subVectors(G[0],G[2])).normalize();let F=y.dot(G[0])<0;F&&y.negate();for(let q=1;q<=G.length-2;q++)[G[q+ +F],G[q+1-+F],G[0]].forEach(j=>{a.push(j.x,j.y,j.z),l.push(y.x,y.y,y.z)})}}function u(){let c=new E;for(let A=0;A<a.length;A+=3){c.x=a[A+0],c.y=a[A+1],c.z=a[A+2];let S=b(c)/2/Math.PI+.5,w=_(c)/Math.PI+.5;o.push(S,1-w)}let d=new E,p=new E,f=new E,g=new E,m=new k,v=new k,y=new k,x=(A,S,w,M)=>{M<0&&A.x===1&&(o[S]=A.x-1),w.x===0&&w.z===0&&(o[S]=M/2/Math.PI+.5)};for(let A=0,S=0;A<a.length;A+=9,S+=6){d.set(a[A+0],a[A+1],a[A+2]),p.set(a[A+3],a[A+4],a[A+5]),f.set(a[A+6],a[A+7],a[A+8]),m.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),g.copy(d).add(p).add(f).divideScalar(3);let w=b(g);x(m,S+0,d,w),x(v,S+2,p,w),x(y,S+4,f,w)}for(let A=0;A<o.length;A+=6){let S=o[A+0],w=o[A+2],M=o[A+4],C=Math.max(S,w,M),T=Math.min(S,w,M);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),w<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function b(A){return Math.atan2(A.z,-A.x)}function _(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new C0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},J6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new h2(t*.5,n,a):new _S(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},h2=class extends C0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,n=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-r,0,-s,r,0,s,-r,0,s,r,-s,-r,0,-s,r,0,s,-r,0,s,r,0,-r,0,-s,r,0,-s,-r,0,s,r,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],o="DodecahedronGeometry";super(n,a,o,e,t,i),this.type=o}static fromJSON(e){return new h2(e.radius,e.corner,e.cornerSides)}},bh=1e-12,T0=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=st.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new T0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Zg=class extends T0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Zg(this.parent).copy(this)}},hl=class extends T0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Zg(this),new Zg(this))}static create(e,t){let i=new hl(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new hl(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(Yb(i,e),Yb(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function Yb(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var P0=e=>e,Yl=new k,Pp=new k,$6=new k,e8=new k,t8=new k,i8=new k,c2=new E,d2=new E;function r8(e){let t=new k;t.addVectors(e.v0,Yl.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Pp.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new $r(e.v0,t,i,e.v2)}function Nh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function s8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function n8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function u2(e,t,i){let r=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-n*n)/(2*s*r))}function a8(e,t,i){return Zb(e,t)&&Zb(t,i)&&Kg(e.position,t.position,i.position)}function Kg(e,t,i){return Yl.copy(t).sub(e).cross(Pp.copy(i).sub(e))===0}function o8(e,t,i,r,s){let n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),a=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(e.y-t.y)/n,h=Math.sqrt(Math.pow(i,2)-Math.pow(n/2,2))*(t.x-e.x)/n;return r.set(o+l,a+h),s.set(o-l,a-h),[r,s]}function l8(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function h8(e,t,i,r,s,n){let a=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,u=Math.sqrt((a+l)*(a+l)+(o+h)*(o+h)),c;return u2(t,e,i)>Math.PI&&(u*=-1),Nh(h,o)?c=(o+h)*(r/u-.5)*8/3/(a-l):c=(a+l)*(r/u-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*a),n.set(i.x+c*h,i.y-c*l),[s,n]}function Qb(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function Zb(e,t){return Kg(e.position,e.controls[1].position,t.position)&&Kg(e.position,t.controls[0].position,t.position)}function c8(e,t,i,r,s=.5){let n=Yl.subVectors(t,e).multiplyScalar(s).add(e),a=Pp.subVectors(i,t).multiplyScalar(s).add(t),o=$6.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=e8.subVectors(a,n).multiplyScalar(s).add(n),u=t8.subVectors(o,a).multiplyScalar(s).add(a),c=o,d=i8.subVectors(u,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,d.x,d.y,u.x,u.y,c.x,c.y,r.x,r.y]}function d8(e,t,i=12,r=!0){let s=d2.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=P0(t[l]),u=Yl,c=Wa(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof $r||h instanceof na||h instanceof ss){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),n!==void 0&&n8(n,s))continue;n===void 0&&(n=c2),n.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}return r&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),e}function u8(e,t,i,r=12,s=!0){let n=d2.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=P0(t[l]),c=Yl,d=Wa(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof $r||u instanceof na||u instanceof ss){if(u.getPoint(p/d,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=c2:(e.setXYZ(a,h.x,h.y,h.z),a++,e.setXYZ(a,n.x,n.y,n.z),a++),h.copy(n)}}return s&&a>1&&!(e.getX(a-1)===e.getX(0)&&e.getY(a-1)===e.getY(0)&&e.getZ(a-1)===e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),o}function Kb(e,t=12,i=!1){let r=[];for(let s=0,n=e.length;s<n;s++){let a=e[s],o=0;if(i&&a.roundedCurveCorner!==void 0){let l=Wa(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=Wa(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=Wa(e[0].roundedCurveCorner,t)*.5),r}function Wa(e,t=12){return e&&e instanceof pp?t*2:e&&(e instanceof ss||e instanceof yS)?1:e&&e instanceof jv?t*e.points.length:t}function p8(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=P0(t[a]),l=Wa(o,i),h=Yl;for(let u=0;u<=l;u++)if(o instanceof $r||o instanceof na||o instanceof ss){if(o.getPoint(u/l,h),s!==void 0&&s8(s,h,bh))continue;s===void 0&&(s=Pp),s.copy(h),e.push(h.x,h.y),n++}}return Nh(e[0],e[e.length-2],bh)&&Nh(e[1],e[e.length-1],bh)&&(e.pop(),e.pop()),r&&n>1&&!(Nh(e[n-1],e[1],bh)&&Nh(e[n-2],e[0],bh))&&(e.push(e[0],e[1]),n++),e}var Kf=new k,f8=new k,m8=new k,g8=new k,v8=new k,y8=new k,Ht=class extends Mu{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new xr(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=st.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new Ht;return r.isClosed=e.isClosed,r.points=e.points.map(s=>hl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>Ht.createFromState(s)),t!==void 0&&i!==void 0&&r.applySize(t,i),r.update(),r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,i=this.points.length;t<i;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){let t=this.points.length,i=this.points.findIndex(r=>r.uuid===e);if(i<0){let r=t;for(let s=0,n=this.shapeHoles.length;s<n;s++){let a=this.shapeHoles[s],o=a.points.length,l=a.getPointIndexById(e);if(l<0)r+=o;else return l+r}}return i}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let t=this.points.length;for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=e-t;if(n<=s.points.length-1)return s.points[n];t+=s.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let i=0,r=this.shapeHoles.length;i<r;i++){let s=this.shapeHoles[i],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let i=Kf.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let n=this.points[r];n.position.multiply(i),n.controls[0].position.multiply(i),n.controls[1].position.multiply(i)}for(let r=0,s=this.shapeHoles.length;r<s;r++)this.shapeHoles[r].applyScale(e,t);this._update()}createPoint(e,t=0,i=st.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new hl(i,r);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(r.uuid===e)return r}for(let t=0,i=this.shapeHoles.length;t<i;t++){let r=this.shapeHoles[t].getPointByUuid(e);if(r)return r}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(i=>i.uuid===e);t&&this.removePoint(t)}update(){for(let e=0,t=this.shapeHoles.length;e<t;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,t=12,i=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let r=i?this.roundedCurveDivisions:this.curveDivisions;return d8(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Kb(this.points,e,!1),this.roundedCurveDivisions=Kb(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return u8(e,this.curves,t,i,this.autoClose).reduce((r,s)=>r+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),p8(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let r=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Wa(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=r.reduce((a,o)=>a+o,0));for(let a=0,o=r.length;a<o;a++){let l=r[a];if(n<i+l)return[a,(n-i+1)/l];i+=l}return[0,1]}getCurveT(e,t,i){let r=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(Qb(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(Kf.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=n[l];return(t-o)/a}dispose(){}_applyCurveForPoint(e,t){Qb(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,t.curveAfter=i;let r=i.clone();e.roundedCurveBefore=r,t.roundedCurveAfter=r,e.roundedCurveCorner=void 0,this.roundedCurves.push(r)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];if(t===0)this.moveTo(r.position.x,r.position.y);else{let s=this.points[t-1];this._applyCurveForPoint(r,s)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let t=this.points[0],i=this.points[this.points.length-1];this._applyCurveForPoint(t,i)}if(this.points.length>2){let t=0;for(let i=0,r=this.points.length;i<r;i++){let s=this.points[i],n=this.points[i-1]??this.points[this.points.length-1],a=this.points[i+1]??this.points[0],o=s.roundness,l=n&&a&&a8(n,s,a);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,u=s.curveAfter;if(h===void 0||u===void 0)continue;let c=s.roundedCurveBefore,d=s.roundedCurveAfter,p=h.getLength(),f=u.getLength(),g=Math.min(o,p*.499),m=Math.min(o,f*.499),v=Math.min(g,m),y=1-v/p,x=v/f,b=h.getPointAt(y,Kf),_=u.getPointAt(x,f8);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(u,d,x,void 0,_);let A;if(this.useCubicForRoundedCorners){let S=u2(b,s.position,_)/2,w=Math.tan(S)*b.distanceTo(s.position),[M,C]=o8(b,_,w,m8,g8),T=l8(M,C,s.position),[D,P]=h8(T,b,_,w,v8,y8);A=new $r(b.clone(),D.clone(),P.clone(),_.clone())}else A=new na(b.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof ss)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,o=n.getUtoTmapping(i,0),l=c8(n.v0,n.v1,n.v2,n.v3,o);return r!==void 0&&(a.v0.set(l[0],l[1]),a.v1.set(l[2],l[3]),a.v2.set(l[4],l[5]),a.v3.set(l[6],l[7])),s!==void 0&&(a.v0.set(l[6],l[7]),a.v1.set(l[8],l[9]),a.v2.set(l[10],l[11]),a.v3.set(l[12],l[13])),a}return t}clone(){let e=new Ht(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let i=0;i<t;i++){let r=i*7,s=e.points[r+0],n=e.points[r+1],a=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],u=e.points[r+6],c=new hl(st.generateUUID(),new k(s,n));c.controls[0].position.set(a,o),c.controls[1].position.set(l,h),c.roundness=u,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new Ht;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof $r&&s.v3.equals(r.position)&&r.controls[0].position.copy(s.v2)},i=r=>{let s=[],n,a;for(n=0,a=r.length;n<a;n++)r[n]instanceof na&&(r[n]=r8(r[n]));for(n=0,a=r.length;n<a;n++){let h=r[n],u=n>0?r[n-1]:null,c;h instanceof $r?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof ss&&(c=this.createPoint(h.v1)),c!==void 0&&(u!==null&&t(c,u),s.push(c))}let o=r[r.length-1],l=!1;return o instanceof $r?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof ss&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof Mu&&(this.shapeHoles=e.holes.map(r=>{let s=new Ht;return s.fromShape(r),s})),this.update(),this}updatePoint(e,t){let i=this.getPointByUuid(e);i&&(t.position!==void 0&&i.position.fromArray(t.position),t.roundness!==void 0&&(i.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}},Jg=Math.PI*2;function Jf({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function x8(e,t){let i=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(e),s=Math.sin(e),n=Math.cos(e+t),a=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:n+a*i,y:a-n*i},{x:n,y:a}]}function Jb(e,t,i,r){let s=e*r-t*i<0?-1:1,n=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(n)}function b8(e,t,i,r,s,n,a,o,l,h){let u=Math.pow(s,2),c=Math.pow(n,2),d=Math.pow(a,2),p=Math.pow(o,2),f=u*c-u*p-c*d;f<0&&(f=0),f/=u*p+c*d,f=Math.sqrt(f)*(l===h?-1:1);let g=f*s/n*o,m=f*-n/s*a,v=g+(e+i)/2,y=m+(t+r)/2,x=(a-g)/s,b=(o-m)/n,_=(-a-g)/s,A=(-o-m)/n,S=Jb(1,0,x,b),w=Jb(x,b,_,A);return!h&&w>0&&(w-=Jg),h&&w<0&&(w+=Jg),{centerx:v,centery:y,ang1:S,ang2:w}}function w8({px:e,py:t,cx:i,cy:r,rx:s,ry:n,largeArcFlag:a,sweepFlag:o}){let l=[];if(s===0||n===0)return[];let h=(e-i)/2,u=(t-r)/2;if(h===0&&u===0)return[];s=Math.abs(s),n=Math.abs(n);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(u,2)/Math.pow(n,2);c>1&&(s*=Math.sqrt(c),n*=Math.sqrt(c));let d=b8(e,t,i,r,s,n,h,u,a,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,v=Math.abs(f)/(Jg/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(x8(p,f)),p+=f;return l.map(x=>{let{x:b,y:_}=Jf(x[0],s,n,g,m),{x:A,y:S}=Jf(x[1],s,n,g,m),{x:w,y:M}=Jf(x[2],s,n,g,m);return{x1:b,y1:_,x2:A,y2:S,x:w,y:M}})}var At;(function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(At||(At={}));var ri;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ri||(ri={}));function He(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){He(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?s<n?i.t-t.t+(t.t-r.t)*(s/(s+n)):i.t-r.t+(r.t-t.t)*(n/(s+n)):0},e.edgeSign=function(t,i,r){He(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,n=r.s-i.s;return s+n>0?(i.t-r.t)*s+(i.t-t.t)*n:0},e.transEval=function(t,i,r){He(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?s<n?i.s-t.s+(t.s-r.s)*(s/(s+n)):i.s-r.s+(r.s-t.s)*(n/(s+n)):0},e.transSign=function(t,i,r){He(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,n=r.t-i.t;return s+n>0?(i.s-r.s)*s+(i.s-t.s)*n:0},e.vertCCW=function(t,i,r){return t.s*(i.t-r.t)+i.s*(r.t-t.t)+r.s*(t.t-i.t)>=0},e.interpolate=function(t,i,r,s){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(i+s)/2:i+(s-i)*(t/(t+r)):s+(i-s)*(r/(t+r))},e.intersect=function(t,i,r,s,n){var a,o,l;e.vertLeq(t,i)||(l=t,t=i,i=l),e.vertLeq(r,s)||(l=r,r=s,s=l),e.vertLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.vertLeq(r,i)?e.vertLeq(i,s)?(a=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,i.s)):(a=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),a+o<0&&(a=-a,o=-o),n.s=e.interpolate(a,r.s,o,s.s)):n.s=(r.s+i.s)/2,e.transLeq(t,i)||(l=t,t=i,i=l),e.transLeq(r,s)||(l=r,r=s,s=l),e.transLeq(t,r)||(l=t,t=r,r=l,l=i,i=s,s=l),e.transLeq(r,i)?e.transLeq(i,s)?(a=e.transEval(t,r,i),o=e.transEval(r,i,s),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,i.t)):(a=e.transSign(t,r,i),o=-e.transSign(t,s,i),a+o<0&&(a=-a,o=-o),n.t=e.interpolate(a,r.t,o,s.t)):n.t=(r.t+i.t)/2},e}(),wh=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return e}(),Rd=function(){function e(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),e}(),Vo=function(){function e(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return e}(),$b=function(){function e(){var t=new Vo,i=new wh,r=new Rd(0),s=new Rd(1);t.next=t.prev=t,t.anEdge=null,i.next=i.prev=i,r.next=r,r.Sym=s,s.next=s,s.Sym=r,this.vHead=t,this.fHead=i,this.eHead=r,this.eHeadSym=s}return e.prototype.makeEdge_=function(t){var i=new Rd(0),r=new Rd(1);t.Sym.side<t.side&&(t=t.Sym);var s=t.Sym.next;return r.next=s,s.Sym.next=i,i.next=t,t.Sym.next=r,i.Sym=r,i.Onext=i,i.Lnext=r,i.Org=null,i.Lface=null,i.winding=0,i.activeRegion=null,r.Sym=i,r.Onext=r,r.Lnext=i,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,i},e.prototype.splice_=function(t,i){var r=t.Onext,s=i.Onext;r.Sym.Lnext=i,s.Sym.Lnext=t,t.Onext=s,i.Onext=r},e.prototype.makeVertex_=function(t,i,r){var s=t;He(s,"Vertex can't be null!");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i;var a=i;do a.Org=s,a=a.Onext;while(a!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;He(s,"Face can't be null");var n=r.prev;s.prev=n,n.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var a=i;do a.Lface=s,a=a.Lnext;while(a!==i)},e.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var i=t.next,r=t.Sym.next;i.Sym.next=r,r.Sym.next=i},e.prototype.killVertex_=function(t,i){var r=t.anEdge,s=r;do s.Org=i,s=s.Onext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},e.prototype.makeEdge=function(){var t=new Vo,i=new Vo,r=new wh,s=this.makeEdge_(this.eHead);return this.makeVertex_(t,s,this.vHead),this.makeVertex_(i,s.Sym,this.vHead),this.makeFace_(r,s,this.fHead),s},e.prototype.splice=function(t,i){var r=!1,s=!1;if(t!==i){if(i.Org!==t.Org&&(s=!0,this.killVertex_(i.Org,t.Org)),i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(i,t),!s){var n=new Vo;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new wh;this.makeFace_(a,i,t.Lface),t.Lface.anEdge=t}}},e.prototype.delete=function(t){var i=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var s=new wh;this.makeFace_(s,t,t.Lface)}i.Onext===i?(this.killVertex_(i.Org,null),this.killFace_(i.Lface,null)):(t.Lface.anEdge=i.Oprev,i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t)},e.prototype.addEdgeVertex=function(t){var i=this.makeEdge_(t),r=i.Sym;this.splice_(i,t.Lnext),i.Org=t.Dst;var s=new Vo;return this.makeVertex_(s,r,i.Org),i.Lface=r.Lface=t.Lface,i},e.prototype.splitEdge=function(t){var i=this.addEdgeVertex(t),r=i.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},e.prototype.connect=function(t,i){var r=!1,s=this.makeEdge_(t),n=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(n,i),s.Org=t.Dst,n.Org=i.Org,s.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new wh;this.makeFace_(a,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,n,a,o;s=i.Lnext;do r=s,s=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=i);a=t.prev,o=t.next,o.prev=a,a.next=o},e.prototype.countFaceVerts_=function(t){var i=t.anEdge,r=0;do r++,i=i.Lnext;while(i!==t.anEdge);return r},e.prototype.mergeConvexFaces=function(t){var i,r,s,n,a,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,a=r.Org;s=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(n.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Fe.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(s=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,n,a,o,l,h;for(n=t,n=t;(s=n.next)!==t;n=s){He(s.prev===n),l=s.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(He(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){He(a.prev===o),l=a.anEdge;do He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l),He(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(He(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)He(l.Sym.next===h.Sym),He(l.Sym!==l),He(l.Sym.Sym===l),He(l.Org!==null),He(l.Dst!==null),He(l.Lnext.Onext.Sym===l),He(l.Onext.Sym.Lnext===l);He(l.Sym.next===h.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},e}(),ew=function(){function e(){this.handle=null}return e}(),tw=function(){function e(){this.key=null,this.node=0}return e}(),_8=function(){function e(t,i){this.leq=i,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new ew,this.handles[r]=new tw;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[i[a+1].handle].key,r[i[a].handle].key)&&++a,He(a<=this.max),n=i[a].handle,a>this.size||this.leq(r[s].key,r[n].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,n,a;for(s=i[t].handle;;){if(a=t>>1,n=i[a].handle,a===0||this.leq(r[n].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=n,r[n].node=t,t=a}},e.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(t){var i,r;if(i=++this.size,i*2>this.max){this.max*=2;var s,n;for(n=this.nodes.length,this.nodes.length=this.max+1,s=n;s<this.nodes.length;s++)this.nodes[s]=new ew;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new tw}return this.freeList===0?r=i:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[i].handle=r,this.handles[r].node=i,this.handles[r].key=t,this.initialized&&this.floatUp_(i),r},e.prototype.extractMin=function(){var t=this.nodes,i=this.handles,r=t[1].handle,s=i[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,i[t[1].handle].node=1,i[r].key=null,i[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),s},e.prototype.delete=function(t){var i=this.nodes,r=this.handles,s;He(t>=1&&t<=this.max&&r[t].key!==null),s=r[t].node,i[s].handle=i[this.size].handle,r[i[s].handle].node=s,--this.size,s<=this.size&&(s<=1||this.leq(r[i[s>>1].handle].key,r[i[s].handle].key)?this.floatDown_(s):this.floatUp_(s)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},e}(),$f=function(){function e(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return e}(),iw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),S8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new iw,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(t){return this.insertBefore(this.head,t)},e.prototype.search=function(t){var i=this.head;do i=i.next;while(i.key!==null&&!this.leq(this.frame,t,i.key));return i},e.prototype.insertBefore=function(t,i){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,i));var r=new iw;return r.key=i,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},e.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},e}(),A8=function(){function e(){}return e.regionBelow=function(t){return t.nodeUp.prev.key},e.regionAbove=function(t){return t.nodeUp.next.key},e.debugEvent=function(t){},e.addWinding=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.edgeLeq=function(t,i,r){var s=t.event,n=i.eUp,a=r.eUp;if(n.Dst===s)return a.Dst===s?Fe.vertLeq(n.Org,a.Org)?Fe.edgeSign(a.Dst,n.Org,a.Org)<=0:Fe.edgeSign(n.Dst,a.Org,n.Org)>=0:Fe.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Fe.edgeSign(n.Dst,s,n.Org)>=0;var o=Fe.edgeEval(n.Dst,s,n.Org),l=Fe.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&He(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){He(i.fixUpperEdge),t.mesh.delete(i.eUp),i.fixUpperEdge=!1,i.eUp=r,r.activeRegion=i},e.topLeftRegion=function(t,i){var r=i.eUp.Org,s;do i=e.regionAbove(i);while(i.eUp.Org===r);if(i.fixUpperEdge){if(s=t.mesh.connect(e.regionBelow(i).eUp.Sym,i.eUp.Lnext),s===null)return null;e.fixUpperEdge(t,i,s),i=e.regionAbove(i)}return i},e.topRightRegion=function(t){var i=t.eUp.Dst;do t=e.regionAbove(t);while(t.eUp.Dst===i);return t},e.addRegionBelow=function(t,i,r){var s=new $f;return s.eUp=r,s.nodeUp=t.dict.insertBefore(i.nodeUp,s),s.fixUpperEdge=!1,s.sentinel=!1,s.dirty=!1,r.activeRegion=s,s},e.isWindingInside=function(t,i){switch(t.windingRule){case At.ODD:return(i&1)!==0;case At.NONZERO:return i!==0;case At.POSITIVE:return i>0;case At.NEGATIVE:return i<0;case At.ABS_GEQ_TWO:return i>=2||i<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,i){i.windingNumber=e.regionAbove(i).windingNumber+i.eUp.winding,i.inside=e.isWindingInside(t,i.windingNumber)},e.finishRegion=function(t,i){var r=i.eUp,s=r.Lface;s.inside=i.inside,s.anEdge=r,e.deleteRegion(t,i)},e.finishLeftRegions=function(t,i,r){for(var s,n=null,a=i,o=i.eUp;a!==r;){if(a.fixUpperEdge=!1,n=e.regionBelow(a),s=n.eUp,s.Org!=o.Org){if(!n.fixUpperEdge){e.finishRegion(t,a);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,n,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,a),o=n.eUp,a=n}return o},e.addRightEdges=function(t,i,r,s,n,a){var o,l,h,u,c=!0;h=r;do He(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(n===null&&(n=e.regionBelow(i).eUp.Rprev),l=i,u=n;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===u.Org;)h.Onext!==u&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(u.Oprev,h)),o.windingNumber=l.windingNumber-h.winding,o.inside=e.isWindingInside(t,o.windingNumber),l.dirty=!0,!c&&e.checkForRightSplice(t,l)&&(e.addWinding(h,u),e.deleteRegion(t,l),t.mesh.delete(u)),c=!1,l=o,u=h;l.dirty=!0,He(l.windingNumber-h.winding===o.windingNumber),a&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),n=Fe.vertL1dist(r,t),a=.5*n/(s+n),o=.5*s/(s+n);t.coords[0]+=a*i.coords[0]+o*r.coords[0],t.coords[1]+=a*i.coords[1]+o*r.coords[1],t.coords[2]+=a*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,n,a){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,n,a)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp;if(Fe.vertLeq(s.Org,n.Org)){if(Fe.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Fe.vertEq(s.Org,n.Org)?s.Org!==n.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,n.Oprev,s)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(s,n.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,n.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a;if(He(!Fe.vertEq(s.Dst,n.Dst)),Fe.vertLeq(s.Dst,n.Dst)){if(Fe.edgeSign(s.Dst,n.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,a=t.mesh.splitEdge(s),t.mesh.splice(n.Sym,a),a.Lface.inside=i.inside}else{if(Fe.edgeSign(n.Dst,s.Dst,n.Org)>0)return!1;i.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(s.Lnext,n.Sym),a.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,n=r.eUp,a=s.Org,o=n.Org,l=s.Dst,h=n.Dst,u,c,d=new Vo,p,f;if(He(!Fe.vertEq(h,l)),He(Fe.edgeSign(l,t.event,a)<=0),He(Fe.edgeSign(h,t.event,o)>=0),He(a!==t.event&&o!==t.event),He(!i.fixUpperEdge&&!r.fixUpperEdge),a===o||(u=Math.min(a.t,l.t),c=Math.max(o.t,h.t),u>c))return!1;if(Fe.vertLeq(a,o)){if(Fe.edgeSign(h,a,o)>0)return!1}else if(Fe.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Fe.intersect(l,a,h,o,d),He(Math.min(a.t,l.t)<=d.t),He(d.t<=Math.max(o.t,h.t)),He(Math.min(h.s,l.s)<=d.s),He(d.s<=Math.max(o.s,a.s)),Fe.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Fe.vertLeq(a,o)?a:o,Fe.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Fe.vertEq(d,a)||Fe.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,d)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,d)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(n.Sym,s),i=e.topLeftRegion(t,i),s=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),r),e.addRightEdges(t,i,s.Oprev,s,s,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Lnext,n.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=n.Oprev,n=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,n.Onext,s.Rprev,f,!0),!0):(Fe.edgeSign(l,t.event,d)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Fe.edgeSign(h,t.event,d)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,s),s.Org.s=d.s,s.Org.t=d.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,a,l,o,h),e.regionAbove(i).dirty=i.dirty=r.dirty=!0,!1)},e.walkDirtyRegions=function(t,i){for(var r=e.regionBelow(i),s,n;;){for(;r.dirty;)i=r,r=e.regionBelow(r);if(!i.dirty&&(r=i,i=e.regionAbove(i),i===null||!i.dirty))return;if(i.dirty=!1,s=i.eUp,n=r.eUp,s.Dst!==n.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(n),r=e.regionBelow(i),n=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==n.Org)if(s.Dst!==n.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||n.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===n.Org&&s.Dst===n.Dst&&(e.addWinding(n,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,n=r.Onext,a=e.regionBelow(i),o=i.eUp,l=a.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(n.Oprev,o),i=e.topLeftRegion(t,i),n=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),a),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,a,null),h=!0),h){e.addRightEdges(t,i,r.Onext,n,n,!0);return}Fe.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,n,a,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){He(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}He(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(He(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Fe.edgeGoesLeft(n)||(n=null),e.addRightEdges(t,i,a.Onext,o,n,!0)},e.connectLeftVertex=function(t,i){var r,s,n,a,o,l,h=new $f;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Fe.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Fe.vertLeq(o.Dst,a.Dst)?r:s,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(i.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(o.Dnext,i.anEdge);l=u.Sym}n.fixUpperEdge?e.fixUpperEdge(t,n,l):e.computeWinding(t,e.addRegionBelow(t,r,l)),e.sweepEvent(t,i)}else e.addRightEdges(t,r,i.anEdge,i.anEdge,null,!0)}},e.sweepEvent=function(t,i){t.event=i,e.debugEvent(t);for(var r=i.anEdge;r.activeRegion===null;)if(r=r.Onext,r===i.anEdge){e.connectLeftVertex(t,i);return}var s=e.topLeftRegion(t,r.activeRegion);He(s!==null);var n=e.regionBelow(s),a=n.eUp,o=e.finishLeftRegions(t,n,null);o.Onext===a?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,a,a,!0)},e.addSentinel=function(t,i,r,s){var n=new $f,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=s,a.Dst.s=i,a.Dst.t=s,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new S8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,n=t.bmax[0]+i,a=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,n,a),e.addSentinel(t,s,n,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(He(i.fixUpperEdge),He(++r===1)),He(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,n=t.mesh.eHead;for(i=n.next;i!==n;i=r)r=i.next,s=i.Lnext,Fe.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,n=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)n++;for(n+=8,i=t.pq=new _8(n,Fe.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,n;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,n=r.anEdge,He(n.Lnext!==n),n.Lnext.Lnext===n&&(e.addWinding(n.Onext,n),t.mesh.delete(n));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Fe.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),M8=function(){function e(){this.mesh=new $b,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=At.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(t,i){return t[0]*i[0]+t[1]*i[1]+t[2]*i[2]},e.prototype.normalize_=function(t){var i=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!i)throw"Zero-size vector!";i=Math.sqrt(i),t[0]/=i,t[1]/=i,t[2]/=i},e.prototype.longAxis_=function(t){var i=0;return Math.abs(t[1])>Math.abs(t[0])&&(i=1),Math.abs(t[2])>Math.abs(t[i])&&(i=2),i},e.prototype.computeNormal_=function(t){var i,r,s,n,a,o,l=[0,0,0],h=[0,0,0],u=[0,0,0],c=[0,0,0],d=[0,0,0],p=[null,null,null],f=[null,null,null],g=this.mesh.vHead;i=g.next;for(var m=0;m<3;++m)n=i.coords[m],h[m]=n,f[m]=i,l[m]=n,p[m]=i;for(i=g.next;i!==g;i=i.next)for(var v=0;v<3;++v)n=i.coords[v],n<h[v]&&(h[v]=n,f[v]=i),n>l[v]&&(l[v]=n,p[v]=i);var y=0;if(l[1]-h[1]>l[0]-h[0]&&(y=1),l[2]-h[2]>l[y]-h[y]&&(y=2),h[y]>=l[y]){t[0]=0,t[1]=0,t[2]=1;return}for(o=0,r=f[y],s=p[y],u[0]=r.coords[0]-s.coords[0],u[1]=r.coords[1]-s.coords[1],u[2]=r.coords[2]-s.coords[2],i=g.next;i!==g;i=i.next)c[0]=i.coords[0]-s.coords[0],c[1]=i.coords[1]-s.coords[1],c[2]=i.coords[2]-s.coords[2],d[0]=u[1]*c[2]-u[2]*c[1],d[1]=u[2]*c[0]-u[0]*c[2],d[2]=u[0]*c[1]-u[1]*c[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>o&&(o=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,n=0,a=t.next;a!==t;a=a.next)if(s=a.anEdge,!(s.winding<=0))do n+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==a.anEdge);if(n<0){for(i=r.next;i!==r;i=i.next)i.t=-i.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var t=this.mesh.vHead,i=[0,0,0],r,s,n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],!i[0]&&!i[1]&&!i[2]&&(this.computeNormal_(i),n=!0),r=this.sUnit,s=this.tUnit;var a=this.longAxis_(i);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,s[a]=0,s[(a+1)%3]=0,s[(a+2)%3]=i[a]>0?1:-1;for(var o=t.next;o!==t;o=o.next)o.s=this.dot_(o.coords,r),o.t=this.dot_(o.coords,s);n&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)n=t.connect(s.Lnext,s),s=n.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)n=t.connect(s.Lnext,s),s=n.Sym;return!0},e.prototype.tessellateInterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)if(i=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},e.prototype.discardExterior_=function(t){for(var i,r=t.fHead.next;r!==t.fHead;r=i)i=r.next,r.inside||t.zapFace(r)},e.prototype.setWindingNumber_=function(t,i,r){for(var s,n=t.eHead.next;n!==t.eHead;n=s)s=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?i:-i:r?t.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},e.prototype.outputPolymesh_=function(t,i,r,s){var n,a=0,o=0,l;r>3&&t.mergeConvexFaces(r);for(var h=t.vHead.next;h!==t.vHead;h=h.next)h.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var h=n.Org;h.n===-1&&(h.n=o,o++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,i===ri.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=o,this.vertices=[],this.vertices.length=o*s,this.vertexIndices=[],this.vertexIndices.length=o;for(var h=t.vHead.next;h!==t.vHead;h=h.next)if(h.n!==-1){var c=h.n*s;this.vertices[c+0]=h.coords[0],this.vertices[c+1]=h.coords[1],s>2&&(this.vertices[c+2]=h.coords[2]),this.vertexIndices[h.n]=h.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(u.inside){n=u.anEdge,l=0;do{var h=n.Org;this.elements[d++]=h.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var p=l;p<r;++p)this.elements[d++]=-1;if(i===ri.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){s=r=o.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==s);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*i,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,h=0,u=0;n=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){a=0,s=r=o.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],i>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[h++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==s);this.elements[u++]=n,this.elements[u++]=a,n+=a}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new $b),t<2&&(t=2),t>3&&(t=3);for(var r=null,s=0;s<i.length;s+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=i[s+0],r.Org.coords[1]=i[s+1],t>2?r.Org.coords[2]=i[s+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(t,i,r,s,n,a){if(t===void 0&&(t=At.ODD),i===void 0&&(i=ri.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),A8.computeInterior(this,a);var o=this.mesh;return i===ri.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===ri.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function Kn(e){var t=e.windingRule,i=t===void 0?At.ODD:t,r=e.elementType,s=r===void 0?ri.POLYGONS:r,n=e.polySize,a=n===void 0?3:n,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,u=h===void 0?[0,0,1]:h,c=e.contours,d=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,g=e.debug,m=g===void 0?!1:g;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new M8;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(i,s,a,l,u,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:m?v.mesh:void 0}}}var sX=At.ODD,nX=At.NONZERO,aX=At.POSITIVE,oX=At.NEGATIVE,lX=At.ABS_GEQ_TWO,hX=ri.POLYGONS,cX=ri.CONNECTED_POLYGONS,dX=ri.BOUNDARY_CONTOURS,$g=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let i=e*$g.eSize;this.buffer=new ArrayBuffer(i);let r=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*r,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*r,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let i=e*$g.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(r,n*s,3*e);n+=3*e;let o=new Float32Array(r,n*s,3*e);n+=3*e;let l=new Float32Array(r,n*s,2*e);t?(a.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=a,this.normals=o,this.uvs=l,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let r=this.capacity;for(;t>r;)r*=2;this.realloc(r)}let i=this.size;return this.size=t,i}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},p2=$g;p2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var E8=Ll($E()),D0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},f2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},m2={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},em=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),I0=class extends qe{constructor(e,t,i=0,r=12,s=3,n=At.ODD,a=!1){super(),this.forPathBevel=a,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],L=C[D-0];T.push(P,L)}return T}),h=[],u=[];for(let M=0;M<o.length;M+=2)u.push([o[M],o[M+1]]);h.push(u);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c=h[0].length?(0,E8.default)(h).distance:i;i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let d;try{d=Kn({windingRule:n,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{d=D0}let p;try{p=Kn({windingRule:At.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=f2}if(!d)throw new Error("error generating geometry");let f=d.elementCount;if(p){d.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?d.vertexCount:0;d.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=d.vertexCount;d.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];d.vertices.push(C)}}let g=1/0,m=-1/0,v=1/0,y=-1/0;for(let M=0,C=d.vertexCount;M<C;M++){let T=M*2,D=d.vertices[T+0],P=d.vertices[T+1];D<g&&(g=D),D>m&&(m=D),P<v&&(v=P),P>y&&(y=P)}this._minX=g,this._minY=v,this._width=m-g,this._height=y-v,this._buffer=new p2(this._computeBufferEstimatedSize(d));let x=[],b=[];for(let M=d.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=d.elements[T+0],P=d.elements[T+1],L=D+P,B={start:D,count:P,normals:[],continuous:[],concave:[]},V=D,U=L-1,z=D+1,X=this._shape.roundedCurves.length;do{let j=V-D,W=d.vertices[U*2+0],N=d.vertices[U*2+1],ie=d.vertices[V*2+0],Q=d.vertices[V*2+1],re=d.vertices[z*2+0],Z=d.vertices[z*2+1],ue=ie-W,ae=Q-N,se=Math.sqrt(ue*ue+ae*ae);ue/=se,ae/=se;let Ae=ie-re,Se=Q-Z,Me=Math.sqrt(Ae*Ae+Se*Se);Ae/=Me,Se/=Me,B.normals[j*2+0]=-Se,B.normals[j*2+1]=Ae,B.concave[j]=ue*Se-ae*Ae>0;let Pe=d.vertexIndices[V];if(Array.isArray(Pe))B.continuous[j]=!1;else{let[xe,ve]=this._shape.getCurveIndexFromVertexId(Pe-1,!0);if(ve>0&&ve<1)B.continuous[j]=!0;else{let Be=ve===1?xe+1:xe-1;Be=(Be+X)%X;let Ze=ve===1?0:1,R=this._shape.roundedCurves[xe].getTangent(ve),I=this._shape.roundedCurves[Be].getTangent(Ze);B.continuous[j]=R.dot(I)>.95}}C&&(B.normals[j*2+0]*=-1,B.normals[j*2+1]*=-1),[U,V,z]=[V,z,z+1],z>=L&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:d.vertices.slice(D*2,L*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((j,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:d.vertices.slice(D*2,L*2)});let G=0;for(let j=1;j<=this._bevelSegments;j++){let W=j/this._bevelSegments*Math.PI/2,N=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],ue=0;for(let se=0;se<P;se++){let Ae=se*2,Se=(se-1+P)%P*2,Me=d.vertices[B.start*2+Ae+0],Pe=d.vertices[B.start*2+Ae+1],xe=-B.normals[Se+0]*N,ve=-B.normals[Se+1]*N,Be=-B.normals[Ae+0]*N,Ze=-B.normals[Ae+1]*N;if(B.concave[se]||!B.concave[se]&&C){let R=Math.atan2(ve,xe),I=Math.atan2(Ze,Be);I>R&&(I-=Math.PI*2);let $=I-R;if(B.continuous[se]||C){let me=R+$/2,ce=Math.cos(me)*N,ye=Math.sin(me)*N;ie[2*ue+0]=Me+ce*(C?-1:1),ie[2*ue+1]=Pe+ye*(C?-1:1),Z[ue]=se,ue++}else{let me=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let ce=0;ce<=me;ce++){let ye=R+$*(ce/me),Oe=Math.cos(ye)*N,Ee=Math.sin(ye)*N;ie[2*ue+0]=Me+Oe,ie[2*ue+1]=Pe+Ee,Z[ue]=se,ue++}}}else ie[2*ue+0]=Me+xe,ie[2*ue+1]=Pe+ve,Z[ue]=se,Q[se]=ue,ue++,ie[2*ue+0]=Me,ie[2*ue+1]=Pe,Z[ue]=se,ue++,ie[2*ue+0]=Me+Be,ie[2*ue+1]=Pe+Ze,Z[ue]=se,re[se]=ue,ue++}let ae=Kn({windingRule:At.POSITIVE,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:se=>{let Ae=se.Org.idx,Se=Z[Ae],Me=Z[(Ae+1)%Z.length];se.idx=[Se,Me],se.Sym.idx=[Me,Se]},vertexIdCallback:se=>{let Ae=se.Lprev.idx;return[Ae?Ae[1]:0,se.idx?se.idx[0]:0]}});if(!ae)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!ae.vertexCount){let se=(j-1)/this._bevelSegments*Math.PI/2;G=(1-Math.sin(se))*this._bevel;break}for(let se=0;se<ae.vertexIndices.length;se++){let[Ae,Se]=ae.vertexIndices[se];if(Ae===Se)continue;let Me=Se;Se<Ae&&(Me+=P);for(let Pe=Ae;Pe<Me;Pe++){let xe=Pe%P,ve=(Pe+1)%P;if(!B.continuous[xe]||!B.continuous[ve]){ae.vertexIndices[se]=[Ae,xe],ae.vertexIndices.splice(se+1,0,[ve,Se]),ae.vertices.splice((se+1)*2,0,ae.vertices[se*2],ae.vertices[se*2+1]);break}}}H.push({bevelI:j,angle:W,size:N,boundary:ae,reverseMap:Z,insetPoints:ie})}let F=(j,W,N)=>{let ie=0,Q=j.boundary.vertexIndices.length;for(;ie<Q&&N(j.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let j=1;j<H.length;j++){let W=H[j-1],N=H[j],ie=W.boundary.vertexIndices.length,Q=N.boundary.vertexIndices.length;if(!ie||!Q)break;let re=B.concave.length,Z=0,ue=em(Z,P);for(;!W.boundary.vertexIndices.filter(ue).length||!N.boundary.vertexIndices.filter(ue).length;)Z++,ue=em(Z,P);let ae=W.boundary.vertexIndices.findIndex(ue),se=N.boundary.vertexIndices.findIndex(ue);do ae=(ae+1)%ie;while(ue(W.boundary.vertexIndices[ae]));do se=(se+1)%Q;while(ue(N.boundary.vertexIndices[se]));Z=(Z+1)%P;let Ae=Z,Se=0,Me=this._buildBevelVert(B,W,(ae-1+ie)%ie,void 0,Se),Pe=this._buildBevelVert(B,N,(se-1+Q)%Q,void 0,Se),xe=Me,ve=Pe,Be,Ze,R=!1;do{Se=(Z||re)/re,ue=em(Z,P);let I=F(W,ae,ue),$=F(N,se,ue),me=R;if(R=!1,I&&!$){for(let ce=0;ce<I;ce++)Be=this._buildBevelVert(B,W,(ae+ce)%ie,ce/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be;R=!0}else if(!I&&$)for(let ce=0;ce<$;ce++)Ze=this._buildBevelVert(B,N,(se+ce)%Q,ce/($-1),Se),x.push(ve.topN,xe.topP,Ze.topP),a===!1&&x.push(xe.bottomP,ve.bottomN,Ze.bottomP),ve=Ze;else if(I&&$)if(Be=this._buildBevelVert(B,W,ae,0,Se),Ze=this._buildBevelVert(B,N,se,0,Se),me?(x.push(xe.topN,Ze.topP,ve.topN),x.push(xe.topN,Be.topP,Ze.topP),a===!1&&(x.push(Ze.bottomP,xe.bottomN,ve.bottomN),x.push(Ze.bottomP,Be.bottomP,xe.bottomN))):(x.push(ve.topN,xe.topN,Be.topP),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&(x.push(Be.bottomP,xe.bottomN,ve.bottomN),x.push(Be.bottomP,ve.bottomN,Ze.bottomP))),xe=Be,ve=Ze,I===$)for(let ce=1;ce<I;ce++)Be=this._buildBevelVert(B,W,(ae+ce)%ie,ce/(I-1),Se),Ze=this._buildBevelVert(B,N,(se+ce)%Q,ce/($-1),Se),x.push(xe.topN,Be.topP,ve.topN),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&(x.push(Be.bottomP,xe.bottomN,ve.bottomN),x.push(Be.bottomP,ve.bottomN,Ze.bottomP)),xe=Be,ve=Ze;else if(I>$){let ce=I/$,ye=0;for(let Oe=1;Oe<I;Oe++)Be=this._buildBevelVert(B,W,(ae+Oe)%ie,Oe/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be,Oe>(ye+1)*ce&&(ye++,Ze=this._buildBevelVert(B,N,(se+ye)%Q,ye/($-1),Se),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&x.push(Be.bottomP,ve.bottomN,Ze.bottomP),ve=Ze)}else{let ce=$/I,ye=0;for(let Oe=1;Oe<$;Oe++)Ze=this._buildBevelVert(B,N,(se+Oe)%Q,Oe/($-1),Se),x.push(ve.topN,Be.topP,Ze.topP),a===!1&&x.push(Be.bottomP,ve.bottomN,Ze.bottomP),ve=Ze,Oe>(ye+1)*ce&&(ye++,Be=this._buildBevelVert(B,W,(ae+ye)%ie,ye/(I-1),Se),x.push(xe.topN,Be.topP,ve.topN),a===!1&&x.push(Be.bottomP,xe.bottomN,ve.bottomN),xe=Be)}ae=(ae+I)%ie,se=(se+$)%Q,Z=(Z+1)%re}while(Z!==Ae)}if(a===!1&&this._depth>this._bevel*2&&this._buildWall(H,B,x),C){let j=[];for(let W=x.length-1;W>=q+2;W-=3){let N=x[W-2],ie=x[W-1],Q=x[W-0];j.push(Q,ie,N)}x.splice(q,x.length-q,...j)}if(C){let j=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let N=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];j.push(N,ie)}b.push(j)}if(!C){let j=H[H.length-1],W;try{W=Kn({windingRule:H.length>1?At.POSITIVE:At.ODD,elementType:ri.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...b]})}catch{W=m2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let N=0;N<W.elementCount*3;N+=3){let ie=this._buildSurfaceVert(W,W.elements[N+0],G),Q=this._buildSurfaceVert(W,W.elements[N+1],G),re=this._buildSurfaceVert(W,W.elements[N+2],G);x.push(ie.top,Q.top,re.top),a===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new Ye(Uint32Array.from(x),1),A=new Ye(this._buffer.positions,3),S=new Ye(this._buffer.normals,3),w=new Ye(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,w.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",w),this.setIndex(_)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],n=e.vertices[t*2+1],a=(s-this._minX)/this._width,o=(n-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,u=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=n,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[u+0]=a,this._buffer.uvs[u+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=n,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[u+2]=a,this._buffer.uvs[u+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let n=`${t.bevelI}:${i}`;if(n in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[n].pathBevelUCoord))return this.vertexCache[n];let[a,o]=t.boundary.vertexIndices[i],l,h,u,c;a!==o?(h=a,l=o,c=!1,u=e.continuous[h]&&e.continuous[l]):(l=a,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,u=e.continuous[l]||c);let d=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,g=l*2,m=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,_=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),_=1);let A=e.normals[g+0],S=e.normals[g+1],w=e.normals[m+0],M=e.normals[m+1];if(c){let L=w-A,B=M-S;A=A+L*(1-r),S=S+B*(1-r);let V=Math.sqrt(A*A+S*S);A/=V,S/=V}let C=this.forPathBevel?this._buffer.get(u?1:2):this._buffer.get(u?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*d,this._buffer.normals[T+1]=S*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*d,this._buffer.normals[T+4]=S*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b),u||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=w*d,this._buffer.normals[T+1]=M*d,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=_,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=w*d,this._buffer.normals[T+4]=M*d,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=_,this._buffer.uvs[D+3]=b)),this.vertexCache[n]=P,P}clone(){let e=new I0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_p(this.userData),e}},g2=class extends qe{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=At.ODD,this.elementType=ri.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:At.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(d=>d.extractShapePointsToFlatArray([],this._curveSegments)),n,a=!0,o=!0,l,h;for(let d=0,p=r.length/2;d<p;d++){let f=d*2,g=r[f+0],m=r[f+1];if(l!==void 0&&g!==l&&(a=!1),h!==void 0&&m!==h&&(o=!1),l=g,h=m,!a&&!o)break}if(!a&&!o)try{n=Kn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{n=D0}let u=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Ye(new Float32Array(u*3),3),this._normalAttribute=new Ye(new Float32Array(u*3),3),this._uvAttribute=new Ye(new Float32Array(u*2),2),this._indexAttribute=new Ye(new Uint32Array(c*3),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,x=u;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1];_<d&&(d=_),_>p&&(p=_),A<f&&(f=A),A>g&&(g=A)}let m=p-d,v=g-f;for(let y=0,x=u;y<x;y++){let b=y*2,_=n.vertices[b+0],A=n.vertices[b+1],S=(_-d)/m,w=(A-f)/v;this._positionAttribute.setXYZ(y,_,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,w)}for(let y=0,x=c;y<x;y++){let b=y*3,_=n.elements[b+0],A=n.elements[b+1],S=n.elements[b+2];this._indexAttribute.setX(b+0,_),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(n?.elementCount??1)*3)}clone(){let e=new g2(this._shape,this._curveSegments);return e.userData=_p(this.userData),e}},v2=class extends I0{constructor(e,t,i=0,r=12,s=3,n=At.ODD){super(e,t,i,r,s,n),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,n=r.boundary.vertexCount;s<n;s++){let a=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%n);i.push(o.topP,a.topN,a.bottomN),i.push(o.topP,a.bottomN,o.bottomP)}}clone(){let e=new v2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_p(this.userData),e}},ro=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:At.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=e.shape??t?.shape,o=a?.roundness??i.roundness;a!==void 0&&(a instanceof Ht?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new Ht(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new Ht(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:n,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:n,windingRule:a}=e.parameters;e.shape.roundness=n;let o;return t<=0?o=new g2(e.shape,s,{windingRule:a}):o=new v2(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},y2=Math.PI*2,L0=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,angle:s,innerRadius:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,u=t*.5,c=i*.5,d=C8(h,u,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=ro.create({shape:h,parameters:{subdivisions:d,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function C8(e,t,i,r,s,n){if(r>=y2)return s>30||s%4===0?(P8(e,t,i,n),Math.round(s/4)):rw(e,r,s,t,i,n);r=Math.max(r,.001);let a={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=w8({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?T8(e,a.x,a.y,h,s,t,i,n):rw(e,r,s,t,i,n)}function T8(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(cl(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=cl(c.x,c.y);d.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?x2(e,n,a,o):e.addPoint(cl(0,0)),l}function rw(e,t,i,r,s,n){let a=-t/i;for(let o=0;o<=i;o++){let l=a*o,h=Math.sin(l)*r,u=Math.cos(l)*s;e.addPoint(cl(h,u))}return t<y2?n>0?x2(e,r,s,n):e.addPoint(cl(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&b2(e,r,s,n)),1}function P8(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Bd(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Bd(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Bd(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Bd(s,n-i,s+o,n-i,s-o,n-i)),r>0&&b2(e,t,i,r)}function cl(e,t){return new hl(st.generateUUID(),new k(e,t))}function Bd(e,t,i,r,s,n){let a=cl(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function x2(e,t,i,r){w2(e,t,i,r).forEach(s=>e.addPoint(s))}function b2(e,t,i,r){let s=w2(e,t,i,r),n=new Ht;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function w2(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new k(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=st.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(a);let h=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(h)}),o}var D8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??r),n=Math.abs(i.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:n,radius:a,segments:Math.round(i.segments),pathSegments:Math.round(i.pathSegments),cornerSegments:Math.round(i.cornerSegments)})}}static build(e){let{width:t,height:i,depth:r,radius:s,revolutions:n,segments:a,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:u,cornerSegments:c}=e.parameters,d=new _2(!1,t,i,r,s,n,a,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},tm=new tl([0,0,0],1),_2=class extends qe{constructor(e=!0,t=1,i=1,r=1,s=1,n=1,a=1,o=1,l=1,h=1,u=1,c=1){if(super(),n===0)return;let d=e&&n===1;d&&(c=0),u>100&&(u=100),u===0&&(c=0);let p=()=>new E,f=new E,g=p(),m=p(),v=p(),y,x,b,_,A,S,w,M,C=p(),T=p(),D=p(),P=p(),L=p(),B=p(),V=p(),U=p(),z=i-2*o+.001,X=z/n,H=Math.ceil(a*n),G=H+1,F=z/H,q=-z/2,j=h+1,W=2*Math.PI/h,N=Math.PI/2/c,ie=.01,Q=Math.min((1-u/100)*o,o-ie),re=o-Q,Z=0,ue=2,ae=c*ue+ue,se=j*ae/ue,Ae=se+j*G,Se=j*(G+ae),[Me,Pe,xe]=[3,3,2].map(De=>Array(Se*De).fill(0)),ve=[],Be=s-o;function Ze(De,Re){let Ie=Math.PI/2;S=Re*F,M=2*Math.PI*(S%X)/X+Ie,S+=q,w=Math.sin(M)*Be,A=Math.cos(M)*Be,e?De.set(A,w,S):De.set(A,S,w)}Ze(f,-1e-10),Ze(g,0),C.copy(f),Ze(f,1);let R=f.distanceTo(g),I=d?0:re+Q,$=R*H+2*I,me=Q,ce=$-I;for(let De=0;De<=H;De++){Ze(m,De),U.subVectors(m,C).normalize(),C.copy(m),B.copy(m).setComponent(+e+1,0).normalize(),V.crossVectors(U,B).normalize();let Re=De===0,Ie=De===H,Xe=Re?3*Math.PI/2:N,Ne=Re?me:ce,ft=Re?j:Ae,Rt=Re?0:Se-j,$t=U.clone().multiplyScalar(Re?-re:re).add(m),Y=U.clone().multiplyScalar(Re?-1:1).normalize();for(let ne=0;ne<j;ne++){let ge=ne*W;if(T.addVectors(f.copy(B).multiplyScalar(o*Math.cos(ge)),g.copy(V).multiplyScalar(o*Math.sin(ge))),D.copy(T).normalize(),Re||Ie){d||(Z=Rt+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=$t.getComponent(we),Pe[Z*3+we]=Y.getComponent(we)}),xe[Z*2]=+Ie,xe[Z*2+1]=ne/h),g.copy(D).multiplyScalar(Q),v.addVectors(m,g);for(let we=0;we<c;we++){let Ge=we*N+Xe;P.addVectors(f.copy(U).multiplyScalar(re*Math.sin(Ge)),g.copy(D).multiplyScalar(re*Math.cos(Ge))),L.copy(P).normalize(),g.addVectors(v,P),P.normalize(),Z=ft+we*j+ne,[0,1,2].forEach(kt=>{Me[Z*3+kt]=g.getComponent(kt),Pe[Z*3+kt]=L.getComponent(kt)});let vt=+Re+Math.sin(Ge);xe[Z*2]=(Ne+re*vt)/$,xe[Z*2+1]=ne/h}}g.addVectors(m,T),Z=se+De*j+ne,[0,1,2].forEach(we=>{Me[Z*3+we]=g.getComponent(we),Pe[Z*3+we]=D.getComponent(we)}),xe[Z*2]=(I+De*R)/$,xe[Z*2+1]=ne/h}}let ye=G+2*c+ue,Oe=1,[Ee,de]=[+d,ye-1];for(let De=Ee;De<=de-1;De++){let Re=d&&De===de-1;for(let Ie=0;Ie<j-1;Ie++)y=De*j+Ie,x=y+1,b=(Re?Ie:y)+j,_=(Re?Ie+1:x)+j,De===0?ve.push(x,_,b):De===ye-2?ve.push(y,x,b):ve.push(y,x,b,x,_,b)}this.setIndex(ve),this.setAttribute("position",new Le(Me,3)),this.setAttribute("normal",new Le(Pe,3)),this.setAttribute("uv",new Le(xe,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,n,a,o,l=6*(t-1)*e.radialSegments,h=t,u=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,n=s+1,a=(u?c:s)+i,o=(u?c+1:n)+i,r[l++]=s,r[l++]=n,r[l++]=a,r[l++]=n,r[l++]=o,r[l++]=a;return r.length=l,tm.array=r,tm.count=r.length,tm}},I8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,detail:s,corner:n,cornerSides:a}=e.parameters,o=s===0&&n!==0?new S2(t*.5,n,a):new CS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},S2=class extends C0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],n=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,n,a,e,t,i),this.type=a}static fromJSON(e){return new S2(e.radius,e.corner,e.cornerSides)}},L8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){(e.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let i=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{points:t,segments:i,verticalSegments:r}=e.parameters,s=new Mu;s.moveTo(t[0].x,t[0].y),s.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new bS(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},ms=new fe,im=new Et,zd=new E,tp=class extends Ti{constructor(){super(),this.uuid=st.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){let t=new bi().getNormalMatrix(e);for(let i=0,r=this.vertices.length;i<r;i++)this.vertices[i].applyMatrix4(e);for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];s.normal.applyMatrix3(t).normalize();for(let n=0,a=s.vertexNormals.length;n<a;n++)s.vertexNormals[n].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ms.makeRotationX(e),this.applyMatrix4(ms),this}rotateY(e){return ms.makeRotationY(e),this.applyMatrix4(ms),this}rotateZ(e){return ms.makeRotationZ(e),this.applyMatrix4(ms),this}translate(e,t,i){return ms.makeTranslation(e,t,i),this.applyMatrix4(ms),this}scale(e,t,i){return ms.makeScale(e,t,i),this.applyMatrix4(ms),this}lookAt(e){return im.lookAt(e),im.updateMatrix(),this.applyMatrix4(im.matrix),this}fromBufferGeometry(e){let t=this,i=e.index!==null?e.index:void 0,r=e.attributes;if(r.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=r.position,n=r.normal,a=r.color,o=r.uv,l=r.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<s.count;c++)t.vertices.push(new E().fromBufferAttribute(s,c)),a!==void 0&&t.colors.push(new je().fromBufferAttribute(a,c));function h(c,d,p,f){let g=a===void 0?[]:[t.colors[c].clone(),t.colors[d].clone(),t.colors[p].clone()],m=n===void 0?[]:[new E().fromBufferAttribute(n,c),new E().fromBufferAttribute(n,d),new E().fromBufferAttribute(n,p)],v=new ev(c,d,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,d),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,d),new k().fromBufferAttribute(l,p)])}let u=e.groups;if(u.length>0)for(let c=0;c<u.length;c++){let d=u[c],p=d.start,f=d.count;for(let g=p,m=p+f;g<m;g+=3)i!==void 0?h(i.getX(g),i.getX(g+1),i.getX(g+2),d.materialIndex):h(g,g+1,g+2,d.materialIndex)}else if(i!==void 0)for(let c=0;c<i.count;c+=3)h(i.getX(c),i.getX(c+1),i.getX(c+2));else for(let c=0;c<s.count;c+=3)h(c,c+1,c+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zd).negate(),this.translate(zd.x,zd.y,zd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new fe;return r.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(r),this}computeFaceNormals(){let e=new E,t=new E;for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=this.vertices[s.a],a=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,a),t.subVectors(n,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let i=0,r=this.vertices.length;i<r;i++)t[i]=new E;if(e){let i=new E,r=new E;for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=this.vertices[a.a],l=this.vertices[a.b],h=this.vertices[a.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[a.a].add(i),t[a.b].add(i),t[a.c].add(i)}}else{this.computeFaceNormals();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let i=0,r=this.vertices.length;i<r;i++)t[i].normalize();for(let i=0,r=this.faces.length;i<r;i++){let s=this.faces[i],n=s.vertexNormals;n.length===3?(n[0].copy(t[s.a]),n[1].copy(t[s.b]),n[2].copy(t[s.c])):(n[0]=t[s.a].clone(),n[1]=t[s.b].clone(),n[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let i=this.faces[e],r=i.vertexNormals;r.length===3?(r[0].copy(i.normal),r[1].copy(i.normal),r[2].copy(i.normal)):(r[0]=i.normal.clone(),r[1]=i.normal.clone(),r[2]=i.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]);for(let s=0,n=r.vertexNormals.length;s<n;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new tp;e.faces=this.faces;for(let t=0,i=this.morphTargets.length;t<i;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,n=this.morphNormals[t].vertexNormals;for(let a=0,o=this.faces.length;a<o;a++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),n.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,n=this.faces.length;s<n;s++){let a=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(a.normal),l.a.copy(a.vertexNormals[0]),l.b.copy(a.vertexNormals[1]),l.c.copy(a.vertexNormals[2])}}for(let t=0,i=this.faces.length;t<i;t++){let r=this.faces[t];r.normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Jt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Sr),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,i=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let r,s=this.vertices.length,n=this.vertices,a=e.vertices,o=this.faces,l=e.faces,h=this.colors,u=e.colors;t!==void 0&&(r=new bi().getNormalMatrix(t));for(let c=0,d=a.length;c<d;c++){let p=a[c].clone();t!==void 0&&p.applyMatrix4(t),n.push(p)}for(let c=0,d=u.length;c<d;c++)h.push(u[c].clone());for(let c=0,d=l.length;c<d;c++){let p=l[c],f,g,m=p.vertexNormals,v=p.vertexColors,y=new ev(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=m.length;x<b;x++)f=m[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)g=v[x],y.vertexColors.push(g.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++)v.push(m[y].clone());this.faceVertexUvs[c].push(v)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},i=[],r=[],s=Math.pow(10,e);for(let o=0,l=this.vertices.length;o<l;o++){let h=this.vertices[o],u=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[u]===void 0?(t[u]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[u]]}let n=[];for(let o=0,l=this.faces.length;o<l;o++){let h=this.faces[o];h.a=r[h.a],h.b=r[h.b],h.c=r[h.c];let u=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(u[c]===u[(c+1)%3]){n.push(o);break}}for(let o=n.length-1;o>=0;o--){let l=n[o];this.faces.splice(l,1);for(let h=0,u=this.faceVertexUvs.length;h<u;h++)this.faceVertexUvs[h].splice(l,1)}let a=this.vertices.length-i.length;return this.vertices=i,a}setFromPoints(e){this.vertices=[];for(let t=0,i=e.length;t<i;t++){let r=e[t];this.vertices.push(new E(r.x,r.y,r.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let o=0;o<t;o++)e[o]._id=o;function i(o,l){return o.materialIndex-l.materialIndex}e.sort(i);let r=this.faceVertexUvs[0],s=this.faceVertexUvs[1],n,a;r&&r.length===t&&(n=[]),s&&s.length===t&&(a=[]);for(let o=0;o<t;o++){let l=e[o]._id;n&&n.push(r[l]),a&&a.push(s[l])}n&&(this.faceVertexUvs[0]=n),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let p=this.parameters;for(let f in p)p[f]!==void 0&&(e[f]=p[f]);return e}let t=[];for(let p=0;p<this.vertices.length;p++){let f=this.vertices[p];t.push(f.x,f.y,f.z)}let i=[],r=[],s={},n=[],a={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],g=!0,m=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,_=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,g),A=h(A,2,m),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),A=h(A,7,_),i.push(A),i.push(f.a,f.b,f.c),i.push(f.materialIndex),v){let S=this.faceVertexUvs[0][p];i.push(d(S[0]),d(S[1]),d(S[2]))}if(y&&i.push(u(f.normal)),x){let S=f.vertexNormals;i.push(u(S[0]),u(S[1]),u(S[2]))}if(b&&i.push(c(f.color)),_){let S=f.vertexColors;i.push(c(S[0]),c(S[1]),c(S[2]))}}function h(p,f,g){return g?p|1<<f:p&~(1<<f)}function u(p){let f=p.x.toString()+p.y.toString()+p.z.toString();return s[f]!==void 0||(s[f]=r.length/3,r.push(p.x,p.y,p.z)),s[f]}function c(p){let f=p.r.toString()+p.g.toString()+p.b.toString();return a[f]!==void 0||(a[f]=n.length,n.push(p.getHex())),a[f]}function d(p){let f=p.x.toString()+p.y.toString();return l[f]!==void 0||(l[f]=o.length/2,o.push(p.x,p.y)),l[f]}return e.data={},e.data.vertices=t,e.data.normals=r,n.length>0&&(e.data.colors=n),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new tp().copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let c=0,d=t.length;c<d;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,d=i.length;c<d;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,d=r.length;c<d;c++)this.faces.push(r[c].clone());for(let c=0,d=e.faceVertexUvs.length;c<d;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,g=p.length;f<g;f++){let m=p[f],v=[];for(let y=0,x=m.length;y<x;y++){let b=m[y];v.push(b.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,d=s.length;c<d;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,g=s[c].vertices.length;f<g;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,g=s[c].normals.length;f<g;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let n=e.morphNormals;for(let c=0,d=n.length;c<d;c++){let p={};if(n[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,g=n[c].vertexNormals.length;f<g;f++){let m=n[c].vertexNormals[f],v={};v.a=m.a.clone(),v.b=m.b.clone(),v.c=m.c.clone(),p.vertexNormals.push(v)}}if(n[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,g=n[c].faceNormals.length;f<g;f++)p.faceNormals.push(n[c].faceNormals[f].clone())}this.morphNormals.push(p)}let a=e.skinWeights;for(let c=0,d=a.length;c<d;c++)this.skinWeights.push(a[c].clone());let o=e.skinIndices;for(let c=0,d=o.length;c<d;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,d=l.length;c<d;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new O8().fromGeometry(this),t=new qe,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Fd.call(new Ye(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Fd.call(new Ye(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",sw.call(new Ye(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",nw.call(new Ye(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",nw.call(new Ye(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],n=e.morphTargets[r];for(let a=0,o=n.length;a<o;a++){let l=n[a],h=new Le(l.data.length*3,3);h.name=l.name,s.push(Fd.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Le(e.skinIndices.length*4,4);t.setAttribute("skinIndex",aw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Le(e.skinWeights.length*4,4);t.setAttribute("skinWeight",aw.call(r,e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new qe,i=e.geometry;if(e.isPoints||e.isLine){let r=new Le(i.vertices.length*3,3),s=new Le(i.colors.length*3,3);if(t.setAttribute("position",Fd.call(r,i.vertices)),t.setAttribute("color",sw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Le(i.lineDistances.length,1);t.setAttribute("lineDistance",R8.call(n,i.lineDistances))}i.boundingSphere!==null&&(t.boundingSphere=i.boundingSphere.clone()),i.boundingBox!==null&&(t.boundingBox=i.boundingBox.clone())}else e.isMesh&&(t=i.toBufferGeometry());return t}};tp.prototype.isGeometry=!0;var O8=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],i,r,s,n=e.faces;for(r=0;r<n.length;r++){let a=n[r];a.materialIndex!==s&&(s=a.materialIndex,i!==void 0&&(i.count=r*3-i.start,t.push(i)),i={start:r*3,materialIndex:s})}i!==void 0&&(i.count=r*3-i.start,t.push(i)),this.groups=t}fromGeometry(e){let t=e.faces,i=e.vertices,r=e.faceVertexUvs,s=r[0]&&r[0].length>0,n=r[1]&&r[1].length>0,a=e.morphTargets,o=a.length,l;if(o>0){l=[];for(let m=0;m<o;m++)l[m]={name:a[m].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,u=h.length,c;if(u>0){c=[];for(let m=0;m<u;m++)c[m]={name:h[m].name,data:[]};this.morphTargets.normal=c}let d=e.skinIndices,p=e.skinWeights,f=d.length===i.length,g=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let m=0;m<t.length;m++){let v=t[m];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][m];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new k,new k,new k))}if(n===!0){let b=r[1][m];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new k,new k,new k))}for(let b=0;b<o;b++){let _=a[b].vertices;l[b].data.push(_[v.a],_[v.b],_[v.c])}for(let b=0;b<u;b++){let _=h[b].vertexNormals[m];c[b].data.push(_.a,_.b,_.c)}f&&this.skinIndices.push(d[v.a],d[v.b],d[v.c]),g&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},ev=class{constructor(e,t,i,r,s,n=0){this.a=e,this.b=t,this.c=i,this.normal=r&&r.isVector3?r:new E,this.vertexNormals=Array.isArray(r)?r:[],this.color=s&&s.isColor?s:new je,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=n}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,i=e.vertexNormals.length;t<i;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,i=e.vertexColors.length;t<i;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};function R8(e){return this.array.set(e),this}function sw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new je),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function nw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new k),t[i++]=n.x,t[i++]=n.y}return this}function Fd(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new E),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z}return this}function aw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let n=e[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new et),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var B8=["a","b","c"];function z8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function rm(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function sm(e,t,i,r,s,n){let a=Math.min(e,t),o=Math.max(e,t),l=a+"_"+o,h;if(r.has(l))h=r.get(l);else{let u=i[a],c=i[o];h={a:u,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),n[e].edges.push(h),n[t].edges.push(h)}function F8(e,t,i,r){let s,n,a;for(s=0,n=e.length;s<n;s++)i[s]={edges:[]};for(s=0,n=t.length;s<n;s++)a=t[s],sm(a.a,a.b,e,r,a,i),sm(a.b,a.c,e,r,a,i),sm(a.c,a.a,e,r,a,i)}function Nd(e,t,i,r,s){e.push(new ev(t,i,r,void 0,void 0,s))}function Do(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function kd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var N8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof qe?e=new tp().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new E,i,r,s,n,a,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],u=h!==void 0&&h.length>0,c=[],d=new Map;F8(o,l,c,d);let p=[],f,g,m,v,y,x,b;for(let ie of Array.from(d.keys())){for(g=d.get(ie),m=new E,y=3/8,x=1/8,b=g.faces.length,b!=2&&(y=.5,x=0,b!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<b;n++){for(v=g.faces[n],a=0;a<3&&(f=o[z8(v,B8[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(x),m.add(t),g.newEdge=p.length,p.push(m)}let _,A,S,w,M,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?_=3/16:i>3&&(_=3/(8*i)),A=1-i*Number(_),S=_,i<=2&&(i==2?(A=3/4,S=1/8):i==1||i==0),T=C.clone().multiplyScalar(A),t.set(0,0,0),n=0;n<i;n++)w=M[n],f=w.a!==C?w.a:w.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),L=D.length,B,V,U,z=[],X=[],H,G,F,q,j=new k,W=new k,N=new k;for(r=0,s=l.length;r<s;r++)v=l[r],B=Number(rm(v.a,v.b,d).newEdge)+L,V=Number(rm(v.b,v.c,d).newEdge)+L,U=Number(rm(v.c,v.a,d).newEdge)+L,Nd(z,B,V,U,v.materialIndex),Nd(z,v.a,B,U,v.materialIndex),Nd(z,v.b,V,B,v.materialIndex),Nd(z,v.c,U,V,v.materialIndex),u&&(H=h[r],G=H[0],F=H[1],q=H[2],j.set(Do(G.x,F.x),Do(G.y,F.y)),W.set(Do(F.x,q.x),Do(F.y,q.y)),N.set(Do(G.x,q.x),Do(G.y,q.y)),kd(X,j,W,N),kd(X,G,j,N),kd(X,F,W,j),kd(X,q,N,W));e.vertices=P,e.faces=z,u&&(e.faceVertexUvs[0]=X)}},ai=new E,k8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new qe().copy(new zs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ai),r={width:ai.x,height:ai.y,depth:ai.z,subdivisions:0}):r=t.parameters;let s={...r,...e.parameters};return{parameters:{width:Math.abs(s.width),height:Math.abs(s.height),depth:Math.abs(s.depth),subdivisions:Math.abs(s.subdivisions)},geometry:i}}static build(e){let{width:t,height:i,depth:r,subdivisions:s}=e.parameters,n=e.geometry??new qe().copy(new zs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(ai)):ai.set(a.width,a.height,a.depth),(t!==ai.x||i!==ai.y||r!==ai.z)&&n.scale(ai.x===0?1:t/ai.x,ai.y===0?1:i/ai.y,ai.z===0?1:r/ai.z);let o=n.originalGeometry;try{s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new N8(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new RS(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ai);let n=100/ai.x;Object.assign(s.parameters,{width:100,height:ai.y*n,depth:ai.z*n}),t(this.build(s))})}},A2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,spikes:r,cornerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5,c=0,d=0,p=2*Math.PI/r;for(let g=0;g<r;g++){let m=p*g,v=c+Math.sin(m)*h,y=d+Math.cos(m)*u;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let g=0,m=l.points.length;g<m;g++)l.points[g].roundness=s;l.roundness=s,l.update();let f=ro.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},U8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,heightSegments:n,openEnded:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=new G8(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function _h(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function nm(e,t,i,r,s,n){let a=t.clone().sub(e),o=i.clone().sub(e),l=a.angleTo(o);if(a.normalize(),o.normalize(),r===s){let h=a.add(o).normalize();n.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=a.angleTo(o);n.copy(e),n.addScaledVector(a,s/Math.sin(h)),n.addScaledVector(o,r/Math.sin(h))}}function j8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var G8=class extends qe{constructor(e=.5,t=1,i=4,r=1,s=!1,n=0,a=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],u=[],c=0,d=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),g=2*Math.PI/i,m=(i-2)*Math.PI/i,v=Math.PI-m,y=new E(0,-d,0),x=new E(0,d,0),b=new k(e,-d),_=new k(f,-d),A=new k(0,x.y).sub(_),S=new k(0,x.y).sub(b),w=new k(A.y,-A.x).normalize(),M=new k(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;n=Math.min(n,C);let T;{let z=new E(w.x,w.y,0),X=new E(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);T=z.angleTo(X)}let D=n/Math.tan((Math.PI-A.angle())/2),P=n/Math.tan((Math.PI-T)/2),L=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let z=c++,X=[],H=b.clone(),G=D/Math.cos(Math.PI/i);H.x-=G;for(let F=0;F<i;F++){let q=F/i*Math.PI*2+p,j=new k(Math.sin(q),Math.cos(q));_h(H,j,L),l.push(L.x,L.y,L.z),h.push(0,-1,0),u.push(0,0),X.push(c++)}for(let F=0;F<X.length;F++)o.push(X[F],z,X[(F+1)%X.length])}let B=[];{let z=new E,X=new E,H=new E,G=new E,F=new E,q=new E;for(let j=0;j<i;j++){let W=j/i*Math.PI*2+p,N=(j+.5)/i*Math.PI*2+p,ie=(j+1)/i*Math.PI*2+p,Q=new k(Math.sin(W),Math.cos(W)),re=new k(Math.sin(N),Math.cos(N)),Z=new k(Math.sin(ie),Math.cos(ie));_h(b,Q,X),_h(b,Z,H),_h(w,re,z),nm(x,X,H,P,P,G),l.push(G.x,G.y,G.z),nm(X,x,H,P,D,F),l.push(F.x,F.y,F.z),nm(H,X,x,D,P,q),l.push(q.x,q.y,q.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),u.push(0,0),u.push(0,0),u.push(0,0);let ue=c++,ae=c++,se=c++;if(o.push(ue,ae,se),n>0){{let Me=X.clone().add(H).multiplyScalar(.5),Pe=x.clone().sub(Me).normalize(),xe=y.clone().sub(Me).normalize().add(Pe).normalize().multiplyScalar(-1),ve=q.clone().sub(F);V(Me,ve,xe,A.angle())}let Ae,Se;{let Me=new E;_h(M,Z,Me);let Pe=q.clone().add(G).multiplyScalar(.5);Pe=j8(Pe,H,x);let xe=q.clone().sub(G);[Ae,Se]=V(Pe,xe,Me,T,G.y)}{let Me=Ae,Pe=Me.clone().setY(0).normalize(),xe=new E(0,-1,0),ve=Pe.clone().cross(xe);U(Me,Pe,xe,ve)}B.concat(Se);{let Me=A.angle(),Pe=Math.PI-Me,xe=x.clone();xe.y-=n/Math.sin(Me-Math.PI/2);let ve=new E,Be=[];for(let R=0;R<a;R++){let I=[],$=Math.PI/2-Pe*R/a,me=Math.cos($),ce=Math.sin($),ye=N;for(let Oe=0;Oe<=R;Oe++){let Ee=Math.cos(ye),de=Math.sin(ye);z.x=me*de,z.y=ce,z.z=me*Ee,ve.copy(xe).addScaledVector(z,n),l.push(ve.x,ve.y,ve.z),h.push(z.x,z.y,z.z),u.push(0,0),I.push(c++),ye+=Math.PI*2/R/i}Be.push(I)}Se.reverse(),Be.push(Se);let Ze=Be.length-1;for(let R=0;R<Ze;R++){let I=Be[R],$=Be[R+1],me=I.length-1;o.push($[1],I[0],$[0]);for(let ce=1;ce<=me;ce++)o.push(I[ce],I[ce-1],$[ce]),o.push($[ce+1],I[ce],$[ce])}}}}}this.setIndex(o),this.setAttribute("position",new Le(l,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(u,2));function V(z,X,H,G,F){let q=-G/2,j=(Math.PI-G)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-n/Math.sin(j));let N=new E,ie=new E,Q=1,re=c,Z=[];for(let ue=0;ue<=a;ue++){let ae=q+ue/a*G;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(ae)),ie.addScaledVector(H,Math.cos(ae));for(let se=0;se<=Q;se++){let Ae=se/Q-.5;if(N.copy(z),N.addScaledVector(X,Ae),N.addScaledVector(ie,n),F!=null){let Se=Math.max(0,N.y-F);N.addScaledVector(X,-Se/X.y)}l.push(N.x,N.y,N.z),h.push(ie.x,ie.y,ie.z),u.push(0,0),se===0&&Z.push(c),c++}}for(let ue=0;ue<a;ue++)for(let ae=0;ae<Q;ae++){let se=re+ae+(Q+1)*ue,Ae=se+(Q+1),Se=Ae+1,Me=se+1;o.push(se,Ae,Me),o.push(Ae,Se,Me)}return[z.clone().addScaledVector(X,.5),Z]}function U(z,X,H,G){let F=Math.PI/2,q=S.angle()-F,j=[],W=new E,N=new E;for(let Q=0;Q<=a;Q++){let re=[],Z=Q/a;for(let ue=0;ue<=Q;ue++){let ae=((Q?ue/Q:0)-.5)*v,se=Math.cos(ae),Ae=Math.sin(ae),Se=Math.atan(Math.tan(q)*se),Me=(F+Se)*Z,Pe=Math.cos(Me),xe=Math.sin(Me);W.set(0,0,0),W.addScaledVector(X,xe*se),W.addScaledVector(H,Pe),W.addScaledVector(G,xe*Ae),N.copy(z).addScaledVector(W,n),l.push(N.x,N.y,N.z),h.push(W.x,W.y,W.z),u.push(0,0),re.push(c++)}j.push(re)}let ie=j.length-1;for(let Q=0;Q<ie;Q++){let re=j[Q],Z=j[Q+1],ue=re.length-1;o.push(re[0],Z[1],Z[0]);for(let ae=1;ae<=ue;ae++)o.push(re[ae-1],re[ae],Z[ae]),o.push(re[ae],Z[ae+1],Z[ae])}}}},M2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},e.ui);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)}),ui:r}}static build(e){let t=e.shape,{width:i,height:r,cornerRadius:s,cornerType:n,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},u={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function d(b,_,A){return _>i&&A>r?Math.min(b*i/_,b*r/A):_>i?b*i/_:A>r?b*r/A:b}let p=[];p[0]=s[0]===0?0:d(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:d(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:d(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:d(s[3],s[3]+s[0],s[3]+s[2]);let f=u.x,g=c.x,m=c.y,v=u.y;t.addPoint(t.createPoint(f,m)),t.addPoint(t.createPoint(g,m)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,_=t.points.length;b<_;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let x=ro.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},V8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t=100,height:i=t,depth:r=t,widthSegments:s=64,heightSegments:n=64,phiStart:a,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,u=new Hv(.5*t,s,n,a,o,l,h);return u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},H8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:0})}}static build(e){let{width:t=100,height:i=t,widthSegments:r=8,heightSegments:s=8}=e.parameters,n=new dp(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},W8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,angle:s,cornerRadius:n,cornerSegments:a}=e.parameters,o=new q8(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},q8=class extends qe{constructor(e=1,t=1,i=1,r=90,s=10,n=24){super(),this.type="BackdropGeometry";let a=[],o=[],l=[],h=.001;s==0&&(n=1),n=Math.max(1,Math.floor(n)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let u=[],c=Math.PI/2,d=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=d(),f=d(),[g,m,v]=[t/2,e/2,i/2],y=-m,x=+m,[b,_,A]=[d(y,-g,+v),d(y,-g,-v),d(y,+g,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),w=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-g;let M=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):_.z=Math.min(_.z-M-v,b.z-h),p.subVectors(b,_),f.subVectors(A,_);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),L=p.clone().normalize().add(f.normalize()).setLength(P).add(_);p.set(0,S(r,!0),w(r,!0)),u.push([A,p.clone()]);let B=(Math.PI-r)/n;for(let ie=0;ie<=n;ie++){let Q=c+r+ie*B;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(L),f.set(0,S(Q),w(Q)),u.push([p.clone(),f.clone()])}u.push([b,d(0,1,0)]);let V=Math.sin(B/2)*D*2,U=u.length-1,z=u[0][0].distanceTo(u[1][0]),X=u[U-1][0].distanceTo(u[U][0]),H=z+V*n+X;u[0].push(1);for(let ie=0;ie<=n;ie++)u[ie+1].push(1-(z+ie*V)/H);u[U].push(0);let[G,F,q]=u[0],j,W,N;for(let ie=1;ie<u.length;ie++)[j,W,N]=u[ie],a.push(y,G.y,G.z,y,j.y,j.z,x,G.y,G.z,x,G.y,G.z,y,j.y,j.z,x,j.y,j.z),o.push(0,F.y,F.z,0,W.y,W.z,0,F.y,F.z,0,F.y,F.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,N,1,q,1,q,0,N,1,N),[G,F,q]=[j,W,N];this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(o,3)),this.setAttribute("uv",new Le(l,2))}},E2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i,innerRadiusPercent:r,spikes:s,cornerRadius:n,angle:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,u=e.shape,c=t*.5,d=i*.5,p=0,f=0,g=a*Math.PI/360/s,m=Math.PI/2*3*-1,v=c*r/100,y=d*r/100;if(s===3&&r===50){g=2*Math.PI/s;for(let b=0;b<s;b++){let _=g*b,A=p+Math.sin(_)*c,S=f+Math.cos(_)*d;u.addPoint(u.createPoint(A,S))}}else for(let b=0;b<s;b++){let _=p+Math.cos(m)*c,A=f+Math.sin(m)*d;u.addPoint(u.createPoint(_,A)),m+=g,_=p+Math.cos(m)*v,A=f+Math.sin(m)*y,b<=s,u.addPoint(u.createPoint(_,A)),m+=g}u.isClosed=!0;for(let b=0,_=u.points.length;b<_;b++)u.points[b].roundness=n;u.roundness=n,u.update();let x=ro.create({shape:u,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},X8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t,height:i}=e.parameters,r=new dp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},Y8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:n})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:n,arc:a,cornerRadius:o,cornerSegments:l}=e.parameters,h=Q8(t,i,r,t*.5,a,n,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function Q8(e,t,i,r,s,n,a,o,l,h,u){return[t,i]=[i,t],a=t/2,s/=2*Math.PI,s==1&&(h=0),new _2(!0,e,t,i,r,s,n,a,o,l,h,u)}var Z8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width),tube:i.tube??i.width*.125})}}static build(e){let{width:t,tube:i,tubularSegments:r,radialSegments:s,p:n,q:a}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new TS(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},K8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:e.shape&&e.shape instanceof Ht?e.shape:new Ht,parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width*(i.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(i.depth??0)})}}static build(e){let{width:t=100,height:i,cornerRadius:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:o}=e.parameters,l=e.shape,h=t*.5,u=i*.5;o?(l.addPoint(l.createPoint(-h,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(h,-u)),l.addPoint(l.createPoint(-h,-u))),l.isClosed=!0;for(let d=0,p=l.points.length;d<p;d++)l.points[d].roundness=r;l.roundness=r,l.update();let c=ro.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function J8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var $8=new fe,ej=new fe;function tj(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((n,a)=>{let o=s[a],l=st.lerp(n.length(),o.length(),i);n.lerp(o,i).setLength(l)}),new fe().makeBasis(r[0],r[1],r[2])}var ij=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),n=Math.abs(i.depth??0),a=t?.shapeData??L0.create({parameters:JA}).userData.shape;return{path:e.path??Wu.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...$A,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new rj(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new qe,{userData:{...e,type:"PathGeometry"}})}},rj=class extends qe{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!J8(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let t=this._computeBasisMatrices(e),{depth:i,offset:r}=this.inputs.parameters.extrusion,s=this.inputs.path.isClosed?e.length:e.length-1,n=Math.floor(r*s),a=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,a-n+1),s+2),l=[],h=[];for(let U=0;U<o;U++){let z=this.inputs.path.isClosed?(U+n)%e.length:Math.min(U+n,e.length-1);l.push(e[z].clone()),h.push(t[z].clone())}let u=(U,z,X)=>{l[U]=l[U].clone().lerp(l[z],X),h[U]=tj(h[U],h[z],X)},c=0,d=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(d||r===0)&&(c=d,u(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,u(l.length-1,l.length-2,1-p)),i===0){let U=l.length-1;l[U].copy(l[0]),h[U].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:g,bevelSides:m}=this.inputs.parameters.extrusion,v=g>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:_}=this._computeShapePoints(y),A=0,S;v==="round"&&(S=new I0(this.inputs.shapeData,2*g,g,y,m,void 0,!0),A=S.getAttribute("position").count);let w=0,M=0;b.sort((U,z)=>U.start-z.start),b.forEach(U=>{U.verticesStart=w,U.verticesCount=U.continuous.reduce((z,X,H)=>z+(H===0||!X?2:1),0),M+=U.verticesCount,w=M});let C=M*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=Kn({windingRule:At.ODD,elementType:ri.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=m2}D=T.vertexCount}let P=C+2*D+A*2,L=C+2*D,B={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},V=[];if(b.forEach(U=>{this._extrudeRegion(U,_,h,l,B,V,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,V,B,h[0],l[0],!1),this._closeEnd(T,C+D,V,B,h[h.length-1],l[l.length-1],!0)),S){B.positions.set(S.getAttribute("position").array,L*3),B.normals.set(S.getAttribute("normal").array,L*3),B.uvs.set(S.getAttribute("uv").array,L*2);let U=V.length;V.push(...S.getIndex().array.map(H=>H+L)),L+=A,B.positions.set(S.getAttribute("position").array,L*3),B.normals.set(S.getAttribute("normal").array,L*3),B.uvs.set(S.getAttribute("uv").array,L*2);let z=V.length;V.push(...S.getIndex().array.map(H=>H+L)),this.setAttribute("position",new Ye(B.positions,3)),this.setAttribute("normal",new Ye(B.normals,3)),this.setAttribute("uv",new Ye(B.uvs,2)),this.setIndex(V);let X=$8;X.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(X,L,P),X.copy(h[0]).setPosition(l[0]).multiply(ej.makeScale(1,1,-1)),this.applyMatrix4OnRange(X,L-A,L),this.reverseIndicesOnRange(U,z)}else this.setAttribute("position",new Ye(B.positions,3)),this.setAttribute("normal",new Ye(B.normals,3)),this.setAttribute("uv",new Ye(B.uvs,2)),this.setIndex(V)}_extractPathPoints(){let e=a2(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,n=new E,a=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let g=e[f],m;f===0?m=r?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[1]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),x=v.clone().sub(g).normalize(),b=y.clone().add(x).normalize();a.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(b).normalize(),A=b.clone().cross(_).normalize();l.copy(A),o.copy(_),f===0&&(s.copy(A),n.copy(b));let S=new fe().makeBasis(_,A,b);t.push(S)}let h=r?n:a,u=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),d=Math.acos(u.dot(c));if(isNaN(d))return t;let p=u.clone().cross(c);h.dot(p)>0&&(d*=-1);for(let f=1;f<t.length;f++){let g=new fe().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:n,startScale:a,endScale:o}=this.inputs.parameters.extrusion,l=new fe,h=new fe;return e.forEach((u,c)=>{let d=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(st.lerp(s,s+n,d));let p=st.lerp(a,o,d);h.makeScale(p,p,p),u.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=At.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),g=[];for(let m=f.length-1;m>=1;m-=2){let v=f[m-1],y=f[m-0];g.push(v,y)}return g}),n;try{n=Kn({windingRule:t,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{n=D0}let a;try{a=Kn({windingRule:At.ODD,elementType:ri.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{a=f2}if(!n)throw new Error("error generating geometry");let o=n.elementCount;if(a){n.elementCount+=a.elementCount;for(let p=0;p<a.elements.length;p++){let f=a.elements[p],g=p%2===0?n.vertexCount:0;n.elements.push(f+g)}for(let p=0;p<a.vertexIndices.length;p++){let f=a.vertexIndices[p],g=n.vertexCount;n.vertexIndices.push(f+g)}for(let p=0;p<a.vertices.length;p++){let f=a.vertices[p];n.vertices.push(f)}}let l=1/0,h=-1/0,u=1/0,c=-1/0;for(let p=0,f=n.vertexCount;p<f;p++){let g=p*2,m=n.vertices[g+0],v=n.vertices[g+1];m<l&&(l=m),m>h&&(h=m),v<u&&(u=v),v>c&&(c=v)}let d=[];for(let p=n.elementCount-1;p>=0;p--){let f=p>=o,g=p*2,m=n.elements[g+0],v=n.elements[g+1],y=m+v,x={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(x);let b=m,_=y-1,A=m+1,S=i.roundedCurves.length;do{let w=b-m,M=n.vertices[_*2+0],C=n.vertices[_*2+1],T=n.vertices[b*2+0],D=n.vertices[b*2+1],P=n.vertices[A*2+0],L=n.vertices[A*2+1],B=T-M,V=D-C,U=Math.sqrt(B*B+V*V);B/=U,V/=U;let z=T-P,X=D-L,H=Math.sqrt(z*z+X*X);z/=H,X/=H,x.normals[w*2+0]=-X,x.normals[w*2+1]=z;let G=n.vertexIndices[b];if(Array.isArray(G))x.continuous[w]=!1;else{let[F,q]=i.getCurveIndexFromVertexId(G-1,!0);if(q>0&&q<1)x.continuous[w]=!0;else{let j=q===1?F+1:F-1;j=(j+S)%S;let W=q===1?0:1,N=i.roundedCurves[F].getTangent(q),ie=i.roundedCurves[j].getTangent(W);x.continuous[w]=N.dot(ie)>.95}}f&&(x.normals[w*2+0]*=-1,x.normals[w*2+1]*=-1),[_,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==m+1)}return{regions:[r,...s],infos:d,vertices:n.vertices}}_insertVertex(e,t,i,r,s){let n=t*2,a=t*3;e.positions[a+0]=i.x,e.positions[a+1]=i.y,e.positions[a+2]=i.z,e.normals[a+0]=r.x,e.normals[a+1]=r.y,e.normals[a+2]=r.z,e.uvs[n+0]=s.x,e.uvs[n+1]=s.y}_extrudeRegion(e,t,i,r,s,n,a){let o=new E,l=new E,h=new E,u=new E,c=new k;i.forEach((p,f)=>{let g=r[f],m=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(g),e.continuous[v])u.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v===0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),u.copy(o).sub(l),u.set(-u.y,u.x,0),e.isHole||u.negate()}if(u.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,m,h,u,c),m++,!e.continuous[v]||v===0){if(v===0)u.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),u.copy(l).sub(o),u.set(-u.y,u.x,0),e.isHole||u.negate()}u.applyMatrix4(p).normalize(),this._insertVertex(s,m,h,u,c),m++}}});let d=i.length-1;for(let p=0;p<d;p++){let f=e.verticesStart*i.length+e.verticesCount*p,g=e.verticesStart*i.length+e.verticesCount*(p+1),m=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&m++;let y=v===e.count-1?0:m+1,x=f+m,b=f+y,_=g+y,A=g+m;e.isHole?n.push(x,_,b,x,A,_):n.push(x,b,_,x,_,A),m++}}}_closeEnd(e,t,i,r,s,n,a){let o=e.vertexCount,l=new E(0,0,a?-1:1).applyMatrix4(s),h=new E,u=new k;for(let d=0;d<o;d++){let p=2*d;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(n),this._insertVertex(r,t+d,h,l,u)}let c=e.elements;for(let d=0;d<e.elementCount;d++){let p=3*d,f=c[p+0]+t,g=c[p+(a?1:2)]+t,m=c[p+(a?2:1)]+t;i.push(f,g,m)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new bi().getNormalMatrix(e).elements,n,a,o,l,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let c=h.array,d=u.array,p=h.itemSize;for(let f=t*p,g=i*p;f<g;f+=p){if(f===t)debugger;n=c[f+0],a=c[f+1],o=c[f+2],l=1/(r[3]*n+r[7]*a+r[11]*o+r[15]),c[f+0]=(r[0]*n+r[4]*a+r[8]*o+r[12])*l,c[f+1]=(r[1]*n+r[5]*a+r[9]*o+r[13])*l,c[f+2]=(r[2]*n+r[6]*a+r[10]*o+r[14])*l,n=d[f+0],a=d[f+1],o=d[f+2],d[f+0]=s[0]*n+s[3]*a+s[6]*o,d[f+1]=s[1]*n+s[4]*a+s[7]*o,d[f+2]=s[2]*n+s[5]*a+s[8]*o}h.needsUpdate=!0,u.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),n=i.getX(r+1),a=i.getX(r+2);i.setXYZ(r,a,n,s)}i.needsUpdate=!0}}};function C2(){let e=new qe;return e.setAttribute("position",new Ye(new Float32Array([]),3)),e.setIndex(new Ye(new Uint16Array([]),1)),e}var sj=C2().attributes,nj=12,aj=1,T2=class extends qe{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,sj),this.userData={parameters:e,type:"TextGeometry"};let i=t.getFont(e.font);i?.isLoaded?(this.font=i,this.update(e)):this.updateFont(e.font,t).then(()=>{this.update(e),t?.requestRender()})}async updateFont(e,t){let i=t.getFont(e);i&&(this.font=i,await i.loadingPromise)}update(e){let t=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!t?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,text:o,textTransform:l}=e,h=l===2?o.toUpperCase():l===3?o.toLowerCase():o,u=oj(e,t,h),{shapes:c,charWidths:d,charCoords:p}=t.generateShapes(u,e),f=i*.5,g=r*.5,m=c.map(x=>new Ht().fromShape(x));this.vectorShapes=m;let v=m.map(x=>ro.create({shape:x,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?At.NONZERO:At.ODD,subdivisions:this.isLowResolution&&s>0?aj:nj}})),y=v.length?za(v):C2();y.translate(-f,g,0),this.dispose(),this.wrappedText=u,this.charCoords=p,this.charWidths=d,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([x,b])=>{this.setAttribute(x,b)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Ka(new qe,T2.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([t,i])=>{this.setAttribute(t,i)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function oj(e,t,i){i=i??e.text;let r=[""],s="";for(let n of i)s+=n,n===" "||n===`
|
|
3139
3139
|
`?(r[r.length-1]+=s,s="",n===`
|
|
3140
|
-
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var P2,O0=new Promise(e=>{P2=e}),ow=!1,Ud;function lj(){if(ow)return;if(Ud)return Ud;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.454/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});P2(a),ow=!0}return Ud=e(),Ud}function ip(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ht.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new RS().parse(e);else{if(e.type==="SubdivGeometry")return new Wi(e,i);if(e.type==="TextGeometry")return new T2(e,t)}let s;try{s=uw(r)}catch(n){console.error(n)}if(!s){let n=Ht.createFromState(Hu.defaultData(),100,100);r.shape=n,s=uw(r)}return s}var hj=new fe;function tv(e,t,i,r){let s=e.position.array,n=e.normal.array,a=hj.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var jd=new Jt,Io=new E,ke;O0.then(e=>{ke=e});var lw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),hw=new Uint32Array([0,1,2,3]),cw=new Uint8Array([4]),Wi=class extends qe{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Va.div(t,i);this.subdividedGeometry&&tv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&tv(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Io.fromArray(r));let n=Io.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Wi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new zs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Wi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;jd.setFromBufferAttribute(t),jd.getCenter(i),e.boundingSphere.radius=i.distanceTo(jd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jd.getSize(Io);let r={width:Io.x,height:Io.y,depth:Io.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(ke.free_bvh(t),ke.free_subdivision_surface(t));try{s=Wi.allocate(e,r)}catch(l){console.error(l,e),s=Wi.allocate({positionWASM:lw,indexWASM:hw,verticesPerFaceWASM:cw},r)}if(ke.set_destination_refinement_level(s,0),n=Wi.buildLevel(s,!0,o),e.subdivisions>0)try{ke.set_destination_refinement_level(s,e.subdivisions),a=Wi.buildLevel(s,!1,o)}catch{try{ke.set_destination_refinement_level(s,e.subdivisions-1),a=Wi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:ip(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=Dp(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:a,verticesPerFace:o}=D2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=lw,r=hw,s=cw);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=ke._malloc(d),m=new Float32Array(ke.HEAPF32.buffer,g,u),v=new Uint32Array(ke.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new fe().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?ke.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):ke.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return ke._free(g),x}static buildLevel(e,t,i,r,s){let n=s?ke.get_mesh_data2(e,t?ke.Level.CONTROL:ke.Level.REFINED,i,s.elements):ke.get_mesh_data(e,t?ke.Level.CONTROL:ke.Level.REFINED,i),a=8,o=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=ke.HEAPU32[o[h]>>2],c=ke.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=ke.HEAPU32[o[h]>>2],p=ke.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=ke.HEAPU32[o[h]>>2],g=ke.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=ke.HEAPU32[o[h]>>2],v=ke.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new qe;if(y.setIndex(new tl(v,1)),y.setAttribute("position",new Le(c,3)),y.setAttribute("normal",new Le(p,3)),t){y.setAttribute("faceMap",new tl(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return ke.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,ke.free_mesh_data(n)}static freeSubdivPointer(e){ke.free_bvh(e),ke.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ke.get_wireframe_data_for_base_level(e),s=4,n=ke.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=ke.HEAPU32[n[o]>>2],h=ke.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=ke.HEAPU32[n[o]>>2],c=ke.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new qe;d.setAttribute("position",new Le(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ye(p,3)),d.setIndex(new tl(c,1)),ke.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,ke.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ke.set_destination_refinement_level(e,t);let s=i?ke.get_topological_data2(e,r?ke.Level.CONTROL:ke.Level.REFINED,i.elements):ke.get_topological_data(e,r?ke.Level.CONTROL:ke.Level.REFINED),n=6,a=ke.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=ke.HEAPU32[a[l]>>2],u=new Float32Array(ke.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=ke.HEAPU32[a[l]>>2],d=new Uint32Array(ke.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=ke.HEAPU32[a[l]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return ke.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},dw=["getX","getY","getZ"];function Dp(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[dw[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[dw[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Gd=new E,am=new E,om=new E,lm=new E;function D2(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return n.push(c),{indices:s,verticesPerFace:n}}let a=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===a||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===a||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===a||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Gd.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),am.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),om.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),lm.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),am.sub(Gd).normalize(),om.sub(Gd).normalize(),lm.sub(Gd).normalize();let l=am.cross(om).dot(lm);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+1])?(s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),n.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===a&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),n.push(u,u)}return{indices:s,verticesPerFace:n}}var hn={};QE(hn,{calcBoolean:()=>fj,calcBooleanTopological:()=>pj,freeMeshSet:()=>yj,getMeshSet:()=>mj,hasOpenEdges:()=>gj,transformMeshSet:()=>vj});var I2,cj=new Promise(e=>{I2=e}),Vd;function dj(){if(Vd)return Vd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.454/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});I2(a)}return Vd=e(),Vd}var at,dl;cj.then(e=>at=e);function uj(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=Dp(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=D2(n,a,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=a[h++],r[u++]=a[h++],r[u++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function L2(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=at._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(at.HEAPU32.buffer,n,t):new Float32Array(at.HEAPF32.buffer,n,t)).set(e,0),n}function O2(e){switch(e){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function pj(e,t){dl===void 0&&(dl=at.init_csg());let i=L2(e),r=at.csg_calc_topological(dl,i,e.length,O2(t));at._free(i);let s=6,n=at.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=at.HEAPU32[n[o]>>2],h=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=at.HEAPU32[n[o]>>2],c=new Uint32Array(at.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=at.HEAPU32[n[o]>>2],p=new Uint8Array(at.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return at.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function fj(e,t,i,r){dl===void 0&&(dl=at.init_csg());let s=L2(e),n=at.csg_calc(dl,s,e.length,r,O2(t));at._free(s);let a=5,o=at.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=at.HEAPU32[o[h]>>2],c=at.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=at.HEAPU32[o[h]>>2],p=at.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Le(c,3)),i.setAttribute("normal",new Le(p,3));let g=at.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Sr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},at.free_mesh_data(n),f}function mj(e,t,i){if(at===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=uj(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=at._malloc(u),f=new Float32Array(at.HEAPF32.buffer,p,l),g=new Uint32Array(at.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),at.get_csg_mesh(p,a,p+c,o,n)}function gj(e){return at.has_open_edges(e)}function vj(e,t){at.transform_csg_mesh(e,t.elements)}function yj(e){at.free_csg_mesh(e)}var xj={ConeGeometry:Q6,CubeGeometry:Z6,CylinderGeometry:o2,DodecahedronGeometry:J6,EllipseGeometry:L0,HelixGeometry:D8,IcosahedronGeometry:I8,LatheGeometry:L8,NonParametricGeometry:k8,PolygonGeometry:A2,PyramidGeometry:U8,RectangleGeometry:M2,SphereGeometry:V8,PlaneGeometry:H8,BackdropGeometry:W8,StarGeometry:E2,TextFrameGeometry:X8,TorusGeometry:Y8,TorusKnotGeometry:Z8,TriangleGeometry:K8,PathGeometry:ij,VectorGeometry:ro},uw=e=>xj[e.type].create(e);function Sh(e){return e!==null&&"booleanOp"in e}var R2=class extends E0(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new fe}updateVisible(){super.updateVisible(),this.visible=!Sh(this.parent)&&this.visible,Sh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(hn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Sh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof R2&&(e.freeBooleanPointer(),Sh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Sh(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Hd=new Jt;function R0(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Hd.min.set(n,a,o),Hd.max.set(l,h,u),Hd.getCenter(r),Hd.getSize(s).multiplyScalar(.5)}var bj=new qe,wj=new Tc,cr=class extends R2{constructor(e,t){super(bj,wj),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?R0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},pw=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},ha=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof ha&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},_j=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},sr=new _j,Ct=class extends ha{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=st.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},ur=class extends Ct{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},Ci=class extends ur{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Lr=class extends ur{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},hr=class extends je{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},cn=class extends ur{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof hr?e:new hr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Sj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,fw=/[a-z_0-9]+/gi,_e=class extends Ct{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=fw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&sr.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=sr.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||sr.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&sr.contains(p)&&e.include(sr.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Sj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(fw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Aj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,B2=class extends Ct{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||B2.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Aj.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},St=B2;St.PI="PI",St.PI2="PI2",St.RECIPROCAL_PI="RECIPROCAL_PI",St.RECIPROCAL_PI2="RECIPROCAL_PI2",St.LOG2="LOG2",St.EPSILON="EPSILON";var Mj=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3140
|
+
`&&r.push("")):t.getTextWidth(r[r.length-1]+s,e)>e.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+s,e)>e.width&&(s.length===1?(r[r.length-1]+=s,s=""):(r[r.length-1]+=s.slice(0,-1),s=s[s.length-1],r.push(""))));return r[r.length-1]+=s,r}var P2,O0=new Promise(e=>{P2=e}),ow=!1,Ud;function lj(){if(ow)return;if(Ud)return Ud;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.455/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});P2(a),ow=!0}return Ud=e(),Ud}function ip(e,t,i){let r={parameters:e,type:e.type};if(e.type==="PathGeometry")r.path=e.path;else if(e.type==="VectorGeometry"){let n=Ht.createFromState(e.shape,e.width,e.height);r.shape=n}else if(e.type==="NonParametricGeometry")e.data.groups&&e.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),r.geometry=new RS().parse(e);else{if(e.type==="SubdivGeometry")return new Wi(e,i);if(e.type==="TextGeometry")return new T2(e,t)}let s;try{s=uw(r)}catch(n){console.error(n)}if(!s){let n=Ht.createFromState(Hu.defaultData(),100,100);r.shape=n,s=uw(r)}return s}var hj=new fe;function tv(e,t,i,r){let s=e.position.array,n=e.normal.array,a=hj.makeScale(t,i,r).invert().elements,o,l,h;for(var u=0,c=s.length;u<c;u+=3)s[u]*=t,s[u+1]*=i,s[u+2]*=r,o=n[u],l=n[u+1],h=n[u+2],n[u]=a[0]*o+a[4]*l+a[8]*h,n[u+1]=a[1]*o+a[5]*l+a[9]*h,n[u+2]=a[2]*o+a[6]*l+a[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var jd=new Jt,Io=new E,ke;O0.then(e=>{ke=e});var lw=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),hw=new Uint32Array([0,1,2,3]),cw=new Uint8Array([4]),Wi=class extends qe{constructor(e,t){super(),this.data=e,this.flatShading=t,this.subdivPointer=0,this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let i=this.data.scaleBaked,r=Va.div(t,i);this.subdividedGeometry&&tv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&tv(this.originalGeometry.attributes,...r),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*r[0],height:s.height*r[1],depth:s.depth*r[2]},this.originalGeometry.boundingSphere.center.multiply(Io.fromArray(r));let n=Io.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=n/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Wi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new zs(100,100,100),i=0}this.subdivPointer=i,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let r=this.subdividedGeometry??this.originalGeometry;Object.assign(this,r),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Wi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Sr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;jd.setFromBufferAttribute(t),jd.getCenter(i),e.boundingSphere.radius=i.distanceTo(jd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jd.getSize(Io);let r={width:Io.x,height:Io.y,depth:Io.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,n,a,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(ke.free_bvh(t),ke.free_subdivision_surface(t));try{s=Wi.allocate(e,r)}catch(l){console.error(l,e),s=Wi.allocate({positionWASM:lw,indexWASM:hw,verticesPerFaceWASM:cw},r)}if(ke.set_destination_refinement_level(s,0),n=Wi.buildLevel(s,!0,o),e.subdivisions>0)try{ke.set_destination_refinement_level(s,e.subdivisions),a=Wi.buildLevel(s,!1,o)}catch{try{ke.set_destination_refinement_level(s,e.subdivisions-1),a=Wi.buildLevel(s,!1,o)}catch{a=null}}else a=null;return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:ip(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let n,a,o,l;({positions:n,triIndices:l}=Dp(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let u=e.radialSegments*e.heightSegments*3*2,c=u+e.radialSegments*3;h=[u,c]}return{indices:a,verticesPerFace:o}=D2(n,l,r,h),{positions:n,indices:a,verticesPerFace:o}}static allocate(e,t){let i,r,s,n=[],a=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=lw,r=hw,s=cw);let o=i.length,l=r.length,h=s.length,u=i.length+n.length+a.length,c=r.length+s.length,d=u*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=u*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,g=ke._malloc(d),m=new Float32Array(ke.HEAPF32.buffer,g,u),v=new Uint32Array(ke.HEAPU32.buffer,g+p,c);m.set(i,0),m.set(n,i.length),m.set(a,i.length+n.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new fe().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?ke.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):ke.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return ke._free(g),x}static buildLevel(e,t,i,r,s){let n=s?ke.get_mesh_data2(e,t?ke.Level.CONTROL:ke.Level.REFINED,i,s.elements):ke.get_mesh_data(e,t?ke.Level.CONTROL:ke.Level.REFINED,i),a=8,o=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=ke.HEAPU32[o[h]>>2],c=ke.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=ke.HEAPU32[o[h]>>2],p=ke.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=ke.HEAPU32[o[h]>>2],g=ke.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=ke.HEAPU32[o[h]>>2],v=ke.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new qe;if(y.setIndex(new tl(v,1)),y.setAttribute("position",new Le(c,3)),y.setAttribute("normal",new Le(p,3)),t){y.setAttribute("faceMap",new tl(g,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ye(x,4))}return ke.free_mesh_data(n),y.userData.type="SubdivGeometry",y}r.getAttribute("position").copyArray(c),r.getAttribute("normal").copyArray(p),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,ke.free_mesh_data(n)}static freeSubdivPointer(e){ke.free_bvh(e),ke.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=ke.get_wireframe_data_for_base_level(e),s=4,n=ke.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=ke.HEAPU32[n[o]>>2],h=ke.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=ke.HEAPU32[n[o]>>2],c=ke.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new qe;d.setAttribute("position",new Le(h,3));let p=new Float32Array(h.length);for(let f=0,g=h.length;f<g;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return d.setAttribute("color",new Ye(p,3)),d.setIndex(new tl(c,1)),ke.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,ke.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||ke.set_destination_refinement_level(e,t);let s=i?ke.get_topological_data2(e,r?ke.Level.CONTROL:ke.Level.REFINED,i.elements):ke.get_topological_data(e,r?ke.Level.CONTROL:ke.Level.REFINED),n=6,a=ke.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=ke.HEAPU32[a[l]>>2],u=new Float32Array(ke.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=ke.HEAPU32[a[l]>>2],d=new Uint32Array(ke.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=ke.HEAPU32[a[l]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return ke.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},dw=["getX","getY","getZ"];function Dp(e,t){let i={},r=t?t.count:e.count,s=0,n=[],a=[],o=1e4;for(let h=0;h<r;h++){let u=t?t.getX(h):h,c="";for(let d=0;d<3;d++)c+=`${~~(e[dw[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[dw[d]](u));i[c]=s,n.push(s),s++}}let l=[];for(let h=0;h<n.length;h+=3)n[h]===n[h+1]||n[h]===n[h+2]||n[h+1]===n[h+2]||l.push(n[h],n[h+1],n[h+2]);return{positions:a,triIndices:l}}var Gd=new E,am=new E,om=new E,lm=new E;function D2(e,t,i,r){let s=[],n=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let d=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);e.length=0;let c=0;if(u<0)for(let d=0;d<l.length;d+=2)e.push(l[d],l[d+1],0),s.push(c++);else for(let d=l.length-2;d>=0;d-=2)e.push(l[d],l[d+1],0),s.push(c++);return n.push(c),{indices:s,verticesPerFace:n}}let a=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===a||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===a||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===a||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Gd.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),am.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),om.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),lm.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),am.sub(Gd).normalize(),om.sub(Gd).normalize(),lm.sub(Gd).normalize();let l=am.cross(om).dot(lm);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:o>=r[u]&&o<r[u+1])?(s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),n.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),n.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],u=0;for(let c=0,d=0;c<e.length;c+=3,d++)e[c+2]===0&&(l.push(d),u++),e[c+2]===a&&h.push(d);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),n.push(u,u)}return{indices:s,verticesPerFace:n}}var hn={};QE(hn,{calcBoolean:()=>fj,calcBooleanTopological:()=>pj,freeMeshSet:()=>yj,getMeshSet:()=>mj,hasOpenEdges:()=>gj,transformMeshSet:()=>vj});var I2,cj=new Promise(e=>{I2=e}),Vd;function dj(){if(Vd)return Vd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.455/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),n=r.default,a=await n({wasmBinary:s});I2(a)}return Vd=e(),Vd}var at,dl;cj.then(e=>at=e);function uj(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:n,triIndices:a}=Dp(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=D2(n,a,e);o=h.length,r=[];for(let u=0,c=0;u<o;u++){r.push(h[u]);for(let d=0;d<h[u];d++)r.push(l[c++])}}else{let l=a.length;r=Array(l+l/3),o=0;for(let h=0,u=0;u<r.length;)r[u++]=3,o++,r[u++]=a[h++],r[u++]=a[h++],r[u++]=a[h++]}return{positions:n,faceIndices:r,nFaces:o}}function L2(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,n=at._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(at.HEAPU32.buffer,n,t):new Float32Array(at.HEAPF32.buffer,n,t)).set(e,0),n}function O2(e){switch(e){case 0:return at.OP.UNION;case 1:return at.OP.INTERSECTION;case 2:return at.OP.A_MINUS_B;case 3:return at.OP.B_MINUS_A;case 4:return at.OP.SYMMETRIC_DIFFERENCE;case 5:return at.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function pj(e,t){dl===void 0&&(dl=at.init_csg());let i=L2(e),r=at.csg_calc_topological(dl,i,e.length,O2(t));at._free(i);let s=6,n=at.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=at.HEAPU32[n[o]>>2],h=new Float32Array(at.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=at.HEAPU32[n[o]>>2],c=new Uint32Array(at.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=at.HEAPU32[n[o]>>2],p=new Uint8Array(at.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return at.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function fj(e,t,i,r){dl===void 0&&(dl=at.init_csg());let s=L2(e),n=at.csg_calc(dl,s,e.length,r,O2(t));at._free(s);let a=5,o=at.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=at.HEAPU32[o[h]>>2],c=at.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=at.HEAPU32[o[h]>>2],p=at.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Le(c,3)),i.setAttribute("normal",new Le(p,3));let g=at.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Sr),i.boundingSphere.center.set(g[0],g[1],g[2]),i.boundingSphere.radius=(g[3]**2+g[4]**2+g[5]**2)**.5,i.userData.parameters={width:g[3]*2,height:g[4]*2,depth:g[5]*2},at.free_mesh_data(n),f}function mj(e,t,i){if(at===void 0)return-1;let r,s,n;if(t&&e.userData.positions!==void 0){let m=e.userData;n=m.verticesPerFace.length,r=m.positions,s=Array(m.verticesPerFace.reduce((v,y)=>v+y,0)+n);for(let v=0,y=0,x=0;v<m.verticesPerFace.length;v++){s[x++]=m.verticesPerFace[v];for(let b=0;b<m.verticesPerFace[v];b++)s[x++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=uj(e,t,i));let a=r.length,o=s.length,l=r.length,h=s.length,u=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,d=h*Uint32Array.BYTES_PER_ELEMENT,p=at._malloc(u),f=new Float32Array(at.HEAPF32.buffer,p,l),g=new Uint32Array(at.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),at.get_csg_mesh(p,a,p+c,o,n)}function gj(e){return at.has_open_edges(e)}function vj(e,t){at.transform_csg_mesh(e,t.elements)}function yj(e){at.free_csg_mesh(e)}var xj={ConeGeometry:Q6,CubeGeometry:Z6,CylinderGeometry:o2,DodecahedronGeometry:J6,EllipseGeometry:L0,HelixGeometry:D8,IcosahedronGeometry:I8,LatheGeometry:L8,NonParametricGeometry:k8,PolygonGeometry:A2,PyramidGeometry:U8,RectangleGeometry:M2,SphereGeometry:V8,PlaneGeometry:H8,BackdropGeometry:W8,StarGeometry:E2,TextFrameGeometry:X8,TorusGeometry:Y8,TorusKnotGeometry:Z8,TriangleGeometry:K8,PathGeometry:ij,VectorGeometry:ro},uw=e=>xj[e.type].create(e);function Sh(e){return e!==null&&"booleanOp"in e}var R2=class extends E0(nr){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new fe}updateVisible(){super.updateVisible(),this.visible=!Sh(this.parent)&&this.visible,Sh(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(hn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Sh(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof R2&&(e.freeBooleanPointer(),Sh(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Sh(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},Hd=new Jt;function R0(e,t=0,i=e.count,r,s){let n=1/0,a=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0;for(let c=t;c<i;c++){let d=e.getX(c),p=e.getY(c),f=e.getZ(c);d<n&&(n=d),p<a&&(a=p),f<o&&(o=f),d>l&&(l=d),p>h&&(h=p),f>u&&(u=f)}Hd.min.set(n,a,o),Hd.max.set(l,h,u),Hd.getCenter(r),Hd.getSize(s).multiplyScalar(.5)}var bj=new qe,wj=new Tc,cr=class extends R2{constructor(e,t){super(bj,wj),this.super_Entity(e,t)}updateState(e,t){this.updateState_Entity(e,t)}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?R0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},pw=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}},ha=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=st.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,i){return i=i??{},this.analyze(e,i),this.flow(e,t,i)}flow(e,t,i){i=i??{},e.addFlow(i.slot,i.cache,i.context);let r={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),r}build(e,t,i){t=t??this.getType(e,t);let r=e.getNodeData(i??this);return e.analyzing&&this.appendDepsNode(e,r,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,i)}updateFrame(e){}generateReadonly(e,t,i,r,s,n){return""}generate(e,t,i,r,s){return""}parse(e,t,i,r){}appendDepsNode(e,t,i){t.deps=(t.deps||0)+1;let r=e.getTypeLength(i);(r>(t.outputMax||0)||this.getType(e,i))&&(t.outputMax=r,t.output=i)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,i;for(t in this)i=this[t],i instanceof ha&&(e+='"'+t+'":'+i.getHash()+",");if(this.hashProperties)for(let r=0;r<this.hashProperties.length;r++)t=this.hashProperties[r],i=this[t],e+='"'+t+'":"'+String(i)+'",';return e+='"id":"'+this.uuid+'"}',e}},_j=class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,i){i=i!==void 0?i:!0,this.keywords[e]={callback:t,cache:i}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},sr=new _j,Ct=class extends ha{constructor(e,t){super(e),this.scope="",t=t??{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,i,r){if(t=t??this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=st.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let n=e.getNodeData(i),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return n.name=n.name||super.build(e,t,i),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,a,t);{o=super.generate(e,t,i,n.output,r);let l=this.generate(e,a,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,a,t)}}return super.build(e,t,i)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let i=e.getVars()[t];return i?i.name:void 0}generate(e,t,i,r,s){return this.getShared(e,t)||console.error("TempNode is not shared"),i=i??this.uuid,e.getTempVar(i,r??this.getType(e),s,this.getLabel()).name}},ur=class extends Ct{constructor(e,t){t=t??{},t.shared=t.shared!==void 0?t.shared:!1,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,t,i,r,s,n){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let a=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(r,this,s,n,this.getLabel())),e.format(a.vertex.name,r,t)):(a.fragment||(a.fragment=e.createFragmentUniform(r,this,s,n,this.getLabel())),e.format(a.fragment.name,r,t))}},Ci=class extends ur{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},Lr=class extends ur{constructor(e=0,t,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof E?e:new E(e,t,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,i,r,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},hr=class extends je{constructor(e,t,i,r){super(e,t,i),this.isColorA=!0,this.a=r}setRGBA(e,t,i,r){super.setRGB(e,t,i),this.a=r}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}setStyle(e,t="srgb"){let i;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(i=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let r,s=i[1],n=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="rgba"?parseFloat(r[4]):1,super.setStyle(e,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return this.a=s==="hsla"?parseFloat(r[4]):1,super.setStyle(e,t);break}}return super.setStyle(e,t)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}},cn=class extends ur{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof hr?e:new hr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Sj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,fw=/[a-z_0-9]+/gi,_e=class extends Ct{constructor(e,t,i,r,s){super(s),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,i,r)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,i,r,s){let n,a=0,o=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let l=[];for(;n=fw.exec(this.src);)l.push(n);for(let h=0;h<l.length;h++){let u=l[h],c=u[0],d=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&d&&sr.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=sr.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||sr.getKeyword(c,e),g.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[u.index+a-1]!=="."&&(o=o.substring(0,u.index+a)+p+o.substring(u.index+c.length+a),a+=p.length-c.length),this.getIncludeByName(p)===void 0&&sr.contains(p)&&e.include(sr.get(p))}return t==="source"?o:this.isMethod?(this.isInterface||e.include(this,void 0,o),this.name):e.format("( "+o+" )",this.getType(e),t)}parse(e,t,i,r){if(this.src=e||"",this.includes=t??[],this.extensions=i??{},this.keywords=r??{},this.isMethod){let s=Sj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(fw);if(n){let a=0;for(;a<n.length;){let o=n[a++],l;o==="in"||o==="out"||o==="inout"?l=n[a++]:(l=o,o="");let h=n[a++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Aj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,B2=class extends Ct{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||B2.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,i,r,s){this.src=e||"";let n,a,o="",l=Aj.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(a=l[1],n=l[2],o=l[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=o}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,i,r,s){return e.format(this.name,this.getType(e),t)}},St=B2;St.PI="PI",St.PI2="PI2",St.RECIPROCAL_PI="RECIPROCAL_PI",St.RECIPROCAL_PI2="RECIPROCAL_PI2",St.LOG2="LOG2",St.EPSILON="EPSILON";var Mj=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
3141
3141
|
)*?)}`,"gim"),Ej=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),z2=class extends Ct{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,i,r,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=Mj.exec(e);if(t){let i=t[2],r;for(;r=Ej.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},B0=class extends Ct{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=e??0}generate(e,t){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",r=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(r,this.getType(e),t)}};sr.addKeyword("uv",function(){return new B0});sr.addKeyword("uv2",function(){return new B0(1)});var Ho=class extends Ct{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??Ho.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Bs:return["Linear"];case $e:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=Ho.Nodes[this.method],n=e.include(s);if(n===Ho.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let a=this.factor.build(e,"f");return e.format(n+"( "+i+", "+a+" )",r,t)}else return e.format(n+"( "+i+" )",r,t)}fromEncoding(e){let t=Ho.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Ho.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Is=Ho;Is.Nodes={LinearToLinear:new _e(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
|
|
3142
3142
|
`)),sRGBToLinear:new _e(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
|
|
3143
3143
|
`)),LinearTosRGB:new _e(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
|
|
@@ -6235,7 +6235,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
|
|
|
6235
6235
|
}
|
|
6236
6236
|
`,wm=new Ot({vertexShader:a9,fragmentShader:o9,uniforms:{depthContrast:{value:1}}}),Xw=new ci,l9=class extends mS{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new k,this.pipeline=new e9(this),this.dummyCamra=new Fi,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(s=!0,n=!0,a=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),n&&(l|=o.DEPTH_BUFFER_BIT),a&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Dv;let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio!==s&&(this._pixelRatio=s,t(s))},this.setSize=(s,n,a=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==n)&&(this.viewportWidth=s,this.viewportHeight=n,i(s,n,a),this.normalRenderTarget?.setSize(s*this._pixelRatio,n*this._pixelRatio),this._resizeTransmission(s,n),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),this.pipeline.resize(s,n,a))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new Mt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:nt,magFilter:nt,wrapS:Qt,wrapT:Qt,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Ue.transmissionLod.value===1}set hdTransmission(e){Ue.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Mt(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:gl,magFilter:nt,wrapS:Qt,wrapT:Qt,depthBuffer:!1}),this.transmissionDepthTarget=new Mt(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Lt,magFilter:Lt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Mt(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Lt,magFilter:Lt,type:wr,depthTexture:new xl(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof Fi?wm.uniforms.depthContrast.value=(i.far-i.near)/1e4:wm.uniforms.depthContrast.value=1,t.overrideMaterial=wm,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?vv:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamra.updateCameraState(t.dataPatched);let r=t.height,s=t.width,n=this.viewportWidth/this.viewportHeight;s<r?s=r*n:r=s/n,this.dummyCamra.setViewplaneSize(s,r);for(let a=0;a<i;a++)this.renderSplineScene(e,this.dummyCamra)}renderSplineScene(e,t,{sceneHelpers:i=void 0,sceneHelpersOnTop:r=void 0,overrideTransmission:s=void 0,overrideNormal:n=void 0}={}){let a=e instanceof Q0?e.activePage:e,o=a.visible;a.visible=!0;let l=a.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(a.bgColor,a.bgColor.a),a.penumbraSizeArray.forEach((d,p)=>{Ue.penumbraSize.value[p]=d}),Ue.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ue.resolution.value.set(this.resolution.x,this.resolution.y):Ue.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),n!==void 0?(Ue.normalRenderTarget.value=n,Ue.normalRenderTargetDepth.value=Xw):l.needsNormal()&&(this.createNormalRenderTarget(),Ue.normalRenderTarget.value=this.normalRenderTarget.texture,Ue.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,a,t));let h=a.data.ao,u=h.occlusion;u&&(this.createAORenderTarget(),Ue.aoRenderTarget.value=this.aoRenderTarget.texture),Ue.aoEnabled.value=u,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,a.aoColor,a.fog!==null,a.backupFog.near,a.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let c=!1;if(s!==void 0)Ue.transmissionRenderTarget.value=s,Ue.transmissionRenderTargetDepth.value=Xw,this.pipeline.setTransmissionPassEnabled(!1);else{let d=l.needsTransmission();d&&(this.transmissionRenderTarget===void 0&&(c=!0),this.createTransmissionRenderTarget(),Ue.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ue.aspectRatio.value=jj(this.viewportWidth,this.viewportHeight),Ue.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(d)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=a,this.pipeline.camera=t,c&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==a.postprocessing&&(this.pipeline.updatePostprocessing(a.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),a.overrideMaterial=l.wireframeState?vv:null,this.pipeline.render(),Ue.frameIndex.value=(Ue.frameIndex.value+1)%16,t instanceof Fi&&t.copyHistory(),a.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},wM=class extends Rc(yO){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Bc(this.object,wM.geometryHelper,e,t)}},_M=class extends Rc(vO){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Bc(this.object,_M.geometryHelper,e,t)}},mv=class extends Rc(gO){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Bc(this.object,mv.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=mv._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},SM=mv;SM._vector=new E;function h9(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var AM=class extends V0($L,wM){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new Tu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Tu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&h9(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},Yw=new E,Qw=new E,Zw=new it,MM=class extends V0(QL,SM){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=st.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new Tu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Tu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Qw.setFromMatrixPosition(this.matrixWorld),Zw.setFromRotationMatrix(this.matrixWorld),Yw.copy(this.up).applyQuaternion(Zw).negate().multiplyScalar(this.distance),this.target.position.copy(Qw).add(Yw),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},sa=class extends E0($n){constructor(e,t){super(),this.data=t,this.bgColor=new hr(1,1,1,1),this.fog=null,this.backupFog=new gS(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new je,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Fi(ql,{...gc.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new XL(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Yi(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Ql)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&n9(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Yi(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Yi(e.aoColor,t))}updateByOp(e,t,i,r){super.updateByOp(e,t,i,r);let s=t;Fr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Fr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Fr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Fr(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Yi(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof AM&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof MM&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;pt.is(s)&&(s.visible||n?.object.data.visible)&&((Jr(s)||hv(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),gv(s,e,t,!0)),i(s))}};return i(this),t}},c9=class extends V0(KL,_M){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new E(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new E(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),a=new Jt(s,n),o=new Pu(a,new je(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof Pu){let i=this.shadow.camera,r=new E(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new E(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},d9=class extends Qi{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?R0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},q0=class extends Qi{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e=this.data.geometry.extrusion.shape,t;if(e.type==="Custom"){let r=e.shapeId;if(r!==this._shapeId&&this.detachShape(),r){this._shapeId=r;let s=this._context.scene.find(r);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let r;switch(e.type){case"Rectangle":r=M2;break;case"Ellipse":r=L0;break;case"Polygon":r=A2;break;case"Star":r=E2;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=r.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build(),this.attachedSurfaceCloners.forEach(r=>r.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?R0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},fl=class extends zc(Qo,Ip){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=Ju.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,s;for(let n of Qn.rootOverrideProps)e[n]===void 0?(r===void 0&&(r={...e}),r[n]=i.data[n]):(s===void 0&&(s={}),s[n]=e[n],r===void 0&&(r={...e}),r[n]=ea.apply(i.data[n],e[n]));return this.overrideData=s,r}else return{...Zi.defaultData,...e,...xn(Zi.defaultData,Qn.rootOverrideProps)}}updateByOp(e,t,i,r){let s;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let n of Qn.rootOverrideProps)n in e.props&&e.props[n]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[n]=this.component.data[n]);else if(e.type===0&&e.path.length>0&&Qn.rootOverrideProps.includes(e.path[0])){let n=e.path[0];s===void 0&&(s={...e,path:[],props:{[n]:t[n]}})}}super.updateByOp(s??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let s=0;for(let n of this.children)if(pt.is(n))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(n),X0(n),s+=1;else break;this.children.splice(0,s)}r=!0}if(i){let s={};EM(e,[this.uuid],t.overrides,this,i,i,0,r,s);for(let n of this.children)if(pt.is(n)){let a=n.data;a.type==="Empty"&&a.animations&&n.traverseEntity(o=>{if(o instanceof Qi&&o.isSkinnedMesh){let l=o.dataPatched;if(l.bones&&l.boneInverses){let h=l.bones.map(d=>e.scene.find(s[d])),u=l.boneInverses.map(d=>new fe().fromArray(d)),c=new kv(h,u);o.bind(c,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function X0(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)pt.is(i)&&X0(i)}}function Kw(e,t,i,r){return e.component===t&&p0(e.identity,r)?e.overrideData===i?2:1:0}function EM(e,t,i,r,s,n,a,o,l){if(a>50)return!1;if(r.component!==s){if(r.component){let u=r.component.instances.indexOf(r);u>=0&&r.component.instances.splice(u,1)}s.instances.push(r),r.component=s}s instanceof fl&&s.isInstanceRoot&&s.expandInstanceChildren(e);let h=0;for(let u of s.children)if(pt.is(u)){let c=[...t,...typeof u.identity=="string"?[u.identity]:u.identity],d=Yu.resolve(i,c,1);d!=null&&!(d instanceof di)&&(Object.setPrototypeOf(d,di.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let g=r.children[h];if(p=pt.is(g)?g:null,p!==null){let m=Kw(p,u,d,c);f=m>=1?p.stateSelection:void 0,m!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(c)??null,p!==null)){let m=Kw(p,u,d,c);if(f=m>=1?p.stateSelection:void 0,m!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let g=d?ea.apply(u.data,d):u.data;Ja.is(g.type)&&(g={...g,type:"Empty"}),p=Zn.createEntity(c,g,e),p.overrideData=d,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let g=p.identity[p.identity.length-1];l[g]=p.uuid}h+=1,EM(e,t,i,p,u,n,a+1,o,l)}if(!o){let u=h;for(;;){let c=r.children[h];if(pt.is(c))e.pendingDeletes.add(c);else break;h+=1}r.children.splice(u,h-u)}return!0}var u9=class extends zc(vS,Ip){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}};function p9(e,t,i){let r;return t.geometry.type==="TextGeometry"?new pM(e,t,i):(t.geometry.type==="SubdivGeometry"?r=new Sc(e,t,i):t.geometry.type==="PathGeometry"?r=new q0(e,t,i):t.geometry.type==="VectorGeometry"?r=new d9(e,t,i):t.geometry.type==="BooleanGeometry"?r=new Dl(e,t,i):r=new Qi(e,t,i),r)}function Y0(e,t,i){return t.type==="Mesh"?p9(e,t,i):t.type==="Empty"?new Ac(e,t):t.type==="Bone"?new u9(e,t):t.type==="Page"?new sa(e,t):t.type==="PointLight"?new c9(e,t,i):t.type==="SpotLight"?new MM(e,t,i):t.type==="DirectionalLight"?new AM(e,t,i):t.type==="Component"||t.type==="Instance"?new fl(e,t,i):Ja.is(t.type)?new Fi(e,t):(console.error(t),new Ac(e,t))}Zn.createEntity=Y0;function f9(e,t,i){let r=Y0(e.identity,t,i),s=e.children,n=e.attachedPaths,a=e.parent,o=e.component,l=e.instances,h=e.overrideData,u=e.uuid,c=e.stateSelection;e.dispose();for(let d of Object.keys(e))delete e[d];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let d of Object.keys(r))e[d]=r[d];e.children=[...e.children,...s],e.attachedPaths=n,e.parent=a,e.component=o,e.instances=l,e.uuid=u,e.overrideData=h,e.updateState(e.data,i),c&&e.changeSelectedState(c,i),e.resetBBoxNeedsUpdate()}Zn.changeEntityProptotype=f9;Zn.Cloner=is;function m9(e,t,i,r){e.updateByOp(t,i,r,!1)}function Jw(e,t){let i=!1,r=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline");return s.length>0&&(e.layers.set(8),r.length>0&&e.layers.enable(3),i=!0,G0(e),j0(e)),r.length===0&&s.length===0&&e.layers.set(0),e instanceof Ql&&e.needsAO&&e.layers.enable(5),i}function $w(e,t){if(!t.layers)return!1;let i=!1,r=t.getLayersOfType("transmission").filter(n=>n.data.visible),s=t.getLayersOfType("outline").filter(n=>n.data.visible);return r.length>0&&(e.layers.set(3),s.length>0&&e.layers.enable(8),i=!0),r.length===0&&s.length===0&&e.layers.set(0),e.needsAO&&e.layers.enable(5),i}function g9(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof Ql)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)Jw(i,i.material[r])&&(t=!0);else Jw(i,i.material)&&(t=!0)}),t}function v9(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof Ql)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)$w(i,i.material[r])&&(t=!0);else $w(i,i.material)&&(t=!0)}),t}var y9=new BS,x9=new fe,b9=new Rl;function gv(e,t,i,r=!1){let s=e.cloner;if(s)for(let n of s.children){let a=x9.copy(n.matrixWorld).invert(),o=b9.copy(t.ray).applyMatrix4(a),l=e.matrixWorld;o.applyMatrix4(l);let h=y9;h.set(o.origin,o.direction),h.near=t.near,h.far=t.far;let u=h.intersectObject(e,!1);u.length>0&&i.push({...u[0],object:r?n:e})}}var w9=class{constructor(){this._constraints=new Map}setConstraint(e,t){t===null?this._constraints.delete(e):this._constraints.set(e,t)}removeDependencies(e){this._constraints.delete(e)}applyConstraints(e){let t=new Set;this._constraints.forEach((i,r)=>{let s=[r,i],n=i;for(;this._constraints.has(n);)n=this._constraints.get(n),t.has(n)||s.push(n);for(let a=s.length-2;a>=0;a--)if(!t.has(s[a])){let o=e.find(s[a]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[a]}`),t.add(s[a])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},vv=new Tc;vv.wireframe=!0;var e_=new E,Q0=class extends $n{constructor(e,t){super(),this.data=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new w9,this.errorPage=new sa("fdasfa",{...Tl.defaultData,name:""}),this.invisibleObjects=new Ac("jflkdsafjasdifjaslk",{...Ng.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=v9(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=g9(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof sa&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let n=r.children.indexOf(s);i.splice(0,0,n)}return{entity:t,sortKey:i}}getAllSorted(e){let t=[];for(let i of e){let r=this.getWithSortKey(i.id);r!==void 0&&t.push(r)}return t.sort((i,r)=>Hk(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===ql)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),Jr(r)&&Ds(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Ds(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Jr(i)&&(i.freeBooleanPointer(),r instanceof Dl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof q0&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid)}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),Jr(i)&&(i.invalidateUpstreamBooleanData(),Ds(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Dl&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof sa&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest:n}=t.props;t={...t,props:n},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{m9(s,t,i,{scene:this,shared:r}),s instanceof Qi&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{Ds(r)&&r.recomputeBoolean(),r instanceof Fi&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){pt.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{pt.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=mc(l.data,h=>{let u=h.events.data(a.id),c=l.goUp(n);if(c){let d=[...yA(c.identity),e].join("-"),p=this.entityIdentityToEntity[d];if(p){let f=p.uuid,g=Os.zoom(u,t);g[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,n){e.forEach(a=>{a.data.type==="Transition"?this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,s,n):a.data.type==="Animation"&&this.relativeizeInner(a.data.object,[...t,a.id],"object",i,r,s,n)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof fl&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(n=>{n.data=mc(n.data,a=>{n.isInstanceRoot||(a.events.delete(r.id),s=!0)}).data}),s===!1)for(let n of Hg.list)this.rewriteActions(r.data.gameActions[n],["gameActions",n],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof fl&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(n=>{i.addClip(n)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),X0(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof fl&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)pt.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let n of s.children){let a=n.cloner;if(pt.is(n)&&!n.raycastLock&&(n.visible||a?.object.data.visible))if(t===!0&&n.isInstanceRoot){let o=[];if(e.intersectObject(n,!0,o),o.length){let l=o[0];l.object=n,l.point.applyMatrix4(l.object.matrixWorld);let h=n.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(Jr(n)||hv(n)&&this.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,i),gv(n,e,i)),r(n)}};return r(this),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;pt.is(s)&&(s.visible||n?.object.data.visible)&&((Jr(s)||hv(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),gv(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)pt.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)pt.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)pt.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof Qi&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s);let n=i.invalidateDownstreamBooleanData();Ds(n)&&n.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)_c.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)pt.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,n){let a={scene:this,shared:n},o=Y0(e,t,a);return o&&(this.entityByUuid[e]=o,r.add(o),r.children.splice(s,0,r.children.pop()),i.length>0&&(o.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(i,o,n)),o.updateState(t,a),o instanceof Qi&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{if(l instanceof Qi&&l.isSkinnedMesh){let h=l.dataPatched;if(h.bones&&h.boneInverses){let u=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new fe().fromArray(p)),d=new kv(u,c);l.bind(d,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:n,recursive:a}=e[r],o=this.find(n),l=a?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new Jt;return i.setFromPoints(t),i.getCenter(e_),e_}copyMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e);i?t.copy(i.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let i=this.find(e)?.parent;i?t.copy(i.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof cr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof oa&&e(t.material[i]);else t.material instanceof oa&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Fi&&r.setViewplaneSize(e,t,i)})}},pu=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},_9=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return A9(Math.atan2(r,i))},S9=(e,t,i)=>{let r={x:0,y:0};return i=yv(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},yv=e=>e*(Math.PI/180),A9=e=>e*(180/Math.PI),M9=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,_m=new Map,t_=e=>{_m.has(e)&&clearTimeout(_m.get(e)),_m.set(e,setTimeout(e,100))},op=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},i_=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let n=0;n<r.length;n+=1)s=r[n],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},CM=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),r_=()=>{if(typeof window>"u")return;let e=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:e,y:t}},xv=(e,t)=>{t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},Z0=(e,t,i)=>{let r=TM(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let n="";for(let a=0,o=t.length;a<o;a+=1)n+=t[a]+" "+i+", ";r[s]=n.slice(0,-2)}return r},E9=(e,t)=>{let i=TM(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},TM=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},Sm=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},C9=(e,t)=>{let i={};for(let r in e)e.hasOwnProperty(r)&&t.hasOwnProperty(r)?i[r]=t[r]:e.hasOwnProperty(r)&&(i[r]=e[r]);return i},bv=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},T9=(e,t,i)=>({x:Math.min(Math.max(e.x,t.x-i),t.x+i),y:Math.min(Math.max(e.y,t.y-i),t.y+i)});typeof window<"u"&&(PM="ontouchstart"in window,DM=!!window.PointerEvent,IM=!!window.MSPointerEvent);var PM,DM,IM,Th={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},$o,Mc={};DM?$o=Th.pointer:IM?$o=Th.MSPointer:PM?($o=Th.touch,Mc=Th.mouse):$o=Th.mouse;function so(){}so.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};so.prototype.off=function(e,t){var i=this;return i._handlers_=i._handlers_||{},e===void 0?i._handlers_={}:t===void 0?i._handlers_[e]=null:i._handlers_[e]&&i._handlers_[e].indexOf(t)>=0&&i._handlers_[e].splice(i._handlers_[e].indexOf(t),1),i};so.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var n=0;n<r.length;n+=1)s=r[n],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(a){a.call(i,{type:s,target:i},t)})};so.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=C9(t.options,e))};so.prototype.bindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i._domHandlers_[t]=function(){typeof i["on"+t]=="function"?i["on"+t].apply(i,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},op(e,$o[t],i._domHandlers_[t]),Mc[t]&&op(e,Mc[t],i._domHandlers_[t]),i};so.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},i_(e,$o[t],i._domHandlers_[t]),Mc[t]&&i_(e,Mc[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var K0=so;function fi(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=fi.id,fi.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}fi.prototype=new K0;fi.constructor=fi;fi.id=0;fi.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};fi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=E9("borderRadius","50%"),i=Z0("transition","opacity",e),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},Sm(r.el,i),this.options.shape==="circle"&&Sm(r.back,t),Sm(r.front,t),this.applyStyles(r),this};fi.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var i in e[t])this.ui[t].style[i]=e[t][i];return this};fi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};fi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};fi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};fi.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof e=="function"&&e.call(this)},t.options.fadeTime)),t};fi.prototype.hide=function(e){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var i=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=i,typeof e=="function"&&e.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let i=t.options.restJoystick,r={};r.x=i===!0||i.x!==!1?0:t.instance.frontPosition.x,r.y=i===!0||i.y!==!1?0:t.instance.frontPosition.y,t.setPosition(e,r)}return t};fi.prototype.setPosition=function(e,t){var i=this;i.frontPosition={x:t.x,y:t.y};var r=i.options.fadeTime+"ms",s={};s.front=Z0("transition",["top","left"],r);var n={front:{}};n.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(n),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};fi.prototype.restCallback=function(){var e=this,t={};t.front=Z0("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};fi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};fi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,n,a;if(t>i&&t<i*3&&!e.lockX?s="up":t>-i&&t<=i&&!e.lockY?s="left":t>-i*3&&t<=-i&&!e.lockX?s="down":e.lockY||(s="right"),e.lockY||(t>-r&&t<r?n="left":n="right"),e.lockX||(t>0?a="up":a="down"),e.force>this.options.threshold){var o={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(o[l]=this.direction[l]);var h={};this.direction={x:n,y:a,angle:s},e.direction=this.direction;for(l in o)o[l]===this.direction[l]&&(h[l]=!0);if(h.x&&h.y&&h.angle)return e;(!h.x||!h.y)&&this.trigger("plain",e),h.x||this.trigger("plain:"+n,e),h.y||this.trigger("plain:"+a,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var P9=fi;function Kt(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Kt.id,Kt.id+=1,i.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},i.config(t),(i.options.mode==="static"||i.options.mode==="semi")&&(i.options.multitouch=!1),i.options.multitouch||(i.options.maxNumberOfNipples=1);let r=getComputedStyle(i.options.zone.parentElement);return r&&r.display==="flex"&&(i.parentIsFlex=!0),i.updateBox(),i.prepareNipples(),i.bindings(),i.begin(),i.nipples}Kt.prototype=new K0;Kt.constructor=Kt;Kt.id=0;Kt.prototype.prepareNipples=function(){var e=this,t=e.nipples;t.on=e.on.bind(e),t.off=e.off.bind(e),t.options=e.options,t.destroy=e.destroy.bind(e),t.ids=e.ids,t.id=e.id,t.processOnMove=e.processOnMove.bind(e),t.processOnEnd=e.processOnEnd.bind(e),t.get=function(i){if(i===void 0)return t[0];for(var r=0,s=t.length;r<s;r+=1)if(t[r].identifier===i)return t[r];return!1}};Kt.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Kt.prototype.begin=function(){var e=this,t=e.options;if(t.mode==="static"){var i=e.createNipple(t.position,e.manager.getIdentifier());i.add(),e.idles.push(i)}};Kt.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},n=i.options,a={x:i.parentIsFlex?r.x:r.x+i.box.left,y:i.parentIsFlex?r.y:r.y+i.box.top};if(e.x&&e.y)s={x:e.x-a.x,y:e.y-a.y};else if(e.top||e.right||e.bottom||e.left){var o=document.createElement("DIV");o.style.display="hidden",o.style.top=e.top,o.style.right=e.right,o.style.bottom=e.bottom,o.style.left=e.left,o.style.position="absolute",n.zone.appendChild(o);var l=o.getBoundingClientRect();n.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new P9(i,{color:n.color,size:n.size,threshold:n.threshold,fadeTime:n.fadeTime,dataOnly:n.dataOnly,restJoystick:n.restJoystick,restOpacity:n.restOpacity,mode:n.mode,identifier:t,position:e,zone:n.zone,frontPosition:{x:0,y:0},shape:n.shape});return n.dataOnly||(xv(h.ui.el,s),xv(h.ui.front,h.frontPosition)),i.nipples.push(h),i.trigger("added "+h.identifier+":added",h),i.manager.trigger("added "+h.identifier+":added",h),i.bindNipple(h),h};Kt.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Kt.prototype.bindNipple=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};Kt.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var n=e.force||e.pressure||e.webkitForce||0;n!==s&&(t.trigger("pressure",n),r.trigger("pressure "+t.identifier+":pressure",n),s=n)}.bind(r),100)};Kt.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=CM(e),t.updateBox();var s=function(n){t.actives.length<i.maxNumberOfNipples?t.processOnStart(n):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var o=[e[0]];o.identifier=a,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(n))};return bv(e,s),t.manager.bindDocument(),!1};Kt.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),n=e.force||e.pressure||e.webkitForce||0,a={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,a);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(u){u.trigger("start",u),t.trigger("start "+u.id+":start",u),u.show(),n>0&&t.pressureFn(e,u,u.identifier),t.processOnMove(e)};if((r=t.idles.indexOf(o))>=0&&t.idles.splice(r,1),t.actives.push(o),t.ids.push(o.identifier),i.mode!=="semi")l(o);else{var h=pu(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Kt.prototype.getOrCreate=function(e,t){var i=this,r=i.options,s;return/(semi|static)/.test(r.mode)?(s=i.idles[0],s?(i.idles.splice(0,1),s):r.mode==="semi"?i.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1)):(s=i.createNipple(t,e),s)};Kt.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.scroll;if(!M9(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var a=s.el.getBoundingClientRect();s.position={x:n.x+a.left,y:n.y+a.top}}s.identifier=r;var o=s.options.size/2,l={x:e.pageX,y:e.pageY};i.lockX&&(l.y=s.position.y),i.lockY&&(l.x=s.position.x);var h=pu(l,s.position),u=_9(l,s.position),c=yv(u),d=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=S9(s.position,f,u)):(g=T9(l,s.position,o),f=pu(g,s.position)),i.follow){if(h>o){let x=l.x-g.x,b=l.y-g.y;s.position.x+=x,s.position.y+=b,s.el.style.top=s.position.y-(t.box.top+n.y)+"px",s.el.style.left=s.position.x-(t.box.left+n.x)+"px",h=pu(l,s.position)}}else l=g,h=f;var m=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:m,y:v},i.dataOnly||xv(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:d,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:u},vector:{x:m/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:yv(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Kt.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),n=t.manager.removeIdentifier(s.identifier);!s||(i.dataOnly||s.hide(function(){i.mode==="dynamic"&&(s.trigger("removed",s),t.trigger("removed "+s.id+":removed",s),t.manager.trigger("removed "+s.id+":removed",s),s.destroy())}),clearInterval(t.pressureIntervals[s.identifier]),s.resetDirection(),s.trigger("end",s),t.trigger("end "+s.id+":end",s),t.ids.indexOf(s.identifier)>=0&&t.ids.splice(t.ids.indexOf(s.identifier),1),t.actives.indexOf(s)>=0&&t.actives.splice(t.actives.indexOf(s),1),/(semi|static)/.test(i.mode)?t.idles.push(s):t.nipples.indexOf(s)>=0&&t.nipples.splice(t.nipples.indexOf(s),1),t.manager.unbindDocument(),/(semi|static)/.test(i.mode)&&(t.manager.ids[n.id]=n.identifier))};Kt.prototype.onDestroyed=function(e,t){var i=this;i.nipples.indexOf(t)>=0&&i.nipples.splice(i.nipples.indexOf(t),1),i.actives.indexOf(t)>=0&&i.actives.splice(i.actives.indexOf(t),1),i.idles.indexOf(t)>=0&&i.idles.splice(i.idles.indexOf(t),1),i.ids.indexOf(t.identifier)>=0&&i.ids.splice(i.ids.indexOf(t.identifier),1),i.manager.removeIdentifier(t.identifier),i.manager.unbindDocument()};Kt.prototype.destroy=function(){var e=this;e.unbindEvt(e.options.zone,"start"),e.nipples.forEach(function(i){i.destroy()});for(var t in e.pressureIntervals)e.pressureIntervals.hasOwnProperty(t)&&clearInterval(e.pressureIntervals[t]);e.trigger("destroyed",e.nipples),e.manager.unbindDocument(),e.off()};var D9=Kt;function _i(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=r_(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(n){n.forEach(function(a){s=a.el.getBoundingClientRect(),a.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;op(window,"resize",function(){t_(i)});var r=function(){t.scroll=r_()};return op(window,"scroll",function(){t_(r)}),t.collections}_i.prototype=new K0;_i.constructor=_i;_i.prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var i;return e.collections.every(function(r){return i=r.get(t),!i}),i}};_i.prototype.create=function(e){return this.createCollection(e)};_i.prototype.createCollection=function(e){var t=this,i=new D9(t,e);return t.bindCollection(i),t.collections.push(i),i};_i.prototype.bindCollection=function(e){var t=this,i,r=function(s,n){i=s.type+" "+n.id+":"+s.type,t.trigger(i,n)};e.on("destroyed",t.onDestroyed.bind(t)),e.on("shown hidden rested dir plain",r),e.on("dir:up dir:right dir:down dir:left",r),e.on("plain:up plain:right plain:down plain:left",r)};_i.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};_i.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};_i.prototype.getIdentifier=function(e){var t;return e?(t=e.identifier===void 0?e.pointerId:e.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};_i.prototype.removeIdentifier=function(e){var t={};for(var i in this.ids)if(this.ids[i]===e){t.id=i,t.identifier=this.ids[i],delete this.ids[i];break}return t};_i.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};_i.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};_i.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};_i.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=CM(t);var n=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},a=function(o){r=i.getIdentifier(o),bv(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return bv(t,a),!1};_i.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};_i.prototype.onDestroyed=function(e,t){var i=this;if(i.collections.indexOf(t)<0)return!1;i.collections.splice(i.collections.indexOf(t),1)};var I9=_i,s_=new I9,L9={create:function(e){return s_.create(e)},factory:s_},LM=new Map,Jh=new Map,Na=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:n,delay:a,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Gh({src:l,volume:n,delay:a,loop:o}),Jh.has(i.uuid)?Jh.get(i.uuid).push(this):Jh.set(i.uuid,[this]),LM.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},wv=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=LM.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=Jh.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...Jh.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},$h=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new Na(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new wv(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof Na?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof Na?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof Na&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},O9="text/plain",R9="us-ascii",n_=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),B9=(e,{stripHash:t})=>{let i=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(e);if(!i)throw new Error(`Invalid URL: ${e}`);let{type:r,data:s,hash:n}=i.groups,a=r.split(";");n=t?"":n;let o=!1;a[a.length-1]==="base64"&&(a.pop(),o=!0);let l=(a.shift()||"").toLowerCase(),h=[...a.map(u=>{let[c,d=""]=u.split("=").map(p=>p.trim());return c==="charset"&&(d=d.toLowerCase(),d===R9)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==O9)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function z9(e,t){if(t={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...t},e=e.trim(),/^data:/i.test(e))return B9(e,t);if(/^view-source:/i.test(e))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let i=e.startsWith("//");!i&&/^\.*\//.test(e)||(e=e.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,t.defaultProtocol));let r=new URL(e);if(t.forceHttp&&t.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(t.forceHttp&&r.protocol==="https:"&&(r.protocol="http:"),t.forceHttps&&r.protocol==="http:"&&(r.protocol="https:"),t.stripAuthentication&&(r.username="",r.password=""),t.stripHash?r.hash="":t.stripTextFragment&&(r.hash=r.hash.replace(/#?:~:text.*?$/i,"")),r.pathname){let n=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,o="";for(;;){let h=n.exec(r.pathname);if(!h)break;let u=h[0],c=h.index,d=r.pathname.slice(a,c);o+=d.replace(/\/{2,}/g,"/"),o+=u,a=c+u.length}let l=r.pathname.slice(a,r.pathname.length);o+=l.replace(/\/{2,}/g,"/"),r.pathname=o}if(r.pathname)try{r.pathname=decodeURI(r.pathname)}catch{}if(t.removeDirectoryIndex===!0&&(t.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(t.removeDirectoryIndex)&&t.removeDirectoryIndex.length>0){let n=r.pathname.split("/"),a=n[n.length-1];n_(a,t.removeDirectoryIndex)&&(n=n.slice(0,-1),r.pathname=n.slice(1).join("/")+"/")}if(r.hostname&&(r.hostname=r.hostname.replace(/\.$/,""),t.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(r.hostname)&&(r.hostname=r.hostname.replace(/^www\./,""))),Array.isArray(t.removeQueryParameters))for(let n of[...r.searchParams.keys()])n_(n,t.removeQueryParameters)&&r.searchParams.delete(n);if(t.removeQueryParameters===!0&&(r.search=""),t.sortQueryParameters){r.searchParams.sort();try{r.search=decodeURIComponent(r.search)}catch{}}t.removeTrailingSlash&&(r.pathname=r.pathname.replace(/\/$/,""));let s=e;return e=r.toString(),!t.removeSingleSlash&&r.pathname==="/"&&!s.endsWith("/")&&r.hash===""&&(e=e.replace(/\/$/,"")),(t.removeTrailingSlash||r.pathname==="/")&&r.hash===""&&t.removeSingleSlash&&(e=e.replace(/\/$/,"")),i&&!t.normalizeProtocol&&(e=e.replace(/^http:\/\//,"//")),t.stripProtocol&&(e=e.replace(/^(?:https?:)?\/\//,"")),e}var F9=class{constructor({url:e,context:t},i){if(this.eventManager=i,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:z9(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){vA?window.location.assign(this.url):(this.context==="tab"?window.open(this.url,"_blank"):this.context==="window"?window.open(this.url,"_blank",`width=${window.innerWidth}, height=${window.innerHeight}`):window.open(this.url,"_parent"),this.eventManager.controlsManager.orbitControls?.onPointerUp(Ve[0]),Wk())}},OM=class{constructor(e,t,i){this.data=e,this.page=t,this.eventManager=i,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=r=>{this.timeoutIdQueue.shift();let s=this.page.scene.find(r);if(s===void 0)return;let n=this.controlsManager.sharedGameControlGlobals.rapierWorld,a=n?s.dataPatched.physics?.fusedBody:!0;if(s.cloner){for(let o of s.cloner.children)a?(o.playModeVisible=!1,o.rigidBody&&s.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),n.removeRigidBody(o.rigidBody),o.rigidBody=void 0),o.bvhGeometry&&(o.bvhGeometry=void 0)):this.clone===void 0||this.clone===o?(o.playModeVisible=!1,o.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(o.rigidBody.collider(0).handle),n.removeRigidBody(o.rigidBody),o.rigidBody=void 0)):o.playModeVisible===void 0&&(o.playModeVisible=!0);(a||this.clone===void 0||this.clone===!1)&&(s.visible=!1,s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0))}else s.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(s.rigidBody.collider(0).handle),n.removeRigidBody(s.rigidBody),s.rigidBody=void 0),s.bvhGeometry&&(s.bvhGeometry=void 0),s.visible=!1;n===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(o=>o.rigidBody!==void 0),this.eventManager.requestRender()},this.objects=[...e.objects],this.controlsManager=i.controlsManager}dispatch(e){this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},RM=class{constructor(e,t,i,r){this.data=e,this.page=t,this.eventManager=r,this.sharedAssets=i}dispatch(){clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{oy(this.page,this.sharedAssets,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},BM={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,timelineChangeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},J0={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},N9=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],lp={CSS:{},springs:{}};function rs(e,t,i){return Math.min(Math.max(e,t),i)}function ec(e,t){return e.indexOf(t)>-1}function Am(e,t){return e.apply(null,t)}var We={arr:function(e){return Array.isArray(e)},obj:function(e){return ec(Object.prototype.toString.call(e),"Object")},pth:function(e){return We.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||We.svg(e))},str:function(e){return typeof e=="string"},fnc:function(e){return typeof e=="function"},und:function(e){return typeof e>"u"},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return We.hex(e)||We.rgb(e)||We.hsl(e)},key:function(e){return!BM.hasOwnProperty(e)&&!J0.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function zM(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function FM(e,t){var i=zM(e),r=rs(We.und(i[0])?1:i[0],.1,100),s=rs(We.und(i[1])?100:i[1],.1,100),n=rs(We.und(i[2])?10:i[2],.1,100),a=rs(We.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=n/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,u=1,c=l<1?(l*o+-a)/h:-a+o;function d(f){var g=t?t*f/1e3:f;return l<1?g=Math.exp(-g*l*o)*(u*Math.cos(h*g)+c*Math.sin(h*g)):g=(u+c*g)*Math.exp(-g*o),f===0||f===1?f:1-g}function p(){var f=lp.springs[e];if(f)return f;for(var g=1/6,m=0,v=0;;)if(m+=g,d(m)===1){if(v++,v>=16)break}else v=0;var y=m*g*1e3;return lp.springs[e]=y,y}return t?d:p}function k9(e){return e===void 0&&(e=10),function(t){return Math.ceil(rs(t,1e-6,1)*e)*(1/e)}}var U9=function(){var e=11,t=1/(e-1);function i(u,c){return 1-3*c+3*u}function r(u,c){return 3*c-6*u}function s(u){return 3*u}function n(u,c,d){return((i(c,d)*u+r(c,d))*u+s(c))*u}function a(u,c,d){return 3*i(c,d)*u*u+2*r(c,d)*u+s(c)}function o(u,c,d,p,f){var g,m,v=0;do m=c+(d-c)/2,g=n(m,p,f)-u,g>0?d=m:c=m;while(Math.abs(g)>1e-7&&++v<10);return m}function l(u,c,d,p){for(var f=0;f<4;++f){var g=a(c,d,p);if(g===0)return c;var m=n(c,d,p)-u;c-=m/g}return c}function h(u,c,d,p){if(!(0<=u&&u<=1&&0<=d&&d<=1))return;var f=new Float32Array(e);if(u!==c||d!==p)for(var g=0;g<e;++g)f[g]=n(g*t,u,d);function m(v){for(var y=0,x=1,b=e-1;x!==b&&f[x]<=v;++x)y+=t;--x;var _=(v-f[x])/(f[x+1]-f[x]),A=y+_*t,S=a(A,u,d);return S>=.001?l(v,A,u,d):S===0?A:o(v,y,y+t,u,d)}return function(v){return u===c&&d===p||v===0||v===1?v:n(m(v),c,p)}}return h}(),NM=function(){var e={linear:function(){return function(r){return r}}},t={Sine:function(){return function(r){return 1-Math.cos(r*Math.PI/2)}},Circ:function(){return function(r){return 1-Math.sqrt(1-r*r)}},Back:function(){return function(r){return r*r*(3*r-2)}},Bounce:function(){return function(r){for(var s,n=4;r<((s=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((s*3-2)/22-r,2)}},Elastic:function(r,s){r===void 0&&(r=1),s===void 0&&(s=.5);var n=rs(r,1,10),a=rs(s,.1,2);return function(o){return o===0||o===1?o:-n*Math.pow(2,10*(o-1))*Math.sin((o-1-a/(Math.PI*2)*Math.asin(1/n))*(Math.PI*2)/a)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(n){return Math.pow(n,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(n,a){return function(o){return 1-s(n,a)(1-o)}},e["easeInOut"+r]=function(n,a){return function(o){return o<.5?s(n,a)(o*2)/2:1-s(n,a)(o*-2+2)/2}}}),e}();function $0(e,t){if(We.fnc(e))return e;var i=e.split("(")[0],r=NM[i],s=zM(e);switch(i){case"spring":return FM(e,t);case"cubicBezier":return Am(U9,s);case"steps":return Am(k9,s);default:return Am(r,s)}}function kM(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Op(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],n=0;n<i;n++)if(n in e){var a=e[n];t.call(r,a,n,e)&&s.push(a)}return s}function Rp(e){return e.reduce(function(t,i){return t.concat(We.arr(i)?Rp(i):i)},[])}function a_(e){return We.arr(e)?e:(We.str(e)&&(e=kM(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function ey(e,t){return e.some(function(i){return i===t})}function ty(e){var t={};for(var i in e)t[i]=e[i];return t}function _v(e,t){var i=ty(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Bp(e,t){var i=ty(e);for(var r in t)i[r]=We.und(e[r])?t[r]:e[r];return i}function j9(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function G9(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,u){return l+l+h+h+u+u}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),n=parseInt(r[2],16),a=parseInt(r[3],16);return"rgba("+s+","+n+","+a+",1)"}function V9(e){var t=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),i=parseInt(t[1],10)/360,r=parseInt(t[2],10)/100,s=parseInt(t[3],10)/100,n=t[4]||1;function a(d,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?d+(p-d)*6*f:f<1/2?p:f<2/3?d+(p-d)*(2/3-f)*6:d}var o,l,h;if(r==0)o=l=h=s;else{var u=s<.5?s*(1+r):s+r-s*r,c=2*s-u;o=a(c,u,i+1/3),l=a(c,u,i),h=a(c,u,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+n+")"}function H9(e){if(We.rgb(e))return j9(e);if(We.hex(e))return G9(e);if(We.hsl(e))return V9(e)}function wn(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function W9(e){if(ec(e,"translate")||e==="perspective")return"px";if(ec(e,"rotate")||ec(e,"skew"))return"deg"}function Sv(e,t){return We.fnc(e)?e(t.target,t.id,t.total):e}function Ls(e,t){return e.getAttribute(t)}function iy(e,t,i){var r=wn(t);if(ey([i,"deg","rad","turn"],r))return t;var s=lp.CSS[t+i];if(!We.und(s))return s;var n=100,a=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(a),a.style.position="absolute",a.style.width=n+i;var l=n/a.offsetWidth;o.removeChild(a);var h=l*parseFloat(t);return lp.CSS[t+i]=h,h}function UM(e,t,i){if(t in e.style){var r=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=e.style[t]||getComputedStyle(e).getPropertyValue(r)||"0";return i?iy(e,s,i):s}}function ry(e,t){if(We.dom(e)&&!We.inp(e)&&(Ls(e,t)||We.svg(e)&&e[t]))return"attribute";if(We.dom(e)&&ey(N9,t))return"transform";if(We.dom(e)&&t!=="transform"&&UM(e,t))return"css";if(e[t]!=null)return"object"}function jM(e){if(We.dom(e)){for(var t=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,r=new Map,s;s=i.exec(t);)r.set(s[1],s[2]);return r}}function q9(e,t,i,r){var s=ec(t,"scale")?1:0+W9(t),n=jM(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?iy(e,n,r):n}function sy(e,t,i,r){switch(ry(e,t)){case"transform":return q9(e,t,r,i);case"css":return UM(e,t,i);case"attribute":return Ls(e,t);default:return e[t]||0}}function ny(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=wn(e)||0,s=parseFloat(t),n=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+n+r;case"-":return s-n+r;case"*":return s*n+r}}function GM(e,t){if(We.col(e))return H9(e);if(/\s/g.test(e))return e;var i=wn(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function ay(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function X9(e){return Math.PI*2*Ls(e,"r")}function Y9(e){return Ls(e,"width")*2+Ls(e,"height")*2}function Q9(e){return ay({x:Ls(e,"x1"),y:Ls(e,"y1")},{x:Ls(e,"x2"),y:Ls(e,"y2")})}function VM(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=ay(r,n)),r=n}return i}function Z9(e){var t=e.points;return VM(e)+ay(t.getItem(t.numberOfItems-1),t.getItem(0))}function HM(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return X9(e);case"rect":return Y9(e);case"line":return Q9(e);case"polyline":return VM(e);case"polygon":return Z9(e)}}function K9(e){var t=HM(e);return e.setAttribute("stroke-dasharray",t),t}function J9(e){for(var t=e.parentNode;We.svg(t)&&We.svg(t.parentNode);)t=t.parentNode;return t}function WM(e,t){var i=t||{},r=i.el||J9(e),s=r.getBoundingClientRect(),n=Ls(r,"viewBox"),a=s.width,o=s.height,l=i.viewBox||(n?n.split(" "):[0,0,a,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:a/l[2],h:o/l[3]}}function $9(e,t){var i=We.str(e)?kM(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:WM(i),totalLength:HM(i)*(r/100)}}}function e7(e,t){function i(o){o===void 0&&(o=0);var l=t+o>=1?t+o:0;return e.el.getPointAtLength(l)}var r=WM(e.el,e.svg),s=i(),n=i(-1),a=i(1);switch(e.property){case"x":return(s.x-r.x)*r.w;case"y":return(s.y-r.y)*r.h;case"angle":return Math.atan2(a.y-n.y,a.x-n.x)*180/Math.PI}}function o_(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=GM(We.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:We.str(e)||t?r.split(i):[]}}function qM(e){var t=e?Rp(We.arr(e)?e.map(a_):a_(e)):[];return Op(t,function(i,r,s){return s.indexOf(i)===r})}function XM(e){var t=qM(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:jM(i)}}})}function t7(e,t){var i=ty(t);if(/^spring/.test(i.easing)&&(i.duration=FM(i.easing)),We.arr(e)){var r=e.length,s=r===2&&!We.obj(e[0]);s?e={value:e}:We.fnc(t.duration)||(i.duration=t.duration/r)}var n=We.arr(e)?e:[e];return n.map(function(a,o){var l=We.obj(a)&&!We.pth(a)?a:{value:a};return We.und(l.delay)&&(l.delay=o?0:t.delay),We.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return Bp(a,i)})}function i7(e){for(var t=Op(Rp(e.map(function(n){return Object.keys(n)})),function(n){return We.key(n)}).reduce(function(n,a){return n.indexOf(a)<0&&n.push(a),n},[]),i={},r=function(n){var a=t[n];i[a]=e.map(function(o){var l={};for(var h in o)We.key(h)?h==a&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function r7(e,t){var i=[],r=t.keyframes;r&&(t=Bp(i7(r),t));for(var s in t)We.key(s)&&i.push({name:s,tweens:t7(t[s],e)});return i}function s7(e,t){var i={};for(var r in e){var s=Sv(e[r],t);We.arr(s)&&(s=s.map(function(n){return Sv(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function n7(e,t){var i;return e.tweens.map(function(r){var s=s7(r,t),n=s.value,a=We.arr(n)?n[1]:n,o=wn(a),l=sy(t.target,e.name,o,t),h=i?i.to.original:l,u=We.arr(n)?n[0]:h,c=wn(u)||wn(l),d=o||c;return We.und(a)&&(a=h),s.from=o_(u,d),s.to=o_(ny(a,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=$0(s.easing,s.duration),s.isPath=We.pth(n),s.isColor=We.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var YM={css:function(e,t,i){return e.style[t]=i},attribute:function(e,t,i){return e.setAttribute(t,i)},object:function(e,t,i){return e[t]=i},transform:function(e,t,i,r,s){if(r.list.set(t,i),t===r.last||s){var n="";r.list.forEach(function(a,o){n+=o+"("+a+") "}),e.style.transform=n}}};function QM(e,t){var i=XM(e);i.forEach(function(r){for(var s in t){var n=Sv(t[s],r),a=r.target,o=wn(n),l=sy(a,s,o,r),h=o||wn(l),u=ny(GM(n,h),l),c=ry(a,s);YM[c](a,s,u,r.transforms,!0)}})}function a7(e,t){var i=ry(e.target,t.name);if(i){var r=n7(t,e),s=r[r.length-1];return{type:i,property:t.name,animatable:e,tweens:r,duration:s.end,delay:r[0].delay,endDelay:s.endDelay}}}function o7(e,t){return Op(Rp(e.map(function(i){return t.map(function(r){return a7(i,r)})})),function(i){return!We.und(i)})}function ZM(e,t){var i=e.length,r=function(n){return n.timelineOffset?n.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+l+n.duration*(n.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0;return r(n)+a+o+n.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(n){let a=n.startOnceDelay??0,o=n.pingPongDelayCorrection??0,l=n.pingPongEndDelayCorrection??0;return r(n)+a+o+n.duration*(n.loop??1)-n.endDelay-l})):t.endDelay,s}var l_=0;function l7(e){var t=_v(BM,e),i=_v(J0,e),r=r7(i,e),s=XM(e.targets),n=o7(s,r),a=ZM(n,i),o=l_;return l_++,Bp(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var Ur=[],h_=[],fu,h7=function(){function e(){fu=requestAnimationFrame(t)}function t(i){var r=Ur.length;if(r){for(var s=0;s<r;){var n=Ur[s];n.paused?(Ur.splice(s,1),r-=1):(n.tick(i),s++)}e()}else fu=cancelAnimationFrame(fu)}return e}();function c7(e){document.hidden?(Ur.forEach(function(t){return t.pause(e.timeStamp)}),h_=Ur.slice(0),Zt.running=Ur=[]):h_.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",c7);function Zt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n,a=0,o=null;function l(S){var w=window.Promise&&new Promise(function(M){return o=M});return S.finished=w,w}var h=l7(e),u=l(h);function c(){var S=h.direction;S!=="alternate"&&(h.direction=S!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,n.forEach(function(w){(w.loop===1||w.loop%2===0)&&(w.reversed=h.reversed)})}function d(){h.direction="normal",h.reversed=!1,n.forEach(function(S){return S.reversed=!1})}function p(S){return h.reversed?h.duration-S:S}function f(){t=0,i=p(h.currentTime)*(1/Zt.speed)}function g(S,w,M=!1){w&&(h.reversed?w.seek(w.duration*w.loop-(S-w.timelineOffset-w.pingPongDelayCorrection),M):w.seek(S-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection,M))}function m(S,w=!1){if(h.reversed)for(var M=a;M--;)g(S,n[M],w);else for(var C=0;C<a;C++)g(S,n[C],w)}function v(S){var w=0,M=h.animations,C=M.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S):_(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S);w<C;){var T=M[w],D=T.animatable,P=T.tweens,L=P.length-1,B=P[L];L&&(B=Op(P,function(Z){return S<Z.end})[0]||B);let re;h.parent?.reversed&&h.direction==="alternate"?re=rs(S-B.start-B.endDelay,0,B.duration)/B.duration:re=rs(S-B.start-B.delay,0,B.duration)/B.duration;for(var V=isNaN(re)?1:B.easing(re),U=B.to.strings,z=B.round,X=[],H=B.to.numbers.length,G=void 0,F=0;F<H;F++){var q=void 0;let Z,ue;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=B.to.numbers[F],ue=B.from.numbers[F]||0):(ue=B.to.numbers[F],Z=B.from.numbers[F]||0):_(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=B.to.numbers[F],ue=B.from.numbers[F]||0):(ue=B.to.numbers[F],Z=B.from.numbers[F]||0),B.isPath?q=e7(B.value,V*ue):q=Z+V*(ue-Z),z&&(B.isColor&&F>2||(q=Math.round(q*z)/z)),X.push(q)}var j=U.length;if(!j)G=X[0];else{G=U[0];for(var W=0;W<j;W++){var N=U[W],ie=U[W+1],Q=X[W];isNaN(Q)||(ie?G+=Q+ie:G+=Q+" ")}}YM[T.type](D.target,T.property,G,D.transforms),T.currentValue=G,w++}}function y(S){h[S]&&!h.passThrough&&h[S](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function _(S,w,M,C,T){return b[S<<4|w<<3|M<<2|C<<1|T]}function A(S,w=!1){var M=h.duration;let C=h.delay,T=M-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(C=h.endDelay,T=M-h.delay);var D=p(S);if(h.progress=rs(D/M*100,0,100),w||(h.reversePlayback=D<h.currentTime),a&&m(D,w),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||D>=0)&&D<=C&&h.currentTime!==0&&(v(0),y("change")),(D>=T&&h.currentTime!==M+h.pingPongDelayCorrection||!M)&&(v(M),y("change")),D>C&&D<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(D),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),a&&y("timelineChangeComplete")):h.began&&D>T&&y("changeComplete"),h.currentTime=rs(D,0,M+h.pingPongDelayCorrection),h.began&&y("update"),S>=M)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{a?t+=h.duration/Zt.speed:t+=h.duration;for(let P of n)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():a&&d()}}return h.reset=function(){var S=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=S==="reverse",h.remaining=h.loop,n=h.children,a=n.length;for(var w=a;w--;)h.children[w].reset();(h.reversed&&h.loop!==!0||S==="alternate"&&h.loop===1)&&h.remaining++,v(h.reversed?h.duration:0)},h.setStartTime=function(S){t=S},h.set=function(S,w){return QM(S,w),h},h.tick=function(S){r=S,t||(t=r),A((r+(i-t))*Zt.speed)},h.seek=function(S,w=!1){A(S-t,w)},h.pause=function(S){h.paused=!0,a&&(s=S??performance.now())},h.play=function(S){!h.paused||(h.completed&&h.reset(),h.paused=!1,Ur.push(h),a&&s!==void 0&&(t+=(S??performance.now())-s),fu||h7())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function c_(e,t){for(var i=t.length;i--;)ey(e,t[i].animatable.target)&&t.splice(i,1)}function d7(e){for(var t=qM(e),i=Ur.length;i--;){var r=Ur[i],s=r.animations,n=r.children;c_(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;c_(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function u7(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?$0(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",u=We.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=wn(u?e[1]:e)||0,f=t.start||0+(u?c:0),g=[],m=0;return function(v,y,x){if(o&&(a=0),l&&(a=(x-1)/2),h&&(a=x-1),!g.length){for(var b=0;b<x;b++){if(!s)g.push(Math.abs(a-b));else{var _=l?(s[0]-1)/2:a%s[0],A=l?(s[1]-1)/2:Math.floor(a/s[0]),S=b%s[0],w=Math.floor(b/s[0]),M=_-S,C=A-w,T=Math.sqrt(M*M+C*C);n==="x"&&(T=-M),n==="y"&&(T=-C),g.push(T)}m=Math.max.apply(Math,g)}r&&(g=g.map(function(P){return r(P/m)*m})),i==="reverse"&&(g=g.map(function(P){return n?P<0?P*-1:-P:Math.abs(m-P)}))}var D=u?(d-c)/m:c;return f+D*(Math.round(g[y]*100)/100)+p}}function p7(e){e===void 0&&(e={});var t=Zt(e);return t.duration=0,t.add=function(i,r){var s=Ur.indexOf(t),n=t.children;s>-1&&Ur.splice(s,1);function a(d){d.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=Bp(i,_v(J0,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=We.und(r)?h:ny(r,h),a(t);var u=Zt(l);a(u),n.push(u),u.parent=t;var c=ZM(n,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,u.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Zt.version="3.2.0";Zt.speed=1;Zt.running=Ur;Zt.remove=d7;Zt.get=sy;Zt.set=QM;Zt.convertPx=iy;Zt.path=$9;Zt.setDashoffset=K9;Zt.stagger=u7;Zt.timeline=p7;Zt.easing=$0;Zt.penner=NM;Zt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var KM=Zt,d_=new E,u_=new E,p_=new it;function f7(e,t,i,r){if(r===0)return i.copy(e);if(r===1)return i.copy(t);let s=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(s>=1)return i.copy(e);let n=1-s*s;if(n<=Number.EPSILON){let u=1-r;return i.w=u*e.w+r*t.w,i.x=u*e.x+r*t.x,i.y=u*e.y+r*t.y,i.z=u*e.z+r*t.z,i.normalize(),i}let a=Math.sqrt(n),o=Math.atan2(a,s),l=Math.sin((1-r)*o)/a,h=Math.sin(r*o)/a;return i.w=e.w*l+t.w*h,i.x=e.x*l+t.x*h,i.y=e.y*l+t.y*h,i.z=e.z*l+t.z*h,i}function $a(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(a==null)return;let o=n??t[e],l=a;if(o!==l)return{update:h=>{let u=st.lerp(o,l,h);s?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function JM(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=[...n??o],h=[...a];if(!(l.length!==h.length||p0(l,h)))return{update:u=>{l.forEach((c,d)=>{let p=st.lerp(c,h[d],u);t[e][d]=s?Math.trunc(p):p})},start:()=>{Object.assign(t[e],l)},end:()=>{Object.assign(t[e],h)}}}function f_(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new E().fromArray(s):a.clone(),l=new E().fromArray(n);if(!o.equals(l))return{update:h=>{a.lerpVectors(o,l,h)},start:()=>{a.copy(o)},end:()=>{a.copy(l)}}}function m7(e,t,i,r){let s=i[e]?i[e]:void 0,n=r[e];if(!n)return;let a=t[e],o=s?new fe().fromArray(s):a.clone(),l=new E,h=new it,u=new E;o.decompose(l,h,u);let c=new fe().fromArray(n),d=new E,p=new it,f=new E;if(c.decompose(d,p,f),!o.equals(c))return{update:g=>{p_.slerpQuaternions(h,p,g),d_.lerpVectors(l,d,g),u_.lerpVectors(u,f,g),a.compose(d_,p_,u_)},start:()=>{a.compose(l,h,u)},end:()=>{a.compose(d,p,f)}}}function g7(e,t,i,r,s){let n=i[e]?i[e]:void 0,a=r[e];if(!a)return;let o=t[e],l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new je().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return t[e]=u,{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function ca(e,t,i,r){if(typeof t[e]=="number")return $a(e,t,i??{},r);if(Array.isArray(t[e]))return JM(e,t,i??{},r)}function v7(e,t,i){let r=[],s=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let a=s??e.zoom,o=n;a!==o&&r.push({update:l=>{e.zoom=st.lerp(a,o,l),e.updateProjectionMatrix()},start:()=>{e.zoom=a,e.updateProjectionMatrix()},end:()=>{e.zoom=o,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let a=$a("targetOffset",e,t,i);a&&r.push(a)}return r}function y7(e,t,i,r){if(i.scaleBaked===void 0)return;let s=t.scaleBaked??e.data.geometry.scaleBaked,n=i.scaleBaked;if(Va.isEqual(s,n))return;let a=[];return a.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[st.lerp(s[0],n[0],o),st.lerp(s[1],n[1],o),st.lerp(s[2],n[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:n},r),e.invalidateDownstreamBooleanData()}}),a}function x7(e,t,i){if(!i.extrusion)return;let r=e.extrusion,s=t.extrusion??{},n=i.extrusion,a=[];return e2.forEach(o=>{let l=ca(o,r,s,n);l&&a.push(l)}),a}function b7(e,t,i,r){let s=[];if(!("geometry"in i))return s;let n=e.geometry.userData.parameters,a="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Sc){let l=y7(e,a,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,xn(n,bb)),bb.forEach(h=>{let u=ca(h,l,a,o);u&&s.push(u)}),e instanceof q0){Object.assign(l,{extrusion:{...n.extrusion}});let h=x7(l,a,o);h&&s.push(...h)}s.length&&s.push({update:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},start:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()},end:h=>{e.updateGeometryInteractions(l,r),e.updateGeometryGroupsIfNeeded()}})}return s}function w7(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=$a("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=g7("color",e,t,i,r);n&&s.push(n)}return s}function _7(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let n="materials"in t&&t.materials?t.materials:[],a=i.materials;e.material.forEach((o,l)=>{if(!a[l])return;let h=n[l]??{},u=a[l];typeof h=="string"||typeof u=="string"||s.push(...m_(o,h,u,r))})}else{if(!("material"in i&&i.material))return s;let n="material"in t&&t.material?t.material:{},a=i.material;if(typeof n=="string"||typeof a=="string")return s;s.push(...m_(e.material,n,a,r))}return s}function m_(e,t,i,r){let s=[],n=sp(i,r)||!!t.layers&&sp(t,r);s.push(I7(e,n));for(let a of e.layers){let o=t.layers?.data(a.uuid),l=i.layers.data(a.uuid);if(!l||!(a.visible??!0)||!(l.visible??!0))continue;let h=a.getNames().filter(u=>!KA.some(c=>u.includes(c)));for(let u of h)try{let c=a.getValue(u),d;if(u==="colors")d=P7(a,o,l,u);else if(Array.isArray(c))u==="steps"&&(d=T7(a,o,l,u));else if(typeof c=="number")d=S7(a,o,l,u);else{if(typeof c=="boolean")continue;c instanceof k?d=A7(a,o,l,u):c instanceof E?d=M7(a,o,l,u):c instanceof hr?d=C7(a,o,l,u,r):c instanceof je?d=E7(a,o,l,u,r):"isTexture"in c&&(d=D7(a,o,l,u))}d&&(Array.isArray(d)?s.push(...d):s.push(d))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return s}function S7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=t?t[r]:e.getValue(r),n=i[r];if(s!==n)return{update:a=>{e.setValue(r,st.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function A7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new k().fromArray(t[r]):s.clone(),a=new k().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function M7(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new E().fromArray(t[r]):s.clone(),a=new E().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function E7(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new je().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function C7(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let n=t?t[r]:void 0,a=i[r],o=e.getValue(r),l=n?typeof n=="string"?s.getColor(n).clone():new je().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new hr(a.r,a.g,a.b,a.a);if(l.equals(h))return;let u=o.clone();return{update:c=>{e.getValue(r)!==u&&e.setValue(r,u),u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function T7(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n,o=i[r];for(let l=0;l<n.length;++l){let h=a[l],u=o[l];h!==u&&s.push({update:c=>{n[l]=st.lerp(h,u,c)},start:()=>{n[l]=h},end:()=>{n[l]=u}})}return s.length?s:void 0}function P7(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],n=e.getValue(r),a=t?t[r]:n.map(l=>l.toArray()),o=i[r];for(let l=0;l<n.length;++l){let h=[...a[l]],u=[...o[l]];Gu.isEqual(h,u)||s.push({update:c=>{n[l].fromArray(Gu.lerp(h,u,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(u)}})}return s.length?s:void 0}function D7(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let n=t?t[r]:s,a=i[r],o=[...n.repeat],l=[...n.offset],h=[...a.repeat],u=[...a.offset];if(!Ko.isEqual(o,h)||!Ko.isEqual(l,u))return{update:c=>{s.repeat=Ko.lerp(o,h,c),s.offset=Ko.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}function I7(e,t){return{update:()=>{e.transparent=t}}}var Mm=new E,g_=new yi;function L7(e,t,i,r){let s=[],n,a,o,l,h,u,c={slide:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).slide,offset:(t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping).offset};if(h=$a("slide",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),h&&s.push(h),u=$a("offset",c,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping),u&&s.push(u),!h&&!u&&(n=f_("position",e,t,i),n&&s.push(n),a=f_("scale",e,t,i),a&&s.push(a),o=O7(e,t,i,r),o&&s.push(o),l=m7("hiddenMatrix",e,t,i),l&&s.push(l)),n||a||o||l||h||u){let d=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),Jr(e)&&Ds(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,c))};s.push({update:d,start:d,end:d})}return s}function O7(e,t,i,r){let s=t?.rotation?t.rotation:void 0,n=i.rotation;if(!n)return;let a=s?new E().fromArray(s):new E().setFromEuler(e.rotation),o=new E().fromArray(n);if(a.equals(o))return;let l=Mm.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new it().setFromEuler(g_.setFromVector3(a)),u=new it().setFromEuler(g_.setFromVector3(o));return{update:c=>{f7(h,u,e.quaternion,c)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{Mm.lerpVectors(a,o,h),e.rotation.setFromVector3(Mm)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function R7(e,t,i){let r=[];if(!("cloner"in i)||!e.cloner)return r;let s=e.cloner,n="cloner"in t?t.cloner:{},a=i.cloner;WA.forEach(d=>{let p;d==="count"?p=$a("count",s.parameters,n,a,!0):p=ca(d,s.parameters,n??{},a),p&&r.push(p)});let o=B7(s,n,a);o?.length&&r.push(...o);let l=z7(s,n,a);l?.length&&r.push(...l);let h=F7(s,n,a);h?.length&&r.push(...h);let u=N7(s,n,a);u?.length&&r.push(...u);let c=k7(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function B7(e,t,i){if(e.parameters.type!=="radial")return;let r=t.radial,s=i.radial;if(!s)return;let n=e.parameters.radial,a=[];return qA.forEach(o=>{let l=ca(o,n,r??{},s);l&&a.push(l)}),a}function z7(e,t,i){if(e.parameters.type!=="linear")return;let r=t.linear,s=i.linear;if(!s)return;let n=[],a=e.parameters.linear;return XA.forEach(o=>{let l=ca(o,a,r??{},s);l&&n.push(l)}),n}function F7(e,t,i){if(e.parameters.type!=="grid")return;let r=t.grid,s=i.grid;if(!s)return;let n=[],a=e.parameters.grid;return YA.forEach(o=>{let l;o==="count"?l=JM(o,a,r??{},s,!0):l=ca(o,a,r??{},s),l&&n.push(l)}),n}function N7(e,t,i){if(e.parameters.type!=="toObject")return;let r=t.toObject,s=i.toObject;if(!s)return;let n=[],a=e.parameters.toObject;return QA.forEach(o=>{let l;o==="count"?l=$a(o,a,r??{},s,!0):l=ca(o,a,r??{},s),l&&n.push(l)}),n}function k7(e,t,i){if(!e.parameters.randomness)return;let r=t.randomnessObject,s=i.randomnessObject;if(!s)return;let n=[],a=e.parameters.randomnessObject;return ZA.forEach(o=>{let l=ca(o,a,r??{},s);l&&n.push(l)}),n}function v_(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...L7(e,t,i,s)),e.data.visible&&n.push(...R7(e,t,i)),Jr(e)?(e instanceof Qi&&e.data.visible&&n.push(...b7(e,t,i,r)),e.data.visible&&n.push(..._7(e,t,i,r))):tV(e)?e.data.visible&&n.push(...w7(e,t,i,r)):eV(e)&&n.push(...v7(e,t,i)),n.length?{update:a=>{n.forEach(o=>o.update(a))},start:a=>{n.forEach(o=>o.start?.(a))},end:a=>{n.forEach(o=>o.end?.(a))}}:void 0}var y_=new E;function oy(e,t,i=!1){let r=[];e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(y_,!0),s.rigidBody?.setAngvel(y_,!0)),!pt.is(s))return;let n=s.uuid,a=s.data;if(delete s.states,s.uuid===ql)return;let o=!1;r.some(l=>e.scene.find(n)?.isDescendantOf(l))?o=!0:a.physics?.fusedBody===!0&&a.physics.rigidBody==="dynamic"&&r.push(n),s.data=a,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let l of a.states){let h={...l.data};e.data.globalPhysics.usePhysics===!0&&a.physics&&(a.physics.rigidBody==="dynamic"||o)&&(l.data.position!==void 0&&delete h.position,l.data.rotation!==void 0&&delete h.rotation,l.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[l.id]=Ba.patch(a,h)}j7(e.scene,s,null,t,a.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),U7(e)})}function U7(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let n=e.scene.find(s.data.object);n&&(n.visible=!1)}}})}function j7(e,t,i,r,s=!1){if(t instanceof Qi&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Qi&&t.updateGeometryGroupsIfNeeded(),t instanceof Fi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let n of t.cloner.children)n.playModeVisible=void 0;t.updateVisible()}function $M(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
|
|
6237
6237
|
${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
|
|
6238
|
-
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=jn.linear;break;case 1:i=jn.ease;break;case 2:i=jn.easeIn;break;case 3:i=jn.easeOut;break;case 4:i=jn.easeInOut;break;default:i=jn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function eE(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var G7={type:"beginState"},V7={type:"completeState",isfromEntity:!1},x_=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Fi&&o.dispatchEvent(G7)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Fi&&o.dispatchEvent(V7)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=v_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=mu(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=mu(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=mu(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...eE(r),...$M(r),change:this.onChange},this.callback=v_(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},tc=class extends Ti{constructor(e,t,i){if(super(),this.data=e,this.page=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=this.page.scene.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=mu(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=eE(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=KM.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Fi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new x_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[a]=u,this.timeline.add(u.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Fi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new x_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[a-1]=u,this.timeline.add(u.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function mu(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var H7={type:"beginState"},b_={type:"completeState",isfromEntity:!1},w_={type:"requestRender"},tE=class extends Ti{constructor(e,t){super(),this.data=e,this.page=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=KM({targets:i,t:1,...$M(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(H7));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(w_),i.t===1&&r.dispatchEvent(b_)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(b_),this.page.activeCamera.dispatchEvent(w_))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},ic=class extends Ti{constructor(e,t,i){super(),this.page=t,this.animationControls=i,this.startOnceDelay=0,this.toggleIsForward=!1;let r=e.object,s=t.scene.find(e.object);s&&Array.isArray(s.identity)&&(r=s.identity[0]),this.data={...e,object:r};let n=this.animationControls.clipIdToAction[e.clipId+"/"+r];this.duration=n?.getClip()?.duration??1;let a=n?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/a*this.duration,this.rightFrameTime=this.data.crop[1]/a*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=st.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let n=r.split("/")[1];this.threeAnimAction!==s&&n===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},iE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.timeOutId=-1,this.scene=t.scene}dispatch(){this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),oy(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Ar(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?us[e.type].includes("Audio")&&a.Audio.push(new $h(o,l,n,r)):l.type==="Video"?us[e.type].includes("Video")&&a.Video.push(new ly(o,l,n)):l.type==="Link"?us[e.type].includes("Link")&&a.Link.push(new F9(l,s)):l.type==="Create"?us[e.type].includes("Create")&&a.Create.push(new sc(l,i,s.controlsManager)):l.type==="Destroy"?us[e.type].includes("Destroy")&&a.Destroy.push(new OM(l,i,s)):l.type==="Reset"?us[e.type].includes("Reset")&&a.Reset.push(new RM(l,i,r,s)):l.type==="Transition"?us[e.type].includes("Transition")&&a.Transition.push(new tc(l,i,r)):l.type==="SwitchCamera"?us[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new tE(l,i)):l.type==="SceneTransition"?us[e.type].includes("SceneTransition")&&a.SceneTransition.push(new iE(l,i,s,r)):l.type==="Animation"&&us[e.type].includes("Animation")&&a.Animation.push(new ic(l,i,s.animationControls))}catch{}}),a}function dr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof $h||i instanceof ly||i instanceof ic||i instanceof tc||i instanceof sc||i instanceof OM||i instanceof tE||i instanceof iE||i instanceof RM)&&i.dispose()})})}function W7(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var rE=new Map,rc=new Map,ml=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=W7(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),rc.has(i.uuid)?rc.get(i.uuid).push(this):rc.set(i.uuid,[this]),rE.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Av=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=rE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=rc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...rc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},ly=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new ml(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Av(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof ml?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof ml?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},__=(()=>{let e,t,i,r;function s(o){!e&&!S_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(n)),o&&(t=o,r=o.requestRender)}function n(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=d>0?requestAnimationFrame(n):void 0,i=d>0?o:void 0}function a(){S_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",a),s})();function S_(){return!!document&&document.hidden}var A_=new it,q7=new E,X7=new E,sc=class{constructor(e,t,i){this.data=e,this.page=t,this.controlsManager=i,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=st.generateUUID(),this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=Lk(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let s=new Bi(this.object);if(s.playModeVisible=!0,s.expand(),this.data.coordinateSystem!=="world"){let a=this.data.coordinateSystem,o=this.page.scene.find(a);o&&(o.updateMatrixWorldSVD(),s.hiddenMatrix.copy(o.matrixWorldRigid))}s.position.fromArray(this.data.position),s.rotation.fromArray(this.data.rotation),s.updateMatrix(),this.page.add(s);let n=this.controlsManager.sharedGameControlGlobals;n.createdObjects.push(s),n.nCreatedPerAction[this.uniqueId]===void 0?n.nCreatedPerAction[this.uniqueId]=1:n.nCreatedPerAction[this.uniqueId]++,s.updateWorldMatrix(!0,!0),s.traverseObject(this.traverseObjectCB),__(),this.controlsManager.requestRender()},this.traverseObjectCB=s=>{s.hasNonUniformScale&&s.updateMatrixWorldSVD();let n;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(s instanceof is)if(s.objectForSample){if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(s instanceof Bi)n=s.object;else if(n=s,n.dataPatched.cloner?.hideBase)return!0}else{if(s instanceof is)return;s instanceof Bi?n=s.object:n=s}this.data.destroy==="Time"?s.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(s.userData.quantity=this.data.destroyAfterQuantity,s.userData.actionId=this.uniqueId);let a=new E().fromArray(this.data.velocity),o=n.dataPatched;if(!(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(s,n,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(s.rigidBody?.collider(0).setActiveEvents(1),s.userData.hasCollisionDestroy=!0),s.matrixWorld.decompose(q7,A_,X7),a.applyQuaternion(A_),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&s.rigidBody?.setLinvel(a.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in s.object&&this.controlsManager.addBoundsTree(s),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&(s.userData.velocity=a)),n.dataPatched.physics?.fusedBody===!0))return!0};let r=this.page.scene.find(this.data.object);if(!r)throw new Error("Missing Property");if(this.object=r,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");__(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},sE=200,Em=.02,Cm=.3,Y7=65,PX=new E,M_=new E,E_=new E,Q7=new E,Mi=new E,Gi=new E,Fn=new E,tu=new fe,Tm=new fe,Z7=new fe,DX=new fe,vr=new it,en=new it,ys=new yi(0,0,0,"YXZ"),K7=new E(1,0,0),Zr=new E(0,1,0),J7=new E(0,0,1),Pm=new E(1,1,1),Dm=new Sr,$7=1,eW=.025,tW=16e-6,C_=12,iW=20,gi=new kr,Dr=new Jt,rW={type:"requestRender"},sW={type:"updateMatrix"},T_=Math.PI/6,Mv=class extends Ti{constructor(e,t,i,r,s,n,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new fe,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=sE,this.euler0=new yi(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new it,this.scale0Cam=new E,this.hiddenMatrix0Cam=new fe,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new kr(new E(0,-40,0),new E(0,40,0)),matrix:new fe,position:new E,rotation:new it},this.euler=new yi(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new it,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new k,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new fe,this.nonColliderPosOffset=new fe,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new fe,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new it,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new fe,this.isFirstPerson=!1,this.actions={},this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new E,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new it,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!_r&&(!qx||Xx>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(qx&&Xx<15.5&&!_r?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Mv.isLocked=!0:Mv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let v=f.axes[m];g===0?m===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),g=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,v;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,v=g.projectOnVector(f)):g.y/f.y>0?v=f.multiplyScalar(g.y/f.y):v=f.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate(),m=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(m,this.position);let y=new yi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Fi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*$7,this.speedOrbit=(i.speedRotate??100)*eW,this.mouseOrbitSensitivity=(i.speedRotate??100)*tW,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??El.defaultData.gravity)*C_,this.usePhysics=this.gloabalPhysics.usePhysics??El.defaultData.usePhysics,this.jumpPower=i.jumpPower*iW,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Ku.defaultDataThirdPerson.orientWith,this.slopeThresh=Y7*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Em/this.pixelsPerMeter,this.stepThresh=i.collider.height*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Em/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Em/this.pixelsPerMeter,this.stepThresh=i.collider.height*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),d=new it().setFromEuler(new yi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,Pm),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new Qe;f.push({fi:0,data:{...tr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...tr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new k0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new nr(o2.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new yi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Fi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.page,i=this.sharedAssets,r=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([s,n],a)=>{n.forEach(({id:o,data:l})=>{try{this.actions[s]===void 0&&(this.actions[s]=[]),l.type==="Transition"?this.actions[s].push(new tc(l,t,i)):l.type==="Animation"?this.actions[s].push(new ic(l,t,this.controlsManager.eventManager.animationControls)):l.type==="Audio"?this.actions[s].push(new $h(o,l,r,i)):l.type==="Video"?this.actions[s].push(new ly(o,l,r)):l.type==="Create"&&this.actions[s].push(new sc(l,t,this.controlsManager))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),dr(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(t=>{t instanceof tc?t.play():t instanceof ic?t.play(this.initialAction===!1):t instanceof sc?t.dispatchStart():t instanceof $h&&t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(t=>{t instanceof tc?(t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):t instanceof ic||(t instanceof sc?t.dispatchStop():t instanceof $h&&t.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return Mi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,n=!1;if(this.usePhysics&&this.collisionEnabled){let o=Gi.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*C_),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(Mi,en,Gi),this.groundVelocity.subVectors(Mi,u.prevT),this.object.getWorldPosition(Gi).add(this.collider.position).sub(Mi),this.groundYRotation=ys.setFromQuaternion(en).y-u.prevR.y,Fn.copy(Gi).applyAxisAngle(Zr,this.groundYRotation),this.groundVelocity.add(Fn.sub(Gi)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Mi.subVectors(this.path[1],this.position),h=Gi.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=Q7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Gi.copy(a);o.y=0,a.set(0,a.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=Mi;this.camera.getWorldDirection(o);let l=Fn.copy(Zr).multiplyScalar(o.dot(Zr));o.sub(l);let h=Gi.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(ys.setFromVector3(this.rot),this.moveMode==="walk"&&(ys.x=0),a.applyEuler(ys),n&&(en.setFromUnitVectors(Zr,this.groundNormal),a.applyQuaternion(en)),i){let o=ys.set(0,this.vrEulerYOffset*T_,0);i.applyEuler(o),a.x+=i.x,a.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=Gi;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Fn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mi.copy(a).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=pt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof Bi&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(Tv));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(a);l<0&&a.addScaledVector(o,-l),a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zr,this.euler.y-this.euler0.y);let o=Gi.copy(this.objectToCamXZ).normalize(),l=Fn.copy(a).multiplyScalar(r);l.y=0;let h=l.sub(Mi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=st.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(ys.copy(t),ys.y=0):(ys.copy(this.euler),ys.y=0),this.nonColliderRotOffset.makeRotationFromEuler(ys)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*T_),vr.setFromAxisAngle(K7,this.rot.x),en.setFromAxisAngle(Zr,this.rot.y),en.multiply(vr),vr.setFromAxisAngle(J7,this.rot.z),en.multiply(vr),this.quaternion.copy(en),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Gi.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let u=0;u<5;u++){let c=o.length(),d=Fn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let _ of p.cloner.children)if(_.rigidBody===x){b=_;break}}y.dispatch(b),p.dispatchEvent(Tv)}}}let f=M_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=E_.copy(d).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(d,m)),o.copy(d).multiplyScalar(c-m),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=Fn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Mi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(vr.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=a.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),h===0&&this.checkTrigger(),this.collisionAdjustment(r/o)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);tu.lookAt(l,o,Zr).setPosition(l),tu.decompose(this.targetPos,this.targetQuat,Mi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=st.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=st.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(sW),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&this.navMeshPathDest?.material?.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(rW),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=vr.setFromAxisAngle(Zr,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?st.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=en.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zr.angleTo(e)*180/Math.PI<15||Zr.angleTo(e)*180/Math.PI>85?vr.identity():vr.setFromUnitVectors(Zr,e),this.groundTilt.slerp(vr,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(pt.is(o)?o:o.object)===!1)continue;let l=Tm.copy(s.matrixWorld).decompose(Mi,vr,Gi).compose(Mi,vr,Pm).multiply(r),h=tu.copy(o.matrixWorld).invert().multiply(l);i instanceof Jt?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(Dm.radius=i,Dm.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(Dm)),e?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(dq)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(u=>u!==o)}}}collisionAdjustment(e){let t=E_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=tu.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mi,vr,Gi).compose(Mi,vr,Pm);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Dr.makeEmpty(),s.updateMatrixWorldSVD();let n=s.matrixWorldRigid,a=Tm.copy(n).invert(),o=Z7.copy(Tm).multiply(i);gi.copy(this.collider.segment),gi.start.applyMatrix4(o),gi.end.applyMatrix4(o);let l=M_.copy(this.position).applyMatrix4(a);Dr.expandByPoint(gi.start),Dr.expandByPoint(gi.end),Dr.min.addScalar(-this.collider.radius),Dr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(gi.end)},intersectsBounds:h=>h.intersectsBox(Dr),intersectsTriangle:h=>{let u=Mi,c=Gi,d=h.closestPointToSegment(gi,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),g=Fn.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(n).sub(this.position);t.add(m),gi.start.addScaledVector(f,p),gi.end.addScaledVector(f,p)}}})}),Dr.makeEmpty(),gi.copy(this.collider.segment),gi.start.applyMatrix4(i),gi.end.applyMatrix4(i),Dr.expandByPoint(gi.start),Dr.expandByPoint(gi.end),Dr.min.addScalar(-this.collider.radius),Dr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(gi.end)},intersectsBounds:s=>s.intersectsBox(Dr),intersectsTriangle:s=>{let n=Mi,a=Gi,o=s.closestPointToSegment(gi,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),gi.start.addScaledVector(h,l),gi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},nE=Mv;nE.isLocked=!1;var nW=Ll(W_());function fn(e,t){let i=new qe;if(!e.getAttribute("position"))return i.setAttribute("position",new Le([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=Dp(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Le(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var aW=new fe,oW=new fe,xs=[[0,0,0],[0,0,0],[0,0,0]];function aE(e){let t=e.elements;xs[0][0]=t[0],xs[0][1]=t[4],xs[0][2]=t[8],xs[1][0]=t[1],xs[1][1]=t[5],xs[1][2]=t[9],xs[2][0]=t[2],xs[2][1]=t[6],xs[2][2]=t[10];let{u:i,v:r}=(0,nW.SVD)(xs),s=aW.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=oW.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var lW=class extends BS{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new la({color:65280,linewidth:10}),t=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new E().addVectors(t,i.multiplyScalar(r)),n=new qe;return n.setFromPoints([t,s]),new Su(n,e)}},oE=e=>e instanceof Ac||e instanceof fl;function hW(e,t){return e.distance-t.distance}function lE(e,t,i){if(!(!pn(t)||!t.visible)){Jr(t)&&t.raycast(e,i);for(let r of t.children)lE(e,r,i)}}function Ev(e,t,i){if(!i.some(s=>hp(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>lE(e,s,r)),r.sort(hW),r}function Cv(e){let t=[];if(e.length){let i=e[0].object;pn(i)&&t.push(i);let r=i.parent;for(;r;)oE(r)&&t.push(r),r=r.parent}return t}function hp(e,t){if(Jr(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(oE(t))return hE(e,t)}function hE(e,t){if(!(!pn(t)||!t.visible)){if(Jr(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=hE(e,i);if(r)return r}}}function cW(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var dW=class{constructor(e,t,i,r,s,n,a,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=n,this.isExport=a,this.frame=o,this.raycaster=new lW,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(cW(t,i,r),this.getCamera())}},cE=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(cE||{}),Hs=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},hy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],dE=e=>hy.find(([t,i])=>i===e)?.[0],Nc=e=>hy.find(([t])=>t===e)?.[1],uW=(e,t)=>{let i=dE(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},pW=class extends Hs{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[dE(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of hy)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=uW(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},fW=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},mW=class extends Hs{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Nc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let u=new fW(l,h,s,i,r,t);u.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(u):o[s.uuid]?o[s.uuid].push(u):o[s.uuid]=[u]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=Ev(i,r,s);Cv(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{hp(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:a}=this.eventContext;if(s){let o=Ev(n,a,i);r=Cv(o)}else i.forEach(o=>{hp(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},gW=new E,vW=new E,uE=class{constructor(e,t,i,r,s){this.actionsIn=Ar(e,e.inActions,i,r,s,t),this.actionsOut=Ar(e,e.outActions,i,r,s,t)}disconnect(){dr(this.actionsIn),dr(this.actionsOut)}},yW=class extends uE{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{for(let d of this.objects)if(!d.visible)return;let h=gW.setFromMatrixPosition(this.objects[0].matrixWorld),u=vW.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},xW=class extends uE{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},bW=class extends Hs{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new yW(n,a,s,i,r,t):a.condition.type==="State"&&(o=new xW(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ph=new E,Nn=new E,Sa=new E,P_=new xr,wW=.01,bt=new E,li=new E,D_=new E,ka=new it,Im=new yi,_W=new fe,Lm=new bi,Ro=new E,bs=new E,Bo=.2;function Om(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var SW=function(){let e=new fe;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Om(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Om(s.position,t.limits):t.reference==="local"&&(ka.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(ka),Om(s.position,t.limits),ka.invert(),s.position.applyQuaternion(ka),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(bt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof cr&&Ds(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),AW=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Ar(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=Ar(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&a.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new fe,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){dr(this.actionsDrag),dr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},MW=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||pt.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(bt,ka,li),Im.setFromQuaternion(ka),d.prevR===void 0?(d.prevR=Im.clone(),d.prevT=bt.clone()):(d.prevR.copy(Im),d.prevT.copy(bt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(Ve.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||pt.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Ac)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||n.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=D_.copy(l.face.normal).applyMatrix3(Lm.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){bt.copy(h).applyMatrix3(Lm.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;bt.x>Bo?li.x=-u.recursiveBBox.min.x:bt.x<-Bo&&(li.x=-u.recursiveBBox.max.x),bt.y>Bo?li.y=-u.recursiveBBox.min.y:bt.y<-Bo&&(li.y=-u.recursiveBBox.max.y),bt.z>Bo?li.z=-u.recursiveBBox.min.z:bt.z<-Bo&&(li.z=-u.recursiveBBox.max.z),li.applyMatrix3(Lm.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(bt.set(0,1,0).cross(h),bt.length()<1e-4&&bt.set(-1,0,0).cross(h),li.crossVectors(D_,bt),o.orientationMatrix.makeBasis(bt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new AW(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:n}=this.eventContext;s().getWorldDirection(Nn),Nn.negate();let a=ka.identity();switch(r==="parent"?_W.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(bt,a,li):r==="local"&&e.matrixWorld.decompose(bt,a,li),i){case"x":bt.set(1,0,0).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"y":bt.set(0,1,0).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"z":bt.set(0,0,1).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"xy":bs.set(0,0,1).applyQuaternion(a);break;case"yz":bs.set(1,0,0).applyQuaternion(a);break;case"xz":bs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Nn.angleTo(li.set(0,1,0))>Math.PI/6?(bt.crossVectors(li.set(0,1,0),Nn),bs.crossVectors(bt,li)):bs.set(0,1,0);break;default:bs.copy(Nn);break}Sa.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Sa;if(P_.setFromNormalAndCoplanarPoint(bs,o),!!n.ray.intersectPlane(P_,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(bt);t.copy(o).addScaledVector(bt,l)}}updateDragItem(e,t=!1){Sa.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ph.subVectors(e.fromPosition,Sa).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ph.subVectors(e.obj.userData.worldPosition0,Sa).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ph.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Sa).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ph.length()<wW:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&SW(e,Ph.add(Sa),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},zo=new E,Rm=new E,tn=new E,rn=new E,I_=new xr,EW=.01,CW={type:"requestRender"},TW=function(){let e=new E,t=new E;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),L_=function(){let e=new fe;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof cr&&Ds(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),PW=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...bg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Ar(e,e.actions,i,r,s,t)}},DW=class extends Hs{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ve.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new PW(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,dr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(tn),e.isReset)rn.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(rn);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(Rm),Rm.negate(),zo.copy(Rm)):i==="xy"?zo.set(0,0,1):i==="xz"?zo.set(0,1,0):i==="yz"&&zo.set(1,0,0),I_.setFromNormalAndCoplanarPoint(zo,tn),!o.ray.intersectPlane(I_,rn))return}if(!e.isReset){if(rn.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)rn.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(rn.x=tn.x),e.data.enabledTranslation[1]===!1&&(rn.y=tn.y),e.data.enabledTranslation[2]===!1&&(rn.z=tn.z);let n=TW(tn,rn,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=zo.subVectors(n,tn).divideScalar(e.currentDampingFactor);tn.add(a),t&&L_(e.object,tn),e.paused=a.length()<EW}else L_(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(CW)}},Dh=new E,iu=new E,Ih=new fe,Fo=new it,kn=new it,Lh=new E,Oh=new E,Aa=new E,sn=new E,Bm=new xr,IW=1e-6,LW={type:"requestRender"},OW={type:"changeRotation"},O_=function(){let e=new fe;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(aE(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof cr&&Ds(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),RW=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...wg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},BW=class extends Hs{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ve.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=Nc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new RW(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:u,target:c}=e;if(u.getWorldPosition(Lh),!e.isReset)if(e.target)e.target.getWorldPosition(Oh);else{if(s==="custom"?(l().getWorldDirection(iu),iu.negate(),Bm.setFromNormalAndCoplanarPoint(iu,Lh)):(s==="xy"?Dh.set(0,0,1):s==="xz"?Dh.set(0,1,0):s==="yz"&&Dh.set(1,0,0),Bm.setFromNormalAndCoplanarPoint(Dh,Lh)),!h.ray.intersectPlane(Bm,Oh))return;r>0&&(s==="custom"||s===void 0)&&Oh.addScaledVector(iu,r)}if(e.isReset||(c?t==="target"?Aa.copy(c.up).applyMatrix4(Ih.extractRotation(c.matrixWorld)).normalize():a.some(d=>d===!1)?(i==="x"?(sn.set(0,0,1),a[2]===!1&&sn.set(0,1,0)):i==="y"?(sn.set(1,0,0),a[0]===!1&&sn.set(0,0,1)):(sn.set(0,1,0),a[1]===!1&&sn.set(1,0,0)),Aa.copy(sn).applyQuaternion(e.worldQuaternion0).normalize()):Aa.set(0,1,0):s==="custom"?Aa.set(0,1,0):Aa.copy(Dh)),e.isReset)kn.copy(e.worldQuaternion0);else if(Lh.distanceTo(Oh)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)kn.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;zW(Ih,Oh,Lh,Aa,i,sn),kn.setFromRotationMatrix(Ih),Fo.setFromUnitVectors(sn.applyQuaternion(kn),Aa),a.some(d=>d===!1)&&t!=="target"&&kn.premultiply(Fo).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),Fo.setFromRotationMatrix(aE(u.matrixWorld)),Fo.slerp(kn,1/e.currentDampingFactor),O_(u,Ih.makeRotationFromQuaternion(Fo)),e.paused=8*(1-Fo.dot(kn))<IW):(O_(u,Ih.makeRotationFromQuaternion(kn)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(LW),u.dispatchEvent(OW)}},Ir=new E,oi=new E,Yt=new E;function zW(e,t,i,r,s,n){let a=e.elements;Yt.subVectors(t,i),Yt.lengthSq()===0&&(Yt.z=1),Yt.normalize(),oi.crossVectors(r,Yt),oi.lengthSq()===0&&(Math.abs(r.z)===1?Yt.x+=1e-4:Yt.z+=1e-4,Yt.normalize(),oi.crossVectors(r,Yt)),oi.normalize(),Ir.crossVectors(Yt,oi),s==="x"?n.z===1?[oi,Ir,Yt]=[Yt,oi,Ir]:(oi.negate(),[oi,Yt]=[Yt,oi]):s==="y"?n.x===1?[oi,Ir,Yt]=[Ir,Yt,oi]:(oi.negate(),[Ir,Yt]=[Yt,Ir]):n.x===1&&(oi.negate(),[oi,Ir]=[Ir,oi]),a[0]=oi.x,a[4]=Ir.x,a[8]=Yt.x,a[1]=oi.y,a[5]=Ir.y,a[9]=Yt.y,a[2]=oi.z,a[6]=Ir.z,a[10]=Yt.z}var FW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch())}},NW=class extends Hs{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ve.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Nc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new FW(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),_r&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let n=Ev(r,s,this.objects);t=Cv(n)}else this.objects.forEach(n=>{hp(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},kW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Ar(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){dr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},UW=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.actions=Ar(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){dr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},jW=class extends Hs{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(u=>u.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=Nc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(u=>{u.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new kW(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new UW(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},GW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Na?t.interaction.audioPlayer.play():t.interaction instanceof wv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ml?t.interaction.play(i==="autoplay"):t.interaction instanceof Av&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Na?t.interaction.audioPlayer.play():t.interaction instanceof wv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ml?t.interaction.play():t.interaction instanceof Av&&t.interaction.dispatch()})}},VW=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{n.interaction instanceof Na&&n.interaction.audioPlayer.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";n.interaction instanceof ml&&n.interaction.play(a==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=Nc(i);n&&n==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let n=new GW(r,s,i,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(n):this.eventsPerObject.set(i,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},HW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.actions=Ar(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){dr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},WW="https://unpkg.com/@splinetool/runtime@0.9.454/build/",qW="https://unpkg.com/@splinetool/navmesh-wasm@0.9.454/build/",XW=`
|
|
6238
|
+
)`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:n}=e;t=`spring( ${i}, ${r}, ${s}, ${n} )`}else{let i;switch(e.easing){case 0:i=jn.linear;break;case 1:i=jn.ease;break;case 2:i=jn.easeIn;break;case 3:i=jn.easeOut;break;case 4:i=jn.easeInOut;break;default:i=jn.linear}let[r,s,n,a]=i;t=`cubicBezier( ${r}, ${s}, ${n}, ${a} )`}return{duration:e.duration,easing:t}}function eE(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var G7={type:"beginState"},V7={type:"completeState",isfromEntity:!1},x_=class{constructor(e,t,i,r,s,n){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=n,this.targets={t:0},this.firstLoop=!0,this._changeBegan=!1,this._changeCompleted=!0,this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0||this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))},this.onChangeBegin=()=>{this.object.reversibleToState=this.to.id;let a=this.targets.t>.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"beginState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Fi&&o.dispatchEvent(G7)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let a=this.targets.t<.5?this.from.id:this.to.id;this.object.prevState!==this.object.currentState&&(this.object.prevState=this.object.currentState),this.object.currentState=a,this.object.dispatchEvent({type:"completeState",state:a}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Fi&&o.dispatchEvent(V7)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=v_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=mu(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!a)throw new Error("Missing property");this.from=a}else{let a=mu(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=mu(this.object,i);if(!a)throw new Error("Missing property");this.to=a}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...eE(r),...$M(r),change:this.onChange},this.callback=v_(this.object,t===void 0?{}:this.from.data,i===void 0?{}:this.to.data,this.sharedAssets,this.allowSlerp)}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}},tc=class extends Ti{constructor(e,t,i){if(super(),this.data=e,this.page=t,this.sharedAssets=i,this.toggleIsForward=!1,this.timelineNeedsRebuild=!1,this.useToggle=!1,this.onTimelineChangeComplete=()=>{this.data.tweens[0].data.direction!=="normal"&&(this.toggleIsForward=!this.toggleIsForward),this.timelineNeedsRebuild!==!1&&(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let r=this.page.scene.find(e.object);if(!r)throw new Error("Missing property");if(!r.states)throw new Error("Missing property");if(this.object=r,e.tweens.length<2)throw new Error("Missing property");this.tweens=Array(this.data.tweens.length-1),this.startOnceDelay=e.tweens[0].data.delayDirection==="start-once"?e.tweens[0].data.delay:0,this.init()}get playing(){return this.tweens.some(e=>e.changeBegan)??!1}init(){this.initialCurrentState=mu(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,isRebuild:t=!1}={}){try{let i=eE(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=KM.timeline({autoplay:!1,...i,...r===!0||r>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(n=>n?.changeBegan);if(this.timelineNeedsRebuild=s!==-1&&(r===!0||r>1),i.pingPongDelayCorrection&&t===!1&&(this.timelineNeedsRebuild=!0),e){let n=s===-1?0:s;for(let a=n;a<this.data.tweens.length-1;a++){let o=this.data.tweens[a],l=this.data.tweens[a+1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Fi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new x_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[a]=u,this.timeline.add(u.params,this.timeline.duration+(a===n?i.delay:0)+(a===n&&!t?i.pingPongDelayCorrection:0))}this.timeline.duration+=i.endDelay}else{let n=s===-1?this.data.tweens.length-1:s+1;for(let a=n;a>0;a--){let o=this.data.tweens[a],l=this.data.tweens[a-1],h;a===n&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Fi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new x_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.sharedAssets,this.data.allowSlerp??!1);s!==-1&&a===n&&Object.assign(u.params,{startOnceDelay:0}),this.tweens[a-1]=u,this.timeline.add(u.params,this.timeline.duration+(a===n?i.endDelay:0))}this.timeline.duration+=i.delay+(t?0:i.pingPongDelayCorrection)}}catch(i){i instanceof Error&&console.error(i.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(this.playing)return!1;clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(e){e instanceof Error&&console.error(e.message)}},this.startOnceDelay)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()):this.timeoutId=window.setTimeout(()=>{this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward}),this.timeline.play()},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause()}};function mu(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var H7={type:"beginState"},b_={type:"completeState",isfromEntity:!1},w_={type:"requestRender"},tE=class extends Ti{constructor(e,t){super(),this.data=e,this.page=t,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=KM({targets:i,t:1,...$M(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(H7));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(w_),i.t===1&&r.dispatchEvent(b_)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(b_),this.page.activeCamera.dispatchEvent(w_))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},ic=class extends Ti{constructor(e,t,i){super(),this.page=t,this.animationControls=i,this.startOnceDelay=0,this.toggleIsForward=!1;let r=e.object,s=t.scene.find(e.object);s&&Array.isArray(s.identity)&&(r=s.identity[0]),this.data={...e,object:r};let n=this.animationControls.clipIdToAction[e.clipId+"/"+r];this.duration=n?.getClip()?.duration??1;let a=n?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/a*this.duration,this.rightFrameTime=this.data.crop[1]/a*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=st.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let n=r.split("/")[1];this.threeAnimAction!==s&&n===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},iE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.timeOutId=-1,this.scene=t.scene}dispatch(){this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),oy(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};function Ar(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?us[e.type].includes("Audio")&&a.Audio.push(new $h(o,l,n,r)):l.type==="Video"?us[e.type].includes("Video")&&a.Video.push(new ly(o,l,n)):l.type==="Link"?us[e.type].includes("Link")&&a.Link.push(new F9(l,s)):l.type==="Create"?us[e.type].includes("Create")&&a.Create.push(new sc(l,i,s.controlsManager)):l.type==="Destroy"?us[e.type].includes("Destroy")&&a.Destroy.push(new OM(l,i,s)):l.type==="Reset"?us[e.type].includes("Reset")&&a.Reset.push(new RM(l,i,r,s)):l.type==="Transition"?us[e.type].includes("Transition")&&a.Transition.push(new tc(l,i,r)):l.type==="SwitchCamera"?us[e.type].includes("SwitchCamera")&&a.SwitchCamera.push(new tE(l,i)):l.type==="SceneTransition"?us[e.type].includes("SceneTransition")&&a.SceneTransition.push(new iE(l,i,s,r)):l.type==="Animation"&&us[e.type].includes("Animation")&&a.Animation.push(new ic(l,i,s.animationControls))}catch{}}),a}function dr(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof $h||i instanceof ly||i instanceof ic||i instanceof tc||i instanceof sc||i instanceof OM||i instanceof tE||i instanceof iE||i instanceof RM)&&i.dispose()})})}function W7(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var rE=new Map,rc=new Map,ml=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:n,delay:a}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=W7(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n)),a!==void 0&&(this.delay=a),rc.has(i.uuid)?rc.get(i.uuid).push(this):rc.set(i.uuid,[this]),rE.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Av=class{constructor(e){this.data=e}dispatch(){this.data.playVideo?this.pauseVideo(this.data.playVideo):this.data.object?this.pauseAllVideosFromObject(this.data.object):this.pauseAllVideos()}pauseVideo(e){let t=rE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t[this.data.interaction](),this.disposeDelay()},this.data.delay)):t[this.data.interaction]())}pauseAllVideosFromObject(e){let t=rc.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(i=>i[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(i=>i[this.data.interaction]()))}pauseAllVideos(){let e=[...rc.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(i=>{i[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},ly=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new ml(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Av(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof ml?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof ml?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},__=(()=>{let e,t,i,r;function s(o){!e&&!S_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(n)),o&&(t=o,r=o.requestRender)}function n(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,u=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,d=0;for(;d<c;){let p=h[d];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&u[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),d++):(u[p.userData.actionId]>p.userData.quantity&&u[p.userData.actionId]--,h.splice(d,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=d>0?requestAnimationFrame(n):void 0,i=d>0?o:void 0}function a(){S_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",a),s})();function S_(){return!!document&&document.hidden}var A_=new it,q7=new E,X7=new E,sc=class{constructor(e,t,i){this.data=e,this.page=t,this.controlsManager=i,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=st.generateUUID(),this.dispatch=()=>{this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=Lk(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let s=new Bi(this.object);if(s.playModeVisible=!0,s.expand(),this.data.coordinateSystem!=="world"){let a=this.data.coordinateSystem,o=this.page.scene.find(a);o&&(o.updateMatrixWorldSVD(),s.hiddenMatrix.copy(o.matrixWorldRigid))}s.position.fromArray(this.data.position),s.rotation.fromArray(this.data.rotation),s.updateMatrix(),this.page.add(s);let n=this.controlsManager.sharedGameControlGlobals;n.createdObjects.push(s),n.nCreatedPerAction[this.uniqueId]===void 0?n.nCreatedPerAction[this.uniqueId]=1:n.nCreatedPerAction[this.uniqueId]++,s.updateWorldMatrix(!0,!0),s.traverseObject(this.traverseObjectCB),__(),this.controlsManager.requestRender()},this.traverseObjectCB=s=>{s.hasNonUniformScale&&s.updateMatrixWorldSVD();let n;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(s instanceof is)if(s.objectForSample){if(s.objectForSample.dataPatched.physics.fusedBody)return;n=s.object}else return s.object.dataPatched.physics.fusedBody===!0&&s.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(s instanceof Bi)n=s.object;else if(n=s,n.dataPatched.cloner?.hideBase)return!0}else{if(s instanceof is)return;s instanceof Bi?n=s.object:n=s}this.data.destroy==="Time"?s.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(s.userData.quantity=this.data.destroyAfterQuantity,s.userData.actionId=this.uniqueId);let a=new E().fromArray(this.data.velocity),o=n.dataPatched;if(!(o.physics.enabled==="visibility"?!o.visible:!o.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(s,n,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(s.rigidBody?.collider(0).setActiveEvents(1),s.userData.hasCollisionDestroy=!0),s.matrixWorld.decompose(q7,A_,X7),a.applyQuaternion(A_),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&s.rigidBody?.setLinvel(a.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in s.object&&this.controlsManager.addBoundsTree(s),this.data.velocity.some(l=>l!==0)&&this.data.dynamic&&(s.userData.velocity=a)),n.dataPatched.physics?.fusedBody===!0))return!0};let r=this.page.scene.find(this.data.object);if(!r)throw new Error("Missing Property");if(this.object=r,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");__(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},sE=200,Em=.02,Cm=.3,Y7=65,PX=new E,M_=new E,E_=new E,Q7=new E,Mi=new E,Gi=new E,Fn=new E,tu=new fe,Tm=new fe,Z7=new fe,DX=new fe,vr=new it,en=new it,ys=new yi(0,0,0,"YXZ"),K7=new E(1,0,0),Zr=new E(0,1,0),J7=new E(0,0,1),Pm=new E(1,1,1),Dm=new Sr,$7=1,eW=.025,tW=16e-6,C_=12,iW=20,gi=new kr,Dr=new Jt,rW={type:"requestRender"},sW={type:"updateMatrix"},T_=Math.PI/6,Mv=class extends Ti{constructor(e,t,i,r,s,n,a,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=n,this.camera=a,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new fe,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=sE,this.euler0=new yi(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new it,this.scale0Cam=new E,this.hiddenMatrix0Cam=new fe,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new kr(new E(0,-40,0),new E(0,40,0)),matrix:new fe,position:new E,rotation:new it},this.euler=new yi(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new it,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new k,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new fe,this.nonColliderPosOffset=new fe,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new fe,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new it,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new fe,this.isFirstPerson=!1,this.actions={},this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new E,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new it,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!_r&&(!qx||Xx>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let g=f.clientX-this.prevMouse.x,m=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(qx&&Xx<15.5&&!_r?(this.eulerDelta.y=-g*this.mouseOrbitSensitivity,this.eulerDelta.x=-m*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-g*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-m*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Mv.isLocked=!0:Mv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]){this.movementState[g[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let g of this.keyAssignments)if(f.key.toUpperCase()===g[1]||f.key===g[1]||f.code.slice(3,f.code.length).toUpperCase()===g[1]){this.movementState[g[0]]=0;break}},this.copyVRGamePadValues=(f,g)=>{for(let m=2;m<4;m++){let v=f.axes[m];g===0?m===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,m===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===a&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),u=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,u,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),g=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let m,v;Math.abs(f.y)<1e-6?(g.y=0,f.y=0,v=g.projectOnVector(f)):g.y/f.y>0?v=f.multiplyScalar(g.y/f.y):v=f.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate(),m=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(m,this.position);let y=new yi().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Fi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*$7,this.speedOrbit=(i.speedRotate??100)*eW,this.mouseOrbitSensitivity=(i.speedRotate??100)*tW,this.keyAssignments=i.keyAssignments.map(f=>{let g=[f[0],f[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??El.defaultData.gravity)*C_,this.usePhysics=this.gloabalPhysics.usePhysics??El.defaultData.usePhysics,this.jumpPower=i.jumpPower*iW,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??Ku.defaultDataThirdPerson.orientWith,this.slopeThresh=Y7*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Em/this.pixelsPerMeter,this.stepThresh=i.collider.height*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Em/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Em/this.pixelsPerMeter,this.stepThresh=i.collider.height*Cm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),d=new it().setFromEuler(new yi().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(d),this.collider.matrix.compose(c,d,Pm),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new Qe;f.push({fi:0,data:{...tr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...tr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let g=new k0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new nr(o2.create({parameters:{width:p,height:p/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new yi().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Fi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.page,i=this.sharedAssets,r=this.object;e.gameActions!==void 0&&Object.entries(e.gameActions).forEach(([s,n],a)=>{n.forEach(({id:o,data:l})=>{try{this.actions[s]===void 0&&(this.actions[s]=[]),l.type==="Transition"?this.actions[s].push(new tc(l,t,i)):l.type==="Animation"?this.actions[s].push(new ic(l,t,this.controlsManager.eventManager.animationControls)):l.type==="Audio"?this.actions[s].push(new $h(o,l,r,i)):l.type==="Video"?this.actions[s].push(new ly(o,l,r)):l.type==="Create"&&this.actions[s].push(new sc(l,t,this.controlsManager))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),dr(this.actions)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].forEach(t=>{t instanceof tc?t.play():t instanceof ic?t.play(this.initialAction===!1):t instanceof sc?t.dispatchStart():t instanceof $h&&t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].forEach(t=>{t instanceof tc?(t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})):t instanceof ic||(t instanceof sc?t.dispatchStop():t instanceof $h&&t.dispatchGameControl("stop"))})))}get colliderWorldPosition(){return Mi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,n=!1;if(this.usePhysics&&this.collisionEnabled){let o=Gi.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*C_),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(n=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===h&&u.userData.isFollowingObj!==this.object.uuid){(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(Mi,en,Gi),this.groundVelocity.subVectors(Mi,u.prevT),this.object.getWorldPosition(Gi).add(this.collider.position).sub(Mi),this.groundYRotation=ys.setFromQuaternion(en).y-u.prevR.y,Fn.copy(Gi).applyAxisAngle(Zr,this.groundYRotation),this.groundVelocity.add(Fn.sub(Gi)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=Mi.subVectors(this.path[1],this.position),h=Gi.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=Q7.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=Gi.copy(a);o.y=0,a.set(0,a.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=Mi;this.camera.getWorldDirection(o);let l=Fn.copy(Zr).multiplyScalar(o.dot(Zr));o.sub(l);let h=Gi.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(ys.setFromVector3(this.rot),this.moveMode==="walk"&&(ys.x=0),a.applyEuler(ys),n&&(en.setFromUnitVectors(Zr,this.groundNormal),a.applyQuaternion(en)),i){let o=ys.set(0,this.vrEulerYOffset*T_,0);i.applyEuler(o),a.x+=i.x,a.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=Gi;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=Fn.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),Mi.copy(a).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=pt.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==c){let d;l instanceof Bi&&(d=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(d),c.dispatchEvent(Tv));this.lastHitObj=c}if(u!==null){this.pushedVelocity.copy(h),o.copy(u.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(a);l<0&&a.addScaledVector(o,-l),a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Zr,this.euler.y-this.euler0.y);let o=Gi.copy(this.objectToCamXZ).normalize(),l=Fn.copy(a).multiplyScalar(r);l.y=0;let h=l.sub(Mi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=st.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(ys.copy(t),ys.y=0):(ys.copy(this.euler),ys.y=0),this.nonColliderRotOffset.makeRotationFromEuler(ys)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*T_),vr.setFromAxisAngle(K7,this.rot.x),en.setFromAxisAngle(Zr,this.rot.y),en.multiply(vr),vr.setFromAxisAngle(J7,this.rot.z),en.multiply(vr),this.quaternion.copy(en),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=Gi.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let u=0;u<5;u++){let c=o.length(),d=Fn.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,d,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&u===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let _ of p.cloner.children)if(_.rigidBody===x){b=_;break}}y.dispatch(b),p.dispatchEvent(Tv)}}}let f=M_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=E_.copy(d).multiplyScalar(l.toi).dot(f),m=l.toi;if(m===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(m=l.toi*(g-this.offset)/g,h.addScaledVector(d,m)),o.copy(d).multiplyScalar(c-m),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=Fn.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{u===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(Mi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(vr.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=a.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),h===0&&this.checkTrigger(),this.collisionAdjustment(r/o)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);tu.lookAt(l,o,Zr).setPosition(l),tu.decompose(this.targetPos,this.targetQuat,Mi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=st.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=st.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(sW),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&this.navMeshPathDest?.material?.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(rW),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=vr.setFromAxisAngle(Zr,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?st.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=st.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=st.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=Mi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=en.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){Zr.angleTo(e)*180/Math.PI<15||Zr.angleTo(e)*180/Math.PI>85?vr.identity():vr.setFromUnitVectors(Zr,e),this.groundTilt.slerp(vr,.06),this.groundTiltInv.copy(this.groundTilt).invert()}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,n]=this.sharedGameControlGlobals.triggers[t];for(let a=0;a<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;a++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[a];if(s===o||n.isValidTriggeringObject(pt.is(o)?o:o.object)===!1)continue;let l=Tm.copy(s.matrixWorld).decompose(Mi,vr,Gi).compose(Mi,vr,Pm).multiply(r),h=tu.copy(o.matrixWorld).invert().multiply(l);i instanceof Jt?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):(Dm.radius=i,Dm.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere(Dm)),e?n.currentIntersectedObjects.indexOf(o)===-1&&(n.currentIntersectedObjects.push(o),n.dispatch(),s.dispatchEvent(dq)):n.currentIntersectedObjects=n.currentIntersectedObjects.filter(u=>u!==o)}}}collisionAdjustment(e){let t=E_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=tu.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(Mi,vr,Gi).compose(Mi,vr,Pm);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;Dr.makeEmpty(),s.updateMatrixWorldSVD();let n=s.matrixWorldRigid,a=Tm.copy(n).invert(),o=Z7.copy(Tm).multiply(i);gi.copy(this.collider.segment),gi.start.applyMatrix4(o),gi.end.applyMatrix4(o);let l=M_.copy(this.position).applyMatrix4(a);Dr.expandByPoint(gi.start),Dr.expandByPoint(gi.end),Dr.min.addScalar(-this.collider.radius),Dr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(gi.end)},intersectsBounds:h=>h.intersectsBox(Dr),intersectsTriangle:h=>{let u=Mi,c=Gi,d=h.closestPointToSegment(gi,u,c);if(d<this.collider.radius){let p=this.collider.radius-d,f=c.sub(u).normalize(),g=Fn.copy(l);g.addScaledVector(f,p);let m=g.applyMatrix4(n).sub(this.position);t.add(m),gi.start.addScaledVector(f,p),gi.end.addScaledVector(f,p)}}})}),Dr.makeEmpty(),gi.copy(this.collider.segment),gi.start.applyMatrix4(i),gi.end.applyMatrix4(i),Dr.expandByPoint(gi.start),Dr.expandByPoint(gi.end),Dr.min.addScalar(-this.collider.radius),Dr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(gi.end)},intersectsBounds:s=>s.intersectsBox(Dr),intersectsTriangle:s=>{let n=Mi,a=Gi,o=s.closestPointToSegment(gi,n,a);if(o<this.collider.radius){let l=this.collider.radius-o,h=a.sub(n).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),gi.start.addScaledVector(h,l),gi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},nE=Mv;nE.isLocked=!1;var nW=Ll(W_());function fn(e,t){let i=new qe;if(!e.getAttribute("position"))return i.setAttribute("position",new Le([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=Dp(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Le(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var aW=new fe,oW=new fe,xs=[[0,0,0],[0,0,0],[0,0,0]];function aE(e){let t=e.elements;xs[0][0]=t[0],xs[0][1]=t[4],xs[0][2]=t[8],xs[1][0]=t[1],xs[1][1]=t[5],xs[1][2]=t[9],xs[2][0]=t[2],xs[2][1]=t[6],xs[2][2]=t[10];let{u:i,v:r}=(0,nW.SVD)(xs),s=aW.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),n=oW.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1);return s.multiply(n.transpose())}var lW=class extends BS{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,i=[]){return e.forEach(r=>{r.visible&&this.intersectObject(r,t,i)}),i}createRaycastLineHelper(){let e=new la({color:65280,linewidth:10}),t=new E(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new E(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),r=this.camera.far-this.camera.near,s=new E().addVectors(t,i.multiplyScalar(r)),n=new qe;return n.setFromPoints([t,s]),new Su(n,e)}},oE=e=>e instanceof Ac||e instanceof fl;function hW(e,t){return e.distance-t.distance}function lE(e,t,i){if(!(!pn(t)||!t.visible)){Jr(t)&&t.raycast(e,i);for(let r of t.children)lE(e,r,i)}}function Ev(e,t,i){if(!i.some(s=>hp(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>lE(e,s,r)),r.sort(hW),r}function Cv(e){let t=[];if(e.length){let i=e[0].object;pn(i)&&t.push(i);let r=i.parent;for(;r;)oE(r)&&t.push(r),r=r.parent}return t}function hp(e,t){if(Jr(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(oE(t))return hE(e,t)}function hE(e,t){if(!(!pn(t)||!t.visible)){if(Jr(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=hE(e,i);if(r)return r}}}function cW(e,t,i){return{x:(e-(i.left+window.scrollX))/i.width*2-1,y:-((t-(i.top+window.scrollY))/i.height)*2+1}}var dW=class{constructor(e,t,i,r,s,n,a,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=n,this.isExport=a,this.frame=o,this.raycaster=new lW,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(cW(t,i,r),this.getCamera())}},cE=(e=>(e[e.keydown=0]="keydown",e[e.keyup=1]="keyup",e[e.pointerdown=2]="pointerdown",e[e.pointerup=3]="pointerup",e[e.pointermove=4]="pointermove",e[e.wheel=5]="wheel",e[e.scroll=6]="scroll",e))(cE||{}),Hs=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},hy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],dE=e=>hy.find(([t,i])=>i===e)?.[0],Nc=e=>hy.find(([t])=>t===e)?.[1],uW=(e,t)=>{let i=dE(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},pW=class extends Hs{constructor(e){super(e),this.objectsPerEvents=new Map,this.splineEvents={},this.onBeginEvent=i=>{if(!i.eventName||!i.target||i.eventName==="Scroll")return;let r=this.splineEvents[dE(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of hy)if(i.data.events.some(n=>n.data.type===s&&!n.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let n={id:i.uuid,name:i.name},a=uW(s,n),o=this.splineEvents[r];o?o[i.uuid]=a:this.splineEvents[r]={[i.uuid]:a}}}})}connect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(e=>{e.forEach(t=>{t.removeEventListener("beginEvent",this.onBeginEvent)})})}},fW=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.useToggle===!1&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()})}},mW=class extends Hs{constructor(e,t){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.windowMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onWindowMouseDown=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()}),this.windowMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&n.dispatch()})},this.onWindowMouseUp=s=>{(s.target===this.eventContext.domElement||s.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()}),this.windowMouseEvents.forEach(n=>{n.data.type==="MouseUp"?n.dispatch():n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseDown"))},this.onMouseUp=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent())},this.onMousePressRelease=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMousePressEvent(!0))},this.onKeyDown=s=>{this.heldKeys[s.key]||(this.handleKeyEvent(s,"KeyDown"),this.handleKeyEventHeld(s,"KeyDown",!0)),this.heldKeys[s.key]=!0},this.onKeyUp=s=>{this.handleKeyEvent(s,"KeyUp"),this.handleKeyEventHeld(s,"KeyUp",!0)},this.onKeyPressDown=s=>{this.heldKeysPress[s.key]?this.handleKeyEventHeld(s,"KeyPress"):(this.handleKeyEvent(s,"KeyPress"),this.handleKeyEventHeld(s,"KeyPress",!0)),this.heldKeysPress[s.key]=!0},this.onKeyPressUp=s=>{this.handleKeyEvent(s,"KeyPress",!0)},this.releaseHeldKey=s=>{delete this.heldKeys[s.key]},this.releaseHeldKeyPress=s=>{delete this.heldKeysPress[s.key]},this._onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Nc(s);o&&(o==="MouseDown"||o==="MouseUp"||o==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent(a)})):(o==="KeyDown"||o==="KeyUp"||o==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:o}),this.eventsPerObjects[o]?.[n.uuid]?.forEach(l=>{l.dispatchUserEvent()})))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!s.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let a of n){let o=this.eventsPerObjects[a];s.data.events.filter(({data:l})=>l.type===a&&l.disabled!==!0).forEach(({id:l,data:h})=>{try{let u=new fW(l,h,s,i,r,t);u.actions.Video.length&&(this.hasVideoAction=!0),(h.type==="MouseDown"||h.type==="MouseUp"||h.type==="MousePress")&&(h.mode==="Canvas"||h.mode==="Window")?h.mode==="Canvas"&&this.canvasMouseEvents.push(u):o[s.uuid]?o[s.uuid].push(u):o[s.uuid]=[u]}catch{}}),o[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),typeof window<"u"&&(window.addEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.addEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.MousePress?.length&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMousePressDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMousePressRelease)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),this.objectsPerTypes.KeyPress?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyPressDown),document.addEventListener("keyup",this.releaseHeldKeyPress),this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyPressUp)),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},this.heldKeysPress={},typeof window<"u"&&(window.removeEventListener("pointerdown",this.onWindowMouseDown,{capture:!0}),window.removeEventListener("pointerup",this.onWindowMouseUp,{capture:!0})),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=Ev(i,r,s);Cv(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{hp(i,n)&&this.handleObjectMouseEventDispatch(n,e)})}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:n,page:a}=this.eventContext;if(s){let o=Ev(n,a,i);r=Cv(o)}else i.forEach(o=>{hp(n,o)&&r.push(o)})}this._prevObjects.length&&this._prevObjects.forEach(s=>{r.includes(s)||this.handleObjectMouseEventDispatchRelease(s,t)}),r.length&&r.forEach(s=>{this.handleObjectMouseEventDispatch(s,t)}),this._prevObjects=r}}handleObjectMouseEventDispatch(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatch()})}handleObjectMouseEventDispatchRelease(e,t){e.dispatchEvent({type:"beginEvent",eventName:t}),this.eventsPerObjects[t]?.[e.uuid]?.forEach(i=>{i.dispatchRelease()})}handleKeyEvent(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{let s=this.eventsPerObjects[t][r.uuid];s.some(({data:n})=>"key"in n&&n.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(n=>{"key"in n.data&&n.data.key===e.key&&(i?n.dispatchRelease():n.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},gW=new E,vW=new E,uE=class{constructor(e,t,i,r,s){this.actionsIn=Ar(e,e.inActions,i,r,s,t),this.actionsOut=Ar(e,e.outActions,i,r,s,t)}disconnect(){dr(this.actionsIn),dr(this.actionsOut)}},yW=class extends uE{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{for(let d of this.objects)if(!d.visible)return;let h=gW.setFromMatrixPosition(this.objects[0].matrixWorld),u=vW.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(u)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let d=c==="in"?this.actionsIn:this.actionsOut;d.Audio.forEach(p=>p.dispatchConditional()),d.Video.forEach(p=>p.dispatchConditional()),d.Link.forEach(p=>p.dispatch()),d.Create.forEach(p=>p.dispatch()),d.Destroy.forEach(p=>p.dispatch()),d.Reset.forEach(p=>p.dispatch()),d.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),d.Transition.forEach(p=>p.play()),d.Animation.forEach(p=>p.play()),d.SwitchCamera.forEach(p=>p.play()),d.SceneTransition.forEach(p=>p.dispatch())}};let{distance:a,fromObject:o,toObject:l}=t.condition;this.distance=a;for(let h of[o,l]){if(!h)throw new Error("Missing property");let u=r.find(h);if(!u)throw new Error("Missing property");this.objects.push(u)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},xW=class extends uE{constructor(e,t,i,r,s,n){super(t,i,r,s,n),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(u=>u.dispatchConditional()),this.actionsOut.Video.forEach(u=>u.dispatchConditional()),this.actionsOut.Link.forEach(u=>u.dispatch()),this.actionsOut.Create.forEach(u=>u.dispatch()),this.actionsOut.Destroy.forEach(u=>u.dispatch()),this.actionsOut.Reset.forEach(u=>u.dispatch()),this.actionsIn.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(u=>u.play()),this.actionsOut.Animation.forEach(u=>u.play()),this.actionsIn.SwitchCamera.forEach(u=>u.pause()),this.actionsOut.SwitchCamera.forEach(u=>u.play()),this.actionsOut.SceneTransition.forEach(u=>u.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(u=>u.dispatchConditional()),this.actionsIn.Video.forEach(u=>u.dispatchConditional()),this.actionsIn.Link.forEach(u=>u.dispatch()),this.actionsIn.Create.forEach(u=>u.dispatch()),this.actionsIn.Destroy.forEach(u=>u.dispatch()),this.actionsIn.Reset.forEach(u=>u.dispatch()),this.actionsOut.Transition.forEach(u=>u.pause()),this.actionsOut.Transition.forEach(u=>u.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(u=>u.play()),this.actionsIn.Animation.forEach(u=>u.play()),this.actionsOut.SwitchCamera.forEach(u=>u.pause()),this.actionsIn.SwitchCamera.forEach(u=>u.play()),this.actionsIn.SceneTransition.forEach(u=>u.dispatch()))};let{condition:a}=t;if(!a.object)throw new Error("Missing property");let o=r.find(a.object);if(!o)throw new Error("Missing property");if(this.toObject=o,a.state&&!this.toObject.states?.[a.state])throw new Error("Missing property");this.toState=a.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},bW=class extends Hs{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="Conditional")try{let o;a.condition.type==="Comparison"||(a.condition.type==="Distance"?o=new yW(n,a,s,i,r,t):a.condition.type==="State"&&(o=new xW(n,a,s,i,r,t))),o&&(this.eventsPerConditions[a.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Ph=new E,Nn=new E,Sa=new E,P_=new xr,wW=.01,bt=new E,li=new E,D_=new E,ka=new it,Im=new yi,_W=new fe,Lm=new bi,Ro=new E,bs=new E,Bo=.2;function Om(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var SW=function(){let e=new fe;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Om(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Om(s.position,t.limits):t.reference==="local"&&(ka.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(ka),Om(s.position,t.limits),ka.invert(),s.position.applyQuaternion(ka),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(bt,s.quaternion,li),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof cr&&Ds(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),AW=class{constructor(e,t,i,r,s,n){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=Ar(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=Ar(t,t.dragDropActions.drop,i,r,s,this.object);let a=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(a.push(l),n[l.uuid]&&n[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&a.push(u)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),n[l.uuid]&&n[l.uuid].forEach(h=>{let u=i.find(h);!u||u.data.visible!==!1&&this.dropDestIds.push(u.uuid)}))}),this.dragItems=a.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new fe,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){dr(this.actionsDrag),dr(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},MW=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(this.lastDropDestination=null,a.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:u,pointStart:c}of o.dragItems){if(h===a[0].object||h===a[0].object.object||pt.is(h)&&h.isAncestorOf(a[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let d=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(bt,ka,li),Im.setFromQuaternion(ka),d.prevR===void 0?(d.prevR=Im.clone(),d.prevT=bt.clone()):(d.prevR.copy(Im),d.prevT.copy(bt)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),u.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Ve.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:n}=this.eventContext,a=n.raycastWithClones(s);if(Ve.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===a[0]?.object||h===a[0]?.object?.object||pt.is(h)&&h.isAncestorOf(a[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=a.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Ac)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(u=>u===h.object.uuid||n.scene.find(u).isAncestorOf(h.object.uuid))))[0]),l){let h=D_.copy(l.face.normal).applyMatrix3(Lm.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){bt.copy(h).applyMatrix3(Lm.setFromMatrix4(o.obj.matrixWorld).transpose());let u=o.obj;bt.x>Bo?li.x=-u.recursiveBBox.min.x:bt.x<-Bo&&(li.x=-u.recursiveBBox.max.x),bt.y>Bo?li.y=-u.recursiveBBox.min.y:bt.y<-Bo&&(li.y=-u.recursiveBBox.max.y),bt.z>Bo?li.z=-u.recursiveBBox.min.z:bt.z<-Bo&&(li.z=-u.recursiveBBox.max.z),li.applyMatrix3(Lm.invert())}else li.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(li)}this.activeEvent.data.autoOrient&&(bt.set(0,1,0).cross(h),bt.length()<1e-4&&bt.set(-1,0,0).cross(h),li.crossVectors(D_,bt),o.orientationMatrix.makeBasis(bt,li,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Animation.forEach(u=>{u.play()}),this.activeEvent.actionsDrop.Audio.forEach(u=>{u.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(u=>{u.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(n=>{n.stop(),n.object.currentState!==null&&n.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(n=>{n.stop()}),this.activeEvent.actionsDrag.Audio.forEach(n=>{n.dispatchGameControl("stop")})),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new AW(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:n}=this.eventContext;s().getWorldDirection(Nn),Nn.negate();let a=ka.identity();switch(r==="parent"?_W.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(bt,a,li):r==="local"&&e.matrixWorld.decompose(bt,a,li),i){case"x":bt.set(1,0,0).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"y":bt.set(0,1,0).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"z":bt.set(0,0,1).applyQuaternion(a),Ro.copy(Nn).cross(bt),bs.copy(bt).cross(Ro);break;case"xy":bs.set(0,0,1).applyQuaternion(a);break;case"yz":bs.set(1,0,0).applyQuaternion(a);break;case"xz":bs.set(0,1,0).applyQuaternion(a);break;case"adaptive":Nn.angleTo(li.set(0,1,0))>Math.PI/6?(bt.crossVectors(li.set(0,1,0),Nn),bs.crossVectors(bt,li)):bs.set(0,1,0);break;default:bs.copy(Nn);break}Sa.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:Sa;if(P_.setFromNormalAndCoplanarPoint(bs,o),!!n.ray.intersectPlane(P_,t)&&(i==="x"||i==="y"||i==="z")){let l=li.subVectors(t,o).dot(bt);t.copy(o).addScaledVector(bt,l)}}updateDragItem(e,t=!1){Sa.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Ph.subVectors(e.fromPosition,Sa).divideScalar(e.currentDampingFactor):e.reset==="original"?(Ph.subVectors(e.obj.userData.worldPosition0,Sa).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Ph.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(Sa).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Ph.length()<wW:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&SW(e,Ph.add(Sa),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},zo=new E,Rm=new E,tn=new E,rn=new E,I_=new xr,EW=.01,CW={type:"requestRender"},TW=function(){let e=new E,t=new E;return(i,r,s)=>s>0?(e.subVectors(i,r),e.length()<=s?i:t.copy(r).add(e.normalize().multiplyScalar(s))):r}(),L_=function(){let e=new fe;return(t,i)=>{t.position.copy(i),t.parent!==null&&(e.copy(t.parent.matrixWorld).invert(),t.position.applyMatrix4(e)),e.copy(t.hiddenMatrix).invert(),t.position.applyMatrix4(e),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldSVD()),t instanceof cr&&Ds(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),PW=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...bg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=Ar(e,e.actions,i,r,s,t)}},DW=class extends Hs{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Ve.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(n=>n.data.type==="Follow"&&!n.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new PW(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents||(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events)if(i.target!==void 0){let r=i.target,s=this.onTargetChange(i);this.pairOfEventListeners.push([r,s]),r.addEventListener("requestRender",s)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let i of this.events)i.paused=!0,i.isReset=!1,dr(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(a=>{a.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(tn),e.isReset)rn.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(rn);else{let{getCamera:a,raycaster:o}=this.eventContext;if(i==="custom"?(a().getWorldDirection(Rm),Rm.negate(),zo.copy(Rm)):i==="xy"?zo.set(0,0,1):i==="xz"?zo.set(0,1,0):i==="yz"&&zo.set(1,0,0),I_.setFromNormalAndCoplanarPoint(zo,tn),!o.ray.intersectPlane(I_,rn))return}if(!e.isReset){if(rn.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)rn.copy(e.worldPosition0),e.currentDampingFactor=e.resetDampingFactor;else return;else if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return}e.data.enabledTranslation[0]===!1&&(rn.x=tn.x),e.data.enabledTranslation[1]===!1&&(rn.y=tn.y),e.data.enabledTranslation[2]===!1&&(rn.z=tn.z);let n=TW(tn,rn,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let a=zo.subVectors(n,tn).divideScalar(e.currentDampingFactor);tn.add(a),t&&L_(e.object,tn),e.paused=a.length()<EW}else L_(e.object,n),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(CW)}},Dh=new E,iu=new E,Ih=new fe,Fo=new it,kn=new it,Lh=new E,Oh=new E,Aa=new E,sn=new E,Bm=new xr,IW=1e-6,LW={type:"requestRender"},OW={type:"changeRotation"},O_=function(){let e=new fe;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(aE(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof cr&&Ds(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),RW=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...wg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},BW=class extends Hs{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Ve.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let n=Nc(r);n&&n==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new RW(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.eventContext.useWindowEvents?t.addEventListener("scroll",this.onScroll):(e.addEventListener("pointerenter",this.onMouseEnter),e.addEventListener("pointerleave",this.onMouseLeave));for(let i of this.events){if(i.target!==void 0){let n=this.onTargetChange(i),a=i.target;this.pairOfEventListeners.push([a,n]),a.addEventListener("requestRender",n)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),_r&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:n,enabledRotation:a,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:u,target:c}=e;if(u.getWorldPosition(Lh),!e.isReset)if(e.target)e.target.getWorldPosition(Oh);else{if(s==="custom"?(l().getWorldDirection(iu),iu.negate(),Bm.setFromNormalAndCoplanarPoint(iu,Lh)):(s==="xy"?Dh.set(0,0,1):s==="xz"?Dh.set(0,1,0):s==="yz"&&Dh.set(1,0,0),Bm.setFromNormalAndCoplanarPoint(Dh,Lh)),!h.ray.intersectPlane(Bm,Oh))return;r>0&&(s==="custom"||s===void 0)&&Oh.addScaledVector(iu,r)}if(e.isReset||(c?t==="target"?Aa.copy(c.up).applyMatrix4(Ih.extractRotation(c.matrixWorld)).normalize():a.some(d=>d===!1)?(i==="x"?(sn.set(0,0,1),a[2]===!1&&sn.set(0,1,0)):i==="y"?(sn.set(1,0,0),a[0]===!1&&sn.set(0,0,1)):(sn.set(0,1,0),a[1]===!1&&sn.set(1,0,0)),Aa.copy(sn).applyQuaternion(e.worldQuaternion0).normalize()):Aa.set(0,1,0):s==="custom"?Aa.set(0,1,0):Aa.copy(Dh)),e.isReset)kn.copy(e.worldQuaternion0);else if(Lh.distanceTo(Oh)>n&&o&&c)if(e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)kn.copy(e.worldQuaternion0),e.currentDampingFactor=e.resetDampingFactor;else return;else{if(e.wasOutside&&(e.data.snapDelay&&typeof window<"u"&&(e.timeoutId=window.setTimeout(()=>{e.delayFinished=!0,e.paused=!1,this.updateSingleEvent(e)},e.data.snapDelay*1e3)),e.currentDampingFactor=e.data.dampingFactor,e.wasOutside=!1),e.delayFinished===!1)return;zW(Ih,Oh,Lh,Aa,i,sn),kn.setFromRotationMatrix(Ih),Fo.setFromUnitVectors(sn.applyQuaternion(kn),Aa),a.some(d=>d===!1)&&t!=="target"&&kn.premultiply(Fo).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),Fo.setFromRotationMatrix(aE(u.matrixWorld)),Fo.slerp(kn,1/e.currentDampingFactor),O_(u,Ih.makeRotationFromQuaternion(Fo)),e.paused=8*(1-Fo.dot(kn))<IW):(O_(u,Ih.makeRotationFromQuaternion(kn)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(LW),u.dispatchEvent(OW)}},Ir=new E,oi=new E,Yt=new E;function zW(e,t,i,r,s,n){let a=e.elements;Yt.subVectors(t,i),Yt.lengthSq()===0&&(Yt.z=1),Yt.normalize(),oi.crossVectors(r,Yt),oi.lengthSq()===0&&(Math.abs(r.z)===1?Yt.x+=1e-4:Yt.z+=1e-4,Yt.normalize(),oi.crossVectors(r,Yt)),oi.normalize(),Ir.crossVectors(Yt,oi),s==="x"?n.z===1?[oi,Ir,Yt]=[Yt,oi,Ir]:(oi.negate(),[oi,Yt]=[Yt,oi]):s==="y"?n.x===1?[oi,Ir,Yt]=[Ir,Yt,oi]:(oi.negate(),[Ir,Yt]=[Yt,Ir]):n.x===1&&(oi.negate(),[oi,Ir]=[Ir,oi]),a[0]=oi.x,a[4]=Ir.x,a[8]=Yt.x,a[1]=oi.y,a[5]=Ir.y,a[9]=Yt.y,a[2]=oi.z,a[6]=Ir.z,a[10]=Yt.z}var FW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch())}},NW=class extends Hs{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Ve.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Ve.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:n,reverse:a})=>{if(!s||!n)return;let o=Nc(s);o&&o==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(l=>l.dispatchUserEvent(a)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:n,data:a}of s.data.events)if(!a.disabled&&a.type==="MouseHover")try{let o=new FW(n,a,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),_r&&(this.domEventsNeeded.add("pointerdown"),e.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),e.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),e.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(t=>{t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),_r&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let n=Ev(r,s,this.objects);t=Cv(n)}else this.objects.forEach(n=>{hp(r,n)&&t.push(n)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{t.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchLeave()))}),t.length&&t.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(r=>r.dispatchEnter())}),this._prevObjects=t}},kW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Ar(t,t.actions,r,s,n,i)}connect(){this.scrollCounter=0}disconnect(){dr(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},UW=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.object=i,this.domElement=n,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.actions=Ar(t,t.actions,r,s,a,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,n=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let a=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?a:l==="bottom"?a-o:a-o*.5;this.scrollStart=n-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){dr(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled())}},jW=class extends Hs{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([a,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=a=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(u=>u.dispatch(o))})},this.onWheel=a=>{!this.isInview||a.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:a.deltaY}),l.forEach(h=>h.dispatch(a.deltaY))})},this.onUserEvent=({eventName:a,target:o,reverse:l})=>{if(!a||!o)return;let h=Nc(a);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(u=>{u.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:n}=this.eventContext;i.traverseEntity(a=>{if(a.data?.events.length){for(let{id:o,data:l}of a.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!n){let h=new kW(o,l,a,i,r,t);this.wheelEventsPerObject.has(a)?this.wheelEventsPerObject.get(a)?.push(h):this.wheelEventsPerObject.set(a,[h])}else{let h=new UW(o,l,a,i,r,s,t);this.scrollEventsPerObject.has(a)?this.scrollEventsPerObject.get(a)?.push(h):this.scrollEventsPerObject.set(a,[h])}}}),this.intersectionObserver=new IntersectionObserver(a=>{let o=a[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},GW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.actions=Ar(t,t.actions,r,s,n,i)}disconnect(){dr(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof Na?t.interaction.audioPlayer.play():t.interaction instanceof wv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof ml?t.interaction.play(i==="autoplay"):t.interaction instanceof Av&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof Na?t.interaction.audioPlayer.play():t.interaction instanceof wv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof ml?t.interaction.play():t.interaction instanceof Av&&t.interaction.dispatch()})}},VW=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,n])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(a=>{a.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(n=>{n.interaction instanceof Na&&n.interaction.audioPlayer.play()}),s.actions.Video.forEach(n=>{let a=n.interaction.data.triggerAfter??"autoplay";n.interaction instanceof ml&&n.interaction.play(a==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let n=Nc(i);n&&n==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(a=>{a.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let n=new GW(r,s,i,t,e,this.eventManager);(n.actions.Transition.length||n.actions.Animation.length||n.actions.SwitchCamera.length||n.actions.Create.length||n.actions.Destroy.length||n.actions.SceneTransition.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(n):this.eventsPerObject.set(i,[n])),n.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n])),n.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(n):this.eventsAfterPerObject.set(i,[n]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(n=>n.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},HW=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.actions=Ar(t,t.actions,r,s,n,i),this.target=t.target,this.useToggle=t.toggle}disconnect(){dr(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},WW="https://unpkg.com/@splinetool/runtime@0.9.455/build/",qW="https://unpkg.com/@splinetool/navmesh-wasm@0.9.455/build/",XW=`
|
|
6239
6239
|
(async function() {
|
|
6240
6240
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
6241
6241
|
import('${WW}' + 'navmesh.js'),
|
|
@@ -6301,7 +6301,7 @@ onmessage = function(messageEvent) {
|
|
|
6301
6301
|
<path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6302
6302
|
</svg>
|
|
6303
6303
|
`),w.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),w.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,f];return}let A={zone:f,mode:"static",position:x,size:g};v==="hide"&&(A.restOpacity=0);let S=L9.create(A);S.on("move",(w,M)=>{let C=this.gameControl;d==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):d==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),S.on("end",(w,M)=>{let C=this.gameControl;d==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):d==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[S,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(d=>d.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new dt.World(new dt.Vector3(0,this.gravity,0)),this.events=new dt.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(a=>{let o;if(a instanceof is)if(a.objectForSample){if(a.objectForSample.dataPatched.physics.fusedBody)return;o=a.object}else return a.object.dataPatched.physics.fusedBody===!0&&a.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(a instanceof Bi)o=a.object;else if(o=a,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0;let l=o.dataPatched,h;for(let m of l.events)m.data.disabled!==!0&&m.data.type==="GameControl"&&(h=m.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;a.updateMatrixWorldSVD();let u=cp(l),c=!1,d=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let m of l.events)if(m.data.disabled!==!0){if(m.data.type==="Collision"){c=!0;let v=new HW(m.id,m.data,o,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==m.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(m.data.type==="Follow"){f=!0;let v=m.data.target;a.traverseVisible(y=>{y.userData.isFollowingObj=v})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(a.matrixWorldFusedFalse=a.matrixWorld.clone());let g=a.geometry;if(h!==void 0){let m=dt.RigidBodyDesc.kinematicPositionBased();(a.hasNonUniformScale?a.matrixWorldRigid:a.matrixWorld).decompose(ii,Kr,Un),a.position0=ii.clone().divideScalar(this.pixelsPerMeter),a.rotation0=Kr.clone(),ii.divideScalar(this.pixelsPerMeter),m.setTranslation(ii.x,ii.y,ii.z).setRotation(Kr);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(m);a.rigidBody=v;let y;h.collider.type==="sphere"?y=dt.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?y=dt.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):y=dt.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(dt.CoefficientCombineRule.Average).setRestitutionCombineRule(dt.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let x=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(x.handle,o),ii.fromArray(h.collider.position).multiply(Un.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),x.setTranslationWrtParent(ii);let b=new it().setFromEuler(new yi().setFromVector3(new E().fromArray(h.collider.rotation)));x.setRotationWrtParent(b),x.setActiveEvents(dt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||u||f||d||p||c?(this.addRigidBody(a,o,{hasFollow:f,hasTransformAnim:u,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(g&&e.push(fn(g,a.matrixWorld)),l.physics.fusedBody&&a.traverseObject((m,v)=>{if(v===0)return;let y;if(m instanceof is)if(m.objectForSample){if(m.objectForSample.dataPatched.physics.fusedBody)return;y=m.object}else return m.object.dataPatched.physics.fusedBody===!0&&m.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(m instanceof Bi)y=m.object;else if(y=m,y.dataPatched.cloner?.hideBase)return!0;let x=y.dataPatched;if(x.physics.enabled==="visibility"?!x.visible:!x.physics.enabled)return!0;let b=m.geometry;b?.getAttribute("position")!==void 0&&e.push(fn(b,m.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=za(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=dt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),n=dt.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(dt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(dt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(n,s);for(let[a,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?(this.gameControl===null||this.needsCollisionDetection)&&this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new k_(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new fe().compose(nn.fromArray(t.data.position),Uo.setFromEuler(U_.fromArray(t.data.rotation)),G_);if(t.data.triggerZone==="box"){let s=new Jt;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics){let s=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let n=e/1e3;n<s&&n>s*.55&&(n=s),this.accumulator+=n;let a=performance.now(),o=0,l=6;for(;this.accumulator>=s&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=s,o++,!(performance.now()-a>s*1e3)););this.accumulator=this.accumulator%s}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(ii,Kr,Un),km.setFromQuaternion(Kr);let t=e;t.prevR===void 0?(t.prevR=km.clone(),t.prevT=ii.clone()):(t.prevR.copy(km),t.prevT.copy(ii)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(ii.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(Kr))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,s;if(t.cloner){for(let n of t.cloner.children)if(n.rigidBody===r){s=n;break}}e.dispatch(s),t.dispatchEvent(Tv)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=hq.copy(e.matrixWorld).invert();e.traverseEntity((s,n)=>{if(t===!1&&n===1)return!0;for(let a of s.dataPatched.events)if(a.data.type==="Trigger"&&a.data.disabled!==!0){let o=new k_(a.id,a.data,s,this.page,this.sharedAssets,this.eventManager),l;if(a.data.triggerZone==="box"?l=dt.ColliderDesc.cuboid(...a.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=dt.ColliderDesc.ball(a.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(dt.ActiveEvents.COLLISION_EVENTS),nn.fromArray(a.data.position),Uo.setFromEuler(U_.fromArray(a.data.rotation)),Um.compose(nn,Uo,G_).premultiply(s.matrixWorld),i?(Um.decompose(nn,Uo,j_),l.setActiveCollisionTypes(dt.ActiveCollisionTypes.KINEMATIC_FIXED|dt.ActiveCollisionTypes.DYNAMIC_FIXED)):(Um.premultiply(r).decompose(nn,Uo,j_),e.rigidBody.bodyType()===dt.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===dt.RigidBodyType.Fixed?l.setActiveCollisionTypes(dt.ActiveCollisionTypes.KINEMATIC_FIXED|dt.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(dt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|dt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),nn.divideScalar(this.pixelsPerMeter),l.setTranslation(nn.x,nn.y,nn.z),l.setRotation(Uo),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}};function fq(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,n=this._loopCount,a=r===Iv;if(e===0)return n===-1?s:a&&(n&1)===1?t-(s-i):s;if(r===J_){n===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(n===-1&&(e>=0?(n=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,n+=Math.abs(o);let l=this.repetitions-n;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,a||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,a)}else this._setEndings(!1,!1,a);this._loopCount=n,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(a&&(n&1)===1)return t-(s-i)}return s}var V_=!1,mq=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((n,a)=>{let o=n[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=$m.parse(JSON.parse(n[2]));s.animations[a]=l;let h=this.mixer.clipAction(l,s);V_===!1&&(Object.getPrototypeOf(h)._updateTime=fq,V_=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new fO(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(n=>n.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(n=>n.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=$_}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=Iv)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},jm=new WeakMap,gq=class extends Wv{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new eg(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,n=>{this.decodeDracoFile(n,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(jm.has(e)){let o=jm.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,n=e.byteLength,a=this._getWorker(s,n).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),jm.set(e,{key:i,promise:a}),a}_createGeometry(e){let t=new qe;e.index&&t.setIndex(new Ye(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,n=r.array,a=r.itemSize;t.setAttribute(s,new Ye(n,a))}return t}_loadLibrary(e,t){let i=new eg(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=vq.toString(),n=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
6304
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function vq(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(a,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===a.TRIANGULAR_MESH)d=new a.Mesh,p=o.DecodeBufferToMesh(l,d);else if(f===a.POINT_CLOUD)d=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in u){let v=self[c[m]],y,x;if(h.useUniqueIDs)x=u[m],y=o.GetAttributeByUniqueId(d,x);else{if(x=o.GetAttributeId(d,a[u[m]]),x===-1)continue;y=o.GetAttribute(d,x)}g.attributes.push(s(a,o,d,m,v,y))}return f===a.TRIANGULAR_MESH&&(g.index=r(a,o,d)),a.destroy(d),g}function r(a,o,l){let h=l.num_faces()*3,u=h*4,c=a._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:d,itemSize:1}}function s(a,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,g=n(a,u),m=a._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,g,f,m);let v=new u(a.HEAPF32.buffer,m,p).slice();return a._free(m),{name:h,array:v,itemSize:d}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Jn;function yq(){return Jn||(Jn=new gq,Jn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Jn.decoderPending}async function xq(e){if(Jn){let t={attributeIDs:Jn.defaultAttributeIDs,attributeTypes:Jn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Jn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function bq(e,t){let[i,r]=IA(yg.deserialize(new Uint8Array(e)));t2(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await yq();for(let n of s){let a=await xq(wi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var wq=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=Ar(i,t.actions,s,n,a,r)}disconnect(){dr(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},_q=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.helperResize=(i,r)=>{this.breakpoints.forEach(s=>{let n=_g.deviceToSize(s.data.size),a=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=a<n[0];break;case">":o=a>n[0];break;case"<>":o=a>n[0]&&a<n[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())})},this.onResize=()=>{let{innerWidth:i,innerHeight:r}=window;this.helperResize(i,r)},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:n}=r.contentRect;this.helperResize(s,n)}})}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r,frame:s}=this.eventContext;r?window.addEventListener("resize",this.onResize):s.preset==="fullscreen"?this.onResizeObserver.observe(i):window.addEventListener("resize",this.onResize),e.traverseEntity(n=>{if(!(!n.visible||!n.data?.events.length))for(let{data:a}of n.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:o,id:l})=>{try{let h=new wq(l,o,a,n,e,t,this.eventManager);this.breakpoints.push(h)}catch{}})})}disconnect(){let{isExport:e,frame:t}=this.eventContext;e?window.removeEventListener("resize",this.onResize):t.preset==="fullscreen"?this.onResizeObserver.disconnect():window.removeEventListener("resize",this.onResize),this.breakpoints.forEach(i=>{i.disconnect()}),this.breakpoints=[]}},H_=Object.keys(cE).filter(e=>isNaN(Number(e))),Sq=class{constructor(e,t,i,r){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.isEnabled=!1,this.activateCount=0,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=s=>{(s.touches.length>1||this.preventTouchScroll)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.handlers={Spline:new pW(this.eventContext),Conditional:new bW(this.eventContext,this),Start:new VW(this.eventContext,this),Basic:new mW(this.eventContext,this),MouseHover:new NW(this.eventContext,this),Scroll:new jW(this.eventContext,this),Follow:new DW(this.eventContext,this),DragDrop:new MW(this.eventContext,this),LookAt:new BW(this.eventContext),Resize:new _q(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),H_.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender)}),H_.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}},Aq=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new k().copy(i),this._editorSize=new k().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=Mq(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function Mq(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var Eq=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new U0(e.shared,t),this.scene=new Q0(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof sa&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Qi&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Cq=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Tq(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function nc(e){return e instanceof Sc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Pq(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof cr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof cr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!zi.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!zi.isMergable(l.material))return;n=zi.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][nc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][nc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][nc(r)].push(l)}),i}function Dq(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function Iq(e,t){let i=Pq(t,e),r=Dq(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof cr&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&Tq(a[m]);let g=za(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new nr(g,l[0].material);break}default:{m=new nr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof cr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][nc(x)]&&i[x.material.uuid][nc(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var Lq=Ll(tC(),1),Oq=new k;function Rq(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var cy=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Oq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=u0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Cq({x:10,y:10})),qk(e)}async load(e,t){Rq(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await bq(e);this._data=i,i.version&&(0,Lq.default)(i.version,"0.9.454")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([zw(i)&&dj(),OG(i)&&lj(),vc.physicsEnabled(i.scene.objects)&&Kk(),Lw(i)&&xG(),eq(i)&&Qk()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new Eq(i);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let a=performance.now();Iq(i,r.scene);let o=performance.now();console.log("Merged geometries in ",o-a," ms")}zw(i)&&this._scene.traverse(a=>{Ds(a)&&a.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(a=>{a instanceof is&&a.pendingMediaLoad&&a.update()})});let s=Object.keys(i.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a).loadingPromise);Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),Lw(i)&&uq(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),oy(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new l9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData);let n=Object.values(i.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Aq(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let a=new dW(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new pq(a),this._animationControls=new mq(this._scene,this._requestRenderAutoMode),this._eventManager=new Sq(i.scene.publish,this._controls,this._animationControls,a),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==ql&&!this._scene.isInvisibleObjects(t)&&!(t instanceof sa)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof fE&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new hr(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{fx.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),Xk(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof sa&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof sa||e instanceof Q0?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=fx(i,(s,n)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=n),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var zp=window,Fp=zp.ShadowRoot&&(zp.ShadyCSS===void 0||zp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dy=Symbol(),mE=new WeakMap,kc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==dy)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(Fp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=mE.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&mE.set(i,t))}return t}toString(){return this.cssText}},gE=e=>new kc(typeof e=="string"?e:e+"",void 0,dy),uy=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new kc(i,e,dy)},py=(e,t)=>{Fp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=zp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Np=Fp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return gE(i)})(e):e;var fy,kp=window,vE=kp.trustedTypes,Bq=vE?vE.emptyScript:"",yE=kp.reactiveElementPolyfillSupport,gy={toAttribute(e,t){switch(t){case Boolean:e=e?Bq:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},xE=(e,t)=>t!==e&&(t==t||e==e),my={attribute:!0,type:String,converter:gy,reflect:!1,hasChanged:xE},En=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=my){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||my}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Np(s))}else t!==void 0&&i.push(Np(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return py(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=my){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:gy).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:gy;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||xE)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};En.finalized=!0,En.elementProperties=new Map,En.elementStyles=[],En.shadowRootOptions={mode:"open"},yE?.({ReactiveElement:En}),((fy=kp.reactiveElementVersions)!==null&&fy!==void 0?fy:kp.reactiveElementVersions=[]).push("1.6.0");var vy,Up=window,Kl=Up.trustedTypes,bE=Kl?Kl.createPolicy("lit-html",{createHTML:e=>e}):void 0,da=`lit$${(Math.random()+"").slice(9)}$`,CE="?"+da,zq=`<${CE}>`,Jl=document,jc=(e="")=>Jl.createComment(e),Gc=e=>e===null||typeof e!="object"&&typeof e!="function",TE=Array.isArray,Fq=e=>TE(e)||typeof e?.[Symbol.iterator]=="function",Uc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,wE=/-->/g,_E=/>/g,no=RegExp(`>|[
|
|
6304
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let n=s.data;switch(n.type){case"decode":r._callbacks[n.id].resolve(n);break;case"error":r._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function vq(){let e,t;onmessage=function(a){let o=a.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(u){e.onModuleLoaded=function(c){u({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(u=>{let c=u.draco,d=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,d,p,h),g=f.attributes.map(m=>m.array.buffer);f.index&&g.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},g)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(d)}});break}};function i(a,o,l,h){let u=h.attributeIDs,c=h.attributeTypes,d,p,f=o.GetEncodedGeometryType(l);if(f===a.TRIANGULAR_MESH)d=new a.Mesh,p=o.DecodeBufferToMesh(l,d);else if(f===a.POINT_CLOUD)d=new a.PointCloud,p=o.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let g={index:null,attributes:[]};for(let m in u){let v=self[c[m]],y,x;if(h.useUniqueIDs)x=u[m],y=o.GetAttributeByUniqueId(d,x);else{if(x=o.GetAttributeId(d,a[u[m]]),x===-1)continue;y=o.GetAttribute(d,x)}g.attributes.push(s(a,o,d,m,v,y))}return f===a.TRIANGULAR_MESH&&(g.index=r(a,o,d)),a.destroy(d),g}function r(a,o,l){let h=l.num_faces()*3,u=h*4,c=a._malloc(u);o.GetTrianglesUInt32Array(l,u,c);let d=new Uint32Array(a.HEAPF32.buffer,c,h).slice();return a._free(c),{array:d,itemSize:1}}function s(a,o,l,h,u,c){let d=c.num_components(),p=l.num_points()*d,f=p*u.BYTES_PER_ELEMENT,g=n(a,u),m=a._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,g,f,m);let v=new u(a.HEAPF32.buffer,m,p).slice();return a._free(m),{name:h,array:v,itemSize:d}}function n(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}var Jn;function yq(){return Jn||(Jn=new gq,Jn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Jn.decoderPending}async function xq(e){if(Jn){let t={attributeIDs:Jn.defaultAttributeIDs,attributeTypes:Jn.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await Jn.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function bq(e,t){let[i,r]=IA(yg.deserialize(new Uint8Array(e)));t2(i);let s=[];i.scene.objects.traverse((n,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&s.push(a)}),s.length&&await yq();for(let n of s){let a=await xq(wi(n.geometry.data.draco));if(a){a.index&&(n.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};a.attributes.forEach(({name:l,array:h,itemSize:u})=>{o[l]={array:h,itemSize:u,type:"Float32Array",normalized:!1}}),n.geometry.data.attributes=o,n.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var wq=class{constructor(e,t,i,r,s,n,a){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=Ar(i,t.actions,s,n,a,r)}disconnect(){dr(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},_q=class extends Hs{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.helperResize=(i,r)=>{this.breakpoints.forEach(s=>{let n=_g.deviceToSize(s.data.size),a=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=a<n[0];break;case">":o=a>n[0];break;case"<>":o=a>n[0]&&a<n[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())})},this.onResize=()=>{let{innerWidth:i,innerHeight:r}=window;this.helperResize(i,r)},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:n}=r.contentRect;this.helperResize(s,n)}})}connect(){let{page:e,sharedAssets:t,domElement:i,isExport:r,frame:s}=this.eventContext;r?window.addEventListener("resize",this.onResize):s.preset==="fullscreen"?this.onResizeObserver.observe(i):window.addEventListener("resize",this.onResize),e.traverseEntity(n=>{if(!(!n.visible||!n.data?.events.length))for(let{data:a}of n.data.events)a.disabled||a.type==="Resize"&&a.breakpoints.forEach(({data:o,id:l})=>{try{let h=new wq(l,o,a,n,e,t,this.eventManager);this.breakpoints.push(h)}catch{}})})}disconnect(){let{isExport:e,frame:t}=this.eventContext;e?window.removeEventListener("resize",this.onResize):t.preset==="fullscreen"?this.onResizeObserver.disconnect():window.removeEventListener("resize",this.onResize),this.breakpoints.forEach(i=>{i.disconnect()}),this.breakpoints=[]}},H_=Object.keys(cE).filter(e=>isNaN(Number(e))),Sq=class{constructor(e,t,i,r){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.isEnabled=!1,this.activateCount=0,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=s=>{(s.touches.length>1||this.preventTouchScroll)&&s.preventDefault()},this.onMouseWheelPreventScroll=s=>{this.preventScroll&&s.preventDefault()},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.handlers={Spline:new pW(this.eventContext),Conditional:new bW(this.eventContext,this),Start:new VW(this.eventContext,this),Basic:new mW(this.eventContext,this),MouseHover:new NW(this.eventContext,this),Scroll:new jW(this.eventContext,this),Follow:new DW(this.eventContext,this),DragDrop:new MW(this.eventContext,this),LookAt:new BW(this.eventContext),Resize:new _q(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),H_.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender)}),H_.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}},Aq=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new k().copy(i),this._editorSize=new k().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=Mq(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function Mq(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var Eq=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new U0(e.shared,t),this.scene=new Q0(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof sa&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Qi&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},Cq=class{constructor({x:e=10,y:t=10}){this._startTime=0;let i=document.getElementById("spe-perfs");i?this.element=i:(this.element=document.createElement("div"),document.body.appendChild(this.element),this.element.style.position="absolute",this.element.style.zIndex="10000",this.element.style.fontFamily="monospace",this.element.style.background="black",this.element.style.color="white",this.element.style.padding="10px",this.element.style.opacity="0.5",this.element.style.fontSize="11px",this.element.setAttribute("id","spe-perfs")),this.element.style.left=`${e}px`,this.element.style.top=`${t}px`}dispose(){this.element.parentElement?.removeChild(this.element)}start(){this._startTime=performance.now()}end(){let e=performance.now()-this._startTime;this.element.innerHTML=e.toFixed(3)+" ms"}};function Tq(e){let t;if(e.index)for(let i=0;i<e.index.array.length;i+=3)t=e.index.array[i],e.index.array[i]=e.index.array[i+2],e.index.array[i+2]=t}function nc(e){return e instanceof Sc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function Pq(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof cr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof cr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!zi.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!zi.isMergable(l.material))return;n=zi.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][nc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][nc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][nc(r)].push(l)}),i}function Dq(e){let t=0;return Object.values(e).forEach(i=>{Object.values(i).forEach(r=>{let s=r.length;s>t&&(t=s)})}),t}function Iq(e,t){let i=Pq(t,e),r=Dq(i),s=new Array(r),n=0,a=new Array(r),o=0,l=new Array(r),h=0,u=new Array(r),c=0;for(let[d,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(m=>{m instanceof cr&&(a[o++]=m.geometry.clone(),l[h++]=m)}),h<2)continue;for(let m=0;m<h;m++)l[m].updateWorldMatrix(!0,!1),a[m].applyMatrix4(l[m].matrixWorld),l[m].matrixWorld.determinant()<0&&Tq(a[m]);let g=za(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new nr(g,l[0].material);break}default:{m=new nr(g,l[0].material);break}}m.castShadow=l[0].castShadow,m.receiveShadow=l[0].receiveShadow,t.add(m);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof cr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][nc(x)]&&i[x.material.uuid][nc(x)].length>1||(u[c++]=x));for(let x=0;x<c;x++)t.attach(u[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[n++]=x}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var Lq=Ll(tC(),1),Oq=new k;function Rq(e){let t="The Spline Runtime only accepts .splinecode files that are generated from Spline export panel.";e.endsWith(".spline")?console.warn(t+" The .spline files are only meant to be used by the Editor."):e.endsWith(".splinecode")||console.warn(t)}var cy=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=Oq.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=u0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new Cq({x:10,y:10})),qk(e)}async load(e,t){Rq(e),this.disposed=!1;let i=await(await fetch(e,t)).arrayBuffer();await this.start(i)}async start(e,{interactive:t=!0}={}){if(this.disposed)return;let i=await bq(e);this._data=i,i.version&&(0,Lq.default)(i.version,"0.9.455")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([zw(i)&&dj(),OG(i)&&lj(),vc.physicsEnabled(i.scene.objects)&&Kk(),Lw(i)&&xG(),eq(i)&&Qk()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let r=new Eq(i);if(r.resetPersonalCameraFromDocumentData(),this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let a=performance.now();Iq(i,r.scene);let o=performance.now();console.log("Merged geometries in ",o-a," ms")}zw(i)&&this._scene.traverse(a=>{Ds(a)&&a.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(a=>{a instanceof is&&a.pendingMediaLoad&&a.update()})});let s=Object.keys(i.shared.fonts).map(a=>this._sharedAssetsManager.getFont(a).loadingPromise);Promise.all(s).then(()=>{r.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),Lw(i)&&uq(i)&&await Promise.all(s),this._scene.rewriteEventsBeforeGoToPlayMode(),oy(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new l9({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=i.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),i.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(i.scene.blueNoiseTextureData);let n=Object.values(i.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new Aq(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let a=new dW(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new pq(a),this._animationControls=new mq(this._scene,this._requestRenderAutoMode),this._eventManager=new Sq(i.scene.publish,this._controls,this._animationControls,a),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==ql&&!this._scene.isInvisibleObjects(t)&&!(t instanceof sa)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof fE&&this._controls?.orbitControls.zoomOut(e)}get eventManager(){return this._eventManager}get controls(){return this._controls}setSize(e,t){this._viewportWidth=e,this._viewportHeight=t,this._viewportMode=2,this._resize()}setBackgroundColor(e){let{r:t,g:i,b:r,a:s}={r:0,g:0,b:0,a:1},n=new hr(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(n),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{fx.unsubscribe(e)}),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),Xk(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof sa&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof sa||e instanceof Q0?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=fx(i,(s,n)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=n),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var zp=window,Fp=zp.ShadowRoot&&(zp.ShadyCSS===void 0||zp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dy=Symbol(),mE=new WeakMap,kc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==dy)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(Fp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=mE.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&mE.set(i,t))}return t}toString(){return this.cssText}},gE=e=>new kc(typeof e=="string"?e:e+"",void 0,dy),uy=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[n+1],e[0]);return new kc(i,e,dy)},py=(e,t)=>{Fp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=zp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Np=Fp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return gE(i)})(e):e;var fy,kp=window,vE=kp.trustedTypes,Bq=vE?vE.emptyScript:"",yE=kp.reactiveElementPolyfillSupport,gy={toAttribute(e,t){switch(t){case Boolean:e=e?Bq:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},xE=(e,t)=>t!==e&&(t==t||e==e),my={attribute:!0,type:String,converter:gy,reflect:!1,hasChanged:xE},En=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var i;this.finalize(),((i=this.h)!==null&&i!==void 0?i:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((i,r)=>{let s=this._$Ep(r,i);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,i=my){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,i);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,i,r){return{get(){return this[i]},set(s){let n=this[t];this[i]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||my}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let i=this.properties,r=[...Object.getOwnPropertyNames(i),...Object.getOwnPropertySymbols(i)];for(let s of r)this.createProperty(s,i[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)i.unshift(Np(s))}else t!==void 0&&i.push(Np(t));return i}static _$Ep(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(i=>this.enableUpdating=i),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(i=>i(this))}addController(t){var i,r;((i=this._$ES)!==null&&i!==void 0?i:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var i;(i=this._$ES)===null||i===void 0||i.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i])})}createRenderRoot(){var t;let i=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return py(i,this.constructor.elementStyles),i}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostConnected)===null||r===void 0?void 0:r.call(i)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var r;return(r=i.hostDisconnected)===null||r===void 0?void 0:r.call(i)})}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$EO(t,i,r=my){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:gy).toAttribute(i,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:gy;this._$El=n,this[n]=o.fromAttribute(i,a.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||xE)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let i=!1,r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw i=!1,this._$Ek(),s}i&&this._$AE(r)}willUpdate(t){}_$AE(t){var i;(i=this._$ES)===null||i===void 0||i.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((i,r)=>this._$EO(r,this[r],i)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};En.finalized=!0,En.elementProperties=new Map,En.elementStyles=[],En.shadowRootOptions={mode:"open"},yE?.({ReactiveElement:En}),((fy=kp.reactiveElementVersions)!==null&&fy!==void 0?fy:kp.reactiveElementVersions=[]).push("1.6.0");var vy,Up=window,Kl=Up.trustedTypes,bE=Kl?Kl.createPolicy("lit-html",{createHTML:e=>e}):void 0,da=`lit$${(Math.random()+"").slice(9)}$`,CE="?"+da,zq=`<${CE}>`,Jl=document,jc=(e="")=>Jl.createComment(e),Gc=e=>e===null||typeof e!="object"&&typeof e!="function",TE=Array.isArray,Fq=e=>TE(e)||typeof e?.[Symbol.iterator]=="function",Uc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,wE=/-->/g,_E=/>/g,no=RegExp(`>|[
|
|
6305
6305
|
\f\r](?:([^\\s"'>=/]+)([
|
|
6306
6306
|
\f\r]*=[
|
|
6307
6307
|
\f\r]*(?:[^
|