@splinetool/viewer 0.9.258 → 0.9.260

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.
@@ -3137,7 +3137,7 @@ void main() {
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
3138
  }`;function UP(e,t,i){let r=new ag,s=new G,n=new G,a=new $e,o=new vw({depthPacking:sw}),l=new BP,h={},u=i.maxTextureSize,c={[Vr]:hi,[hi]:Vr,[$i]:$i},d=new ri({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new G},radius:{value:4}},vertexShader:NP,fragmentShader:zP}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ve;f.setAttribute("position",new Xe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let g=new er(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ig,this.render=function(x,w,A){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||x.length===0)return;let S=e.getRenderTarget(),_=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(fi),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,P=x.length;T<P;T++){let O=x[T],D=O.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;s.copy(D.mapSize);let k=D.getFrameExtents();if(s.multiply(k),n.copy(D.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(n.x=Math.floor(u/k.x),s.x=n.x*k.x,D.mapSize.x=n.x),s.y>u&&(n.y=Math.floor(u/k.y),s.y=n.y*k.y,D.mapSize.y=n.y)),D.map===null){let X=this.type!==jl?{minFilter:Lt,magFilter:Lt}:{};D.map=new ii(s.x,s.y,X),D.map.texture.name=O.name+".shadowMap",D.camera.updateProjectionMatrix()}e.setRenderTarget(D.map),e.clear();let W=D.getViewportCount();for(let X=0;X<W;X++){let N=D.getViewport(X);a.set(n.x*N.x,n.y*N.y,n.x*N.z,n.y*N.w),C.viewport(a),D.updateMatrices(O,X),r=D.getFrustum(),b(w,A,D.camera,O,this.type)}D.isPointLightShadow!==!0&&this.type===jl&&v(D,A),D.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(S,_,M)};function v(x,w){let A=t.update(g);d.defines.VSM_SAMPLES!==x.blurSamples&&(d.defines.VSM_SAMPLES=x.blurSamples,p.defines.VSM_SAMPLES=x.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),x.mapPass===null&&(x.mapPass=new ii(s.x,s.y)),d.uniforms.shadow_pass.value=x.map.texture,d.uniforms.resolution.value=x.mapSize,d.uniforms.radius.value=x.radius,e.setRenderTarget(x.mapPass),e.clear(),e.renderBufferDirect(w,null,A,d,g,null),p.uniforms.shadow_pass.value=x.mapPass.texture,p.uniforms.resolution.value=x.mapSize,p.uniforms.radius.value=x.radius,e.setRenderTarget(x.map),e.clear(),e.renderBufferDirect(w,null,A,p,g,null)}function y(x,w,A,S,_,M){let C=null,T=A.isPointLight===!0?x.customDistanceMaterial:x.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let P=C.uuid,O=w.uuid,D=h[P];D===void 0&&(D={},h[P]=D);let k=D[O];k===void 0&&(k=C.clone(),D[O]=k),C=k}return C.visible=w.visible,C.wireframe=w.wireframe,M===jl?C.side=w.shadowSide!==null?w.shadowSide:w.side:C.side=w.shadowSide!==null?w.shadowSide:c[w.side],C.alphaMap=w.alphaMap,C.alphaTest=w.alphaTest,C.map=w.map,C.clipShadows=w.clipShadows,C.clippingPlanes=w.clippingPlanes,C.clipIntersection=w.clipIntersection,C.displacementMap=w.displacementMap,C.displacementScale=w.displacementScale,C.displacementBias=w.displacementBias,C.wireframeLinewidth=w.wireframeLinewidth,C.linewidth=w.linewidth,A.isPointLight===!0&&C.isMeshDistanceMaterial===!0&&(C.referencePosition.setFromMatrixPosition(A.matrixWorld),C.nearDistance=S,C.farDistance=_),C}function b(x,w,A,S,_){if(x.visible===!1)return;if(x.layers.test(w.layers)&&(x.isMesh||x.isLine||x.isPoints)&&(x.castShadow||x.receiveShadow&&_===jl)&&(!x.frustumCulled||r.intersectsObject(x))){x.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,x.matrixWorld);let C=t.update(x),T=x.material;if(Array.isArray(T)){let P=C.groups;for(let O=0,D=P.length;O<D;O++){let k=P[O],W=T[k.materialIndex];if(W&&W.visible){let X=y(x,W,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,X,x,k)}}}else if(T.visible){let P=y(x,T,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,P,x,null)}}let M=x.children;for(let C=0,T=M.length;C<T;C++)b(M[C],w,A,S,_)}}function FP(e,t,i){let r=i.isWebGL2;function s(){let q=!1,ne=new $e,de=null,Ae=new $e(0,0,0,0);return{setMask:function(De){de!==De&&!q&&(e.colorMask(De,De,De,De),de=De)},setLocked:function(De){q=De},setClear:function(De,ot,Xt,Ft,kn){kn===!0&&(De*=Ft,ot*=Ft,Xt*=Ft),ne.set(De,ot,Xt,Ft),Ae.equals(ne)===!1&&(e.clearColor(De,ot,Xt,Ft),Ae.copy(ne))},reset:function(){q=!1,de=null,Ae.set(-1,0,0,0)}}}function n(){let q=!1,ne=null,de=null,Ae=null;return{setTest:function(De){De?se(2929):V(2929)},setMask:function(De){ne!==De&&!q&&(e.depthMask(De),ne=De)},setFunc:function(De){if(de!==De){switch(De){case sM:e.depthFunc(512);break;case nM:e.depthFunc(519);break;case aM:e.depthFunc(513);break;case Df:e.depthFunc(515);break;case oM:e.depthFunc(514);break;case lM:e.depthFunc(518);break;case hM:e.depthFunc(516);break;case cM:e.depthFunc(517);break;default:e.depthFunc(515)}de=De}},setLocked:function(De){q=De},setClear:function(De){Ae!==De&&(e.clearDepth(De),Ae=De)},reset:function(){q=!1,ne=null,de=null,Ae=null}}}function a(){let q=!1,ne=null,de=null,Ae=null,De=null,ot=null,Xt=null,Ft=null,kn=null;return{setTest:function(Dt){q||(Dt?se(2960):V(2960))},setMask:function(Dt){ne!==Dt&&!q&&(e.stencilMask(Dt),ne=Dt)},setFunc:function(Dt,Ss,lr){(de!==Dt||Ae!==Ss||De!==lr)&&(e.stencilFunc(Dt,Ss,lr),de=Dt,Ae=Ss,De=lr)},setOp:function(Dt,Ss,lr){(ot!==Dt||Xt!==Ss||Ft!==lr)&&(e.stencilOp(Dt,Ss,lr),ot=Dt,Xt=Ss,Ft=lr)},setLocked:function(Dt){q=Dt},setClear:function(Dt){kn!==Dt&&(e.clearStencil(Dt),kn=Dt)},reset:function(){q=!1,ne=null,de=null,Ae=null,De=null,ot=null,Xt=null,Ft=null,kn=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,b=null,x=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,P=null,O=null,D=null,k=e.getParameter(35661),W=!1,X=0,N=e.getParameter(7938);N.indexOf("WebGL")!==-1?(X=parseFloat(/^WebGL (\d)/.exec(N)[1]),W=X>=1):N.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),W=X>=2);let j=null,F={},z=e.getParameter(3088),B=e.getParameter(2978),H=new $e().fromArray(z),Q=new $e().fromArray(B);function Y(q,ne,de){let Ae=new Uint8Array(4),De=e.createTexture();e.bindTexture(q,De),e.texParameteri(q,10241,9728),e.texParameteri(q,10240,9728);for(let ot=0;ot<de;ot++)e.texImage2D(ne+ot,0,6408,1,1,0,6408,5121,Ae);return De}let U={};U[3553]=Y(3553,3553,1),U[34067]=Y(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),se(2929),l.setFunc(Df),Te(!1),xe(Yv),se(2884),ue(fi);function se(q){d[q]!==!0&&(e.enable(q),d[q]=!0)}function V(q){d[q]!==!1&&(e.disable(q),d[q]=!1)}function ee(q,ne){return p[q]!==ne?(e.bindFramebuffer(q,ne),p[q]=ne,r&&(q===36009&&(p[36160]=ne),q===36160&&(p[36009]=ne)),!0):!1}function J(q,ne){let de=g,Ae=!1;if(q)if(de=f.get(ne),de===void 0&&(de=[],f.set(ne,de)),q.isWebGLMultipleRenderTargets){let De=q.texture;if(de.length!==De.length||de[0]!==36064){for(let ot=0,Xt=De.length;ot<Xt;ot++)de[ot]=36064+ot;de.length=De.length,Ae=!0}}else de[0]!==36064&&(de[0]=36064,Ae=!0);else de[0]!==1029&&(de[0]=1029,Ae=!0);Ae&&(i.isWebGL2?e.drawBuffers(de):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(de))}function fe(q){return m!==q?(e.useProgram(q),m=q,!0):!1}let re={[so]:32774,[q2]:32778,[Y2]:32779};if(r)re[Jv]=32775,re[$v]=32776;else{let q=t.get("EXT_blend_minmax");q!==null&&(re[Jv]=q.MIN_EXT,re[$v]=q.MAX_EXT)}let oe={[Q2]:0,[Z2]:1,[K2]:768,[$b]:770,[rM]:776,[tM]:774,[$2]:772,[J2]:769,[ew]:771,[iM]:775,[eM]:773};function ue(q,ne,de,Ae,De,ot,Xt,Ft){if(q===fi){v===!0&&(V(3042),v=!1);return}if(v===!1&&(se(3042),v=!0),q!==X2){if(q!==y||Ft!==M){if((b!==so||A!==so)&&(e.blendEquation(32774),b=so,A=so),Ft)switch(q){case _o:e.blendFuncSeparate(1,771,1,771);break;case Qv:e.blendFunc(1,1);break;case Zv:e.blendFuncSeparate(0,769,0,1);break;case Kv:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",q);break}else switch(q){case _o:e.blendFuncSeparate(770,771,1,771);break;case Qv:e.blendFunc(770,1);break;case Zv:e.blendFuncSeparate(0,769,0,1);break;case Kv:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",q);break}x=null,w=null,S=null,_=null,y=q,M=Ft}return}De=De||ne,ot=ot||de,Xt=Xt||Ae,(ne!==b||De!==A)&&(e.blendEquationSeparate(re[ne],re[De]),b=ne,A=De),(de!==x||Ae!==w||ot!==S||Xt!==_)&&(e.blendFuncSeparate(oe[de],oe[Ae],oe[ot],oe[Xt]),x=de,w=Ae,S=ot,_=Xt),y=q,M=!1}function ye(q,ne){q.side===$i?V(2884):se(2884);let de=q.side===hi;ne&&(de=!de),Te(de),q.blending===_o&&q.transparent===!1?ue(fi):ue(q.blending,q.blendEquation,q.blendSrc,q.blendDst,q.blendEquationAlpha,q.blendSrcAlpha,q.blendDstAlpha,q.premultipliedAlpha),l.setFunc(q.depthFunc),l.setTest(q.depthTest),l.setMask(q.depthWrite),o.setMask(q.colorWrite);let Ae=q.stencilWrite;h.setTest(Ae),Ae&&(h.setMask(q.stencilWriteMask),h.setFunc(q.stencilFunc,q.stencilRef,q.stencilFuncMask),h.setOp(q.stencilFail,q.stencilZFail,q.stencilZPass)),Ie(q.polygonOffset,q.polygonOffsetFactor,q.polygonOffsetUnits),q.alphaToCoverage===!0?se(32926):V(32926)}function Te(q){C!==q&&(q?e.frontFace(2304):e.frontFace(2305),C=q)}function xe(q){q!==H2?(se(2884),q!==T&&(q===Yv?e.cullFace(1029):q===W2?e.cullFace(1028):e.cullFace(1032))):V(2884),T=q}function we(q){q!==P&&(W&&e.lineWidth(q),P=q)}function Ie(q,ne,de){q?(se(32823),(O!==ne||D!==de)&&(e.polygonOffset(ne,de),O=ne,D=de)):V(32823)}function He(q){q?se(3089):V(3089)}function dt(q){q===void 0&&(q=33984+k-1),j!==q&&(e.activeTexture(q),j=q)}function I(q,ne,de){de===void 0&&(j===null?de=33984+k-1:de=j);let Ae=F[de];Ae===void 0&&(Ae={type:void 0,texture:void 0},F[de]=Ae),(Ae.type!==q||Ae.texture!==ne)&&(j!==de&&(e.activeTexture(de),j=de),e.bindTexture(q,ne||U[q]),Ae.type=q,Ae.texture=ne)}function L(){let q=F[j];q!==void 0&&q.type!==void 0&&(e.bindTexture(q.type,null),q.type=void 0,q.texture=void 0)}function ie(){try{e.compressedTexImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function pe(){try{e.compressedTexImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function me(){try{e.texSubImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function be(){try{e.texSubImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function We(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Me(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function ce(){try{e.texStorage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Fe(){try{e.texStorage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Ee(){try{e.texImage2D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function _e(){try{e.texImage3D.apply(e,arguments)}catch(q){console.error("THREE.WebGLState:",q)}}function Oe(q){H.equals(q)===!1&&(e.scissor(q.x,q.y,q.z,q.w),H.copy(q))}function ze(q){Q.equals(q)===!1&&(e.viewport(q.x,q.y,q.z,q.w),Q.copy(q))}function at(q,ne){let de=c.get(ne);de===void 0&&(de=new WeakMap,c.set(ne,de));let Ae=de.get(q);Ae===void 0&&(Ae=e.getUniformBlockIndex(ne,q.name),de.set(q,Ae))}function Mt(q,ne){let de=c.get(ne).get(q);u.get(ne)!==de&&(e.uniformBlockBinding(ne,de,q.__bindingPointIndex),u.set(ne,de))}function Wt(){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={},j=null,F={},p={},f=new WeakMap,g=[],m=null,v=!1,y=null,b=null,x=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,P=null,O=null,D=null,H.set(0,0,e.canvas.width,e.canvas.height),Q.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:se,disable:V,bindFramebuffer:ee,drawBuffers:J,useProgram:fe,setBlending:ue,setMaterial:ye,setFlipSided:Te,setCullFace:xe,setLineWidth:we,setPolygonOffset:Ie,setScissorTest:He,activeTexture:dt,bindTexture:I,unbindTexture:L,compressedTexImage2D:ie,compressedTexImage3D:pe,texImage2D:Ee,texImage3D:_e,updateUBOMapping:at,uniformBlockBinding:Mt,texStorage2D:ce,texStorage3D:Fe,texSubImage2D:me,texSubImage3D:be,compressedTexSubImage2D:We,compressedTexSubImage3D:Me,scissor:Oe,viewport:ze,reset:Wt}}function kP(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(I,L){return v?new OffscreenCanvas(I,L):fd("canvas")}function b(I,L,ie,pe){let me=1;if((I.width>pe||I.height>pe)&&(me=pe/Math.max(I.width,I.height)),me<1||L===!0)if(typeof HTMLImageElement<"u"&&I instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&I instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&I instanceof ImageBitmap){let be=L?pd:Math.floor,We=be(me*I.width),Me=be(me*I.height);g===void 0&&(g=y(We,Me));let ce=ie?y(We,Me):g;return ce.width=We,ce.height=Me,ce.getContext("2d").drawImage(I,0,0,We,Me),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+I.width+"x"+I.height+") to ("+We+"x"+Me+")."),ce}else return"data"in I&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+I.width+"x"+I.height+")."),I;return I}function x(I){return Nf(I.width)&&Nf(I.height)}function w(I){return o?!1:I.wrapS!==Ki||I.wrapT!==Ki||I.minFilter!==Lt&&I.minFilter!==mt}function A(I,L){return I.generateMipmaps&&L&&I.minFilter!==Lt&&I.minFilter!==mt}function S(I){e.generateMipmap(I)}function _(I,L,ie,pe,me=!1){if(o===!1)return L;if(I!==null){if(e[I]!==void 0)return e[I];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+I+"'")}let be=L;return L===6403&&(ie===5126&&(be=33326),ie===5131&&(be=33325),ie===5121&&(be=33321)),L===33319&&(ie===5126&&(be=33328),ie===5131&&(be=33327),ie===5121&&(be=33323)),L===6408&&(ie===5126&&(be=34836),ie===5131&&(be=34842),ie===5121&&(be=pe===Ke&&me===!1?35907:32856),ie===32819&&(be=32854),ie===32820&&(be=32855)),(be===33325||be===33326||be===33327||be===33328||be===34842||be===34836)&&t.get("EXT_color_buffer_float"),be}function M(I,L,ie){return A(I,ie)===!0||I.isFramebufferTexture&&I.minFilter!==Lt&&I.minFilter!==mt?Math.log2(Math.max(L.width,L.height))+1:I.mipmaps!==void 0&&I.mipmaps.length>0?I.mipmaps.length:I.isCompressedTexture&&Array.isArray(I.image)?L.mipmaps.length:1}function C(I){return I===Lt||I===e0||I===Wu?9728:9729}function T(I){let L=I.target;L.removeEventListener("dispose",T),O(L),L.isVideoTexture&&f.delete(L)}function P(I){let L=I.target;L.removeEventListener("dispose",P),k(L)}function O(I){let L=r.get(I);if(L.__webglInit===void 0)return;let ie=I.source,pe=m.get(ie);if(pe){let me=pe[L.__cacheKey];me.usedTimes--,me.usedTimes===0&&D(I),Object.keys(pe).length===0&&m.delete(ie)}r.remove(I)}function D(I){let L=r.get(I);e.deleteTexture(L.__webglTexture);let ie=I.source,pe=m.get(ie);delete pe[L.__cacheKey],a.memory.textures--}function k(I){let L=I.texture,ie=r.get(I),pe=r.get(L);if(pe.__webglTexture!==void 0&&(e.deleteTexture(pe.__webglTexture),a.memory.textures--),I.depthTexture&&I.depthTexture.dispose(),I.isWebGLCubeRenderTarget)for(let me=0;me<6;me++)e.deleteFramebuffer(ie.__webglFramebuffer[me]),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer[me]);else{if(e.deleteFramebuffer(ie.__webglFramebuffer),ie.__webglDepthbuffer&&e.deleteRenderbuffer(ie.__webglDepthbuffer),ie.__webglMultisampledFramebuffer&&e.deleteFramebuffer(ie.__webglMultisampledFramebuffer),ie.__webglColorRenderbuffer)for(let me=0;me<ie.__webglColorRenderbuffer.length;me++)ie.__webglColorRenderbuffer[me]&&e.deleteRenderbuffer(ie.__webglColorRenderbuffer[me]);ie.__webglDepthRenderbuffer&&e.deleteRenderbuffer(ie.__webglDepthRenderbuffer)}if(I.isWebGLMultipleRenderTargets)for(let me=0,be=L.length;me<be;me++){let We=r.get(L[me]);We.__webglTexture&&(e.deleteTexture(We.__webglTexture),a.memory.textures--),r.remove(L[me])}r.remove(L),r.remove(I)}let W=0;function X(){W=0}function N(){let I=W;return I>=l&&console.warn("THREE.WebGLTextures: Trying to use "+I+" texture units while this GPU supports only "+l),W+=1,I}function j(I){let L=[];return L.push(I.wrapS),L.push(I.wrapT),L.push(I.wrapR||0),L.push(I.magFilter),L.push(I.minFilter),L.push(I.anisotropy),L.push(I.internalFormat),L.push(I.format),L.push(I.type),L.push(I.generateMipmaps),L.push(I.premultiplyAlpha),L.push(I.flipY),L.push(I.unpackAlignment),L.push(I.encoding),L.join()}function F(I,L){let ie=r.get(I);if(I.isVideoTexture&&He(I),I.isRenderTargetTexture===!1&&I.version>0&&ie.__version!==I.version){let pe=I.image;if(pe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(pe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{V(ie,I,L);return}}i.bindTexture(3553,ie.__webglTexture,33984+L)}function z(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){V(ie,I,L);return}i.bindTexture(35866,ie.__webglTexture,33984+L)}function B(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){V(ie,I,L);return}i.bindTexture(32879,ie.__webglTexture,33984+L)}function H(I,L){let ie=r.get(I);if(I.version>0&&ie.__version!==I.version){ee(ie,I,L);return}i.bindTexture(34067,ie.__webglTexture,33984+L)}let Q={[oh]:10497,[Ki]:33071,[If]:33648},Y={[Lt]:9728,[e0]:9984,[Wu]:9986,[mt]:9729,[yM]:9985,[Ro]:9987};function U(I,L,ie){if(ie?(e.texParameteri(I,10242,Q[L.wrapS]),e.texParameteri(I,10243,Q[L.wrapT]),(I===32879||I===35866)&&e.texParameteri(I,32882,Q[L.wrapR]),e.texParameteri(I,10240,Y[L.magFilter]),e.texParameteri(I,10241,Y[L.minFilter])):(e.texParameteri(I,10242,33071),e.texParameteri(I,10243,33071),(I===32879||I===35866)&&e.texParameteri(I,32882,33071),(L.wrapS!==Ki||L.wrapT!==Ki)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(I,10240,C(L.magFilter)),e.texParameteri(I,10241,C(L.minFilter)),L.minFilter!==Lt&&L.minFilter!==mt&&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 pe=t.get("EXT_texture_filter_anisotropic");if(L.magFilter===Lt||L.minFilter!==Wu&&L.minFilter!==Ro||L.type===vn&&t.has("OES_texture_float_linear")===!1||o===!1&&L.type===lh&&t.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||r.get(L).__currentAnisotropy)&&(e.texParameterf(I,pe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,s.getMaxAnisotropy())),r.get(L).__currentAnisotropy=L.anisotropy)}}function se(I,L){let ie=!1;I.__webglInit===void 0&&(I.__webglInit=!0,L.addEventListener("dispose",T));let pe=L.source,me=m.get(pe);me===void 0&&(me={},m.set(pe,me));let be=j(L);if(be!==I.__cacheKey){me[be]===void 0&&(me[be]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,ie=!0),me[be].usedTimes++;let We=me[I.__cacheKey];We!==void 0&&(me[I.__cacheKey].usedTimes--,We.usedTimes===0&&D(L)),I.__cacheKey=be,I.__webglTexture=me[be].texture}return ie}function V(I,L,ie){let pe=3553;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(pe=35866),L.isData3DTexture&&(pe=32879);let me=se(I,L),be=L.source;i.bindTexture(pe,I.__webglTexture,33984+ie);let We=r.get(be);if(be.version!==We.__version||me===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,L.flipY),e.pixelStorei(37441,L.premultiplyAlpha),e.pixelStorei(3317,L.unpackAlignment),e.pixelStorei(37443,0);let Me=w(L)&&x(L.image)===!1,ce=b(L.image,Me,!1,u);ce=dt(L,ce);let Fe=x(ce)||o,Ee=n.convert(L.format,L.encoding),_e=n.convert(L.type),Oe=_(L.internalFormat,Ee,_e,L.encoding,L.isVideoTexture);U(pe,L,Fe);let ze,at=L.mipmaps,Mt=o&&L.isVideoTexture!==!0,Wt=We.__version===void 0||me===!0,q=M(L,ce,Fe);if(L.isDepthTexture)Oe=6402,o?L.type===vn?Oe=36012:L.type===gn?Oe=33190:L.type===ca?Oe=35056:Oe=33189:L.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===da&&Oe===6402&&L.type!==rw&&L.type!==gn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=gn,_e=n.convert(L.type)),L.format===ba&&Oe===6402&&(Oe=34041,L.type!==ca&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=ca,_e=n.convert(L.type))),Wt&&(Mt?i.texStorage2D(3553,1,Oe,ce.width,ce.height):i.texImage2D(3553,0,Oe,ce.width,ce.height,0,Ee,_e,null));else if(L.isDataTexture)if(at.length>0&&Fe){Mt&&Wt&&i.texStorage2D(3553,q,Oe,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)ze=at[ne],Mt?i.texSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,_e,ze.data):i.texImage2D(3553,ne,Oe,ze.width,ze.height,0,Ee,_e,ze.data);L.generateMipmaps=!1}else Mt?(Wt&&i.texStorage2D(3553,q,Oe,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,ce.width,ce.height,Ee,_e,ce.data)):i.texImage2D(3553,0,Oe,ce.width,ce.height,0,Ee,_e,ce.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){Mt&&Wt&&i.texStorage3D(35866,q,Oe,at[0].width,at[0].height,ce.depth);for(let ne=0,de=at.length;ne<de;ne++)ze=at[ne],L.format!==Ur?Ee!==null?Mt?i.compressedTexSubImage3D(35866,ne,0,0,0,ze.width,ze.height,ce.depth,Ee,ze.data,0,0):i.compressedTexImage3D(35866,ne,Oe,ze.width,ze.height,ce.depth,0,ze.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Mt?i.texSubImage3D(35866,ne,0,0,0,ze.width,ze.height,ce.depth,Ee,_e,ze.data):i.texImage3D(35866,ne,Oe,ze.width,ze.height,ce.depth,0,Ee,_e,ze.data)}else{Mt&&Wt&&i.texStorage2D(3553,q,Oe,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)ze=at[ne],L.format!==Ur?Ee!==null?Mt?i.compressedTexSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,ze.data):i.compressedTexImage2D(3553,ne,Oe,ze.width,ze.height,0,ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Mt?i.texSubImage2D(3553,ne,0,0,ze.width,ze.height,Ee,_e,ze.data):i.texImage2D(3553,ne,Oe,ze.width,ze.height,0,Ee,_e,ze.data)}else if(L.isDataArrayTexture)Mt?(Wt&&i.texStorage3D(35866,q,Oe,ce.width,ce.height,ce.depth),i.texSubImage3D(35866,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(35866,0,Oe,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(L.isData3DTexture)Mt?(Wt&&i.texStorage3D(32879,q,Oe,ce.width,ce.height,ce.depth),i.texSubImage3D(32879,0,0,0,0,ce.width,ce.height,ce.depth,Ee,_e,ce.data)):i.texImage3D(32879,0,Oe,ce.width,ce.height,ce.depth,0,Ee,_e,ce.data);else if(L.isFramebufferTexture){if(Wt)if(Mt)i.texStorage2D(3553,q,Oe,ce.width,ce.height);else{let ne=ce.width,de=ce.height;for(let Ae=0;Ae<q;Ae++)i.texImage2D(3553,Ae,Oe,ne,de,0,Ee,_e,null),ne>>=1,de>>=1}}else if(at.length>0&&Fe){Mt&&Wt&&i.texStorage2D(3553,q,Oe,at[0].width,at[0].height);for(let ne=0,de=at.length;ne<de;ne++)ze=at[ne],Mt?i.texSubImage2D(3553,ne,0,0,Ee,_e,ze):i.texImage2D(3553,ne,Oe,Ee,_e,ze);L.generateMipmaps=!1}else Mt?(Wt&&i.texStorage2D(3553,q,Oe,ce.width,ce.height),i.texSubImage2D(3553,0,0,0,Ee,_e,ce)):i.texImage2D(3553,0,Oe,Ee,_e,ce);A(L,Fe)&&S(pe),We.__version=be.version,L.onUpdate&&L.onUpdate(L)}I.__version=L.version}function ee(I,L,ie){if(L.image.length!==6)return;let pe=se(I,L),me=L.source;i.bindTexture(34067,I.__webglTexture,33984+ie);let be=r.get(me);if(me.version!==be.__version||pe===!0){i.activeTexture(33984+ie),e.pixelStorei(37440,L.flipY),e.pixelStorei(37441,L.premultiplyAlpha),e.pixelStorei(3317,L.unpackAlignment),e.pixelStorei(37443,0);let We=L.isCompressedTexture||L.image[0].isCompressedTexture,Me=L.image[0]&&L.image[0].isDataTexture,ce=[];for(let ne=0;ne<6;ne++)!We&&!Me?ce[ne]=b(L.image[ne],!1,!0,h):ce[ne]=Me?L.image[ne].image:L.image[ne],ce[ne]=dt(L,ce[ne]);let Fe=ce[0],Ee=x(Fe)||o,_e=n.convert(L.format,L.encoding),Oe=n.convert(L.type),ze=_(L.internalFormat,_e,Oe,L.encoding),at=o&&L.isVideoTexture!==!0,Mt=be.__version===void 0||pe===!0,Wt=M(L,Fe,Ee);U(34067,L,Ee);let q;if(We){at&&Mt&&i.texStorage2D(34067,Wt,ze,Fe.width,Fe.height);for(let ne=0;ne<6;ne++){q=ce[ne].mipmaps;for(let de=0;de<q.length;de++){let Ae=q[de];L.format!==Ur?_e!==null?at?i.compressedTexSubImage2D(34069+ne,de,0,0,Ae.width,Ae.height,_e,Ae.data):i.compressedTexImage2D(34069+ne,de,ze,Ae.width,Ae.height,0,Ae.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):at?i.texSubImage2D(34069+ne,de,0,0,Ae.width,Ae.height,_e,Oe,Ae.data):i.texImage2D(34069+ne,de,ze,Ae.width,Ae.height,0,_e,Oe,Ae.data)}}}else{q=L.mipmaps,at&&Mt&&(q.length>0&&Wt++,i.texStorage2D(34067,Wt,ze,ce[0].width,ce[0].height));for(let ne=0;ne<6;ne++)if(Me){at?i.texSubImage2D(34069+ne,0,0,0,ce[ne].width,ce[ne].height,_e,Oe,ce[ne].data):i.texImage2D(34069+ne,0,ze,ce[ne].width,ce[ne].height,0,_e,Oe,ce[ne].data);for(let de=0;de<q.length;de++){let Ae=q[de].image[ne].image;at?i.texSubImage2D(34069+ne,de+1,0,0,Ae.width,Ae.height,_e,Oe,Ae.data):i.texImage2D(34069+ne,de+1,ze,Ae.width,Ae.height,0,_e,Oe,Ae.data)}}else{at?i.texSubImage2D(34069+ne,0,0,0,_e,Oe,ce[ne]):i.texImage2D(34069+ne,0,ze,_e,Oe,ce[ne]);for(let de=0;de<q.length;de++){let Ae=q[de];at?i.texSubImage2D(34069+ne,de+1,0,0,_e,Oe,Ae.image[ne]):i.texImage2D(34069+ne,de+1,ze,_e,Oe,Ae.image[ne])}}}A(L,Ee)&&S(34067),be.__version=me.version,L.onUpdate&&L.onUpdate(L)}I.__version=L.version}function J(I,L,ie,pe,me){let be=n.convert(ie.format,ie.encoding),We=n.convert(ie.type),Me=_(ie.internalFormat,be,We,ie.encoding);r.get(L).__hasExternalTextures||(me===32879||me===35866?i.texImage3D(me,0,Me,L.width,L.height,L.depth,0,be,We,null):i.texImage2D(me,0,Me,L.width,L.height,0,be,We,null)),i.bindFramebuffer(36160,I),Ie(L)?d.framebufferTexture2DMultisampleEXT(36160,pe,me,r.get(ie).__webglTexture,0,we(L)):(me===3553||me>=34069&&me<=34074)&&e.framebufferTexture2D(36160,pe,me,r.get(ie).__webglTexture,0),i.bindFramebuffer(36160,null)}function fe(I,L,ie){if(e.bindRenderbuffer(36161,I),L.depthBuffer&&!L.stencilBuffer){let pe=33189;if(ie||Ie(L)){let me=L.depthTexture;me&&me.isDepthTexture&&(me.type===vn?pe=36012:me.type===gn&&(pe=33190));let be=we(L);Ie(L)?d.renderbufferStorageMultisampleEXT(36161,be,pe,L.width,L.height):e.renderbufferStorageMultisample(36161,be,pe,L.width,L.height)}else e.renderbufferStorage(36161,pe,L.width,L.height);e.framebufferRenderbuffer(36160,36096,36161,I)}else if(L.depthBuffer&&L.stencilBuffer){let pe=we(L);ie&&Ie(L)===!1?e.renderbufferStorageMultisample(36161,pe,35056,L.width,L.height):Ie(L)?d.renderbufferStorageMultisampleEXT(36161,pe,35056,L.width,L.height):e.renderbufferStorage(36161,34041,L.width,L.height),e.framebufferRenderbuffer(36160,33306,36161,I)}else{let pe=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let me=0;me<pe.length;me++){let be=pe[me],We=n.convert(be.format,be.encoding),Me=n.convert(be.type),ce=_(be.internalFormat,We,Me,be.encoding),Fe=we(L);ie&&Ie(L)===!1?e.renderbufferStorageMultisample(36161,Fe,ce,L.width,L.height):Ie(L)?d.renderbufferStorageMultisampleEXT(36161,Fe,ce,L.width,L.height):e.renderbufferStorage(36161,ce,L.width,L.height)}}e.bindRenderbuffer(36161,null)}function re(I,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,I),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),F(L.depthTexture,0);let ie=r.get(L.depthTexture).__webglTexture,pe=we(L);if(L.depthTexture.format===da)Ie(L)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,ie,0,pe):e.framebufferTexture2D(36160,36096,3553,ie,0);else if(L.depthTexture.format===ba)Ie(L)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,ie,0,pe):e.framebufferTexture2D(36160,33306,3553,ie,0);else throw new Error("Unknown depthTexture format")}function oe(I){let L=r.get(I),ie=I.isWebGLCubeRenderTarget===!0;if(I.depthTexture&&!L.__autoAllocateDepthBuffer){if(ie)throw new Error("target.depthTexture not supported in Cube render targets");re(L.__webglFramebuffer,I)}else if(ie){L.__webglDepthbuffer=[];for(let pe=0;pe<6;pe++)i.bindFramebuffer(36160,L.__webglFramebuffer[pe]),L.__webglDepthbuffer[pe]=e.createRenderbuffer(),fe(L.__webglDepthbuffer[pe],I,!1)}else i.bindFramebuffer(36160,L.__webglFramebuffer),L.__webglDepthbuffer=e.createRenderbuffer(),fe(L.__webglDepthbuffer,I,!1);i.bindFramebuffer(36160,null)}function ue(I,L,ie){let pe=r.get(I);L!==void 0&&J(pe.__webglFramebuffer,I,I.texture,36064,3553),ie!==void 0&&oe(I)}function ye(I){let L=I.texture,ie=r.get(I),pe=r.get(L);I.addEventListener("dispose",P),I.isWebGLMultipleRenderTargets!==!0&&(pe.__webglTexture===void 0&&(pe.__webglTexture=e.createTexture()),pe.__version=L.version,a.memory.textures++);let me=I.isWebGLCubeRenderTarget===!0,be=I.isWebGLMultipleRenderTargets===!0,We=x(I)||o;if(me){ie.__webglFramebuffer=[];for(let Me=0;Me<6;Me++)ie.__webglFramebuffer[Me]=e.createFramebuffer()}else{if(ie.__webglFramebuffer=e.createFramebuffer(),be)if(s.drawBuffers){let Me=I.texture;for(let ce=0,Fe=Me.length;ce<Fe;ce++){let Ee=r.get(Me[ce]);Ee.__webglTexture===void 0&&(Ee.__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&&I.samples>0&&Ie(I)===!1){let Me=be?L:[L];ie.__webglMultisampledFramebuffer=e.createFramebuffer(),ie.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,ie.__webglMultisampledFramebuffer);for(let ce=0;ce<Me.length;ce++){let Fe=Me[ce];ie.__webglColorRenderbuffer[ce]=e.createRenderbuffer(),e.bindRenderbuffer(36161,ie.__webglColorRenderbuffer[ce]);let Ee=n.convert(Fe.format,Fe.encoding),_e=n.convert(Fe.type),Oe=_(Fe.internalFormat,Ee,_e,Fe.encoding,I.isXRRenderTarget===!0),ze=we(I);e.renderbufferStorageMultisample(36161,ze,Oe,I.width,I.height),e.framebufferRenderbuffer(36160,36064+ce,36161,ie.__webglColorRenderbuffer[ce])}e.bindRenderbuffer(36161,null),I.depthBuffer&&(ie.__webglDepthRenderbuffer=e.createRenderbuffer(),fe(ie.__webglDepthRenderbuffer,I,!0)),i.bindFramebuffer(36160,null)}}if(me){i.bindTexture(34067,pe.__webglTexture),U(34067,L,We);for(let Me=0;Me<6;Me++)J(ie.__webglFramebuffer[Me],I,L,36064,34069+Me);A(L,We)&&S(34067),i.unbindTexture()}else if(be){let Me=I.texture;for(let ce=0,Fe=Me.length;ce<Fe;ce++){let Ee=Me[ce],_e=r.get(Ee);i.bindTexture(3553,_e.__webglTexture),U(3553,Ee,We),J(ie.__webglFramebuffer,I,Ee,36064+ce,3553),A(Ee,We)&&S(3553)}i.unbindTexture()}else{let Me=3553;(I.isWebGL3DRenderTarget||I.isWebGLArrayRenderTarget)&&(o?Me=I.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Me,pe.__webglTexture),U(Me,L,We),J(ie.__webglFramebuffer,I,L,36064,Me),A(L,We)&&S(Me),i.unbindTexture()}I.depthBuffer&&oe(I)}function Te(I){let L=x(I)||o,ie=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let pe=0,me=ie.length;pe<me;pe++){let be=ie[pe];if(A(be,L)){let We=I.isWebGLCubeRenderTarget?34067:3553,Me=r.get(be).__webglTexture;i.bindTexture(We,Me),S(We),i.unbindTexture()}}}function xe(I){if(o&&I.samples>0&&Ie(I)===!1){let L=I.isWebGLMultipleRenderTargets?I.texture:[I.texture],ie=I.width,pe=I.height,me=16384,be=[],We=I.stencilBuffer?33306:36096,Me=r.get(I),ce=I.isWebGLMultipleRenderTargets===!0;if(ce)for(let Fe=0;Fe<L.length;Fe++)i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,null),i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,null,0);i.bindFramebuffer(36008,Me.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Me.__webglFramebuffer);for(let Fe=0;Fe<L.length;Fe++){be.push(36064+Fe),I.depthBuffer&&be.push(We);let Ee=Me.__ignoreDepthValues!==void 0?Me.__ignoreDepthValues:!1;if(Ee===!1&&(I.depthBuffer&&(me|=256),I.stencilBuffer&&(me|=1024)),ce&&e.framebufferRenderbuffer(36008,36064,36161,Me.__webglColorRenderbuffer[Fe]),Ee===!0&&(e.invalidateFramebuffer(36008,[We]),e.invalidateFramebuffer(36009,[We])),ce){let _e=r.get(L[Fe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,_e,0)}e.blitFramebuffer(0,0,ie,pe,0,0,ie,pe,me,9728),p&&e.invalidateFramebuffer(36008,be)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ce)for(let Fe=0;Fe<L.length;Fe++){i.bindFramebuffer(36160,Me.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Fe,36161,Me.__webglColorRenderbuffer[Fe]);let Ee=r.get(L[Fe]).__webglTexture;i.bindFramebuffer(36160,Me.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Fe,3553,Ee,0)}i.bindFramebuffer(36009,Me.__webglMultisampledFramebuffer)}}function we(I){return Math.min(c,I.samples)}function Ie(I){let L=r.get(I);return o&&I.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function He(I){let L=a.render.frame;f.get(I)!==L&&(f.set(I,L),I.update())}function dt(I,L){let ie=I.encoding,pe=I.format,me=I.type;return I.isCompressedTexture===!0||I.isVideoTexture===!0||I.format===Bf||ie!==ms&&(ie===Ke?o===!1?t.has("EXT_sRGB")===!0&&pe===Ur?(I.format=Bf,I.minFilter=mt,I.generateMipmaps=!1):L=ow.sRGBToLinear(L):(pe!==Ur||me!==Mi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ie)),L}this.allocateTextureUnit=N,this.resetTextureUnits=X,this.setTexture2D=F,this.setTexture2DArray=z,this.setTexture3D=B,this.setTextureCube=H,this.rebindTextures=ue,this.setupRenderTarget=ye,this.updateRenderTargetMipmap=Te,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=J,this.useMultisampledRTT=Ie}function jP(e,t,i){let r=i.isWebGL2;function s(n,a=null){let o;if(n===Mi)return 5121;if(n===_M)return 32819;if(n===AM)return 32820;if(n===xM)return 5120;if(n===bM)return 5122;if(n===rw)return 5123;if(n===wM)return 5124;if(n===gn)return 5125;if(n===vn)return 5126;if(n===lh)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(n===SM)return 6406;if(n===Ur)return 6408;if(n===MM)return 6409;if(n===EM)return 6410;if(n===da)return 6402;if(n===ba)return 34041;if(n===Bf)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(n===CM)return 6403;if(n===TM)return 36244;if(n===PM)return 33319;if(n===DM)return 33320;if(n===OM)return 36249;if(n===Xu||n===qu||n===Yu||n===Qu)if(a===Ke)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Xu)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===qu)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Yu)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Qu)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Xu)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===qu)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Yu)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Qu)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===t0||n===i0||n===r0||n===s0)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===t0)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===i0)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===r0)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===s0)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===LM)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===n0||n===a0)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(n===n0)return a===Ke?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===a0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===o0||n===l0||n===h0||n===c0||n===d0||n===u0||n===p0||n===f0||n===m0||n===g0||n===v0||n===y0||n===x0||n===b0)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(n===o0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===l0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===h0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===c0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===d0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===u0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===p0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===f0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===m0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===g0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===v0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===y0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===x0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===b0)return a===Ke?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Zu)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(n===Zu)return a===Ke?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(n===IM||n===w0||n===_0||n===A0)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(n===Zu)return o.COMPRESSED_RED_RGTC1_EXT;if(n===w0)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_0)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===A0)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ca?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 GP=class extends wi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},uo=class extends bt{constructor(){super(),this.isGroup=!0,this.type="Group"}},VP={type:"move"},_p=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new uo,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 uo,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 uo,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(VP)))}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 uo;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},lg=class extends ci{constructor(e,t,i,r,s,n,a,o,l,h){if(h=h!==void 0?h:da,h!==da&&h!==ba)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===da&&(i=gn),i===void 0&&h===ba&&(i=ca),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}},HP=class extends Vi{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=[],b=new Set,x=new Map,w=new wi;w.layers.enable(1),w.viewport=new $e;let A=new wi;A.layers.enable(2),A.viewport=new $e;let S=[w,A],_=new GP;_.layers.enable(1),_.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let B=v[z];return B===void 0&&(B=new _p,v[z]=B),B.getTargetRaySpace()},this.getControllerGrip=function(z){let B=v[z];return B===void 0&&(B=new _p,v[z]=B),B.getGripSpace()},this.getHand=function(z){let B=v[z];return B===void 0&&(B=new _p,v[z]=B),B.getHandSpace()};function T(z){let B=y.indexOf(z.inputSource);if(B===-1)return;let H=v[B];H!==void 0&&H.dispatchEvent({type:z.type,data:z.inputSource})}function P(){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",P),r.removeEventListener("inputsourceschange",O);for(let z=0;z<v.length;z++){let B=y[z];B!==null&&(y[z]=null,v[z].disconnect(B))}M=null,C=null,e.setRenderTarget(g),d=null,c=null,u=null,r=null,m=null,F.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(z){s=z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(z){a=z,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(z){l=z},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(z){if(r=z,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",P),r.addEventListener("inputsourceschange",O),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let B={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,B),r.updateRenderState({baseLayer:d}),m=new ii(d.framebufferWidth,d.framebufferHeight,{format:Ur,type:Mi,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let B=null,H=null,Q=null;f.depth&&(Q=f.stencil?35056:33190,B=f.stencil?ba:da,H=f.stencil?ca:gn);let Y={colorFormat:32856,depthFormat:Q,scaleFactor:s};u=new XRWebGLBinding(r,t),c=u.createProjectionLayer(Y),r.updateRenderState({layers:[c]}),m=new ii(c.textureWidth,c.textureHeight,{format:Ur,type:Mi,depthTexture:new lg(c.textureWidth,c.textureHeight,H,void 0,void 0,void 0,void 0,void 0,void 0,B),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(m);U.__ignoreDepthValues=c.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(a),F.setContext(r),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function O(z){for(let B=0;B<z.removed.length;B++){let H=z.removed[B],Q=y.indexOf(H);Q>=0&&(y[Q]=null,v[Q].disconnect(H))}for(let B=0;B<z.added.length;B++){let H=z.added[B],Q=y.indexOf(H);if(Q===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(H),Q=U;break}else if(y[U]===null){y[U]=H,Q=U;break}if(Q===-1)break}let Y=v[Q];Y&&Y.connect(H)}}let D=new E,k=new E;function W(z,B,H){D.setFromMatrixPosition(B.matrixWorld),k.setFromMatrixPosition(H.matrixWorld);let Q=D.distanceTo(k),Y=B.projectionMatrix.elements,U=H.projectionMatrix.elements,se=Y[14]/(Y[10]-1),V=Y[14]/(Y[10]+1),ee=(Y[9]+1)/Y[5],J=(Y[9]-1)/Y[5],fe=(Y[8]-1)/Y[0],re=(U[8]+1)/U[0],oe=se*fe,ue=se*re,ye=Q/(-fe+re),Te=ye*-fe;B.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(Te),z.translateZ(ye),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert();let xe=se+ye,we=V+ye,Ie=oe-Te,He=ue+(Q-Te),dt=ee*V/we*xe,I=J*V/we*xe;z.projectionMatrix.makePerspective(Ie,He,dt,I,xe,we)}function X(z,B){B===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(B.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(r===null)return;_.near=A.near=w.near=z.near,_.far=A.far=w.far=z.far,(M!==_.near||C!==_.far)&&(r.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,C=_.far);let B=z.parent,H=_.cameras;X(_,B);for(let Y=0;Y<H.length;Y++)X(H[Y],B);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),z.matrix.copy(_.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale);let Q=z.children;for(let Y=0,U=Q.length;Y<U;Y++)Q[Y].updateMatrixWorld(!0);H.length===2?W(_,w,A):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(!(c===null&&d===null))return o},this.setFoveation=function(z){o=z,c!==null&&(c.fixedFoveation=z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=z)},this.getPlanes=function(){return b};let N=null;function j(z,B){if(h=B.getViewerPose(l||n),p=B,h!==null){let H=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let Q=!1;H.length!==_.cameras.length&&(_.cameras.length=0,Q=!0);for(let Y=0;Y<H.length;Y++){let U=H[Y],se=null;if(d!==null)se=d.getViewport(U);else{let ee=u.getViewSubImage(c,U);se=ee.viewport,Y===0&&(e.setRenderTargetTextures(m,ee.colorTexture,c.ignoreDepthValues?void 0:ee.depthStencilTexture),e.setRenderTarget(m))}let V=S[Y];V===void 0&&(V=new wi,V.layers.enable(Y),V.viewport=new $e,S[Y]=V),V.matrix.fromArray(U.transform.matrix),V.projectionMatrix.fromArray(U.projectionMatrix),V.viewport.set(se.x,se.y,se.width,se.height),Y===0&&_.matrix.copy(V.matrix),Q===!0&&_.cameras.push(V)}}for(let H=0;H<v.length;H++){let Q=y[H],Y=v[H];Q!==null&&Y!==void 0&&Y.update(Q,B,l||n)}if(N&&N(z,B),B.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:B.detectedPlanes});let H=null;for(let Q of b)B.detectedPlanes.has(Q)||(H===null&&(H=[]),H.push(Q));if(H!==null)for(let Q of H)b.delete(Q),x.delete(Q),i.dispatchEvent({type:"planeremoved",data:Q});for(let Q of B.detectedPlanes)if(!b.has(Q))b.add(Q),x.set(Q,B.lastChangedTime),i.dispatchEvent({type:"planeadded",data:Q});else{let Y=x.get(Q);Q.lastChangedTime>Y&&(x.set(Q,Q.lastChangedTime),i.dispatchEvent({type:"planechanged",data:Q}))}}p=null}let F=new uw;F.setAnimationLoop(j),this.setAnimationLoop=function(z){N=z},this.dispose=function(){}}};function WP(e,t){function i(g,m){m.color.getRGB(g.fogColor.value,dw(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,b){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,b)):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===hi&&(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===hi&&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 x=e.physicallyCorrectLights!==!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*x}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 b;m.aoMap?b=m.aoMap:m.lightMap&&(b=m.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uv2Transform.value.copy(b.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 b;m.map?b=m.map:m.alphaMap&&(b=m.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),g.uvTransform.value.copy(b.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===hi&&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 XP(e,t,i,r){let s={},n={},a=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,b){let x=b.program;r.uniformBlockBinding(y,x)}function h(y,b){let x=s[y.id];x===void 0&&(f(y),x=u(y),s[y.id]=x,y.addEventListener("dispose",m));let w=b.program;r.updateUBOMapping(y,w);let A=t.render.frame;n[y.id]!==A&&(d(y),n[y.id]=A)}function u(y){let b=c();y.__bindingPointIndex=b;let x=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,x),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,b,x),x}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 b=s[y.id],x=y.uniforms,w=y.__cache;e.bindBuffer(35345,b);for(let A=0,S=x.length;A<S;A++){let _=x[A];if(p(_,A,w)===!0){let M=_.__offset,C=Array.isArray(_.value)?_.value:[_.value],T=0;for(let P=0;P<C.length;P++){let O=C[P],D=g(O);typeof O=="number"?(_.__data[0]=O,e.bufferSubData(35345,M+T,_.__data)):O.isMatrix3?(_.__data[0]=O.elements[0],_.__data[1]=O.elements[1],_.__data[2]=O.elements[2],_.__data[3]=O.elements[0],_.__data[4]=O.elements[3],_.__data[5]=O.elements[4],_.__data[6]=O.elements[5],_.__data[7]=O.elements[0],_.__data[8]=O.elements[6],_.__data[9]=O.elements[7],_.__data[10]=O.elements[8],_.__data[11]=O.elements[0]):(O.toArray(_.__data,T),T+=D.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,_.__data)}}e.bindBuffer(35345,null)}function p(y,b,x){let w=y.value;if(x[b]===void 0){if(typeof w=="number")x[b]=w;else{let A=Array.isArray(w)?w:[w],S=[];for(let _=0;_<A.length;_++)S.push(A[_].clone());x[b]=S}return!0}else if(typeof w=="number"){if(x[b]!==w)return x[b]=w,!0}else{let A=Array.isArray(x[b])?x[b]:[x[b]],S=Array.isArray(w)?w:[w];for(let _=0;_<A.length;_++){let M=A[_];if(M.equals(S[_])===!1)return M.copy(S[_]),!0}}return!1}function f(y){let b=y.uniforms,x=0,w=16,A=0;for(let S=0,_=b.length;S<_;S++){let M=b[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let P=0,O=T.length;P<O;P++){let D=T[P],k=g(D);C.boundary+=k.boundary,C.storage+=k.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=x,S>0){A=x%w;let P=w-A;A!==0&&P-C.boundary<0&&(x+=w-A,M.__offset=x)}x+=C.storage}return A=x%w,A>0&&(x+=w-A),y.__size=x,y.__cache={},this}function g(y){let b={boundary:0,storage:0};return typeof y=="number"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=48,b.storage=48):y.isMatrix4?(b.boundary=64,b.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),b}function m(y){let b=y.target;b.removeEventListener("dispose",m);let x=a.indexOf(b.__bindingPointIndex);a.splice(x,1),e.deleteBuffer(s[b.id]),delete s[b.id],delete n[b.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);a=[],s={},n={}}return{bind:l,update:h,dispose:v}}function qP(){let e=fd("canvas");return e.style.display="block",e}function yw(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:qP(),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=ms,this.physicallyCorrectLights=!1,this.toneMapping=js,this.toneMappingExposure=1;let g=this,m=!1,v=0,y=0,b=null,x=-1,w=null,A=new $e,S=new $e,_=null,M=t.width,C=t.height,T=1,P=null,O=null,D=new $e(0,0,M,C),k=new $e(0,0,M,C),W=!1,X=new ag,N=!1,j=!1,F=null,z=new ve,B=new G,H=new E,Q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return b===null?T:1}let U=i;function se(R,$){for(let ae=0;ae<R.length;ae++){let K=R[ae],he=t.getContext(K,$);if(he!==null)return he}return null}try{let R={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${Ho}`),t.addEventListener("webglcontextlost",Oe,!1),t.addEventListener("webglcontextrestored",ze,!1),t.addEventListener("webglcontextcreationerror",at,!1),U===null){let $=["webgl2","webgl","experimental-webgl"];if(g.isWebGL1Renderer===!0&&$.shift(),U=se($,R),U===null)throw se($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}U.getShaderPrecisionFormat===void 0&&(U.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(R){throw console.error("THREE.WebGLRenderer: "+R.message),R}let V,ee,J,fe,re,oe,ue,ye,Te,xe,we,Ie,He,dt,I,L,ie,pe,me,be,We,Me,ce,Fe;function Ee(){V=new a3(U),ee=new e3(U,V,e),V.init(ee),Me=new jP(U,V,ee),J=new FP(U,V,ee),fe=new h3,re=new EP,oe=new kP(U,V,J,re,ee,Me,fe),ue=new i3(g),ye=new n3(g),Te=new yE(U,ee),ce=new JT(U,V,Te,ee),xe=new o3(U,Te,fe,ce),we=new p3(U,xe,Te,fe),me=new u3(U,ee,oe),L=new t3(re),Ie=new MP(g,ue,ye,V,ee,ce,L),He=new WP(g,re),dt=new TP,I=new RP(V,ee),pe=new KT(g,ue,ye,J,we,u,a),ie=new UP(g,we,ee),Fe=new XP(U,fe,ee,J),be=new $T(U,V,fe,ee),We=new l3(U,V,fe,ee),fe.programs=Ie.programs,g.capabilities=ee,g.extensions=V,g.properties=re,g.renderLists=dt,g.shadowMap=ie,g.state=J,g.info=fe}Ee();let _e=new HP(g,U);this.xr=_e,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let R=V.get("WEBGL_lose_context");R&&R.loseContext()},this.forceContextRestore=function(){let R=V.get("WEBGL_lose_context");R&&R.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(R){R!==void 0&&(T=R,this.setSize(M,C,!1))},this.getSize=function(R){return R.set(M,C)},this.setSize=function(R,$,ae){if(_e.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=R,C=$,t.width=Math.floor(R*T),t.height=Math.floor($*T),ae!==!1&&(t.style.width=R+"px",t.style.height=$+"px"),this.setViewport(0,0,R,$)},this.getDrawingBufferSize=function(R){return R.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(R,$,ae){M=R,C=$,T=ae,t.width=Math.floor(R*ae),t.height=Math.floor($*ae),this.setViewport(0,0,R,$)},this.getCurrentViewport=function(R){return R.copy(A)},this.getViewport=function(R){return R.copy(D)},this.setViewport=function(R,$,ae,K){R.isVector4?D.set(R.x,R.y,R.z,R.w):D.set(R,$,ae,K),J.viewport(A.copy(D).multiplyScalar(T).floor())},this.getScissor=function(R){return R.copy(k)},this.setScissor=function(R,$,ae,K){R.isVector4?k.set(R.x,R.y,R.z,R.w):k.set(R,$,ae,K),J.scissor(S.copy(k).multiplyScalar(T).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(R){J.setScissorTest(W=R)},this.setOpaqueSort=function(R){P=R},this.setTransparentSort=function(R){O=R},this.getClearColor=function(R){return R.copy(pe.getClearColor())},this.setClearColor=function(){pe.setClearColor.apply(pe,arguments)},this.getClearAlpha=function(){return pe.getClearAlpha()},this.setClearAlpha=function(){pe.setClearAlpha.apply(pe,arguments)},this.clear=function(R=!0,$=!0,ae=!0){let K=0;R&&(K|=16384),$&&(K|=256),ae&&(K|=1024),U.clear(K)},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",Oe,!1),t.removeEventListener("webglcontextrestored",ze,!1),t.removeEventListener("webglcontextcreationerror",at,!1),dt.dispose(),I.dispose(),re.dispose(),ue.dispose(),ye.dispose(),we.dispose(),ce.dispose(),Fe.dispose(),Ie.dispose(),_e.dispose(),_e.removeEventListener("sessionstart",Ae),_e.removeEventListener("sessionend",De),F&&(F.dispose(),F=null),ot.stop()};function Oe(R){R.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function ze(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;let R=fe.autoReset,$=ie.enabled,ae=ie.autoUpdate,K=ie.needsUpdate,he=ie.type;Ee(),fe.autoReset=R,ie.enabled=$,ie.autoUpdate=ae,ie.needsUpdate=K,ie.type=he}function at(R){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",R.statusMessage)}function Mt(R){let $=R.target;$.removeEventListener("dispose",Mt),Wt($)}function Wt(R){q(R),re.remove(R)}function q(R){let $=re.get(R).programs;$!==void 0&&($.forEach(function(ae){Ie.releaseProgram(ae)}),R.isShaderMaterial&&Ie.releaseShaderCache(R))}this.renderBufferDirect=function(R,$,ae,K,he,Be){$===null&&($=Q);let Je=he.isMesh&&he.matrixWorld.determinant()<0,et=S2(R,$,ae,K,he);J.setMaterial(K,Je);let st=ae.index,wt=1;K.wireframe===!0&&(st=xe.getWireframeAttribute(ae),wt=2);let ut=ae.drawRange,lt=ae.attributes.position,vi=ut.start*wt,Hi=(ut.start+ut.count)*wt;Be!==null&&(vi=Math.max(vi,Be.start*wt),Hi=Math.min(Hi,(Be.start+Be.count)*wt)),st!==null?(vi=Math.max(vi,0),Hi=Math.min(Hi,st.count)):lt!=null&&(vi=Math.max(vi,0),Hi=Math.min(Hi,lt.count));let Ms=Hi-vi;if(Ms<0||Ms===1/0)return;ce.setup(he,K,et,ae,st);let jn,qt=be;if(st!==null&&(jn=Te.get(st),qt=We,qt.setIndex(jn)),he.isMesh)K.wireframe===!0?(J.setLineWidth(K.wireframeLinewidth*Y()),qt.setMode(1)):qt.setMode(4);else if(he.isLine){let ht=K.linewidth;ht===void 0&&(ht=1),J.setLineWidth(ht*Y()),he.isLineSegments?qt.setMode(1):he.isLineLoop?qt.setMode(2):qt.setMode(3)}else he.isPoints?qt.setMode(0):he.isSprite&&qt.setMode(4);if(he.isInstancedMesh)qt.renderInstances(vi,Ms,he.count);else if(ae.isInstancedBufferGeometry){let ht=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,ku=Math.min(ae.instanceCount,ht);qt.renderInstances(vi,Ms,ku)}else qt.render(vi,Ms)},this.compile=function(R,$){function ae(K,he,Be){K.transparent===!0&&K.side===$i&&K.forceSinglePass===!1?(K.side=hi,K.needsUpdate=!0,lr(K,he,Be),K.side=Vr,K.needsUpdate=!0,lr(K,he,Be),K.side=$i):lr(K,he,Be)}d=I.get(R),d.init(),f.push(d),R.traverseVisible(function(K){K.isLight&&K.layers.test($.layers)&&(d.pushLight(K),K.castShadow&&d.pushShadow(K))}),d.setupLights(g.physicallyCorrectLights),R.traverse(function(K){let he=K.material;if(he)if(Array.isArray(he))for(let Be=0;Be<he.length;Be++){let Je=he[Be];ae(Je,R,K)}else ae(he,R,K)}),f.pop(),d=null};let ne=null;function de(R){ne&&ne(R)}function Ae(){ot.stop()}function De(){ot.start()}let ot=new uw;ot.setAnimationLoop(de),typeof self<"u"&&ot.setContext(self),this.setAnimationLoop=function(R){ne=R,_e.setAnimationLoop(R),R===null?ot.stop():ot.start()},_e.addEventListener("sessionstart",Ae),_e.addEventListener("sessionend",De),this.render=function(R,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(m===!0)return;R.matrixWorldAutoUpdate===!0&&R.updateMatrixWorld(),$.parent===null&&$.matrixWorldAutoUpdate===!0&&$.updateMatrixWorld(),_e.enabled===!0&&_e.isPresenting===!0&&(_e.cameraAutoUpdate===!0&&_e.updateCamera($),$=_e.getCamera()),R.isScene===!0&&R.onBeforeRender(g,R,$,b),d=I.get(R,f.length),d.init(),f.push(d),z.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),X.setFromProjectionMatrix(z),j=this.localClippingEnabled,N=L.init(this.clippingPlanes,j),c=dt.get(R,p.length),c.init(),p.push(c),Xt(R,$,0,g.sortObjects),c.finish(),g.sortObjects===!0&&c.sort(P,O),N===!0&&L.beginShadows();let ae=d.state.shadowsArray;if(ie.render(ae,R,$),N===!0&&L.endShadows(),this.info.autoReset===!0&&this.info.reset(),pe.render(c,R),d.setupLights(g.physicallyCorrectLights),$.isArrayCamera){let K=$.cameras;for(let he=0,Be=K.length;he<Be;he++){let Je=K[he];Ft(c,R,Je,Je.viewport)}}else Ft(c,R,$);b!==null&&(oe.updateMultisampleRenderTarget(b),oe.updateRenderTargetMipmap(b)),R.isScene===!0&&R.onAfterRender(g,R,$),ce.resetDefaultState(),x=-1,w=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 Xt(R,$,ae,K){if(R.visible===!1)return;if(R.layers.test($.layers)){if(R.isGroup)ae=R.renderOrder;else if(R.isLOD)R.autoUpdate===!0&&R.update($);else if(R.isLight)d.pushLight(R),R.castShadow&&d.pushShadow(R);else if(R.isSprite){if(!R.frustumCulled||X.intersectsSprite(R)){K&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(z);let Be=we.update(R),Je=R.material;Je.visible&&c.push(R,Be,Je,ae,H.z,null)}}else if((R.isMesh||R.isLine||R.isPoints)&&(R.isSkinnedMesh&&R.skeleton.frame!==fe.render.frame&&(R.skeleton.update(),R.skeleton.frame=fe.render.frame),!R.frustumCulled||X.intersectsObject(R))){K&&H.setFromMatrixPosition(R.matrixWorld).applyMatrix4(z);let Be=we.update(R),Je=R.material;if(Array.isArray(Je)){let et=Be.groups;for(let st=0,wt=et.length;st<wt;st++){let ut=et[st],lt=Je[ut.materialIndex];lt&&lt.visible&&c.push(R,Be,lt,ae,H.z,ut)}}else Je.visible&&c.push(R,Be,Je,ae,H.z,null)}}let he=R.children;for(let Be=0,Je=he.length;Be<Je;Be++)Xt(he[Be],$,ae,K)}function Ft(R,$,ae,K){let he=R.opaque,Be=R.transmissive,Je=R.transparent;d.setupLightsView(ae),N===!0&&L.setGlobalState(g.clippingPlanes,ae),Be.length>0&&kn(he,$,ae),K&&J.viewport(A.copy(K)),he.length>0&&Dt(he,$,ae),Be.length>0&&Dt(Be,$,ae),Je.length>0&&Dt(Je,$,ae),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function kn(R,$,ae){let K=ee.isWebGL2;F===null&&(F=new ii(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?lh:Mi,minFilter:Ro,samples:K&&n===!0?4:0})),g.getDrawingBufferSize(B),K?F.setSize(B.x,B.y):F.setSize(pd(B.x),pd(B.y));let he=g.getRenderTarget();g.setRenderTarget(F),g.clear();let Be=g.toneMapping;g.toneMapping=js,Dt(R,$,ae),g.toneMapping=Be,oe.updateMultisampleRenderTarget(F),oe.updateRenderTargetMipmap(F),g.setRenderTarget(he)}function Dt(R,$,ae){let K=$.isScene===!0?$.overrideMaterial:null;for(let he=0,Be=R.length;he<Be;he++){let Je=R[he],et=Je.object,st=Je.geometry,wt=K===null?Je.material:K,ut=Je.group;et.layers.test(ae.layers)&&Ss(et,$,ae,st,wt,ut)}}function Ss(R,$,ae,K,he,Be){R.onBeforeRender(g,$,ae,K,he,Be),R.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,R.matrixWorld),R.normalMatrix.getNormalMatrix(R.modelViewMatrix),he.onBeforeRender(g,$,ae,K,R,Be),he.transparent===!0&&he.side===$i&&he.forceSinglePass===!1?(he.side=hi,he.needsUpdate=!0,g.renderBufferDirect(ae,$,K,he,R,Be),he.side=Vr,he.needsUpdate=!0,g.renderBufferDirect(ae,$,K,he,R,Be),he.side=$i):g.renderBufferDirect(ae,$,K,he,R,Be),R.onAfterRender(g,$,ae,K,he,Be)}function lr(R,$,ae){$.isScene!==!0&&($=Q);let K=re.get(R),he=d.state.lights,Be=d.state.shadowsArray,Je=he.state.version,et=Ie.getParameters(R,he.state,Be,$,ae),st=Ie.getProgramCacheKey(et),wt=K.programs;K.environment=R.isMeshStandardMaterial?$.environment:null,K.fog=$.fog,K.envMap=(R.isMeshStandardMaterial?ye:ue).get(R.envMap||K.environment),wt===void 0&&(R.addEventListener("dispose",Mt),wt=new Map,K.programs=wt);let ut=wt.get(st);if(ut!==void 0){if(K.currentProgram===ut&&K.lightsStateVersion===Je)return Vv(R,et),ut}else et.uniforms=Ie.getUniforms(R),R.onBuild(ae,et,g),R.onBeforeCompile(et,g),ut=Ie.acquireProgram(et,st),wt.set(st,ut),K.uniforms=et.uniforms;let lt=K.uniforms;(!R.isShaderMaterial&&!R.isRawShaderMaterial||R.clipping===!0)&&(lt.clippingPlanes=L.uniform),Vv(R,et),K.needsLights=E2(R),K.lightsStateVersion=Je,K.needsLights&&(lt.ambientLightColor.value=he.state.ambient,lt.lightProbe.value=he.state.probe,lt.directionalLights.value=he.state.directional,lt.directionalLightShadows.value=he.state.directionalShadow,lt.spotLights.value=he.state.spot,lt.spotLightShadows.value=he.state.spotShadow,lt.rectAreaLights.value=he.state.rectArea,lt.ltc_1.value=he.state.rectAreaLTC1,lt.ltc_2.value=he.state.rectAreaLTC2,lt.pointLights.value=he.state.point,lt.pointLightShadows.value=he.state.pointShadow,lt.hemisphereLights.value=he.state.hemi,lt.directionalShadowMap.value=he.state.directionalShadowMap,lt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,lt.spotShadowMap.value=he.state.spotShadowMap,lt.spotLightMatrix.value=he.state.spotLightMatrix,lt.spotLightMap.value=he.state.spotLightMap,lt.pointShadowMap.value=he.state.pointShadowMap,lt.pointShadowMatrix.value=he.state.pointShadowMatrix);let vi=ut.getUniforms(),Hi=Kc.seqWithValue(vi.seq,lt);return K.currentProgram=ut,K.uniformsList=Hi,ut}function Vv(R,$){let ae=re.get(R);ae.outputEncoding=$.outputEncoding,ae.instancing=$.instancing,ae.skinning=$.skinning,ae.morphTargets=$.morphTargets,ae.morphNormals=$.morphNormals,ae.morphColors=$.morphColors,ae.morphTargetsCount=$.morphTargetsCount,ae.numClippingPlanes=$.numClippingPlanes,ae.numIntersection=$.numClipIntersection,ae.vertexAlphas=$.vertexAlphas,ae.vertexTangents=$.vertexTangents,ae.toneMapping=$.toneMapping}function S2(R,$,ae,K,he){$.isScene!==!0&&($=Q),oe.resetTextureUnits();let Be=$.fog,Je=K.isMeshStandardMaterial?$.environment:null,et=b===null?g.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:ms,st=(K.isMeshStandardMaterial?ye:ue).get(K.envMap||Je),wt=K.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,ut=!!K.normalMap&&!!ae.attributes.tangent,lt=!!ae.morphAttributes.position,vi=!!ae.morphAttributes.normal,Hi=!!ae.morphAttributes.color,Ms=K.toneMapped?g.toneMapping:js,jn=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,qt=jn!==void 0?jn.length:0,ht=re.get(K),ku=d.state.lights;if(N===!0&&(j===!0||R!==w)){let Wi=R===w&&K.id===x;L.setState(K,R,Wi)}let ju=!1;K.version===ht.__version?(ht.needsLights&&ht.lightsStateVersion!==ku.state.version||ht.outputEncoding!==et||he.isInstancedMesh&&ht.instancing===!1||!he.isInstancedMesh&&ht.instancing===!0||he.isSkinnedMesh&&ht.skinning===!1||!he.isSkinnedMesh&&ht.skinning===!0||ht.envMap!==st||K.fog===!0&&ht.fog!==Be||ht.numClippingPlanes!==void 0&&(ht.numClippingPlanes!==L.numPlanes||ht.numIntersection!==L.numIntersection)||ht.vertexAlphas!==wt||ht.vertexTangents!==ut||ht.morphTargets!==lt||ht.morphNormals!==vi||ht.morphColors!==Hi||ht.toneMapping!==Ms||ee.isWebGL2===!0&&ht.morphTargetsCount!==qt)&&(ju=!0):(ju=!0,ht.__version=K.version);let Gn=ht.currentProgram;ju===!0&&(Gn=lr(K,$,he));let Hv=!1,cl=!1,Gu=!1,Ei=Gn.getUniforms(),Vn=ht.uniforms;if(J.useProgram(Gn.program)&&(Hv=!0,cl=!0,Gu=!0),K.id!==x&&(x=K.id,cl=!0),Hv||w!==R){if(Ei.setValue(U,"projectionMatrix",R.projectionMatrix),ee.logarithmicDepthBuffer&&Ei.setValue(U,"logDepthBufFC",2/(Math.log(R.far+1)/Math.LN2)),w!==R&&(w=R,cl=!0,Gu=!0),K.isShaderMaterial||K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshStandardMaterial||K.envMap){let Wi=Ei.map.cameraPosition;Wi!==void 0&&Wi.setValue(U,H.setFromMatrixPosition(R.matrixWorld))}(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial)&&Ei.setValue(U,"isOrthographic",R.isOrthographicCamera===!0),(K.isMeshPhongMaterial||K.isMeshToonMaterial||K.isMeshLambertMaterial||K.isMeshBasicMaterial||K.isMeshStandardMaterial||K.isShaderMaterial||K.isShadowMaterial||he.isSkinnedMesh)&&Ei.setValue(U,"viewMatrix",R.matrixWorldInverse)}if(he.isSkinnedMesh){Ei.setOptional(U,he,"bindMatrix"),Ei.setOptional(U,he,"bindMatrixInverse");let Wi=he.skeleton;Wi&&(ee.floatVertexTextures?(Wi.boneTexture===null&&Wi.computeBoneTexture(),Ei.setValue(U,"boneTexture",Wi.boneTexture,oe),Ei.setValue(U,"boneTextureSize",Wi.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 Vu=ae.morphAttributes;if((Vu.position!==void 0||Vu.normal!==void 0||Vu.color!==void 0&&ee.isWebGL2===!0)&&me.update(he,ae,K,Gn),(cl||ht.receiveShadow!==he.receiveShadow)&&(ht.receiveShadow=he.receiveShadow,Ei.setValue(U,"receiveShadow",he.receiveShadow)),K.isMeshGouraudMaterial&&K.envMap!==null&&(Vn.envMap.value=st,Vn.flipEnvMap.value=st.isCubeTexture&&st.isRenderTargetTexture===!1?-1:1),cl&&(Ei.setValue(U,"toneMappingExposure",g.toneMappingExposure),ht.needsLights&&M2(Vn,Gu),Be&&K.fog===!0&&He.refreshFogUniforms(Vn,Be),He.refreshMaterialUniforms(Vn,K,T,C,F),Kc.upload(U,ht.uniformsList,Vn,oe)),K.isShaderMaterial&&K.uniformsNeedUpdate===!0&&(Kc.upload(U,ht.uniformsList,Vn,oe),K.uniformsNeedUpdate=!1),K.isSpriteMaterial&&Ei.setValue(U,"center",he.center),Ei.setValue(U,"modelViewMatrix",he.modelViewMatrix),Ei.setValue(U,"normalMatrix",he.normalMatrix),Ei.setValue(U,"modelMatrix",he.matrixWorld),K.isShaderMaterial||K.isRawShaderMaterial){let Wi=K.uniformsGroups;for(let Hu=0,C2=Wi.length;Hu<C2;Hu++)if(ee.isWebGL2){let Wv=Wi[Hu];Fe.update(Wv,Gn),Fe.bind(Wv,Gn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Gn}function M2(R,$){R.ambientLightColor.needsUpdate=$,R.lightProbe.needsUpdate=$,R.directionalLights.needsUpdate=$,R.directionalLightShadows.needsUpdate=$,R.pointLights.needsUpdate=$,R.pointLightShadows.needsUpdate=$,R.spotLights.needsUpdate=$,R.spotLightShadows.needsUpdate=$,R.rectAreaLights.needsUpdate=$,R.hemisphereLights.needsUpdate=$}function E2(R){return R.isMeshLambertMaterial||R.isMeshToonMaterial||R.isMeshPhongMaterial||R.isMeshStandardMaterial||R.isShadowMaterial||R.isShaderMaterial&&R.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(R,$,ae){re.get(R.texture).__webglTexture=$,re.get(R.depthTexture).__webglTexture=ae;let K=re.get(R);K.__hasExternalTextures=!0,K.__hasExternalTextures&&(K.__autoAllocateDepthBuffer=ae===void 0,K.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),K.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(R,$){let ae=re.get(R);ae.__webglFramebuffer=$,ae.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(R,$=0,ae=0){b=R,v=$,y=ae;let K=!0,he=null,Be=!1,Je=!1;if(R){let et=re.get(R);et.__useDefaultFramebuffer!==void 0?(J.bindFramebuffer(36160,null),K=!1):et.__webglFramebuffer===void 0?oe.setupRenderTarget(R):et.__hasExternalTextures&&oe.rebindTextures(R,re.get(R.texture).__webglTexture,re.get(R.depthTexture).__webglTexture);let st=R.texture;(st.isData3DTexture||st.isDataArrayTexture||st.isCompressedArrayTexture)&&(Je=!0);let wt=re.get(R).__webglFramebuffer;R.isWebGLCubeRenderTarget?(he=wt[$],Be=!0):ee.isWebGL2&&R.samples>0&&oe.useMultisampledRTT(R)===!1?he=re.get(R).__webglMultisampledFramebuffer:he=wt,A.copy(R.viewport),S.copy(R.scissor),_=R.scissorTest}else A.copy(D).multiplyScalar(T).floor(),S.copy(k).multiplyScalar(T).floor(),_=W;if(J.bindFramebuffer(36160,he)&&ee.drawBuffers&&K&&J.drawBuffers(R,he),J.viewport(A),J.scissor(S),J.setScissorTest(_),Be){let et=re.get(R.texture);U.framebufferTexture2D(36160,36064,34069+$,et.__webglTexture,ae)}else if(Je){let et=re.get(R.texture),st=$||0;U.framebufferTextureLayer(36160,36064,et.__webglTexture,ae||0,st)}x=-1},this.readRenderTargetPixels=function(R,$,ae,K,he,Be,Je){if(!(R&&R.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let et=re.get(R).__webglFramebuffer;if(R.isWebGLCubeRenderTarget&&Je!==void 0&&(et=et[Je]),et){J.bindFramebuffer(36160,et);try{let st=R.texture,wt=st.format,ut=st.type;if(wt!==Ur&&Me.convert(wt)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let lt=ut===lh&&(V.has("EXT_color_buffer_half_float")||ee.isWebGL2&&V.has("EXT_color_buffer_float"));if(ut!==Mi&&Me.convert(ut)!==U.getParameter(35738)&&!(ut===vn&&(ee.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=R.width-K&&ae>=0&&ae<=R.height-he&&U.readPixels($,ae,K,he,Me.convert(wt),Me.convert(ut),Be)}finally{let st=b!==null?re.get(b).__webglFramebuffer:null;J.bindFramebuffer(36160,st)}}},this.copyFramebufferToTexture=function(R,$,ae=0){let K=Math.pow(2,-ae),he=Math.floor($.image.width*K),Be=Math.floor($.image.height*K);oe.setTexture2D($,0),U.copyTexSubImage2D(3553,ae,0,0,R.x,R.y,he,Be),J.unbindTexture()},this.copyTextureToTexture=function(R,$,ae,K=0){let he=$.image.width,Be=$.image.height,Je=Me.convert(ae.format),et=Me.convert(ae.type);oe.setTexture2D(ae,0),U.pixelStorei(37440,ae.flipY),U.pixelStorei(37441,ae.premultiplyAlpha),U.pixelStorei(3317,ae.unpackAlignment),$.isDataTexture?U.texSubImage2D(3553,K,R.x,R.y,he,Be,Je,et,$.image.data):$.isCompressedTexture?U.compressedTexSubImage2D(3553,K,R.x,R.y,$.mipmaps[0].width,$.mipmaps[0].height,Je,$.mipmaps[0].data):U.texSubImage2D(3553,K,R.x,R.y,Je,et,$.image),K===0&&ae.generateMipmaps&&U.generateMipmap(3553),J.unbindTexture()},this.copyTextureToTexture3D=function(R,$,ae,K,he=0){if(g.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Be=R.max.x-R.min.x+1,Je=R.max.y-R.min.y+1,et=R.max.z-R.min.z+1,st=Me.convert(K.format),wt=Me.convert(K.type),ut;if(K.isData3DTexture)oe.setTexture3D(K,0),ut=32879;else if(K.isDataArrayTexture)oe.setTexture2DArray(K,0),ut=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,K.flipY),U.pixelStorei(37441,K.premultiplyAlpha),U.pixelStorei(3317,K.unpackAlignment);let lt=U.getParameter(3314),vi=U.getParameter(32878),Hi=U.getParameter(3316),Ms=U.getParameter(3315),jn=U.getParameter(32877),qt=ae.isCompressedTexture?ae.mipmaps[0]:ae.image;U.pixelStorei(3314,qt.width),U.pixelStorei(32878,qt.height),U.pixelStorei(3316,R.min.x),U.pixelStorei(3315,R.min.y),U.pixelStorei(32877,R.min.z),ae.isDataTexture||ae.isData3DTexture?U.texSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,wt,qt.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,qt.data)):U.texSubImage3D(ut,he,$.x,$.y,$.z,Be,Je,et,st,wt,qt),U.pixelStorei(3314,lt),U.pixelStorei(32878,vi),U.pixelStorei(3316,Hi),U.pixelStorei(3315,Ms),U.pixelStorei(32877,jn),he===0&&K.generateMipmaps&&U.generateMipmap(ut),J.unbindTexture()},this.initTexture=function(R){R.isCubeTexture?oe.setTextureCube(R,0):R.isData3DTexture?oe.setTexture3D(R,0):R.isDataArrayTexture||R.isCompressedArrayTexture?oe.setTexture2DArray(R,0):oe.setTexture2D(R,0),J.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,J.reset(),ce.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var YP=class extends yw{};YP.prototype.isWebGL1Renderer=!0;var xw=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ge(e),this.near=t,this.far=i}clone(){return new xw(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},pa=class extends bt{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}},QP=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Rf,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=us()}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=us()),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=us()),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}}},Ti=new E,Uf=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++)Ti.fromBufferAttribute(this,t),Ti.applyMatrix4(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ti.fromBufferAttribute(this,t),Ti.applyNormalMatrix(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ti.fromBufferAttribute(this,t),Ti.transformDirection(e),this.setXYZ(t,Ti.x,Ti.y,Ti.z);return this}setX(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=_t(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=_t(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=Fs(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Fs(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Fs(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Fs(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=_t(t,this.array),i=_t(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=_t(t,this.array),i=_t(i,this.array),r=_t(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=_t(t,this.array),i=_t(i,this.array),r=_t(r,this.array),s=_t(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 Xe(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 Uf(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}}},ZP=class extends Xe{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}},Rn=class extends Th{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ge(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}},oy=new E,ly=new E,hy=new ve,Ap=new Wo,cc=new Mr,gd=class extends bt{constructor(e=new Ve,t=new Rn){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++)oy.fromBufferAttribute(t,r-1),ly.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=oy.distanceTo(ly);e.setAttribute("lineDistance",new Ce(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(),cc.copy(i.boundingSphere),cc.applyMatrix4(r),cc.radius+=s,e.ray.intersectsSphere(cc)===!1)return;hy.copy(r).invert(),Ap.copy(e.ray).applyMatrix4(hy);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 b=p.getX(v),x=p.getX(v+1);if(l.fromBufferAttribute(f,b),h.fromBufferAttribute(f,x),Ap.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let w=e.ray.origin.distanceTo(c);w<e.near||w>e.far||t.push({distance:w,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),Ap.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let b=e.ray.origin.distanceTo(c);b<e.near||b>e.far||t.push({distance:b,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}}}}},cy=new E,dy=new E,Dh=class extends gd{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)cy.fromBufferAttribute(t,r),dy.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+cy.distanceTo(dy);e.setAttribute("lineDistance",new Ce(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},KP=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:mt,this.magFilter=s!==void 0?s:mt,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)}},ws=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 G: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 ve;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(ti(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(ti(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}},lu=class extends ws{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 G,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}},JP=class extends lu{constructor(e,t,i,r,s,n){super(e,t,i,i,r,s,n),this.isArcCurve=!0,this.type="ArcCurve"}};function hg(){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 dc=new E,Sp=new hg,Mp=new hg,Ep=new hg,$P=class extends ws{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]:(dc.subVectors(r[0],r[1]).add(r[0]),l=dc);let u=r[a%s],c=r[(a+1)%s];if(this.closed||a+2<s?h=r[(a+2)%s]:(dc.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=dc),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),Sp.initNonuniformCatmullRom(l.x,u.x,c.x,h.x,p,f,g),Mp.initNonuniformCatmullRom(l.y,u.y,c.y,h.y,p,f,g),Ep.initNonuniformCatmullRom(l.z,u.z,c.z,h.z,p,f,g)}else this.curveType==="catmullrom"&&(Sp.initCatmullRom(l.x,u.x,c.x,h.x,this.tension),Mp.initCatmullRom(l.y,u.y,c.y,h.y,this.tension),Ep.initCatmullRom(l.z,u.z,c.z,h.z,this.tension));return i.set(Sp.calc(o),Mp.calc(o),Ep.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 uy(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 eD(e,t){let i=1-e;return i*i*t}function tD(e,t){return 2*(1-e)*e*t}function iD(e,t){return e*e*t}function Jl(e,t,i,r){return eD(e,t)+tD(e,i)+iD(e,r)}function rD(e,t){let i=1-e;return i*i*i*t}function sD(e,t){let i=1-e;return 3*i*i*e*t}function nD(e,t){return 3*(1-e)*e*e*t}function aD(e,t){return e*e*e*t}function $l(e,t,i,r,s){return rD(e,t)+sD(e,i)+nD(e,r)+aD(e,s)}var Fr=class extends ws{constructor(e=new G,t=new G,i=new G,r=new G){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2,a=this.v3;return i.set($l(e,r.x,s.x,n.x,a.x),$l(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}},Jc=class extends ws{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($l(e,r.x,s.x,n.x,a.x),$l(e,r.y,s.y,n.y,a.y),$l(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}},Gr=class extends ws{constructor(e=new G,t=new G){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new G){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 G;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}},bw=class extends ws{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}},Pn=class extends ws{constructor(e=new G,t=new G,i=new G){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new G){let i=t,r=this.v0,s=this.v1,n=this.v2;return i.set(Jl(e,r.x,s.x,n.x),Jl(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}},oD=class extends ws{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(Jl(e,r.x,s.x,n.x),Jl(e,r.y,s.y,n.y),Jl(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}},cg=class extends ws{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new G){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(uy(a,o.x,l.x,h.x,u.x),uy(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 G().fromArray(r))}return this}},lD=Object.freeze({__proto__:null,ArcCurve:JP,CatmullRomCurve3:$P,CubicBezierCurve:Fr,CubicBezierCurve3:Jc,EllipseCurve:lu,LineCurve:Gr,LineCurve3:bw,QuadraticBezierCurve:Pn,QuadraticBezierCurve3:oD,SplineCurve:cg}),ww=class extends ws{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 Gr(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 lD[r.type]().fromJSON(r))}return this}},vd=class extends ww{constructor(e){super(),this.type="Path",this.currentPoint=new G,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 Gr(this.currentPoint.clone(),new G(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new Pn(this.currentPoint.clone(),new G(e,t),new G(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,n){let a=new Fr(this.currentPoint.clone(),new G(e,t),new G(i,r),new G(s,n));return this.curves.push(a),this.currentPoint.set(s,n),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new cg(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 lu(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}},_w=class extends Ve{constructor(e=[new G(0,-.5),new G(.5,0),new G(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=ti(r,0,Math.PI*2);let s=[],n=[],a=[],o=[],l=[],h=1/t,u=new E,c=new G,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,b=Math.sin(y),x=Math.cos(y);for(let w=0;w<=e.length-1;w++){u.x=e[w].x*b,u.y=e[w].y,u.z=e[w].x*x,n.push(u.x,u.y,u.z),c.x=v/t,c.y=w/(e.length-1),a.push(c.x,c.y);let A=o[3*w+0]*b,S=o[3*w+1],_=o[3*w+0]*x;l.push(A,S,_)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let b=y+v*e.length,x=b,w=b+e.length,A=b+e.length+1,S=b+1;s.push(x,w,S),s.push(A,S,w)}this.setIndex(s),this.setAttribute("position",new Ce(n,3)),this.setAttribute("uv",new Ce(a,2)),this.setAttribute("normal",new Ce(l,3))}static fromJSON(e){return new _w(e.points,e.segments,e.phiStart,e.phiLength)}},dg=class extends Ve{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 Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function v(){let b=new E,x=new E,w=0,A=(t-e)/i;for(let S=0;S<=s;S++){let _=[],M=S/s,C=M*(t-e)+e;for(let T=0;T<=r;T++){let P=T/r,O=P*o+a,D=Math.sin(O),k=Math.cos(O);x.x=C*D,x.y=-M*i+g,x.z=C*k,u.push(x.x,x.y,x.z),b.set(D,A,k).normalize(),c.push(b.x,b.y,b.z),d.push(P,1-M),_.push(p++)}f.push(_)}for(let S=0;S<r;S++)for(let _=0;_<s;_++){let M=f[_][S],C=f[_+1][S],T=f[_+1][S+1],P=f[_][S+1];h.push(M,C,P),h.push(C,T,P),w+=6}l.addGroup(m,w,0),m+=w}function y(b){let x=p,w=new G,A=new E,S=0,_=b===!0?e:t,M=b===!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 P=T/r*o+a,O=Math.cos(P),D=Math.sin(P);A.x=_*D,A.y=g*M,A.z=_*O,u.push(A.x,A.y,A.z),c.push(0,M,0),w.x=O*.5+.5,w.y=D*.5*M+.5,d.push(w.x,w.y),p++}for(let T=0;T<r;T++){let P=x+T,O=C+T;b===!0?h.push(O,O+1,P):h.push(O+1,O,P),S+=3}l.addGroup(m,S,b===!0?1:2),m+=S}}static fromJSON(e){return new dg(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Aw=class extends dg{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 Aw(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ug=class extends Ve{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 Ce(s,3)),this.setAttribute("normal",new Ce(s.slice(),3)),this.setAttribute("uv",new Ce(n,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let y=new E,b=new E,x=new E;for(let w=0;w<t.length;w+=3)d(t[w+0],y),d(t[w+1],b),d(t[w+2],x),o(y,b,x,v)}function o(v,y,b,x){let w=x+1,A=[];for(let S=0;S<=w;S++){A[S]=[];let _=v.clone().lerp(b,S/w),M=y.clone().lerp(b,S/w),C=w-S;for(let T=0;T<=C;T++)T===0&&S===w?A[S][T]=_:A[S][T]=_.clone().lerp(M,T/C)}for(let S=0;S<w;S++)for(let _=0;_<2*(w-S)-1;_++){let M=Math.floor(_/2);_%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 b=0;b<s.length;b+=3)y.x=s[b+0],y.y=s[b+1],y.z=s[b+2],y.normalize().multiplyScalar(v),s[b+0]=y.x,s[b+1]=y.y,s[b+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 b=g(v)/2/Math.PI+.5,x=m(v)/Math.PI+.5;n.push(b,1-x)}p(),u()}function u(){for(let v=0;v<n.length;v+=6){let y=n[v+0],b=n[v+2],x=n[v+4],w=Math.max(y,b,x),A=Math.min(y,b,x);w>.9&&A<.1&&(y<.2&&(n[v+0]+=1),b<.2&&(n[v+2]+=1),x<.2&&(n[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function d(v,y){let b=v*3;y.x=e[b+0],y.y=e[b+1],y.z=e[b+2]}function p(){let v=new E,y=new E,b=new E,x=new E,w=new G,A=new G,S=new G;for(let _=0,M=0;_<s.length;_+=9,M+=6){v.set(s[_+0],s[_+1],s[_+2]),y.set(s[_+3],s[_+4],s[_+5]),b.set(s[_+6],s[_+7],s[_+8]),w.set(n[M+0],n[M+1]),A.set(n[M+2],n[M+3]),S.set(n[M+4],n[M+5]),x.copy(v).add(y).add(b).divideScalar(3);let C=g(x);f(w,M+0,v,C),f(A,M+2,y,C),f(S,M+4,b,C)}}function f(v,y,b,x){x<0&&v.x===1&&(n[y]=v.x-1),b.x===0&&b.z===0&&(n[y]=x/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 ug(e.vertices,e.indices,e.radius,e.details)}},Sw=class extends ug{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 Sw(e.radius,e.detail)}},yd=class extends vd{constructor(e){super(e),this.uuid=us(),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 vd().fromJSON(r))}return this}},hD={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,n=Mw(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=fD(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 ch(n,a,i,o,l,p,0),a}};function Mw(e,t,i,r,s){let n,a;if(s===MD(e,t,i,r)>0)for(n=t;n<i;n+=r)a=py(n,e[n],e[n+1],a);else for(n=i-r;n>=t;n-=r)a=py(n,e[n],e[n+1],a);return a&&hu(a,a.next)&&(uh(a),a=a.next),a}function wa(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(hu(i,i.next)||It(i.prev,i,i.next)===0)){if(uh(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function ch(e,t,i,r,s,n,a){if(!e)return;!a&&n&&xD(e,r,s,n);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,n?dD(e,r,s,n):cD(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),uh(e),e=h.next,o=h.next;continue}if(e=h,e===o){a?a===1?(e=uD(wa(e),t,i),ch(e,t,i,r,s,n,2)):a===2&&pD(e,t,i,r,s,n):ch(wa(e),t,i,r,s,n,1);break}}}function cD(e){let t=e.prev,i=e,r=e.next;if(It(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&&po(s,o,n,l,a,h,f.x,f.y)&&It(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function dD(e,t,i,r){let s=e.prev,n=e,a=e.next;if(It(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=Ff(p,f,t,i,r),y=Ff(g,m,t,i,r),b=e.prevZ,x=e.nextZ;for(;b&&b.z>=v&&x&&x.z<=y;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&po(o,u,l,c,h,d,b.x,b.y)&&It(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&po(o,u,l,c,h,d,x.x,x.y)&&It(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=v;){if(b.x>=p&&b.x<=g&&b.y>=f&&b.y<=m&&b!==s&&b!==a&&po(o,u,l,c,h,d,b.x,b.y)&&It(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=y;){if(x.x>=p&&x.x<=g&&x.y>=f&&x.y<=m&&x!==s&&x!==a&&po(o,u,l,c,h,d,x.x,x.y)&&It(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function uD(e,t,i){let r=e;do{let s=r.prev,n=r.next.next;!hu(s,n)&&Ew(s,r,r.next,n)&&dh(s,n)&&dh(n,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(n.i/i|0),uh(r),uh(r.next),r=e=n),r=r.next}while(r!==e);return wa(r)}function pD(e,t,i,r,s,n){let a=e;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&_D(a,o)){let l=Cw(a,o);a=wa(a,a.next),l=wa(l,l.next),ch(a,t,i,r,s,n,0),ch(l,t,i,r,s,n,0);return}o=o.next}a=a.next}while(a!==e)}function fD(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=Mw(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(wD(h));for(s.sort(mD),n=0;n<s.length;n++)i=gD(s[n],i);return i}function mD(e,t){return e.x-t.x}function gD(e,t){let i=vD(e,t);if(!i)return t;let r=Cw(i,e);return wa(r,r.next),wa(i,i.next)}function vD(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&&po(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),dh(i,e)&&(c<u||c===u&&(i.x>s.x||i.x===s.x&&yD(s,i)))&&(s=i,u=c)),i=i.next;while(i!==o);return s}function yD(e,t){return It(e.prev,e,t.prev)<0&&It(t.next,e,e.next)<0}function xD(e,t,i,r){let s=e;do s.z===0&&(s.z=Ff(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,bD(s)}function bD(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 Ff(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 wD(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 po(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 _D(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!AD(e,t)&&(dh(e,t)&&dh(t,e)&&SD(e,t)&&(It(e.prev,e,t.prev)||It(e,t.prev,t))||hu(e,t)&&It(e.prev,e,e.next)>0&&It(t.prev,t,t.next)>0)}function It(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function hu(e,t){return e.x===t.x&&e.y===t.y}function Ew(e,t,i,r){let s=pc(It(e,t,i)),n=pc(It(e,t,r)),a=pc(It(i,r,e)),o=pc(It(i,r,t));return!!(s!==n&&a!==o||s===0&&uc(e,i,t)||n===0&&uc(e,r,t)||a===0&&uc(i,e,r)||o===0&&uc(i,t,r))}function uc(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 pc(e){return e>0?1:e<0?-1:0}function AD(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&&Ew(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function dh(e,t){return It(e.prev,e,e.next)<0?It(e,t,e.next)>=0&&It(e,e.prev,t)>=0:It(e,t,e.prev)<0||It(e,e.next,t)<0}function SD(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 Cw(e,t){let i=new kf(e.i,e.x,e.y),r=new kf(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 py(e,t,i,r){let s=new kf(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 uh(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 kf(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 MD(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 Tw=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 Tw.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];fy(e),my(i,e);let n=e.length;t.forEach(fy);for(let o=0;o<t.length;o++)r.push(n),n+=t[o].length,my(i,t[o]);let a=hD.triangulate(i,r);for(let o=0;o<a.length;o+=3)s.push(a.slice(o,o+3));return s}};function fy(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function my(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var Pw=class extends ug{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 Pw(e.radius,e.detail)}},pg=class extends Ve{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,b=0;m==0&&n==0?b=.5/t:m==i&&o==Math.PI&&(b=-.5/t);for(let x=0;x<=t;x++){let w=x/t;u.x=-e*Math.cos(r+w*s)*Math.sin(n+y*a),u.y=e*Math.cos(n+y*a),u.z=e*Math.sin(r+w*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(w+b,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],b=h[m][v],x=h[m+1][v],w=h[m+1][v+1];(m!==0||n>0)&&d.push(y,b,w),(m!==i-1||o<Math.PI)&&d.push(b,x,w)}this.setIndex(d),this.setAttribute("position",new Ce(p,3)),this.setAttribute("normal",new Ce(f,3)),this.setAttribute("uv",new Ce(g,2))}static fromJSON(e){return new pg(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},Dw=class extends Ve{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 b=y/i*s*Math.PI*2;v(b,s,n,e,d),v(b+.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 x=0;x<=r;++x){let w=x/r*Math.PI*2,A=-t*Math.cos(w),S=t*Math.sin(w);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(x/r)}}for(let y=1;y<=i;y++)for(let b=1;b<=r;b++){let x=(r+1)*(y-1)+(b-1),w=(r+1)*y+(b-1),A=(r+1)*y+b,S=(r+1)*(y-1)+b;a.push(x,w,S),a.push(w,A,S)}this.setIndex(a),this.setAttribute("position",new Ce(o,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(h,2));function v(y,b,x,w,A){let S=Math.cos(y),_=Math.sin(y),M=x/b*y,C=Math.cos(M);A.x=w*(2+C)*.5*S,A.y=w*(2+C)*_*.5,A.z=w*Math.sin(M)*.5}}static fromJSON(e){return new Dw(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function en(e,t,i){return Ow(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function fc(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 Ow(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var cu=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];i:{e:{let n;t:{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 e}n=t.length;break t}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 e}n=i,i=0;break t}break i}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_(){}},ED=class extends cu{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:S0,endingEnd:S0}}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 M0:s=e,a=2*t-i;break;case E0: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 M0:n=e,o=2*i-t;break;case E0: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,b=d*g-d*f;for(let x=0;x!==a;++x)s[x]=m*n[h+x]+v*n[l+x]+y*n[o+x]+b*n[u+x];return s}},CD=class extends cu{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}},TD=class extends cu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},qs=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=fc(t,this.TimeBufferType),this.values=fc(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:fc(e.times,Array),values:fc(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new TD(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new CD(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ED(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case cd:t=this.InterpolantFactoryMethodDiscrete;break;case dd:t=this.InterpolantFactoryMethodLinear;break;case Ku: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 cd;case this.InterpolantFactoryMethodLinear:return dd;case this.InterpolantFactoryMethodSmooth:return Ku}}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=en(i,s,n),this.values=en(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&&Ow(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=en(this.times),t=en(this.values),i=this.getValueSize(),r=this.getInterpolation()===Ku,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=en(e,0,n),this.values=en(t,0,n*i)):(this.times=e,this.values=t),this}clone(){let e=en(this.times,0),t=en(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};qs.prototype.TimeBufferType=Float32Array;qs.prototype.ValueBufferType=Float32Array;qs.prototype.DefaultInterpolation=dd;var Oh=class extends qs{};Oh.prototype.ValueTypeName="bool";Oh.prototype.ValueBufferType=Array;Oh.prototype.DefaultInterpolation=cd;Oh.prototype.InterpolantFactoryMethodLinear=void 0;Oh.prototype.InterpolantFactoryMethodSmooth=void 0;var PD=class extends qs{};PD.prototype.ValueTypeName="color";var DD=class extends qs{};DD.prototype.ValueTypeName="number";var OD=class extends cu{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)ct.slerpFlat(s,0,n,l-a,n,l,o);return s}},fg=class extends qs{InterpolantFactoryMethodLinear(e){return new OD(this.times,this.values,this.getValueSize(),e)}};fg.prototype.ValueTypeName="quaternion";fg.prototype.DefaultInterpolation=dd;fg.prototype.InterpolantFactoryMethodSmooth=void 0;var Lh=class extends qs{};Lh.prototype.ValueTypeName="string";Lh.prototype.ValueBufferType=Array;Lh.prototype.DefaultInterpolation=cd;Lh.prototype.InterpolantFactoryMethodLinear=void 0;Lh.prototype.InterpolantFactoryMethodSmooth=void 0;var LD=class extends qs{};LD.prototype.ValueTypeName="vector";var gy={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={}}},Lw=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}}},ID=new Lw,mg=class{constructor(e){this.manager=e!==void 0?e:ID,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}},Os={},RD=class extends Error{constructor(e,t){super(e),this.response=t}},jf=class extends mg{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=gy.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Os[e]!==void 0){Os[e].push({onLoad:t,onProgress:i,onError:r});return}Os[e]=[],Os[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=Os[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:b})=>{if(y)m.close();else{f+=b.byteLength;let x=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:d});for(let w=0,A=h.length;w<A;w++){let S=h[w];S.onProgress&&S.onProgress(x)}m.enqueue(b),v()}})}}});return new Response(g)}else throw new RD(`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=>{gy.add(e,l);let h=Os[e];delete Os[e];for(let u=0,c=h.length;u<c;u++){let d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{let h=Os[e];if(h===void 0)throw this.manager.itemError(e),l;delete Os[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}},Ih=class extends bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ge(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}},BD=class extends Ih{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ge(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Cp=new ve,vy=new E,yy=new E,gg=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new G(512,512),this.map=null,this.mapPass=null,this.matrix=new ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ag,this._frameExtents=new G(1,1),this._viewportCount=1,this._viewports=[new $e(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;vy.setFromMatrixPosition(e.matrixWorld),t.position.copy(vy),yy.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(yy),t.updateMatrixWorld(),Cp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Cp),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Cp)}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}},ND=class extends gg{constructor(){super(new wi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=hh*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}},zD=class extends Ih{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(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=n,this.map=null,this.shadow=new ND}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}},xy=new ve,xl=new E,Tp=new E,UD=class extends gg{constructor(){super(new wi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new G(4,2),this._viewportCount=6,this._viewports=[new $e(2,1,1,1),new $e(0,1,1,1),new $e(3,1,1,1),new $e(1,1,1,1),new $e(3,0,1,1),new $e(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()),xl.setFromMatrixPosition(e.matrixWorld),i.position.copy(xl),Tp.copy(i.position),Tp.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Tp),i.updateMatrixWorld(),r.makeTranslation(-xl.x,-xl.y,-xl.z),xy.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xy)}},FD=class extends Ih{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 UD}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}},kD=class extends gg{constructor(){super(new md(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},jD=class extends Ih{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.shadow=new kD}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},GD=class extends Ve{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}},Iw=class extends mg{constructor(e){super(e)}load(e,t,i,r){let s=this,n=new jf(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=Wh(p.type,f),m=new QP(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 GD:new Ve,a=e.data.index;if(a!==void 0){let c=Wh(a.type,a.array);n.setIndex(new Xe(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 Uf(f,d.itemSize,d.offset,d.normalized)}else{let f=Wh(d.type,d.array),g=d.isInstancedBufferAttribute?ZP:Xe;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 Uf(y,m.itemSize,m.offset,m.normalized)}else{let y=Wh(m.type,m.array);v=new Xe(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 Mr(c,u.radius)}return e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}},VD=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=by(),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=by();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function by(){return(typeof performance>"u"?Date:performance).now()}var vg="\\[\\]\\.:\\/",HD=new RegExp("["+vg+"]","g"),yg="[^"+vg+"]",WD="[^"+vg.replace("\\.","")+"]",XD=/((?:WC+[\/:])*)/.source.replace("WC",yg),qD=/(WCOD+)?/.source.replace("WCOD",WD),YD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yg),QD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yg),ZD=new RegExp("^"+XD+qD+YD+QD+"$"),KD=["material","materials","bones","map"],JD=class{constructor(e,t,i){let r=i||At.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()}},At=class{constructor(e,t,i){this.path=t,this.parsedPath=i||At.parseTrackName(t),this.node=At.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 At.Composite(e,t,i):new At(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HD,"")}static parseTrackName(e){let t=ZD.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);KD.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=At.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}};At.Composite=JD;At.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};At.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};At.prototype.GetterByBindingType=[At.prototype._getValue_direct,At.prototype._getValue_array,At.prototype._getValue_arrayElement,At.prototype._getValue_toArray];At.prototype.SetterByBindingTypeAndVersioning=[[At.prototype._setValue_direct,At.prototype._setValue_direct_setNeedsUpdate,At.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[At.prototype._setValue_array,At.prototype._setValue_array_setNeedsUpdate,At.prototype._setValue_array_setMatrixWorldNeedsUpdate],[At.prototype._setValue_arrayElement,At.prototype._setValue_arrayElement_setNeedsUpdate,At.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[At.prototype._setValue_fromArray,At.prototype._setValue_fromArray_setNeedsUpdate,At.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var r9=new Float32Array(1),Le=class{constructor(e){this.value=e}clone(){return new Le(this.value.clone===void 0?this.value:this.value.clone())}},Rw=class{constructor(e,t,i=0,r=1/0){this.ray=new Wo(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new sg,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 Gf(e,this,i,t),i.sort(wy),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Gf(e[r],this,i,t);return i.sort(wy),i}};function wy(e,t){return e.distance-t.distance}function Gf(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++)Gf(s[n],t,i,!0)}}var _y=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(ti(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Ay=new G,$D=class{constructor(e=new G(1/0,1/0),t=new G(-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=Ay.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 Ay.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)}},Sy=new E,mc=new E,_r=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){Sy.subVectors(e,this.start),mc.subVectors(this.end,this.start);let i=mc.dot(mc),r=mc.dot(Sy)/i;return t&&(r=ti(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)}},My=new E,eO=class extends bt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ve,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 Ce(r,3));let s=new Rn({fog:!1,toneMapped:!1});this.cone=new Dh(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),My.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(My),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},tO=class extends er{constructor(e,t,i){let r=new pg(t,4,2),s=new Ph({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)}},Ey=new E,gc=new E,Cy=new E,iO=class extends bt{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 Ve;r.setAttribute("position",new Ce([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Rn({fog:!1,toneMapped:!1});this.lightPlane=new gd(r,s),this.add(this.lightPlane),r=new Ve,r.setAttribute("position",new Ce([0,0,0,0,0,1],3)),this.targetLine=new gd(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),Ey.setFromMatrixPosition(this.light.matrixWorld),gc.setFromMatrixPosition(this.light.target.matrixWorld),Cy.subVectors(gc,Ey),this.lightPlane.lookAt(gc),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(gc),this.targetLine.scale.z=Cy.length()}},vc=new E,Rt=new qo,xd=class extends Dh{constructor(e){let t=new Ve,i=new Rn({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 Ce(r,3)),t.setAttribute("color",new Ce(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 Ge(16755200),h=new Ge(16711680),u=new Ge(43775),c=new Ge(16777215),d=new Ge(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;Rt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),kt("c",t,e,Rt,0,0,-1),kt("t",t,e,Rt,0,0,1),kt("n1",t,e,Rt,-i,-r,-1),kt("n2",t,e,Rt,i,-r,-1),kt("n3",t,e,Rt,-i,r,-1),kt("n4",t,e,Rt,i,r,-1),kt("f1",t,e,Rt,-i,-r,1),kt("f2",t,e,Rt,i,-r,1),kt("f3",t,e,Rt,-i,r,1),kt("f4",t,e,Rt,i,r,1),kt("u1",t,e,Rt,i*.7,r*1.1,-1),kt("u2",t,e,Rt,-i*.7,r*1.1,-1),kt("u3",t,e,Rt,0,r*2,-1),kt("cf1",t,e,Rt,-i,0,1),kt("cf2",t,e,Rt,i,0,1),kt("cf3",t,e,Rt,0,-r,1),kt("cf4",t,e,Rt,0,r,1),kt("cn1",t,e,Rt,-i,0,-1),kt("cn2",t,e,Rt,i,0,-1),kt("cn3",t,e,Rt,0,-r,-1),kt("cn4",t,e,Rt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function kt(e,t,i,r,s,n,a){vc.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],vc.x,vc.y,vc.z)}}var bd=class extends Dh{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 Ve;s.setIndex(new Xe(i,1)),s.setAttribute("position",new Ce(r,3)),super(s,new Rn({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()}},rO=class extends Dh{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 Ve;r.setAttribute("position",new Ce(t,3)),r.setAttribute("color",new Ce(i,3));let s=new Rn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new Ge,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:Ho}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ho);var bl=".",xg=Symbol("target"),Bw=Symbol("unsubscribe");function Vf(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function sO(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var ns=Array.isArray;function bg(e){return typeof e=="symbol"}var nO={after:(e,t)=>ns(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>ns(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=bl),bg(t)?e+t.toString():e+t):e,initial:e=>{if(ns(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(bl);return t===-1?"":e.slice(0,t)},last:e=>{if(ns(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(bl);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(ns(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(bl);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(bl,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},mr=nO;function aO(e){return typeof e=="object"&&typeof e.next=="function"}function oO(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[xg].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 Ty(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&bg(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var lO=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,mr.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 Hf(e){return toString.call(e)==="[object Object]"}function yc(){return!0}function qa(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var Nw=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),hO=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),zw={push:yc,pop:yc,shift:yc,unshift:yc,copyWithin:qa,reverse:qa,sort:qa,splice:qa,flat:qa,fill:qa},cO=new Set([...Nw,...hO,...Object.keys(zw)]);function xc(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var Uw=["keys","values","entries"],Fw=new Set(["has","toString"]),kw={add:xc,clear:xc,delete:xc,forEach:xc},dO=new Set([...Fw,...Object.keys(kw),...Uw]);function bc(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 uO=new Set([...Fw,"get"]),jw={set:bc,clear:bc,delete:bc,forEach:bc},pO=new Set([...uO,...Object.keys(jw),...Uw]),Dn=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 Nw.has(e)}_shallowClone(e){let t=e;if(Hf(e))t={...e};else if(ns(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?(ns(r)?this._onIsChanged=zw[t]:r instanceof Set?this._onIsChanged=kw[t]:r instanceof Map&&(this._onIsChanged=jw[t]),r):i}update(e,t,i){let r=mr.after(e,this._path);if(t!=="length"){let s=this.clone;mr.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],mr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Py=class extends Dn{static isHandledMethod(e){return cO.has(e)}},fO=class extends Dn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Dy=class extends Dn{static isHandledMethod(e){return dO.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)}},Oy=class extends Dn{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)}},mO=class extends Dn{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)}},gO=class extends Dn{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)}},no=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return Hf(e)||ns(e)||Vf(e)}static isHandledMethod(e,t){return Hf(e)?Dn.isHandledMethod(t):ns(e)?Py.isHandledMethod(t):e instanceof Set?Dy.isHandledMethod(t):e instanceof Map?Oy.isHandledMethod(t):Vf(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=Dn;ns(e)?r=Py:e instanceof Date?r=fO:e instanceof Set?r=Dy:e instanceof Map?r=Oy:e instanceof WeakSet?r=mO:e instanceof WeakMap&&(r=gO),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=no.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}},vO={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},wg=(e,t,i={})=>{i={...vO,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:n,ignoreDetached:a,details:o}=i,l=new lO(s),h=typeof i.onValidate=="function",u=new no(h),c=(y,b,x,w,A)=>!h||u.isCloning||i.onValidate(mr.concat(l.getPath(y),b),x,w,A)===!0,d=(y,b,x,w)=>{!Ty(l,i,b)&&!(a&&l.isDetached(y,e))&&p(l.getPath(y),b,x,w)},p=(y,b,x,w,A)=>{u.isCloning?u.update(y,b,w):t(mr.concat(y,b),x,w,A)},f=y=>y&&(y[r]||y),g=(y,b,x,w)=>sO(y)||x==="constructor"||n&&!no.isHandledMethod(b,x)||Ty(l,i,x)||l.isGetInvariant(b,x)||a&&l.isDetached(b,e)?y:(w===void 0&&(w=l.getPath(b)),l.getProxy(y,mr.concat(w,x),m,r)),m={get(y,b,x){if(bg(b)){if(b===r||b===xg)return y;if(b===Bw&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=Vf(y)?Reflect.get(y,b):Reflect.get(y,b,x);return g(w,y,b)},set(y,b,x,w){x=f(x);let A=y[r]||y,S=A[b];if(s(S,x)&&b in y)return!0;let _=c(y,b,x,S);return _&&l.setProperty(A,b,x,w,S)?(d(y,b,y[b],S),!0):!_},defineProperty(y,b,x){if(!l.isSameDescriptor(x,y,b)){let w=y[b];c(y,b,x.value,w)&&l.defineProperty(y,b,x,w)&&d(y,b,x.value,w)}return!0},deleteProperty(y,b){if(!Reflect.has(y,b))return!0;let x=Reflect.get(y,b),w=c(y,b,void 0,x);return w&&l.deleteProperty(y,b,x)?(d(y,b,void 0,x),!0):!w},apply(y,b,x){let w=b[r]||b;if(l.isUnsubscribed)return Reflect.apply(y,w,x);if((o===!1||o!==!0&&!o.includes(y.name))&&no.isHandledType(w)){let A=mr.initial(l.getPath(y)),S=no.isHandledMethod(w,y.name);u.start(w,A,x);let _=Reflect.apply(y,u.preferredThisArg(y,b,w),S?x.map(T=>f(T)):x),M=u.isChanged(w,s),C=u.stop();if(no.isHandledType(_)&&S&&(b instanceof Map&&y.name==="get"&&(A=mr.concat(A,x[0])),_=l.getProxy(_,A,m)),M){let T={name:y.name,args:x,result:_},P=u.isCloning?mr.initial(A):A,O=u.isCloning?mr.last(A):"";c(mr.get(e,P),O,w,C,T)?p(P,O,w,C,T):u.undo(w)}return(b instanceof Map||b instanceof Set)&&aO(_)?oO(_,y,b,A,g):_}return Reflect.apply(y,b,x)}},v=l.getProxy(e,i.pathAsArray?[]:"",m);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};wg.target=e=>e&&e[xg]||e;wg.unsubscribe=e=>e[Bw]||e;var Ly=wg,yO=typeof global=="object"&&global&&global.Object===Object&&global,Gw=yO,xO=typeof self=="object"&&self&&self.Object===Object&&self,bO=Gw||xO||Function("return this")(),Hr=bO,wO=Hr.Symbol,Er=wO,Vw=Object.prototype,_O=Vw.hasOwnProperty,AO=Vw.toString,wl=Er?Er.toStringTag:void 0;function SO(e){var t=_O.call(e,wl),i=e[wl];try{e[wl]=void 0;var r=!0}catch{}var s=AO.call(e);return r&&(t?e[wl]=i:delete e[wl]),s}var MO=SO,EO=Object.prototype,CO=EO.toString;function TO(e){return CO.call(e)}var PO=TO,DO="[object Null]",OO="[object Undefined]",Iy=Er?Er.toStringTag:void 0;function LO(e){return e==null?e===void 0?OO:DO:Iy&&Iy in Object(e)?MO(e):PO(e)}var Sa=LO;function IO(e){return e!=null&&typeof e=="object"}var Hs=IO,RO="[object Symbol]";function BO(e){return typeof e=="symbol"||Hs(e)&&Sa(e)==RO}var du=BO;function NO(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 Hw=NO,zO=Array.isArray,vs=zO,UO=1/0,Ry=Er?Er.prototype:void 0,By=Ry?Ry.toString:void 0;function Ww(e){if(typeof e=="string")return e;if(vs(e))return Hw(e,Ww)+"";if(du(e))return By?By.call(e):"";var t=e+"";return t=="0"&&1/e==-UO?"-0":t}var FO=Ww,kO=/\s/;function jO(e){for(var t=e.length;t--&&kO.test(e.charAt(t)););return t}var GO=jO,VO=/^\s+/;function HO(e){return e&&e.slice(0,GO(e)+1).replace(VO,"")}var WO=HO;function XO(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ys=XO,Ny=0/0,qO=/^[-+]0x[0-9a-f]+$/i,YO=/^0b[01]+$/i,QO=/^0o[0-7]+$/i,ZO=parseInt;function KO(e){if(typeof e=="number")return e;if(du(e))return Ny;if(ys(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ys(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=WO(e);var i=YO.test(e);return i||QO.test(e)?ZO(e.slice(2),i?2:8):qO.test(e)?Ny:+e}var zy=KO;function JO(e){return e}var $O=JO,eL="[object AsyncFunction]",tL="[object Function]",iL="[object GeneratorFunction]",rL="[object Proxy]";function sL(e){if(!ys(e))return!1;var t=Sa(e);return t==tL||t==iL||t==eL||t==rL}var Xw=sL,nL=Hr["__core-js_shared__"],Pp=nL,Uy=function(){var e=/[^.]+$/.exec(Pp&&Pp.keys&&Pp.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function aL(e){return!!Uy&&Uy in e}var oL=aL,lL=Function.prototype,hL=lL.toString;function cL(e){if(e!=null){try{return hL.call(e)}catch{}try{return e+""}catch{}}return""}var Ma=cL,dL=/[\\^$.*+?()[\]{}|]/g,uL=/^\[object .+?Constructor\]$/,pL=Function.prototype,fL=Object.prototype,mL=pL.toString,gL=fL.hasOwnProperty,vL=RegExp("^"+mL.call(gL).replace(dL,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yL(e){if(!ys(e)||oL(e))return!1;var t=Xw(e)?vL:uL;return t.test(Ma(e))}var xL=yL;function bL(e,t){return e?.[t]}var wL=bL;function _L(e,t){var i=wL(e,t);return xL(i)?i:void 0}var Ea=_L,AL=Ea(Hr,"WeakMap"),Wf=AL,Fy=Object.create,SL=function(){function e(){}return function(t){if(!ys(t))return{};if(Fy)return Fy(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),ML=SL;function EL(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 CL=EL;function TL(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var PL=TL,DL=800,OL=16,LL=Date.now;function IL(e){var t=0,i=0;return function(){var r=LL(),s=OL-(r-i);if(i=r,s>0){if(++t>=DL)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var RL=IL;function BL(e){return function(){return e}}var NL=BL,zL=function(){try{var e=Ea(Object,"defineProperty");return e({},"",{}),e}catch{}}(),wd=zL,UL=wd?function(e,t){return wd(e,"toString",{configurable:!0,enumerable:!1,value:NL(t),writable:!0})}:$O,FL=UL,kL=RL(FL),jL=kL;function GL(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var VL=GL,HL=9007199254740991,WL=/^(?:0|[1-9]\d*)$/;function XL(e,t){var i=typeof e;return t=t??HL,!!t&&(i=="number"||i!="symbol"&&WL.test(e))&&e>-1&&e%1==0&&e<t}var _g=XL;function qL(e,t,i){t=="__proto__"&&wd?wd(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var qw=qL;function YL(e,t){return e===t||e!==e&&t!==t}var Ag=YL,QL=Object.prototype,ZL=QL.hasOwnProperty;function KL(e,t,i){var r=e[t];(!(ZL.call(e,t)&&Ag(r,i))||i===void 0&&!(t in e))&&qw(e,t,i)}var Sg=KL;function JL(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?qw(i,o,l):Sg(i,o,l)}return i}var Rh=JL,ky=Math.max;function $L(e,t,i){return t=ky(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,n=ky(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),CL(e,this,o)}}var eI=$L,tI=9007199254740991;function iI(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=tI}var Mg=iI;function rI(e){return e!=null&&Mg(e.length)&&!Xw(e)}var Yw=rI,sI=Object.prototype;function nI(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||sI;return e===i}var Eg=nI;function aI(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var oI=aI,lI="[object Arguments]";function hI(e){return Hs(e)&&Sa(e)==lI}var jy=hI,Qw=Object.prototype,cI=Qw.hasOwnProperty,dI=Qw.propertyIsEnumerable,uI=jy(function(){return arguments}())?jy:function(e){return Hs(e)&&cI.call(e,"callee")&&!dI.call(e,"callee")},Cg=uI;function pI(){return!1}var fI=pI,Zw=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gy=Zw&&typeof module=="object"&&module&&!module.nodeType&&module,mI=Gy&&Gy.exports===Zw,Vy=mI?Hr.Buffer:void 0,gI=Vy?Vy.isBuffer:void 0,vI=gI||fI,_d=vI,yI="[object Arguments]",xI="[object Array]",bI="[object Boolean]",wI="[object Date]",_I="[object Error]",AI="[object Function]",SI="[object Map]",MI="[object Number]",EI="[object Object]",CI="[object RegExp]",TI="[object Set]",PI="[object String]",DI="[object WeakMap]",OI="[object ArrayBuffer]",LI="[object DataView]",II="[object Float32Array]",RI="[object Float64Array]",BI="[object Int8Array]",NI="[object Int16Array]",zI="[object Int32Array]",UI="[object Uint8Array]",FI="[object Uint8ClampedArray]",kI="[object Uint16Array]",jI="[object Uint32Array]",Tt={};Tt[II]=Tt[RI]=Tt[BI]=Tt[NI]=Tt[zI]=Tt[UI]=Tt[FI]=Tt[kI]=Tt[jI]=!0;Tt[yI]=Tt[xI]=Tt[OI]=Tt[bI]=Tt[LI]=Tt[wI]=Tt[_I]=Tt[AI]=Tt[SI]=Tt[MI]=Tt[EI]=Tt[CI]=Tt[TI]=Tt[PI]=Tt[DI]=!1;function GI(e){return Hs(e)&&Mg(e.length)&&!!Tt[Sa(e)]}var VI=GI;function HI(e){return function(t){return e(t)}}var Tg=HI,Kw=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eh=Kw&&typeof module=="object"&&module&&!module.nodeType&&module,WI=eh&&eh.exports===Kw,Dp=WI&&Gw.process,XI=function(){try{var e=eh&&eh.require&&eh.require("util").types;return e||Dp&&Dp.binding&&Dp.binding("util")}catch{}}(),No=XI,Hy=No&&No.isTypedArray,qI=Hy?Tg(Hy):VI,Jw=qI,YI=Object.prototype,QI=YI.hasOwnProperty;function ZI(e,t){var i=vs(e),r=!i&&Cg(e),s=!i&&!r&&_d(e),n=!i&&!r&&!s&&Jw(e),a=i||r||s||n,o=a?oI(e.length,String):[],l=o.length;for(var h in e)(t||QI.call(e,h))&&!(a&&(h=="length"||s&&(h=="offset"||h=="parent")||n&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||_g(h,l)))&&o.push(h);return o}var $w=ZI;function KI(e,t){return function(i){return e(t(i))}}var e_=KI,JI=e_(Object.keys,Object),$I=JI,e4=Object.prototype,t4=e4.hasOwnProperty;function i4(e){if(!Eg(e))return $I(e);var t=[];for(var i in Object(e))t4.call(e,i)&&i!="constructor"&&t.push(i);return t}var r4=i4;function s4(e){return Yw(e)?$w(e):r4(e)}var Pg=s4;function n4(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var a4=n4,o4=Object.prototype,l4=o4.hasOwnProperty;function h4(e){if(!ys(e))return a4(e);var t=Eg(e),i=[];for(var r in e)r=="constructor"&&(t||!l4.call(e,r))||i.push(r);return i}var c4=h4;function d4(e){return Yw(e)?$w(e,!0):c4(e)}var Dg=d4,u4=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,p4=/^\w*$/;function f4(e,t){if(vs(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||du(e)?!0:p4.test(e)||!u4.test(e)||t!=null&&e in Object(t)}var m4=f4,g4=Ea(Object,"create"),ph=g4;function v4(){this.__data__=ph?ph(null):{},this.size=0}var y4=v4;function x4(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var b4=x4,w4="__lodash_hash_undefined__",_4=Object.prototype,A4=_4.hasOwnProperty;function S4(e){var t=this.__data__;if(ph){var i=t[e];return i===w4?void 0:i}return A4.call(t,e)?t[e]:void 0}var M4=S4,E4=Object.prototype,C4=E4.hasOwnProperty;function T4(e){var t=this.__data__;return ph?t[e]!==void 0:C4.call(t,e)}var P4=T4,D4="__lodash_hash_undefined__";function O4(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ph&&t===void 0?D4:t,this}var L4=O4;function Qo(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])}}Qo.prototype.clear=y4;Qo.prototype.delete=b4;Qo.prototype.get=M4;Qo.prototype.has=P4;Qo.prototype.set=L4;var Wy=Qo;function I4(){this.__data__=[],this.size=0}var R4=I4;function B4(e,t){for(var i=e.length;i--;)if(Ag(e[i][0],t))return i;return-1}var uu=B4,N4=Array.prototype,z4=N4.splice;function U4(e){var t=this.__data__,i=uu(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():z4.call(t,i,1),--this.size,!0}var F4=U4;function k4(e){var t=this.__data__,i=uu(t,e);return i<0?void 0:t[i][1]}var j4=k4;function G4(e){return uu(this.__data__,e)>-1}var V4=G4;function H4(e,t){var i=this.__data__,r=uu(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var W4=H4;function Zo(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])}}Zo.prototype.clear=R4;Zo.prototype.delete=F4;Zo.prototype.get=j4;Zo.prototype.has=V4;Zo.prototype.set=W4;var pu=Zo,X4=Ea(Hr,"Map"),fh=X4;function q4(){this.size=0,this.__data__={hash:new Wy,map:new(fh||pu),string:new Wy}}var Y4=q4;function Q4(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Z4=Q4;function K4(e,t){var i=e.__data__;return Z4(t)?i[typeof t=="string"?"string":"hash"]:i.map}var fu=K4;function J4(e){var t=fu(this,e).delete(e);return this.size-=t?1:0,t}var $4=J4;function eR(e){return fu(this,e).get(e)}var tR=eR;function iR(e){return fu(this,e).has(e)}var rR=iR;function sR(e,t){var i=fu(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var nR=sR;function Ko(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])}}Ko.prototype.clear=Y4;Ko.prototype.delete=$4;Ko.prototype.get=tR;Ko.prototype.has=rR;Ko.prototype.set=nR;var mu=Ko,aR="Expected a function";function Og(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(aR);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(Og.Cache||mu),i}Og.Cache=mu;var oR=Og,lR=500;function hR(e){var t=oR(e,function(r){return i.size===lR&&i.clear(),r}),i=t.cache;return t}var cR=hR,dR=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,uR=/\\(\\)?/g,pR=cR(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(dR,function(i,r,s,n){t.push(s?n.replace(uR,"$1"):r||i)}),t}),fR=pR;function mR(e){return e==null?"":FO(e)}var gR=mR;function vR(e,t){return vs(e)?e:m4(e,t)?[e]:fR(gR(e))}var Jo=vR,yR=1/0;function xR(e){if(typeof e=="string"||du(e))return e;var t=e+"";return t=="0"&&1/e==-yR?"-0":t}var gu=xR;function bR(e,t){t=Jo(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[gu(t[i++])];return i&&i==r?e:void 0}var t_=bR;function wR(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var Lg=wR,Xy=Er?Er.isConcatSpreadable:void 0;function _R(e){return vs(e)||Cg(e)||!!(Xy&&e&&e[Xy])}var AR=_R;function i_(e,t,i,r,s){var n=-1,a=e.length;for(i||(i=AR),s||(s=[]);++n<a;){var o=e[n];t>0&&i(o)?t>1?i_(o,t-1,i,r,s):Lg(s,o):r||(s[s.length]=o)}return s}var SR=i_;function MR(e){var t=e==null?0:e.length;return t?SR(e,1):[]}var ER=MR;function CR(e){return jL(eI(e,void 0,ER),e+"")}var r_=CR,TR=e_(Object.getPrototypeOf,Object),Ig=TR,PR="[object Object]",DR=Function.prototype,OR=Object.prototype,s_=DR.toString,LR=OR.hasOwnProperty,IR=s_.call(Object);function RR(e){if(!Hs(e)||Sa(e)!=PR)return!1;var t=Ig(e);if(t===null)return!0;var i=LR.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&s_.call(i)==IR}var BR=RR;function NR(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 zR=NR;function UR(){this.__data__=new pu,this.size=0}var FR=UR;function kR(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var jR=kR;function GR(e){return this.__data__.get(e)}var VR=GR;function HR(e){return this.__data__.has(e)}var WR=HR,XR=200;function qR(e,t){var i=this.__data__;if(i instanceof pu){var r=i.__data__;if(!fh||r.length<XR-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new mu(r)}return i.set(e,t),this.size=i.size,this}var YR=qR;function $o(e){var t=this.__data__=new pu(e);this.size=t.size}$o.prototype.clear=FR;$o.prototype.delete=jR;$o.prototype.get=VR;$o.prototype.has=WR;$o.prototype.set=YR;var $c=$o;function QR(e,t){return e&&Rh(t,Pg(t),e)}var ZR=QR;function KR(e,t){return e&&Rh(t,Dg(t),e)}var JR=KR,n_=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qy=n_&&typeof module=="object"&&module&&!module.nodeType&&module,$R=qy&&qy.exports===n_,Yy=$R?Hr.Buffer:void 0,Qy=Yy?Yy.allocUnsafe:void 0;function eB(e,t){if(t)return e.slice();var i=e.length,r=Qy?Qy(i):new e.constructor(i);return e.copy(r),r}var tB=eB;function iB(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 rB=iB;function sB(){return[]}var a_=sB,nB=Object.prototype,aB=nB.propertyIsEnumerable,Zy=Object.getOwnPropertySymbols,oB=Zy?function(e){return e==null?[]:(e=Object(e),rB(Zy(e),function(t){return aB.call(e,t)}))}:a_,Rg=oB;function lB(e,t){return Rh(e,Rg(e),t)}var hB=lB,cB=Object.getOwnPropertySymbols,dB=cB?function(e){for(var t=[];e;)Lg(t,Rg(e)),e=Ig(e);return t}:a_,o_=dB;function uB(e,t){return Rh(e,o_(e),t)}var pB=uB;function fB(e,t,i){var r=t(e);return vs(e)?r:Lg(r,i(e))}var l_=fB;function mB(e){return l_(e,Pg,Rg)}var Xf=mB;function gB(e){return l_(e,Dg,o_)}var h_=gB,vB=Ea(Hr,"DataView"),qf=vB,yB=Ea(Hr,"Promise"),Yf=yB,xB=Ea(Hr,"Set"),Qf=xB,Ky="[object Map]",bB="[object Object]",Jy="[object Promise]",$y="[object Set]",e1="[object WeakMap]",t1="[object DataView]",wB=Ma(qf),_B=Ma(fh),AB=Ma(Yf),SB=Ma(Qf),MB=Ma(Wf),$n=Sa;(qf&&$n(new qf(new ArrayBuffer(1)))!=t1||fh&&$n(new fh)!=Ky||Yf&&$n(Yf.resolve())!=Jy||Qf&&$n(new Qf)!=$y||Wf&&$n(new Wf)!=e1)&&($n=function(e){var t=Sa(e),i=t==bB?e.constructor:void 0,r=i?Ma(i):"";if(r)switch(r){case wB:return t1;case _B:return Ky;case AB:return Jy;case SB:return $y;case MB:return e1}return t});var mh=$n,EB=Object.prototype,CB=EB.hasOwnProperty;function TB(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&CB.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var PB=TB,DB=Hr.Uint8Array,Ad=DB;function OB(e){var t=new e.constructor(e.byteLength);return new Ad(t).set(new Ad(e)),t}var Bg=OB;function LB(e,t){var i=t?Bg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var IB=LB,RB=/\w*$/;function BB(e){var t=new e.constructor(e.source,RB.exec(e));return t.lastIndex=e.lastIndex,t}var NB=BB,i1=Er?Er.prototype:void 0,r1=i1?i1.valueOf:void 0;function zB(e){return r1?Object(r1.call(e)):{}}var UB=zB;function FB(e,t){var i=t?Bg(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var kB=FB,jB="[object Boolean]",GB="[object Date]",VB="[object Map]",HB="[object Number]",WB="[object RegExp]",XB="[object Set]",qB="[object String]",YB="[object Symbol]",QB="[object ArrayBuffer]",ZB="[object DataView]",KB="[object Float32Array]",JB="[object Float64Array]",$B="[object Int8Array]",e5="[object Int16Array]",t5="[object Int32Array]",i5="[object Uint8Array]",r5="[object Uint8ClampedArray]",s5="[object Uint16Array]",n5="[object Uint32Array]";function a5(e,t,i){var r=e.constructor;switch(t){case QB:return Bg(e);case jB:case GB:return new r(+e);case ZB:return IB(e,i);case KB:case JB:case $B:case e5:case t5:case i5:case r5:case s5:case n5:return kB(e,i);case VB:return new r;case HB:case qB:return new r(e);case WB:return NB(e);case XB:return new r;case YB:return UB(e)}}var o5=a5;function l5(e){return typeof e.constructor=="function"&&!Eg(e)?ML(Ig(e)):{}}var h5=l5,c5="[object Map]";function d5(e){return Hs(e)&&mh(e)==c5}var u5=d5,s1=No&&No.isMap,p5=s1?Tg(s1):u5,f5=p5,m5="[object Set]";function g5(e){return Hs(e)&&mh(e)==m5}var v5=g5,n1=No&&No.isSet,y5=n1?Tg(n1):v5,x5=y5,b5=1,w5=2,_5=4,c_="[object Arguments]",A5="[object Array]",S5="[object Boolean]",M5="[object Date]",E5="[object Error]",d_="[object Function]",C5="[object GeneratorFunction]",T5="[object Map]",P5="[object Number]",u_="[object Object]",D5="[object RegExp]",O5="[object Set]",L5="[object String]",I5="[object Symbol]",R5="[object WeakMap]",B5="[object ArrayBuffer]",N5="[object DataView]",z5="[object Float32Array]",U5="[object Float64Array]",F5="[object Int8Array]",k5="[object Int16Array]",j5="[object Int32Array]",G5="[object Uint8Array]",V5="[object Uint8ClampedArray]",H5="[object Uint16Array]",W5="[object Uint32Array]",Et={};Et[c_]=Et[A5]=Et[B5]=Et[N5]=Et[S5]=Et[M5]=Et[z5]=Et[U5]=Et[F5]=Et[k5]=Et[j5]=Et[T5]=Et[P5]=Et[u_]=Et[D5]=Et[O5]=Et[L5]=Et[I5]=Et[G5]=Et[V5]=Et[H5]=Et[W5]=!0;Et[E5]=Et[d_]=Et[R5]=!1;function ed(e,t,i,r,s,n){var a,o=t&b5,l=t&w5,h=t&_5;if(i&&(a=s?i(e,r,s,n):i(e)),a!==void 0)return a;if(!ys(e))return e;var u=vs(e);if(u){if(a=PB(e),!o)return PL(e,a)}else{var c=mh(e),d=c==d_||c==C5;if(_d(e))return tB(e,o);if(c==u_||c==c_||d&&!s){if(a=l||d?{}:h5(e),!o)return l?pB(e,JR(a,e)):hB(e,ZR(a,e))}else{if(!Et[c])return s?e:{};a=o5(e,c,o)}}n||(n=new $c);var p=n.get(e);if(p)return p;n.set(e,a),x5(e)?e.forEach(function(m){a.add(ed(m,t,i,m,e,n))}):f5(e)&&e.forEach(function(m,v){a.set(v,ed(m,t,i,v,e,n))});var f=h?l?h_:Xf:l?Dg:Pg,g=u?void 0:f(e);return VL(g||e,function(m,v){g&&(v=m,m=e[v]),Sg(a,v,ed(m,t,i,v,e,n))}),a}var p_=ed,X5=1,q5=4;function Y5(e){return p_(e,X5|q5)}var vu=Y5,Q5="__lodash_hash_undefined__";function Z5(e){return this.__data__.set(e,Q5),this}var K5=Z5;function J5(e){return this.__data__.has(e)}var $5=J5;function Sd(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new mu;++t<i;)this.add(e[t])}Sd.prototype.add=Sd.prototype.push=K5;Sd.prototype.has=$5;var eN=Sd;function tN(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 iN=tN;function rN(e,t){return e.has(t)}var sN=rN,nN=1,aN=2;function oN(e,t,i,r,s,n){var a=i&nN,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&aN?new eN: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(!iN(t,function(v,y){if(!sN(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 f_=oN;function lN(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var hN=lN;function cN(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var dN=cN,uN=1,pN=2,fN="[object Boolean]",mN="[object Date]",gN="[object Error]",vN="[object Map]",yN="[object Number]",xN="[object RegExp]",bN="[object Set]",wN="[object String]",_N="[object Symbol]",AN="[object ArrayBuffer]",SN="[object DataView]",a1=Er?Er.prototype:void 0,Op=a1?a1.valueOf:void 0;function MN(e,t,i,r,s,n,a){switch(i){case SN:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case AN:return!(e.byteLength!=t.byteLength||!n(new Ad(e),new Ad(t)));case fN:case mN:case yN:return Ag(+e,+t);case gN:return e.name==t.name&&e.message==t.message;case xN:case wN:return e==t+"";case vN:var o=hN;case bN:var l=r&uN;if(o||(o=dN),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=f_(o(e),o(t),r,s,n,a);return a.delete(e),u;case _N:if(Op)return Op.call(e)==Op.call(t)}return!1}var EN=MN,CN=1,TN=Object.prototype,PN=TN.hasOwnProperty;function DN(e,t,i,r,s,n){var a=i&CN,o=Xf(e),l=o.length,h=Xf(t),u=h.length;if(l!=u&&!a)return!1;for(var c=l;c--;){var d=o[c];if(!(a?d in t:PN.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 b=a?r(y,v,d,t,e,n):r(v,y,d,e,t,n);if(!(b===void 0?v===y||s(v,y,i,r,n):b)){g=!1;break}m||(m=d=="constructor")}if(g&&!m){var x=e.constructor,w=t.constructor;x!=w&&"constructor"in e&&"constructor"in t&&!(typeof x=="function"&&x instanceof x&&typeof w=="function"&&w instanceof w)&&(g=!1)}return n.delete(e),n.delete(t),g}var ON=DN,LN=1,o1="[object Arguments]",l1="[object Array]",wc="[object Object]",IN=Object.prototype,h1=IN.hasOwnProperty;function RN(e,t,i,r,s,n){var a=vs(e),o=vs(t),l=a?l1:mh(e),h=o?l1:mh(t);l=l==o1?wc:l,h=h==o1?wc:h;var u=l==wc,c=h==wc,d=l==h;if(d&&_d(e)){if(!_d(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new $c),a||Jw(e)?f_(e,t,i,r,s,n):EN(e,t,l,i,r,s,n);if(!(i&LN)){var p=u&&h1.call(e,"__wrapped__"),f=c&&h1.call(t,"__wrapped__");if(p||f){var g=p?e.value():e,m=f?t.value():t;return n||(n=new $c),s(g,m,i,r,n)}}return d?(n||(n=new $c),ON(e,t,i,r,s,n)):!1}var BN=RN;function m_(e,t,i,r,s){return e===t?!0:e==null||t==null||!Hs(e)&&!Hs(t)?e!==e&&t!==t:BN(e,t,i,r,m_,s)}var NN=m_;function zN(e,t){return e!=null&&t in Object(e)}var UN=zN;function FN(e,t,i){t=Jo(t,e);for(var r=-1,s=t.length,n=!1;++r<s;){var a=gu(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&&Mg(s)&&_g(a,s)&&(vs(e)||Cg(e)))}var kN=FN;function jN(e,t){return e!=null&&kN(e,t,UN)}var GN=jN,VN=function(){return Hr.Date.now()},Lp=VN,HN="Expected a function",WN=Math.max,XN=Math.min;function qN(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(HN);t=zy(t)||0,ys(i)&&(u=!!i.leading,c="maxWait"in i,n=c?WN(zy(i.maxWait)||0,t):n,d="trailing"in i?!!i.trailing:d);function p(A){var S=r,_=s;return r=s=void 0,h=A,a=e.apply(_,S),a}function f(A){return h=A,o=setTimeout(v,t),u?p(A):a}function g(A){var S=A-l,_=A-h,M=t-S;return c?XN(M,n-_):M}function m(A){var S=A-l,_=A-h;return l===void 0||S>=t||S<0||c&&_>=n}function v(){var A=Lp();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 b(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function x(){return o===void 0?a:y(Lp())}function w(){var A=Lp(),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 w.cancel=b,w.flush=x,w}var g_=qN;function YN(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var QN=YN;function ZN(e,t){return t.length<2?e:t_(e,zR(t,0,-1))}var KN=ZN;function JN(e,t){return NN(e,t)}var Ng=JN;function $N(e,t){return t=Jo(t,e),e=KN(e,t),e==null||delete e[gu(QN(t))]}var ez=$N;function tz(e){return BR(e)?void 0:e}var iz=tz,rz=1,sz=2,nz=4,az=r_(function(e,t){var i={};if(e==null)return i;var r=!1;t=Hw(t,function(n){return n=Jo(n,e),r||(r=n.length>1),n}),Rh(e,h_(e),i),r&&(i=p_(i,rz|sz|nz,iz));for(var s=t.length;s--;)ez(i,t[s]);return i}),Zf=az;function oz(e,t,i,r){if(!ys(e))return e;t=Jo(t,e);for(var s=-1,n=t.length,a=n-1,o=e;o!=null&&++s<n;){var l=gu(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=ys(u)?u:_g(t[s+1])?[]:{})}Sg(o,l,h),o=o[l]}return e}var lz=oz;function hz(e,t,i){for(var r=-1,s=t.length,n={};++r<s;){var a=t[r],o=t_(e,a);i(o,a)&&lz(n,Jo(a,e),o)}return n}var cz=hz;function dz(e,t){return cz(e,t,function(i,r){return GN(e,r)})}var uz=dz,pz=r_(function(e,t){return e==null?{}:uz(e,t)}),gh=pz,v_,fz=new Promise(e=>{v_=e}),c1=!1;async function mz(){if(c1)return;let e=await import("./physics.js");await e.init(),v_(e),c1=!0}var Qt=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,Qt.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,Qt.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,Qt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function zg(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"&&zg(r)}return Object.freeze(e)}function gz(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 y_=class extends Error{};function Ip(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function yn(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 Ug(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 vz(){return typeof process<"u"}function x_(e,t){for(let i of e)t(i.id,i.data)!==!0&&x_(i.children,t)}function b_(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)b_(i,t)}var ji=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,ji.prototype)}deepFreeze(){let e=0;for(;e<this.length;)zg(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}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&&b_(i,t)}}traverse(e){x_(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,ji.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 y_("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)=>gz(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 yn(0,i,i);{let s=r[0].fi;return yn(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 yn(a,a+i,i)}else return yn(s.fi,n.fi,i)}}},Md;(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})(Md||(Md={}));var it=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,it.prototype)}deepFreeze(){let e=0;for(;e<this.length;)zg(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,it.prototype);let t=e;return vz()||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 yn(0,t,t);{let r=i[0].fi;return yn(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 yn(n,n+t,t)}else return yn(r.fi,s.fi,t)}}};function zo(e){return e&&typeof e=="object"&&e instanceof mi}var mi=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&&!zo(i))return null;r+=1}i=i?Ip(i):new mi;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=Ip(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=Ip(o);l[e.path[r-1]]=i,i=l}else{let l=new mi;l[e.path[r-1]]=i,i=l}}r-=1}let n=Object.setPrototypeOf(i,mi.prototype),a={...e,props:s};return{data:n,actual:e,reverse:a}}},fa;(e=>{function t(s,n){return vh(s,n)??s}e.apply=t;function i(s,n){return kg(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=ps.zoomOnce(l,o[a]),l===void 0)return n;if(!zo(l))return;a+=1}if(l===void 0)return n;if(zo(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=Fg([n],l);return h?(console.log(h),h):n}else return n}e.filterOp=r})(fa||(fa={}));function Fg(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=vh(s.data,t[n]);if(i=i||a!==void 0,a===void 0&&(a=s.data),s.children){let o=Fg(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 yz(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let n=s.id,a=vh(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 vh(e,t){if(!zo(t))return t;if(e instanceof ji){let i=Fg(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof it)return yz(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,n)=>{let a=vh(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 mi)return kg(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,n]of Object.entries(e)){let a=vh(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 kg(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!zo(t))return t;if(!zo(e))return fa.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 mi;for(let s of i){let n=kg(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=n}return r}function xz(e,t){let i={cur:[],result:[],len:0};return e=yh(e,t,i)??e,[e,i.result]}function Ed(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Cd(e){e&&(e.len-=1)}function bz(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function w_(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=yh(n.data,t,Ed(i,a));Cd(i),r=r||l!==void 0,l===void 0&&(l=n.data);let h=w_(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 wz(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=yh(n.data,t,Ed(i,a));return Cd(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 yh(e,t,i){if(e instanceof ji){let r=w_(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof it)return wz(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((n,a)=>{let o=yh(n,t,Ed(i,a));return Cd(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"&&!Ug(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=yh(a,t,Ed(i,n));Cd(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];if(r!==void 0){if(e.length!==36)throw new Error("for now you should only call this method when the key is a uuid");bz(i)}return r}else return}}var Kf;(e=>{function t(i,r){let s=ps.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})(Kf||(Kf={}));var tr;(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 mi&&h.type===0&&(d=l.runOp({...h,path:u.slice(c.length)}),d===null&&(d=void 0)),c.length===u.length&&(l instanceof ji||l instanceof it||l instanceof Qt?d=l.runOp(h):d=Md.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 ji){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof it){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof Qt){if(typeof v=="number")throw new Error("illegal arg");g=y.modifyById(v,g)}else if(y instanceof mi){let b={...y,[v]:g};g=Object.setPrototypeOf(b,mi.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 b=g;g=[...y],g[v]=b}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 ji){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof it){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})(tr||(tr={}));var d1;(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=>tr.subsumed(c,d))),...u]}e.compress=n;function a(h,u){return h.every(c=>u.every(d=>tr.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=ps.zoom(c,[...f.path,f.id]),m=tr.apply(c,{...f,type:2});if(m!==null){c=m.data;let[v,y]=xz(c,{[f.id]:g});c=v;for(let b of y){let x=b[b.length-1];b.splice(b.length-1,1),d.push({type:0,path:b,props:{[x]:g}}),p.push({type:0,path:b,props:{[x]:f.id}})}p.push(m.reverse),d.push(m.actual)}}else{let g=tr.apply(c,f);g!==null&&(d.push(g.actual),c=g.data,p.push(g.reverse))}}catch(g){if(g instanceof y_)return null;throw g}return{data:c,actual:d,reverse:p.reverse()}}e.apply=l})(d1||(d1={}));var __=Symbol(),_z=Symbol(),yu=Symbol(),Bh=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof S_);){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[yu];i&&i(),delete this._children[e]}}}},Az=class extends Bh{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,Md.runOp(this._current,e),e.path)}},Sz=class extends Bh{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,Qt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},A_={get(e,t){if(t===yu)return()=>{e._parent=null};if(t===__)return e._current;if(t===_z)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=xu(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]}}},Mz={...A_,set(e,t,i){let r={type:0,props:{[t]:Si(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}},Ez={...A_,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}},jg=class extends Bh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[yu]=()=>{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=xu(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)}},Gg=class extends Bh{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[yu]=()=>{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=xu(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 Rp(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&ps.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var S_=class extends Bh{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){Rp(this.ts,t,e),Rp(this.actual,i,e),Rp(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function xu(e,t,i){return i instanceof ji?new jg(e,t,i):i instanceof it?new Gg(e,t,i):i instanceof Qt?new Proxy(new Sz(e,t,i),Ez):i!==null&&typeof i=="object"?Ug(i)?i:new Proxy(new Az(e,t,i),Mz):i}function M_(e){let t=new S_(e);return[xu(t,"",e),t]}function Td(e,t){let[i,r]=M_(e);return t(i),r.result()}function Si(e){return e instanceof jg||e instanceof Gg?e._current:e!==null&&typeof e=="object"?e[__]:e}var ps;(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 ji||n instanceof jg)&&typeof a=="string"||(n instanceof it||n instanceof Gg)&&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})(ps||(ps={}));function Cz(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 pn(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 E_=class{},u1=class extends E_{constructor(e){super(),this.id=e}},p1=class extends E_{constructor(e){super(),this.data=e}},Jf;try{Jf=new TextDecoder}catch{}var Se,En,Z=0,C_=[],$f=C_,em=0,zi={},pt,xn,gr=0,as=0,Qi,Gs,Ri=[],ft,f1={useRecords:!1,mapsAsObjects:!0},T_=class{},P_=new T_;P_.name="MessagePack 0xC1";var Uo=!1,Pd=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(Se)return B_(()=>(im(),this?this.unpack(e,t):Pd.prototype.unpack.call(f1,e,t)));En=t>-1?t:e.length,Z=0,em=0,as=0,xn=null,$f=C_,Qi=null,Se=e;try{ft=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw Se=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 Pd){if(zi=this,this.structures)return pt=this.structures,_c();(!pt||pt.length>0)&&(pt=[])}else zi=f1,(!pt||pt.length>0)&&(pt=[]);return _c()}unpackMultiple(e,t){let i,r=0;try{Uo=!0;let s=e.length,n=this?this.unpack(e,s):wu.unpack(e,s);if(t){for(t(n);Z<s;)if(r=Z,t(_c())===!1)return}else{for(i=[n];Z<s;)r=Z,i.push(_c());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Uo=!1,im()}}_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 _c(){try{if(!zi.trusted&&!Uo){let t=pt.sharedLength||0;t<pt.length&&(pt.length=t)}let e=Nt();if(Z==En)pt.restoreStructures&&m1(),pt=null,Se=null,Gs&&(Gs=null);else if(Z>En){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Uo)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw pt.restoreStructures&&m1(),im(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function m1(){for(let e in pt.restoreStructures)pt[e]=pt.restoreStructures[e];pt.restoreStructures=null}function Nt(){let e=Se[Z++];if(e<160)if(e<128){if(e<64)return e;{let t=pt[e&63]||zi.getStructures&&D_()[e&63];return t?(t.read||(t.read=Vg(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,zi.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[L_()]=Nt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Nt(),Nt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Nt();return t}else if(e<192){let t=e-160;if(as>=Z)return xn.slice(Z-gr,(Z+=t)-gr);if(as==0&&En<140){let i=t<16?Hg(t):O_(t);if(i!=null)return i}return tm(t)}else{let t;switch(e){case 192:return null;case 193:return Qi?(t=Nt(),t>0?Qi[1].slice(Qi.position1,Qi.position1+=t):Qi[0].slice(Qi.position0,Qi.position0-=t)):P_;case 194:return!1;case 195:return!0;case 196:return Bp(Se[Z++]);case 197:return t=ft.getUint16(Z),Z+=2,Bp(t);case 198:return t=ft.getUint32(Z),Z+=4,Bp(t);case 199:return qn(Se[Z++]);case 200:return t=ft.getUint16(Z),Z+=2,qn(t);case 201:return t=ft.getUint32(Z),Z+=4,qn(t);case 202:if(t=ft.getFloat32(Z),zi.useFloat32>2){let i=Wg[(Se[Z]&127)<<1|Se[Z+1]>>7];return Z+=4,(i*t+(t>0?.5:-.5)>>0)/i}return Z+=4,t;case 203:return t=ft.getFloat64(Z),Z+=8,t;case 204:return Se[Z++];case 205:return t=ft.getUint16(Z),Z+=2,t;case 206:return t=ft.getUint32(Z),Z+=4,t;case 207:return zi.int64AsNumber?(t=ft.getUint32(Z)*4294967296,t+=ft.getUint32(Z+4)):t=ft.getBigUint64(Z),Z+=8,t;case 208:return ft.getInt8(Z++);case 209:return t=ft.getInt16(Z),Z+=2,t;case 210:return t=ft.getInt32(Z),Z+=4,t;case 211:return zi.int64AsNumber?(t=ft.getInt32(Z)*4294967296,t+=ft.getUint32(Z+4)):t=ft.getBigInt64(Z),Z+=8,t;case 212:if(t=Se[Z++],t==114)return b1(Se[Z++]&63);{let i=Ri[t];if(i)return i.read?(Z++,i.read(Nt())):i.noBuffer?(Z++,i()):i(Se.subarray(Z,++Z));throw new Error("Unknown extension "+t)}case 213:return t=Se[Z],t==114?(Z++,b1(Se[Z++]&63,Se[Z++])):qn(2);case 214:return qn(4);case 215:return qn(8);case 216:return qn(16);case 217:return t=Se[Z++],as>=Z?xn.slice(Z-gr,(Z+=t)-gr):Pz(t);case 218:return t=ft.getUint16(Z),Z+=2,as>=Z?xn.slice(Z-gr,(Z+=t)-gr):Dz(t);case 219:return t=ft.getUint32(Z),Z+=4,as>=Z?xn.slice(Z-gr,(Z+=t)-gr):Oz(t);case 220:return t=ft.getUint16(Z),Z+=2,v1(t);case 221:return t=ft.getUint32(Z),Z+=4,v1(t);case 222:return t=ft.getUint16(Z),Z+=2,y1(t);case 223:return t=ft.getUint32(Z),Z+=4,y1(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 Tz=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Vg(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(n=>Tz.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Nt);return e.highByte===0&&(e.read=g1(t,e.read)),s()}let r={};for(let s=0,n=e.length;s<n;s++){let a=e[s];r[a]=Nt()}return r}return i.count=0,e.highByte===0?g1(t,i):i}var g1=(e,t)=>function(){let i=Se[Z++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=pt[r]||D_()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=Vg(s,e)),s.read()};function D_(){let e=B_(()=>(Se=null,zi.getStructures()));return pt=zi._mergeStructures(e,pt)}var tm=bu,Pz=bu,Dz=bu,Oz=bu;function bu(e){let t;if(e<16&&(t=Hg(e)))return t;if(e>64&&Jf)return Jf.decode(Se.subarray(Z,Z+=e));let i=Z+e,r=[];for(t="";Z<i;){let s=Se[Z++];if((s&128)===0)r.push(s);else if((s&224)===192){let n=Se[Z++]&63;r.push((s&31)<<6|n)}else if((s&240)===224){let n=Se[Z++]&63,a=Se[Z++]&63;r.push((s&31)<<12|n<<6|a)}else if((s&248)===240){let n=Se[Z++]&63,a=Se[Z++]&63,o=Se[Z++]&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+=li.apply(String,r),r.length=0)}return r.length>0&&(t+=li.apply(String,r)),t}function v1(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Nt();return t}function y1(e){if(zi.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[L_()]=Nt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Nt(),Nt());return t}}var li=String.fromCharCode;function O_(e){let t=Z,i=new Array(e);for(let r=0;r<e;r++){let s=Se[Z++];if((s&128)>0){Z=t;return}i[r]=s}return li.apply(String,i)}function Hg(e){if(e<4)if(e<2){if(e===0)return"";{let t=Se[Z++];if((t&128)>1){Z-=1;return}return li(t)}}else{let t=Se[Z++],i=Se[Z++];if((t&128)>0||(i&128)>0){Z-=2;return}if(e<3)return li(t,i);let r=Se[Z++];if((r&128)>0){Z-=3;return}return li(t,i,r)}else{let t=Se[Z++],i=Se[Z++],r=Se[Z++],s=Se[Z++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){Z-=4;return}if(e<6){if(e===4)return li(t,i,r,s);{let n=Se[Z++];if((n&128)>0){Z-=5;return}return li(t,i,r,s,n)}}else if(e<8){let n=Se[Z++],a=Se[Z++];if((n&128)>0||(a&128)>0){Z-=6;return}if(e<7)return li(t,i,r,s,n,a);let o=Se[Z++];if((o&128)>0){Z-=7;return}return li(t,i,r,s,n,a,o)}else{let n=Se[Z++],a=Se[Z++],o=Se[Z++],l=Se[Z++];if((n&128)>0||(a&128)>0||(o&128)>0||(l&128)>0){Z-=8;return}if(e<10){if(e===8)return li(t,i,r,s,n,a,o,l);{let h=Se[Z++];if((h&128)>0){Z-=9;return}return li(t,i,r,s,n,a,o,l,h)}}else if(e<12){let h=Se[Z++],u=Se[Z++];if((h&128)>0||(u&128)>0){Z-=10;return}if(e<11)return li(t,i,r,s,n,a,o,l,h,u);let c=Se[Z++];if((c&128)>0){Z-=11;return}return li(t,i,r,s,n,a,o,l,h,u,c)}else{let h=Se[Z++],u=Se[Z++],c=Se[Z++],d=Se[Z++];if((h&128)>0||(u&128)>0||(c&128)>0||(d&128)>0){Z-=12;return}if(e<14){if(e===12)return li(t,i,r,s,n,a,o,l,h,u,c,d);{let p=Se[Z++];if((p&128)>0){Z-=13;return}return li(t,i,r,s,n,a,o,l,h,u,c,d,p)}}else{let p=Se[Z++],f=Se[Z++];if((p&128)>0||(f&128)>0){Z-=14;return}if(e<15)return li(t,i,r,s,n,a,o,l,h,u,c,d,p,f);let g=Se[Z++];if((g&128)>0){Z-=15;return}return li(t,i,r,s,n,a,o,l,h,u,c,d,p,f,g)}}}}}function Bp(e){return zi.copyBuffers?Uint8Array.prototype.slice.call(Se,Z,Z+=e):Se.subarray(Z,Z+=e)}function qn(e){let t=Se[Z++];if(Ri[t])return Ri[t](Se.subarray(Z,Z+=e));throw new Error("Unknown extension type "+t)}var x1=new Array(4096);function L_(){let e=Se[Z++];if(e>=160&&e<192){if(e=e-160,as>=Z)return xn.slice(Z-gr,(Z+=e)-gr);if(!(as==0&&En<180))return tm(e)}else return Z--,Nt();let t=(e<<5^(e>1?ft.getUint16(Z):e>0?Se[Z]:0))&4095,i=x1[t],r=Z,s=Z+e-3,n,a=0;if(i&&i.bytes==e){for(;r<s;){if(n=ft.getUint32(r),n!=i[a++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(n=Se[r++],n!=i[a++]){r=1879048192;break}if(r===s)return Z=r,i.string;s-=3,r=Z}for(i=[],x1[t]=i,i.bytes=e;r<s;)n=ft.getUint32(r),i.push(n),r+=4;for(s+=3;r<s;)n=Se[r++],i.push(n);let o=e<16?Hg(e):O_(e);return o!=null?i.string=o:i.string=tm(e)}var b1=(e,t)=>{var i=Nt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=pt[e];return s&&s.isShared&&((pt.restoreStructures||(pt.restoreStructures=[]))[e]=s),pt[e]=i,i.read=Vg(i,r),i.read()},I_=typeof self=="object"?self:global;Ri[0]=()=>{};Ri[0].noBuffer=!0;Ri[101]=()=>{let e=Nt();return(I_[e[0]]||Error)(e[1])};Ri[105]=e=>{let t=ft.getUint32(Z-4);Gs||(Gs=new Map);let i=Se[Z],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Gs.set(t,s);let n=Nt();return s.used?Object.assign(r,n):(s.target=n,n)};Ri[112]=e=>{let t=ft.getUint32(Z-4),i=Gs.get(t);return i.used=!0,i.target};Ri[115]=()=>new Set(Nt());var R_=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");Ri[116]=e=>{let t=e[0],i=R_[t];if(!i)throw new Error("Could not find typed array for code "+t);return new I_[i](Uint8Array.prototype.slice.call(e,1).buffer)};Ri[120]=()=>{let e=Nt();return new RegExp(e[0],e[1])};Ri[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=Z;Z+=t-4,Qi=[Nt(),Nt()],Qi.position0=0,Qi.position1=0;let r=Z;Z=i;try{return Nt()}finally{Z=r}};Ri[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 B_(e){let t=En,i=Z,r=em,s=gr,n=as,a=xn,o=$f,l=Gs,h=Qi,u=new Uint8Array(Se.slice(0,En)),c=pt,d=pt.slice(0,pt.length),p=zi,f=Uo,g=e();return En=t,Z=i,em=r,gr=s,as=n,xn=a,$f=o,Gs=l,Qi=h,Se=u,Uo=f,pt=c,pt.splice(0,pt.length,...d),zi=p,ft=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),g}function im(){Se=null,Gs=null,pt=null}function Lz(e){e.unpack?Ri[e.type]=e.unpack:Ri[e.type]=e}var Wg=new Array(147);for(let e=0;e<256;e++)Wg[e]=+("1e"+Math.floor(45.15-e*.30103));var wu=new Pd({useRecords:!1}),s9=wu.unpack,n9=wu.unpackMultiple,a9=wu.unpack,Iz={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Rz=new Float32Array(1),o9=new Uint8Array(Rz.buffer,0,4),td;try{td=new TextEncoder}catch{}var Dd,Xg,_u=typeof Buffer<"u",Np=_u?Buffer.allocUnsafeSlow:Uint8Array,N_=_u?Buffer:Uint8Array,w1=_u?4294967296:2144337920,le,jt,te=0,Xr,qr=null,Bz=/[\u0080-\uFFFF]/,_l=Symbol("record-id"),z_=class extends Pd{constructor(e){super(e),this.offset=0;let t,i,r,s,n,a,o=0,l=N_.prototype.utf8Write?function(S,_,M){return le.utf8Write(S,_,M)}:td&&td.encodeInto?function(S,_){return td.encodeInto(S,le.subarray(_)).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,b=0;this.pack=this.encode=function(S,_){if(le||(le=new Np(8192),jt=new DataView(le.buffer,0,8192),te=0),Xr=le.length-10,Xr-te<2048?(le=new Np(le.length),jt=new DataView(le.buffer,0,le.length),Xr=le.length-10,te=0):te=te+7&2147483640,i=te,a=h.structuredClone?new Map:null,h.bundleStrings?(qr=["",""],le[te++]=214,le[te++]=98,qr.position=te-i,te+=4):qr=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 P,O=r.transitions;for(let D=0,k=T.length;D<k;D++){let W=T[D];P=O[W],P||(P=O[W]=Object.create(null)),O=P}O[_l]=C+64}o=M}u||(r.nextId=M+64)}s&&(s=!1),n=r||[];try{if(x(S),qr){jt.setUint32(qr.position+i,te-qr.position-i);let M=qr;qr=null,x(M[0]),x(M[1])}if(h.offset=te,a&&a.idsToInsert){te+=a.idsToInsert.length*6,te>Xr&&A(te),h.offset=te;let M=zz(le.subarray(i,te),a.idsToInsert);return a=null,M}return _&Uz?(le.start=i,le.end=te,le):le.subarray(i,te)}finally{if(r){if(b<10&&b++,y>1e4)r.transitions=null,b=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][_l]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||d;r.length>M&&(r=r.slice(0,M));let C=le.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}_&Fz&&(te=i)}};let x=S=>{te>Xr&&(le=A(te));var _=typeof S,M;if(_==="string"){let C=S.length;if(qr&&C>=8&&C<4096){let O=Bz.test(S);qr[O?0:1]+=S,le[te++]=193,x(O?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let P=C*3;if(te+P>Xr&&(le=A(te+P)),C<64||!l){let O,D,k,W=te+T;for(O=0;O<C;O++)D=S.charCodeAt(O),D<128?le[W++]=D:D<2048?(le[W++]=D>>6|192,le[W++]=D&63|128):(D&64512)===55296&&((k=S.charCodeAt(O+1))&64512)===56320?(D=65536+((D&1023)<<10)+(k&1023),O++,le[W++]=D>>18|240,le[W++]=D>>12&63|128,le[W++]=D>>6&63|128,le[W++]=D&63|128):(le[W++]=D>>12|224,le[W++]=D>>6&63|128,le[W++]=D&63|128);M=W-te-T}else M=l(S,te+T,P);M<32?le[te++]=160|M:M<256?(T<2&&le.copyWithin(te+2,te+1,te+1+M),le[te++]=217,le[te++]=M):M<65536?(T<3&&le.copyWithin(te+3,te+2,te+2+M),le[te++]=218,le[te++]=M>>8,le[te++]=M&255):(T<5&&le.copyWithin(te+5,te+3,te+3+M),le[te++]=219,jt.setUint32(te,M),te+=4),te+=M}else if(_==="number")if(S>>>0===S)S<64?le[te++]=S:S<256?(le[te++]=204,le[te++]=S):S<65536?(le[te++]=205,le[te++]=S>>8,le[te++]=S&255):(le[te++]=206,jt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?le[te++]=256+S:S>=-128?(le[te++]=208,le[te++]=S+256):S>=-32768?(le[te++]=209,jt.setInt16(te,S),te+=2):(le[te++]=210,jt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){le[te++]=202,jt.setFloat32(te,S);let T;if(C<4||(T=S*Wg[(le[te]&127)<<1|le[te+1]>>7])>>0===T){te+=4;return}else te--}le[te++]=203,jt.setFloat64(te,S),te+=8}else if(_==="object")if(!S)le[te++]=192;else{if(a){let T=a.get(S);if(T){if(!T.id){let P=a.idsToInsert||(a.idsToInsert=[]);T.id=P.push(T)}le[te++]=214,le[te++]=112,jt.setUint32(te,T.id),te+=4;return}else a.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)w(S,!0);else if(C===Array){M=S.length,M<16?le[te++]=144|M:M<65536?(le[te++]=220,le[te++]=M>>8,le[te++]=M&255):(le[te++]=221,jt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)x(S[T])}else if(C===Map){M=S.size,M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,jt.setUint32(te,M),te+=4);for(let[T,P]of S)x(T),x(P)}else{for(let T=0,P=Dd.length;T<P;T++){let O=Xg[T];if(S instanceof O){let D=Dd[T];if(D.write){D.type&&(le[te++]=212,le[te++]=D.type,le[te++]=0),x(D.write.call(this,S));return}let k=le,W=jt,X=te;le=null;let N;try{N=D.pack.call(this,S,j=>(le=k,k=null,te+=j,te>Xr&&A(te),{target:le,targetView:jt,position:te-j}),x)}finally{k&&(le=k,jt=W,te=X,Xr=le.length-10)}N&&(N.length+te>Xr&&A(N.length+te),te=Nz(N,le,te,D.type));return}}w(S,!S.hasOwnProperty)}}else if(_==="boolean")le[te++]=S?195:194;else if(_==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))le[te++]=211,jt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)le[te++]=207,jt.setBigUint64(te,S);else if(this.largeBigIntToFloat)le[te++]=203,jt.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(_==="undefined")this.encodeUndefinedAsNil?le[te++]=192:(le[te++]=212,le[te++]=0,le[te++]=0);else if(_==="function")x(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+_)},w=this.useRecords===!1?this.variableMapSize?S=>{let _=Object.keys(S),M=_.length;M<16?le[te++]=128|M:M<65536?(le[te++]=222,le[te++]=M>>8,le[te++]=M&255):(le[te++]=223,jt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)x(C=_[T]),x(S[C])}:(S,_)=>{le[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(_||S.hasOwnProperty(T))&&(x(T),x(S[T]),C++);le[M+++i]=C>>8,le[M+i]=C&255}:S=>{let _=Object.keys(S),M,C=n.transitions||(n.transitions=Object.create(null)),T=0;for(let O=0,D=_.length;O<D;O++){let k=_[O];M=C[k],M||(M=C[k]=Object.create(null),T++),C=M}let P=C[_l];if(P)P>=96&&f?(le[te++]=((P-=96)&31)+96,le[te++]=P>>5):le[te++]=P;else{P=n.nextId,P||(P=64),P<g&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(P=n.nextOwnId,P<m||(P=g),n.nextOwnId=P+1):(P>=m&&(P=g),n.nextId=P+1);let O=_.highByte=P>=96&&f?P-96>>5:-1;C[_l]=P,n[P-64]=_,P<g?(_.isShared=!0,n.sharedLength=P-63,s=!0,O>=0?(le[te++]=(P&31)+96,le[te++]=O):le[te++]=P):(O>=0?(le[te++]=213,le[te++]=114,le[te++]=(P&31)+96,le[te++]=O):(le[te++]=212,le[te++]=114,le[te++]=P),T&&(y+=b*T),v.length>=p&&(v.shift()[_l]=0),v.push(C),x(_))}for(let O=0,D=_.length;O<D;O++)x(S[_[O]])},A=S=>{let _;if(S>16777216){if(S-i>w1)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(w1,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(S-i<<2,le.length-1)>>12)+1<<12;let M=new Np(_);return jt=new DataView(M.buffer,0,_),le.copy?le.copy(M,0,i,S):M.set(le.slice(i,S)),te-=i,i=0,Xr=M.length-10,le=M}}useBuffer(e){le=e,jt=new DataView(le.buffer,le.byteOffset,le.byteLength),te=0}};Xg=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,T_];Dd=[{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?_1(e,16,t):A1(_u?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==N_&&this.structuredClone?_1(e,R_.indexOf(i.name),t):A1(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function _1(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 A1(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 Nz(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 zz(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 el(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)");Xg.unshift(e.Class),Dd.unshift(e)}Lz(e)}var U_=new z_({useRecords:!1}),l9=U_.pack,h9=U_.pack,{NEVER:c9,ALWAYS:d9,DECIMAL_ROUND:u9,DECIMAL_FIT:p9}=Iz,Uz=512,Fz=1024,S1=new z_({structuredClone:!0});el({Class:Qt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,Qt.prototype),e}});el({Class:it.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,it.prototype),e}});el({Class:ji.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,ji.prototype),e}});el({Class:u1.prototype.constructor,type:4,write(e){return e.id},read(e){return new u1(e)}});el({Class:p1.prototype.constructor,type:5,write(e){return e.data},read(e){return new p1(e)}});el({Class:mi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,mi.prototype),e}});function kz(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 rm(e){if(Ug(e))return e;if(Array.isArray(e))return e.map(rm);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=rm(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var sm;(e=>{function t(s){return S1.pack(s)}e.serialize=t;function i(s){return S1.unpack(s)}e.deserialize=i;function r(s){return kz(t(rm(s))).toString()}e.checksum=r})(sm||(sm={}));var Al={LookAt:[],Follow:[],MouseHover:["Transition"],Scroll:["Transition"],Start:["Transition","Audio","Video"],Conditional:["Transition","Audio","Video"],MouseDown:["Transition","Audio","Video","Link","Reset"],MouseUp:["Transition","Audio","Video","Link","Reset"],MousePress:["Transition","Audio","Video","Link","Reset"],KeyDown:["Transition","Audio","Video","Link","Reset"],KeyUp:["Transition","Audio","Video","Link","Reset"],KeyPress:["Transition","Audio","Video","Link","Reset"],GameControl:["Transition","Audio"],Collision:["Transition","Audio"]},M1;(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,disabled:!1,toggle:!1,actions:new it}:{type:r,disabled:!1,key:void 0,toggle:!1,actions:new it}}e.defaultData=i})(M1||(M1={}));var Od;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Od||(Od={}));var nm;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Od.propertyDefaultData(s),rOperand:{...Od.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})(nm||(nm={}));var E1;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new it,outActions:new it,condition:nm.distanceDefaultData(r)}}e.defaultData=i})(E1||(E1={}));var am;(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})(am||(am={}));var om;(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})(om||(om={}));var C1;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new it}}e.defaultData=i})(C1||(C1={}));var T1;(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 it}}e.defaultData=i})(T1||(T1={}));var P1;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new it}}e.defaultData=i})(P1||(P1={}));var D1;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,toggle:!1,target:"character",actions:new it}}e.defaultData=i})(D1||(D1={}));var fo;(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})(fo||(fo={}));var ma;(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})(ma||(ma={}));var Ld;(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})(Ld||(Ld={}));var Fo;(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})(Fo||(Fo={}));var Ji;(e=>{function t(o){return typeof o=="object"&&typeof o.r=="number"&&typeof o.g=="number"&&typeof o.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(o){return{r:Math.round(o.r*255),g:Math.round(o.g*255),b:Math.round(o.b*255),a:1}}e.toRgb255a1=i;function r(o){return{r:o.r,g:o.g,b:o.b}}e.clone=r;function s(o){return o=Math.floor(o),{r:(o>>16&255)/255,g:(o>>8&255)/255,b:(o&255)/255}}e.fromHex=s;function n(o,l){return o.r===l.r&&o.g===l.g&&o.b===l.b}e.equals=n;function a(o,l,h){return{r:o.r+(l.r-o.r)*h,g:o.g+(l.g-o.g)*h,b:o.b+(l.b-o.b)*h}}e.lerp=a})(Ji||(Ji={}));var kr;(e=>{e.white={...Ji.white,a:1},e.transparent={...Ji.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{...Ji.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 Ji.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})(kr||(kr={}));var lm;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(lm||(lm={}));var O1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(O1||(O1={}));var L1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(L1||(L1={}));var _a;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(_a||(_a={}));var xh;(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,autoZoom:!1,autoZoomFrustumSize:790},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(xh||(xh={}));var bn;(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(F_.forEach(a=>{Object.assign(n,{[a]:s[a]??r[a]})}),n.radial={...r.radial},s.radial){let a=r.radial,o=s.radial;k_.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;j_.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;G_.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;V_.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;H_.forEach(l=>{Object.assign(n.randomnessObject,{[l]:o[l]??a[l]})})}return n}e.merge=i})(bn||(bn={}));var hm;(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})(hm||(hm={}));var F_=["count"],k_=["radius","start","end","position","scale","rotation"],j_=["position","scale","rotation"],G_=["count","size"],V_=["count","position","scale","rotation"],H_=["strength","scale","rotation","position","movement","seed","freqScale"],bh;(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}}})(bh||(bh={}));var cm;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(cm||(cm={}));var dm;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(r==="SpotLight")return{type:r,color:kr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:kr.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(dm||(dm={}));var um;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(um||(um={}));var pm;(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})(pm||(pm={}));var fm;(e=>e.defaultData={...pm.defaultData,...um.defaultData})(fm||(fm={}));var Id;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Id||(Id={}));var W_=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],jz=["wrapping","image","video"],xr;(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){switch(n){case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",alpha:.6,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function s(n){switch(n){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"video",projection:0,texture:{video:Id.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Ji.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Ji.fromHex(6710886),a:1},colorB:{...Ji.fromHex(6710886),a:1},colorC:{...Ji.fromHex(16777215),a:1},colorD:{...Ji.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:kr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:kr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:kr.fromHexAndA(0,1),contourColor:kr.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(xr||(xr={}));var sr;(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 it}}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 it;return d.push({fi:0,data:xr.defaultData("light",h),id:u}),d.push({fi:1,data:xr.defaultData("color"),id:c}),{layers:d}}e.defaultTwoLayerData=a;function o(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new it;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:xr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,u="phong",c="layer1",d="layer2"){let p=xr.defaultData("video");Object.assign(p.texture,{video:h});let f=new it;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:xr.defaultData("light",u),id:d}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(sr||(sr={}));var Rd;(e=>{function t(){return{points:new it,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Rd||(Rd={}));var Bd;(e=>{function t(){return{points:new it,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Bd||(Bd={}));var X_={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0},mm;(e=>{function t(i,r){let s={...i};return Y_.forEach(n=>{Object.assign(s,{[n]:r[n]??i[n]})}),s}e.merge=t})(mm||(mm={}));var q_={shape:X_,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},Y_=["depth","offset","angle","twist","startScale","endScale"],Nd;(e=>{function t(i){return i==="PolygonGeometry"||i==="RectangleGeometry"||i==="StarGeometry"||i==="TriangleGeometry"||i==="EllipseGeometry"}e.is2DParametricMesh=t})(Nd||(Nd={}));var gm;(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,mm.merge(s.extrusion,r.extrusion))),s}e.merge=t})(gm||(gm={}));var Ao;(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:Bd.defaultData(),extrusion:q_};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Rd.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};throw new Error("not implemented")}e.defaultData=t})(Ao||(Ao={}));var I1=["width","height","depth"],R1;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(R1||(R1={}));var ko;(e=>{e.identity={...lm.identity,hiddenMatrix:Fo.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{position:ma.isEqual(s.position,n.position)?null:n.position,rotation:ma.isEqual(s.rotation,n.rotation)?null:n.rotation,scale:ma.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Fo.isEqual(s.hiddenMatrix,n.hiddenMatrix)?null:n.hiddenMatrix}}e.diff=r})(ko||(ko={}));var vm;(e=>e.defaultData={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]})(vm||(vm={}));var Ar;(e=>e.defaultData={states:new it,events:new it,visible:!0,raycastLock:!1,physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ko.identity,cloner:null})(Ar||(Ar={}));var B1;(e=>e.defaultData={type:"Empty",...Ar.defaultData})(B1||(B1={}));var N1;(e=>e.defaultData={type:"Component",...Ar.defaultData})(N1||(N1={}));var So;(e=>e.defaultData={type:"Mesh",...Ar.defaultData,...fm.defaultData})(So||(So={}));var zd;(e=>e.defaultData={...Ar.defaultData,...ko.identity,...xh.defaultData})(zd||(zd={}));var ym;(e=>{function t(i){return{...Ar.defaultData,...dm.defaultData(i)}}e.defaultData=t})(ym||(ym={}));var Ud;(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})(Ud||(Ud={}));var jo;(e=>{e.rootOverrideProps=["physics"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...Ar.defaultData,...s,component:r,overrides:new mi,physics:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=ko.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(jo||(jo={}));var xm;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Fo.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:vm.defaultData,states:new it,events:new it,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...xh.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",...Ar.defaultData,...So.defaultData,geometry:Ao.defaultData("RectangleGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...Ar.defaultData,...So.defaultData,geometry:Ao.defaultData("BooleanGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...Ar.defaultData,...So.defaultData,geometry:Ao.defaultData("TextGeometry"),material:sr.defaultTwoLayerData("phong","layer1","layer2")}))(xm||(xm={}));var oa;(e=>{function t(n,a){let o={name:a};return n.type==="Mesh"?(o.geometry={},"material"in n&&(o.material={layers:new mi}),"materials"in n&&(o.materials=n.materials.map(l=>({layers:new mi})))):_a.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=Td(o.material,l=>{if(typeof l!="string")for(let[h,u]of Object.entries(a.material.layers)){let c=l.layers.data(h);c&&xr.patch(c,u)}}).data),o.materials&&a.materials&&(o.materials=Td(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&&xr.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(...hm.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,ko.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})}),_a.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:gm.merge(o.geometry,a.geometry)}),(a.material||a.materials)&&(o=i(o,a)),o.cloner&&"cloner"in a&&Object.assign(o,{cloner:bn.merge(o.cloner,a.cloner)});else if(n.type==="Empty")o.cloner&&"cloner"in a&&Object.assign(o,{cloner:bn.merge(o.cloner,a.cloner)});else if(cm.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=Ji.clone(l.color))}return o}e.patch=s})(oa||(oa={}));var Fd;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Ji.white,near:.1,far:2e3})(Fd||(Fd={}));var kd;(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,autoZoom:!1})(kd||(kd={}));var Go;(e=>e.defaultData={orbitControls:kd.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio: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,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"]}),gameControlObject:null})(Go||(Go={}));function Aa(e,t){return Object.setPrototypeOf(e,t),e}var Gz=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),Vz=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),Hz=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Au&&"ontouchend"in document,Wz=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Xz=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,qz=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},Yz=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},f9=Gz(),Au=Vz(),bm=Hz(),Qz=Wz(),ir=Xz(),z1=qz(),U1=Number(Yz());function Q_(e){return Array.isArray(e)?e:[e]}function Zz(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 Ac(e){return Au?e.metaKey:e.ctrlKey}var Qe=[],jd={},Vl={},id={};function Z_(e){Qe.includes(e)||Qe.push(e)}function Mo(e){delete jd[e.pointerId];for(let t=0;t<Qe.length;t++)if(Qe[t].pointerId===e.pointerId){Qe.splice(t,1);break}}function Kz(){Qe.splice(0,Qe.length)}function Gd(e){if(e.pointerType!=="touch")return;let t=jd[e.pointerId];t===void 0&&(t={x:0,y:0},jd[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function zp(e){let t=e.pointerId===Qe[0].pointerId?Qe[1]:Qe[0];return jd[t.pointerId]}function K_(e){Vl[e.key]=!0,id[e.key]=id[e.key]===void 0?1:id[e.key]+1}function J_(e){if(Au&&Vl.Meta)for(let t in Vl)Vl[t]=!1;else Vl[e.key]=!1;id={}}function Jz(e){e.addEventListener("pointerdown",Z_,!0),e.addEventListener("pointerdown",Gd,!0),e.addEventListener("pointermove",Gd,!0),e.addEventListener("pointerup",Mo,!0),e.addEventListener("pointercancel",Mo,!0),e.addEventListener("pointerleave",Mo,!0),window.addEventListener("keydown",K_,!0),window.addEventListener("keyup",J_,!0)}function $z(e){e.removeEventListener("pointerdown",Z_,!0),e.removeEventListener("pointerdown",Gd,!0),e.removeEventListener("pointermove",Gd,!0),e.removeEventListener("pointerup",Mo,!0),e.removeEventListener("pointercancel",Mo,!0),e.removeEventListener("pointerleave",Mo,!0),window.removeEventListener("keydown",K_,!0),window.removeEventListener("keyup",J_,!0)}var Zi;(e=>e.defaultData={ambientLight:{enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!0,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200,skinWidthRelative:.02,stepThreshRelative:.3,slopeThresh:65})(Zi||(Zi={}));var wm;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let n=new ji,a=xm.defaultMeshObject;return s.withLight===!0&&n.push({fi:-1,data:{...ym.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&n.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:a,children:[]}),n}e.defaultData={backgroundColor:kr.fromHexAndA(1908256,1),postprocessing:bh.defaultData,fog:Fd.defaultData,objects:t(),environment:Zi.defaultData,publish:Go.defaultData},e.emptyData=function(s){return{backgroundColor:kr.fromHexAndA(1908256,1),postprocessing:bh.defaultData,fog:Fd.defaultData,objects:s?t(s):new ji,environment:Zi.defaultData,publish:Go.defaultData}};function i(s){return{...e.defaultData,objects:Aa(s,ji.prototype)}}e.withObjs=i;function r(s,n){return i([{id:s,data:n,children:[],fi:0}])}e.withObj=r})(wm||(wm={}));var Vd;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Vd||(Vd={}));var Hd;(e=>{function t(){let s={};return s["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Aa(s,Qt.prototype)}e.defaultColors=t;function i(s){let n={};return s?.withAITexture&&(n["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Vd.emptyImage,name:"AI generated image"}),Aa(n,Qt.prototype)}e.defaultImages=i;function r(){return{materials:new Qt,images:new Qt,videos:new Qt,colors:new Qt,audios:new Qt,fonts:new Qt,penumbraSize:[.5,.5,.5]}}e.emptyData=r})(Hd||(Hd={}));function F1(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={...gh(Si(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={...Si(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function rd(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function sd(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach(s=>{typeof s!="string"&&t(s)}):"material"in r&&typeof r.material!="string"&&t(r.material)})}function eU(e){Object.assign(e.scene.publish,{orbitControls:{...kd.defaultData,...Si(e.scene.publish.orbitControls)}})}function tU(e){Object.assign(e.scene.publish.settings,{video:{...Go.defaultData.settings.video,...Si(e.scene.publish.settings.video)}})}function iU(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((W_.includes(s)||typeof n=="boolean")&&delete r[s],s==="texture")for(let[a,o]of Object.entries(n))(jz.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 rU(e){e.scene.publish.withBackground=!0}function sU(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function nU(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 aU(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=Si(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=Si(i).booleanExclude!==!0)}})}function lU(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 hU(e){function t(r){Object.setPrototypeOf(r,mi.prototype),r.texture&&Object.setPrototypeOf(r.texture,mi.prototype)}function i(r){Object.setPrototypeOf(r,mi.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=Si(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=Si(l).layers;i(h),l.layers=h}})})}function k1(e){e.layers===void 0&&Object.assign(e,sr.defaultTwoLayerData("lambert"))}function Up(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={...Si(t),colors:i,steps:r};Object.assign(t,s)}})}function cU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function j1(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Up(r)}):"material"in i&&typeof i.material!="string"&&Up(i.material)}),Object.values(e.shared.materials).forEach(t=>Up(t))}function dU(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 uU(e){e.shared.audios=Aa({},Qt.prototype)}function pU(e){e.shared.videos=Aa({},Qt.prototype)}function fU(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 mU(e){Object.entries(Si(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(Si(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 G1(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 vU(e){e.shared.fonts=Aa({},Qt.prototype)}function yU(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 xU(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let n=sr.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=yU(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...Ar.defaultData,...So.defaultData,flatShading:!1,wireframe:!1,geometry:{...Ao.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:Si(s.states),events:Si(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=Si(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 bU(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 it,move:new it,jump:new it}});else{let n=new it;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:rt.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,gh(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 it({fi:0,id:rt.generateUUID(),data:h},{fi:1,id:rt.generateUUID(),data:d})};n.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function wU(e){e.scene.objects.traverse((t,i)=>{function r(s,n){let a=new it,o=[];if(i.events.forEach((l,h,u)=>{if(l.type==="Audio"&&l.trigger===n){let c;o.push(h),l.interaction==="play"?c={...gh(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={...gh(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:rt.generateUUID(),data:{type:s,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function V1(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=xr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function H1(e){rd(e,V1),sd(e,V1)}function _U(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function AU(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 SU(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=sr.defaultTwoLayerData("phong"))})}function MU(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 EU(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 CU(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)}var W1=34;function TU(e){let t=e.schema??0;t!==W1&&(console.warn("updating from ",t,"to ",W1),t<1&&(sd(e,F1),rd(e,F1),e.schema=1),t<2&&(eU(e),e.schema=2),t<3&&(iU(e),e.schema=3),t<4&&(rU(e),e.schema=4),t<5&&(sU(e),e.schema=5),t<6&&(nU(e),e.schema=6),t<7&&(aU(e),e.schema=7),t<8&&(e.schema=8),t<9&&(j1(e),e.schema=9),t<10&&(cU(e),e.schema=10),t<11&&(dU(e),e.schema=11),t<12&&(j1(e),e.schema=12),t<13&&(uU(e),e.schema=13),t<14&&(fU(e),e.schema=14),t<15&&(mU(e),e.schema=15),t<16&&(gU(e),e.schema=16),t<17&&(sd(e,G1),rd(e,G1),e.schema=17),t<18&&(sd(e,k1),rd(e,k1),e.schema=18),t<19&&(tU(e),e.schema=19),t<20&&(vU(e),xU(e),e.schema=20),t<21&&(bU(e),wU(e),e.schema=21),t<22&&(H1(e),e.schema=22),t<23&&(_U(e),e.schema=23),t<24&&(AU(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(pU(e),t<25&&(e.schema=25)),t<26&&(oU(e),e.schema=26),t<27&&(lU(e),e.schema=27),t<28&&(H1(e),e.schema=28),t<29&&(hU(e),e.schema=29),t<30&&(SU(e),e.schema=30),t<31&&(MU(e),e.schema=31),t<33&&(EU(e),e.schema=33),t<34&&(CU(e),e.schema=34))}function mo(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 Ve,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=X1(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=X1(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 X1(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 Xe(n,i,r)}var _m;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,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"]],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 it,move:new it,jump:new it}}))(_m||(_m={}));var PU=Math.pow(2,-24),Sc=class{constructor(){}};function os(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 q1(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 Y1(e,t){t.set(e)}function Q1(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 Mc(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 Sl(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 DU(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 Xe(s,1));for(let n=0;n<i;n++)s[n]=n}}function OU(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 Fp(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,b=(t+i)*6;y<b;y+=6){let x=e[y+0],w=e[y+1],A=x-w,S=x+w;A<n&&(n=A),S>l&&(l=S),v&&x<c&&(c=x),v&&x>f&&(f=x);let _=e[y+2],M=e[y+3],C=_-M,T=_+M;C<a&&(a=C),T>h&&(h=T),v&&_<d&&(d=_),v&&_>g&&(g=_);let P=e[y+4],O=e[y+5],D=P-O,k=P+O;D<o&&(o=D),k>u&&(u=k),v&&P<p&&(p=P),v&&P>m&&(m=P)}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 LU(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 IU(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 zs=32,RU=(e,t)=>e.candidate-t.candidate,tn=new Array(zs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ec=new Float32Array(6);function BU(e,t,i,r,s,n){let a=-1,o=0;if(n===0)a=q1(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(n===1)a=q1(e),a!==-1&&(o=NU(i,r,s,a));else if(n===2){let l=Sl(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)/zs;if(s<zs/4){let g=[...tn];g.length=s;let m=0;for(let y=u;y<c;y+=6,m++){let b=g[m];b.candidate=i[y+2*d],b.count=0;let{bounds:x,leftCacheBounds:w,rightCacheBounds:A}=b;for(let S=0;S<3;S++)A[S]=1/0,A[S+3]=-1/0,w[S]=1/0,w[S+3]=-1/0,x[S]=1/0,x[S+3]=-1/0;Mc(y,i,x)}g.sort(RU);let v=s;for(let y=0;y<v;y++){let b=g[y];for(;y+1<v&&g[y+1].candidate===b.candidate;)g.splice(y+1,1),v--}for(let y=u;y<c;y+=6){let b=i[y+2*d];for(let x=0;x<v;x++){let w=g[x];b>=w.candidate?Mc(y,i,w.rightCacheBounds):(Mc(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let b=g[y],x=b.count,w=s-b.count,A=b.leftCacheBounds,S=b.rightCacheBounds,_=0;x!==0&&(_=Sl(A)/l);let M=0;w!==0&&(M=Sl(S)/l);let C=1+1.25*(_*x+M*w);C<h&&(a=d,h=C,o=b.candidate)}}else{for(let v=0;v<zs;v++){let y=tn[v];y.count=0,y.candidate=p+f+v*f;let b=y.bounds;for(let x=0;x<3;x++)b[x]=1/0,b[x+3]=-1/0}for(let v=u;v<c;v+=6){let y=~~((i[v+2*d]-p)/f);y>=zs&&(y=zs-1);let b=tn[y];b.count++,Mc(v,i,b.bounds)}let g=tn[zs-1];Y1(g.bounds,g.rightCacheBounds);for(let v=zs-2;v>=0;v--){let y=tn[v],b=tn[v+1];Q1(y.bounds,b.rightCacheBounds,y.rightCacheBounds)}let m=0;for(let v=0;v<zs-1;v++){let y=tn[v],b=y.count,x=y.bounds,w=tn[v+1].rightCacheBounds;b!==0&&(m===0?Y1(x,Ec):Q1(x,Ec,Ec)),m+=b;let A=0,S=0;m!==0&&(A=Sl(Ec)/l);let _=s-m;_!==0&&(S=Sl(w)/l);let M=1+1.25*(A*m+S*_);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 NU(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 zU(e,t){let i=e.attributes.position,r=i.array,s=e.index.array,n=s.length/3,a=new Float32Array(n*6),o=i.offset||0,l=3;i.isInterleavedBufferAttribute&&(l=i.data.stride);for(let h=0;h<n;h++){let u=h*3,c=h*6,d=s[u+0]*l+o,p=s[u+1]*l+o,f=s[u+2]*l+o;for(let g=0;g<3;g++){let m=r[d+g],v=r[p+g],y=r[f+g],b=m;v<b&&(b=v),y<b&&(b=y);let x=m;v>x&&(x=v),y>x&&(x=y);let w=(x-b)/2,A=g*2;a[c+A+0]=b+w,a[c+A+1]=w+(Math.abs(b)+w)*PU,b<t[g]&&(t[g]=b),x>t[g+3]&&(t[g+3]=x)}}return a}function UU(e,t){function i(v){d&&d(v/p)}function r(v,y,b,x=null,w=0){if(!f&&w>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),b<=u||w>=l)return i(y+b),v.offset=y,v.count=b,v;let A=BU(v.boundingData,x,a,y,b,c);if(A.axis===-1)return i(y+b),v.offset=y,v.count=b,v;let S=IU(o,a,y,b,A);if(S===y||S===y+b)i(y+b),v.offset=y,v.count=b;else{v.splitAxis=A.axis;let _=new Sc,M=y,C=S-y;v.left=_,_.boundingData=new Float32Array(6),Fp(a,M,C,_.boundingData,n),r(_,M,C,n,w+1);let T=new Sc,P=S,O=b-C;v.right=T,T.boundingData=new Float32Array(6),Fp(a,P,O,T.boundingData,n),r(T,P,O,n,w+1)}return v}DU(e,t);let s=new Float32Array(6),n=new Float32Array(6),a=zU(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=OU(e);if(m.length===1){let v=m[0],y=new Sc;y.boundingData=s,LU(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 Sc;y.boundingData=new Float32Array(6),Fp(a,v.offset,v.count,y.boundingData,n),r(y,v.offset,v.count,n),g.push(y)}return g}function FU(e,t){let i=UU(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,b;if(b=h(u+32,m),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[d+6]=b/4,b=h(b,v),s[d+7]=y,b}}}var xs=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}};xs.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 m9=function(){let e=new xs;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}}}(),kU=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,s.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}}(),qg=function(){let e=new G,t=new E,i=new E;return function(r,s,n,a){kU(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}}}}(),jU=function(){let e=new E,t=new E,i=new yr,r=new _r;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}}(),GU=1e-15;function Ya(e){return Math.abs(e)<GU}var Ws=class extends Ni{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new E),this.satBounds=new Array(4).fill().map(()=>new xs),this.points=[this.a,this.b,this.c],this.sphere=new Mr,this.plane=new yr,this.needsUpdate=!0}intersectsSphere(e){return jU(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}};Ws.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new _r;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]),qg(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)}}();Ws.prototype.intersectsTriangle=function(){let e=new Ws,t=new Array(3),i=new Array(3),r=new xs,s=new xs,n=new E,a=new E,o=new E,l=new E,h=new _r,u=new _r,c=new _r;return function(d,p=null){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(e.copy(d),e.update(),d=e);let f=this.plane,g=d.plane;if(Math.abs(f.normal.dot(g.normal))>1-1e-10){let m=this.satBounds,v=this.satAxes;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let x=0;x<4;x++){let w=m[x],A=v[x];if(r.setFromPoints(A,i),w.isSeparated(r))return!1}let y=d.satBounds,b=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let x=0;x<4;x++){let w=y[x],A=b[x];if(r.setFromPoints(A,t),w.isSeparated(r))return!1}for(let x=0;x<4;x++){let w=v[x];for(let A=0;A<4;A++){let S=b[A];if(n.crossVectors(w,S),r.setFromPoints(n,t),s.setFromPoints(n,i),r.isSeparated(s))return!1}}return p&&(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 m=this.points,v=!1,y=0;for(let P=0;P<3;P++){let O=m[P],D=m[(P+1)%3];h.start.copy(O),h.end.copy(D),h.delta(a);let k=v?u.start:u.end,W=Ya(g.distanceToPoint(O));if(Ya(g.normal.dot(a))&&W){u.copy(h),y=2;break}if((g.intersectLine(h,k)||W)&&!Ya(k.distanceTo(D))){if(y++,v)break;v=!0}}if(y===1&&this.containsPoint(u.start))return p&&(p.start.copy(u.start),p.end.copy(u.start)),!0;if(y!==2)return!1;let b=d.points,x=!1,w=0;for(let P=0;P<3;P++){let O=b[P],D=b[(P+1)%3];h.start.copy(O),h.end.copy(D),h.delta(o);let k=x?c.start:c.end,W=Ya(f.distanceToPoint(O));if(Ya(f.normal.dot(o))&&W){c.copy(h),w=2;break}if((f.intersectLine(h,k)||W)&&!Ya(k.distanceTo(D))){if(w++,x)break;x=!0}}if(w===1&&this.containsPoint(c.start))return p&&(p.start.copy(c.start),p.end.copy(c.start)),!0;if(w!==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 A=u.start.dot(a),S=u.end.dot(a),_=c.start.dot(a),M=c.end.dot(a),C=S<_,T=A<M;return A!==M&&_!==S&&C===T?!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)}}}();Ws.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ws.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new _r,s=new _r;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]),qg(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 bs=class extends Kt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new ve,this.invMatrix=new ve,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 xs),this.alignedSatBounds=new Array(3).fill().map(()=>new xs),this.needsUpdate=!1}set(e,t,i){super.set(e,t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};bs.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}}();bs.prototype.intersectsBox=function(){let e=new xs;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}}();bs.prototype.intersectsTriangle=function(){let e=new Ws,t=new Array(3),i=new xs,r=new xs,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}}();bs.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}}();bs.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();bs.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new _r),i=new Array(12).fill().map(()=>new _r),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,b=(g+2)%3,x=m<<y|v<<b,w=1<<g|m<<y|v<<b,A=d[x],S=d[w];t[f].set(A,S);let _=e[g],M=e[y],C=e[b],T=i[f],P=T.start,O=T.end;P[_]=u[_],P[M]=m?u[M]:c[M],P[C]=v?u[C]:c[M],O[_]=c[_],O[M]=m?u[M]:c[M],O[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];qg(m,y,r,s);let b=r.distanceToSquared(s);if(b<p&&(p=b,o&&o.copy(r),l&&l.copy(s),b<h))return Math.sqrt(b)}}return Math.sqrt(p)}}();var Cc=new E,Tc=new E,Pc=new E,Z1=new G,K1=new G,J1=new G,$1=new E;function VU(e,t,i,r,s,n){let a;return n===hi?a=e.intersectTriangle(r,i,t,!0,s):a=e.intersectTriangle(t,i,r,n!==$i,s),a===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function HU(e,t,i,r,s,n,a){Cc.fromBufferAttribute(t,r),Tc.fromBufferAttribute(t,s),Pc.fromBufferAttribute(t,n);let o=VU(e,Cc,Tc,Pc,$1,a);if(o){i&&(Z1.fromBufferAttribute(i,r),K1.fromBufferAttribute(i,s),J1.fromBufferAttribute(i,n),o.uv=Ni.getUV($1,Cc,Tc,Pc,Z1,K1,J1,new G));let l={a:r,b:s,c:n,normal:new E,materialIndex:0};Ni.getNormal(Cc,Tc,Pc,l.normal),o.face=l,o.faceIndex=r}return o}function $_(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),h=HU(i,e.attributes.position,e.attributes.uv,a,o,l,t);return h?(h.faceIndex=r,s&&s.push(h),h):null}function WU(e,t,i,r,s,n){for(let a=r,o=r+s;a<o;a++)$_(e,t,i,a,n)}function XU(e,t,i,r,s){let n=1/0,a=null;for(let o=r,l=r+s;o<l;o++){let h=$_(e,t,i,o);h&&h.distance<n&&(a=h,n=h.distance)}return a}function eA(e,t,i){return e===null||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function ss(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 ex(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(ss(a,h*3,o,l),a.needsUpdate=!0,r(a,h,s,n))return!0;return!1}var tA=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 fn(e,t){return t[e+15]===65535}function Eo(e,t){return t[e+6]}function wh(e,t){return t[e+14]}function _h(e){return e+8}function Ah(e,t){return t[e+6]}function qU(e,t){return t[e+7]}var go=new Kt,Wd=new E,YU=["x","y","z"];function Am(e,t,i,r,s){let n=e*2,a=tl,o=Cn,l=Tn;if(fn(n,o)){let h=Eo(e,l),u=wh(n,o);WU(t,i,r,h,u,s)}else{let h=_h(e);Xd(h,a,r,Wd)&&Am(h,t,i,r,s);let u=Ah(e,l);Xd(u,a,r,Wd)&&Am(u,t,i,r,s)}}function Sm(e,t,i,r){let s=e*2,n=tl,a=Cn,o=Tn;if(fn(s,a)){let l=Eo(e,o),h=wh(s,a);return XU(t,i,r,l,h)}else{let l=qU(e,o),h=YU[l],u=r.direction[h]>=0,c,d;u?(c=_h(e),d=Ah(e,o)):(c=Ah(e,o),d=_h(e));let p=Xd(c,n,r,Wd)?Sm(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=Xd(d,n,r,Wd)?Sm(d,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var QU=function(){let e,t,i=[],r=new tA(()=>new Kt);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 b=y*2,x=Cn,w=Tn;for(;!fn(b,x);)y=_h(y),b=y*2;return Eo(y,w)}function p(y){let b=y*2,x=Cn,w=Tn;for(;!fn(b,x);)y=Ah(y,w),b=y*2;return Eo(y,w)+wh(b,x)}let f=n*2,g=tl,m=Cn,v=Tn;if(fn(f,m)){let y=Eo(n,v),b=wh(f,m);return os(n,g,e),l(y,b,!1,c,u+n,e)}else{let y=_h(n),b=Ah(n,v),x=y,w=b,A,S,_,M;if(h&&(_=e,M=t,os(x,g,_),os(w,g,M),A=h(_),S=h(M),S<A)){x=b,w=y;let W=A;A=S,S=W,_=M}_||(_=e,os(x,g,_));let C=fn(x*2,m),T=o(_,C,A,c+1,u+x),P;if(T===2){let W=d(x),X=p(x)-W;P=l(W,X,!0,c+1,u+x,_)}else P=T&&s(x,a,o,l,h,u,c+1);if(P)return!0;M=t,os(w,g,M);let O=fn(w*2,m),D=o(M,O,S,c+1,u+w),k;if(D===2){let W=d(w),X=p(w)-W;k=l(W,X,!0,c+1,u+w,M)}else k=D&&s(w,a,o,l,h,u,c+1);return!!k}}}(),ZU=function(){let e=new Ws,t=new Ws,i=new ve,r=new bs,s=new bs;return function n(a,o,l,h,u=null){let c=a*2,d=tl,p=Cn,f=Tn;if(u===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),u=r),fn(c,p)){let g=o,m=g.index,v=g.attributes.position,y=l.index,b=l.attributes.position,x=Eo(a,f),w=wh(c,p);if(i.copy(h).invert(),l.boundsTree)return os(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=x*3,_=(w+x)*3;S<_;S+=3)if(ss(t,S,m,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=x*3,S=w+x*3;A<S;A+=3){ss(e,A,m,v),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let _=0,M=y.count;_<M;_+=3)if(ss(t,_,y,b),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let g=a+8,m=f[a+6];return os(g,d,go),!!(u.intersectsBox(go)&&n(g,o,l,h,u)||(os(m,d,go),u.intersectsBox(go)&&n(m,o,l,h,u)))}}}();function Xd(e,t,i,r){return os(e,t,go),i.intersectBox(go,r)}var Mm=[],nd,tl,Cn,Tn;function Hl(e){nd&&Mm.push(nd),nd=e,tl=new Float32Array(e),Cn=new Uint16Array(e),Tn=new Uint32Array(e)}function Dc(){nd=null,tl=null,Cn=null,Tn=null,Mm.length&&Hl(Mm.pop())}var kp=Symbol("skip tree generation"),jp=new Kt,Gp=new Kt,Qa=new ve,Yn=new bs,Ml=new bs,El=new E,Oc=new E,KU=new E,JU=new E,$U=new E,tx=new Kt,Yr=new tA(()=>new Ws),gi=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."),gi.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."),gi.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 gi(t,{...i,[kp]:!0});if(n._roots=s,i.setIndex){let a=t.getIndex();if(a===null){let o=new Xe(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,[kp]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[kp]||(this._roots=FU(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Kt))),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=r.array,n=r.offset||0,a=3;r.isInterleavedBufferAttribute&&(a=r.data.stride);let o,l,h,u,c=0,d=this._roots;for(let f=0,g=d.length;f<g;f++)o=d[f],l=new Uint32Array(o),h=new Uint16Array(o),u=new Float32Array(o),p(0,c),c+=o.byteLength;function p(f,g,m=!1){let v=f*2;if(h[v+15]===65535){let y=l[f+6],b=h[v+14],x=1/0,w=1/0,A=1/0,S=-1/0,_=-1/0,M=-1/0;for(let C=3*y,T=3*(y+b);C<T;C++){let P=i[C]*a+n,O=s[P+0],D=s[P+1],k=s[P+2];O<x&&(x=O),O>S&&(S=O),D<w&&(w=D),D>_&&(_=D),k<A&&(A=k),k>M&&(M=k)}return u[f+0]!==x||u[f+1]!==w||u[f+2]!==A||u[f+3]!==S||u[f+4]!==_||u[f+5]!==M?(u[f+0]=x,u[f+1]=w,u[f+2]=A,u[f+3]=S,u[f+4]=_,u[f+5]=M,!0):!1}else{let y=f+8,b=l[f+6],x=y+g,w=b+g,A=m,S=!1,_=!1;e?A||(S=e.has(x),_=e.has(w),A=!S&&!_):(S=!0,_=!0);let M=A||S,C=A||_,T=!1;M&&(T=p(y,g,A));let P=!1;C&&(P=p(b,g,A));let O=T||P;if(O)for(let D=0;D<3;D++){let k=y+D,W=b+D,X=u[k],N=u[k+3],j=u[W],F=u[W+3];u[f+D]=X<j?X:j,u[f+D+3]=N>F?N:F}return O}}}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=Vr){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(Hl(i[h]),Am(0,r,c,e,s),Dc(),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=Vr){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;Hl(i[h]);let d=Sm(0,r,c,e);Dc(),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(Hl(s),r=ZU(0,i,e,t),Dc(),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=Yr.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:ex(d,p,r,l,f,g,s)}else o||(l?o=(c,d,p,f)=>ex(c,d,r,l,p,f,s):o=(c,d,p)=>p);let h=!1,u=0;for(let c of this._roots){if(Hl(c),h=QU(0,r,a,o,n,u),Dc(),h)break;u+=c.byteLength}return Yr.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;Qa.copy(t).invert();let h=Yr.getPrimitive(),u=Yr.getPrimitive();if(s){let d=function(p,f,g,m,v,y,b,x){for(let w=g,A=g+m;w<A;w++){ss(u,w*3,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let S=p,_=p+f;S<_;S++)if(ss(h,S*3,n,a),h.needsUpdate=!0,s(h,u,S,w,v,y,b,x))return!0}return!1};if(r){let p=r;r=function(f,g,m,v,y,b,x,w){return p(f,g,m,v,y,b,x,w)?!0:d(f,g,m,v,y,b,x,w)}}else r=d}e.getBoundingBox(Gp),Gp.applyMatrix4(t);let c=this.shapecast({intersectsBounds:d=>Gp.intersectsBox(d),intersectsRange:(d,p,f,g,m,v)=>(jp.copy(v),jp.applyMatrix4(Qa),e.shapecast({intersectsBounds:y=>jp.intersectsBox(y),intersectsRange:(y,b,x,w,A)=>r(d,p,y,b,g,m,w,A)}))});return Yr.releasePrimitive(h),Yr.releasePrimitive(u),c}intersectsBox(e,t){return Yn.set(e.min,e.max,t),Yn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Yn.intersectsBox(i),intersectsTriangle:i=>Yn.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(),Yn.set(e.boundingBox.min,e.boundingBox.max,t),Yn.needsUpdate=!0;let a=this.geometry,o=a.attributes.position,l=a.index,h=e.attributes.position,u=e.index,c=Yr.getPrimitive(),d=Yr.getPrimitive(),p=Oc,f=KU,g=null,m=null;r&&(g=JU,m=$U);let v=1/0,y=null,b=null;return Qa.copy(t).invert(),Ml.matrix.copy(Qa),this.shapecast({boundsTraverseOrder:x=>Yn.distanceToBox(x),intersectsBounds:(x,w,A)=>A<v&&A<n?(w&&(Ml.min.copy(x.min),Ml.max.copy(x.max),Ml.needsUpdate=!0),!0):!1,intersectsRange:(x,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Ml.distanceToBox(A),intersectsBounds:(A,S,_)=>_<v&&_<n,intersectsRange:(A,S)=>{for(let _=A*3,M=(A+S)*3;_<M;_+=3){ss(d,_,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let C=x*3,T=(x+w)*3;C<T;C+=3){ss(c,C,l,o),c.needsUpdate=!0;let P=c.distanceToTriangle(d,p,g);if(P<v&&(f.copy(p),m&&m.copy(g),v=P,y=C/3,b=_/3),P<s)return!0}}}});{let A=u?u.count:h.count;for(let S=0,_=A;S<_;S+=3){ss(d,S,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let M=x*3,C=(x+w)*3;M<C;M+=3){ss(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,b=S/3),T<s)return!0}}}}}),Yr.releasePrimitive(c),Yr.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(Qa),f.applyMatrix4(Qa),r.distance=f.sub(r.point).length(),r.faceIndex=b),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=>(El.copy(e).clamp(h.min,h.max),El.distanceToSquared(e)),intersectsBounds:(h,u,c)=>c<a&&c<n,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,El);let c=e.distanceToSquared(El);return c<a&&(Oc.copy(El),a=c,o=u),c<s}}),a===1/0)return null;let l=Math.sqrt(a);return t.point?t.point.copy(Oc):t.point=Oc.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{os(0,new Float32Array(t),tx),e.union(tx)}),e}},ix=gi.prototype.raycast;gi.prototype.raycast=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[t,i,r,s]=e;return ix.call(this,r,t.material).forEach(n=>{n=eA(n,t,i),n&&s.push(n)}),s}else return ix.apply(this,e)};var rx=gi.prototype.raycastFirst;gi.prototype.raycastFirst=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[t,i,r]=e;return eA(rx.call(this,r,t.material),t,i)}else return rx.apply(this,e)};var sx=gi.prototype.closestPointToPoint;gi.prototype.closestPointToPoint=function(...e){if(e[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),e.unshift();let t=e[1],i={};return e[1]=i,sx.apply(this,e),t&&t.copy(i.point),i.distance}else return sx.apply(this,e)};var nx=gi.prototype.closestPointToGeometry;gi.prototype.closestPointToGeometry=function(...e){let t=e[2],i=e[3];if(t&&t.isVector3||i&&i.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let r={},s={},n=e[1];return e[2]=r,e[3]=s,nx.apply(this,e),t&&t.copy(r.point),i&&i.copy(s.point).applyMatrix4(n),r.distance}else return nx.apply(this,e)};var ax=gi.prototype.refit;gi.prototype.refit=function(...e){let t=e[0],i=e[1];if(i&&(i instanceof Set||Array.isArray(i))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let r=new Set;i.forEach(s=>r.add(s)),t&&t.forEach(s=>r.add(s)),ax.call(this,r)}else ax.apply(this,e)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(e=>{let t=gi.prototype[e];gi.prototype[e]=function(...i){return(i[0]===null||i[0].isMesh)&&(i.shift(),console.warn(`MeshBVH: The function signature for "${e}" has changed and no longer takes Mesh. See docs for new signature.`)),t.apply(this,i)}});var Cl=Eh(j2()),eF=.5*(Math.sqrt(3)-1),Tl=(3-Math.sqrt(3))/6,tF=1/3,Qr=1/6,g9=(Math.sqrt(5)-1)/4,v9=(5-Math.sqrt(5))/20,th=e=>Math.floor(e)|0,ox=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]),Vp=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 Hp(e=Math.random){let t=iA(e),i=new Float64Array(t).map(s=>ox[s%12*2]),r=new Float64Array(t).map(s=>ox[s%12*2+1]);return function(s,n){let a=0,o=0,l=0,h=(s+n)*eF,u=th(s+h),c=th(n+h),d=(u+c)*Tl,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 b=g-v+Tl,x=m-y+Tl,w=g-1+2*Tl,A=m-1+2*Tl,S=u&255,_=c&255,M=.5-g*g-m*m;if(M>=0){let P=S+t[_],O=i[P],D=r[P];M*=M,a=M*M*(O*g+D*m)}let C=.5-b*b-x*x;if(C>=0){let P=S+v+t[_+y],O=i[P],D=r[P];C*=C,o=C*C*(O*b+D*x)}let T=.5-w*w-A*A;if(T>=0){let P=S+1+t[_+1],O=i[P],D=r[P];T*=T,l=T*T*(O*w+D*A)}return 70*(a+o+l)}}function iF(e=Math.random){let t=iA(e),i=new Float64Array(t).map(n=>Vp[n%12*3]),r=new Float64Array(t).map(n=>Vp[n%12*3+1]),s=new Float64Array(t).map(n=>Vp[n%12*3+2]);return function(n,a,o){let l,h,u,c,d=(n+a+o)*tF,p=th(n+d),f=th(a+d),g=th(o+d),m=(p+f+g)*Qr,v=p-m,y=f-m,b=g-m,x=n-v,w=a-y,A=o-b,S,_,M,C,T,P;x>=w?w>=A?(S=1,_=0,M=0,C=1,T=1,P=0):x>=A?(S=1,_=0,M=0,C=1,T=0,P=1):(S=0,_=0,M=1,C=1,T=0,P=1):w<A?(S=0,_=0,M=1,C=0,T=1,P=1):x<A?(S=0,_=1,M=0,C=0,T=1,P=1):(S=0,_=1,M=0,C=1,T=1,P=0);let O=x-S+Qr,D=w-_+Qr,k=A-M+Qr,W=x-C+2*Qr,X=w-T+2*Qr,N=A-P+2*Qr,j=x-1+3*Qr,F=w-1+3*Qr,z=A-1+3*Qr,B=p&255,H=f&255,Q=g&255,Y=.6-x*x-w*w-A*A;if(Y<0)l=0;else{let ee=B+t[H+t[Q]];Y*=Y,l=Y*Y*(i[ee]*x+r[ee]*w+s[ee]*A)}let U=.6-O*O-D*D-k*k;if(U<0)h=0;else{let ee=B+S+t[H+_+t[Q+M]];U*=U,h=U*U*(i[ee]*O+r[ee]*D+s[ee]*k)}let se=.6-W*W-X*X-N*N;if(se<0)u=0;else{let ee=B+C+t[H+T+t[Q+P]];se*=se,u=se*se*(i[ee]*W+r[ee]*X+s[ee]*N)}let V=.6-j*j-F*F-z*z;if(V<0)c=0;else{let ee=B+1+t[H+1+t[Q+1]];V*=V,c=V*V*(i[ee]*j+r[ee]*F+s[ee]*z)}return 32*(l+h+u+c)}}function iA(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 Ir=new Ni,rF=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;Ir.a.fromBufferAttribute(e,r),Ir.b.fromBufferAttribute(e,r+1),Ir.c.fromBufferAttribute(e,r+2),s*=Ir.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),Ir.a.fromBufferAttribute(this.positionAttribute,e*3),Ir.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ir.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ir.a,r).addScaledVector(Ir.b,s).addScaledVector(Ir.c,1-(r+s)),Ir.getNormal(i),this}},sF=Eh(Kb()),nF=new ve,aF=new ve,oF=new ve,qd;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(qd||(qd={}));var Yg=e=>class extends e{constructor(){super(...arguments),this.hiddenMatrix=new ve,this.matrixWorldRigid=new ve,this.shearScale=new ve,this.shearScaleInv=new ve}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof bt&&(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)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)qd.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,sF.SVD)(i),a=nF.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=aF.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=oF.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 ve().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof ve?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}},lF=class extends Yg(bt){},hF=e=>e.type==="Mesh",la=class extends lF{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1}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 la(t),this.add(i),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.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 hF(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}},ra=new E,sa=new E,Co=new ve,rA=[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)],cF=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],dF=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],lx=(e,t,i)=>{e.updateEntityBoxSize(ra,sa),Co.copy(t).multiply(e.matrixWorld),sa.x===0&&sa.y===0&&sa.z===0?i.push(new E(ra.x,ra.y,ra.z).applyMatrix4(Co)):rA.forEach(r=>{i.push(r.clone().multiply(sa).add(ra).applyMatrix4(Co))})},hx=class extends Kt{constructor(){super(...arguments),this.matrix=new ve,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 ve().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{(s.visible||s.cloner&&s.data.visible)&&lx(s,t,r)}):lx(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(Co.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(sa).multiplyScalar(.5),this.getCenter(ra),Co.copy(this.matrix).setPosition(ra),this.vertices=rA.map(e=>e.clone().multiply(sa).applyMatrix4(Co))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=cF.map(([e,t])=>new _r(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=dF.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},wn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},uF=class extends ww{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}},Em=.001;function Cm(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=Em}function Wp(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 Cm(i,r,n)&&Cm(i,s,n)}function sA(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++)Cm(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,b=i[v].data,x=new E(...y.position),w=new E(...b.position),A=x.clone().sub(d).normalize(),S=w.clone().sub(d).normalize();Object.assign(g,{prevDir:A,nextDir:S});let _=Wp(y,c),M=Wp(c,b);if(!_||!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(!Wp(i[c].data,i[d].data))p.position.distanceTo(f.position)>Em&&(g=new Jc(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)>Em&&(g=new Jc(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,b=m.clone().multiplyScalar(Math.sqrt(Math.pow(g,2)-Math.pow(y,2))).add(v),x=m.clone().multiplyScalar(-g).add(b),w=d.distanceTo(x)/d.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*d.distanceTo(p)).add(d),S=A.clone().lerp(x,2),_=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*u]=new Jc(p,_,M,f)}let h=new uF;return l.forEach(u=>{u&&h.add(u)}),h}var Ct;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(Ct||(Ct={}));var mn=e=>Ct.is(e),nA=e=>class extends Yg(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 hx,this._recursiveBBox=new hx,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(Ct.is(i))return i}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(Ct.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)oa.toOps(this.data,s.data).forEach(n=>{let a=Kf.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=oa.patch(this.data,s),oa.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=>{mn(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(Ct.is(i[r]))return i[r];if(Ct.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Ct.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)mn(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{Ct.is(i)&&t(i)})}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)mn(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)mn(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}copy(t,i=!0){return super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>mn(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 Zf(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??Fo.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)Ct.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Ct.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return Zf(i,t)}updateByOp(t,i,r,s){let n=this.data;this.data=i;let a=t,o=pn(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(Object.values(t.props).some(u=>u===void 0)){let u=this.data;if(u!==void 0){let c=ps.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=ps.removeOverridden(t.path,t.props,l);a={...t,props:h}}}if(this.updateByPatchedOpBase(a,oa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),pn(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(fa.apply(c.component.data,c.overrideData),r))}}else{let u=r.scene.findInstance([this.uuid,...l]);if(u){let c=ps.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=Ud.resolve(i.overrides,l),u.updateByOp(t,tr.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 jo.rootOverrideProps)u in t.props&&(h===void 0&&(h={}),h[u]=t.props[u]);h&&(l={...t,props:h})}else for(let h of jo.rootOverrideProps)if(pn(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let u=fa.filterOp(h.overrideData,l);u&&h.updateByOp(u,tr.applySimple(h.data,u),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let u=fa.filterOp(h.overrideData,t);if(u){let c;n===h.data&&t===u?c=i:c=tr.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&&!_a.is(t.props.type)&&wn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){wn.changeEntityProptotype(this,i,r);for(let s of this.children)Ct.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),pn(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),pn(t.path,["cloner"])!==null){let s=tr.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}applyPathSnapping(t){let i=this._updatedPathSnapping||this.dataPatched.pathSnapping;if(i.pathId===null)return;let r=t.find(i.pathId);if(!r)return;let s=r.data,n=sA(s.geometry.path),a=(i.slide+i.offset)%1,o=n.getPointAt(a),l=this.parent?this.parent?.matrixWorld:new ve;r.updateMatrixWorld();let h=new ve().multiplyMatrices(l.clone().invert(),r.matrixWorld);o.applyMatrix4(h);let u={position:o.toArray(),rotation:s.rotation};if(i.orientation==="tangential"){let c=new ve().extractRotation(r.matrixWorld),d=n.getTangentAt(a).applyMatrix4(c).add(o),p=new ve().lookAt(o,d,new E(0,1,0)),f=new _i().setFromRotationMatrix(p);u={...u,rotation:[f.x,f.y,f.z]}}this.updateTransformState(u)}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()),"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 wn.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 wn.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)}},pF=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:0,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 aA(h,u,r,s,n,a,o,l*Math.PI/180,c,c,d,p):f=new dg(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 rn(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function cx(e){return new G(e.y,-e.x)}var aA=class extends Ve{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,b=new E,x=new E;d&&e==0&&(e=l),d&&t==0&&(t=h);let w=new G(e,y),A=new G(t,-y),S=null,_=null,M=null,C=null,T=w.clone().sub(A),P=0,O=0,D=0;c>0&&(P=Math.min(e,t)*(1-c),O=e-P,D=t-P);let k=w.clone();k.x-=P;let W=Math.PI-T.angle(),X=T.angle(),N=Math.tan(X/2),j=Math.tan(W/2),F=N+j,z=c?F:j,B=c?F:N;if(l=Math.min(l,(e-O)/z,T.length()/F),h=Math.min(h,(t-D)/B,T.length()/F),l>0){let V=l/N;S=w.clone().sub(new G(V,l)),c&&(M=S.clone(),M.x-=P-F*l),w.sub(T.clone().setLength(V))}if(h>0){let V=h/j;_=A.clone().sub(new G(V,-h)),A.add(T.clone().setLength(V)),c&&(C=_.clone(),C.x-=P-F*h,k.sub(T.clone().setLength(V)))}T=w.clone().sub(A);let H=T.length()<.5,Q=[];for(let V=0;V<=r;V++){let ee=[],J=V/r,fe=J*o+a,re=new G(Math.sin(fe),Math.cos(fe));C&&_?(Y(ee,J,re,W,h,C,-1,!0),Y(ee,J,re,X,h,_,-1,!1)):_?(U(ee,re,_.x,0,-1),Y(ee,J,re,X,h,_,-1,!1)):n||U(ee,re,t,D,-1);let oe=cx(T).normalize();if(rn(oe,re,b),!H)for(let ue=0;ue<=s;ue++){let ye=ue/s,Te=T.clone().multiplyScalar(ye).add(A);rn(Te,re,x),f.push(x.x,x.y,x.z),g.push(b.x,b.y,b.z),m.push(J,.5+x.y/i),ee.push(v++)}if(M&&S?(Y(ee,J,re,W,l,S,1,!1),Y(ee,J,re,X,l,M,1,!0)):S?(Y(ee,J,re,W,l,S,1,!1),U(ee,re,S.x,0,1)):n||U(ee,re,e,O,1),c&&!H){let ue=cx(T).multiplyScalar(-1).normalize();rn(ue,re,b);for(let ye=0;ye<=s;ye++){let Te=ye/s,xe=T.clone().multiplyScalar(-Te).add(k);rn(xe,re,x),f.push(x.x,x.y,x.z),g.push(b.x,b.y,b.z),m.push(J,.5+x.y/i),ee.push(v++)}}c&&!n&&ee.push(ee[0]),Q.push(ee)}for(let V=0;V<Q.length-1;V++)for(let ee=0;ee<Q[0].length-1;ee++){if(n&&c&&ee==s)continue;let J=Q[V][ee],fe=Q[V+1][ee],re=Q[V+1][ee+1],oe=Q[V][ee+1],ue=f[re*3+0],ye=f[re*3+2];p.push(J,fe,oe),(ue!=0||ye!=0)&&p.push(fe,re,oe)}o<Math.PI*2&&(se(-1,Q[0],a),se(1,Q[Q.length-1],a+o)),this.setIndex(p),this.setAttribute("position",new Ce(f,3)),this.setAttribute("normal",new Ce(g,3)),this.setAttribute("uv",new Ce(m,2));function Y(V,ee,J,fe,re,oe,ue,ye){for(let Te=0;Te<u+1;Te++){let xe=Te/u,we=ue<0?xe:1-xe;ye&&(we-=1),we*=fe;let Ie=new G(Math.sin(we),Math.cos(we)*ue),He=Ie.clone().multiplyScalar(re).add(oe);rn(He,J,x),f.push(x.x,x.y,x.z),rn(Ie,J,b),g.push(b.x,b.y,b.z),m.push(ee,.5+x.y/i),V.push(v++)}}function U(V,ee,J,fe,re){let oe=new E,ue=new G,ye=[J,fe];re<0&&ye.reverse();for(let Te of ye)ue.set(Te,y*re),rn(ue,ee,oe),f.push(oe.x,oe.y,oe.z),g.push(0,re,0),m.push(.5,.5),V.push(v++)}function se(V,ee,J){let fe=new G(Math.sin(J),Math.cos(J)),re=new G(-Math.cos(J),Math.sin(J)),oe=new E,ue=V<0?(xe,we,Ie)=>p.push(xe,we,Ie):(xe,we,Ie)=>p.push(xe,Ie,we),ye=new G((e+t+O+D)/4,0);rn(ye,fe,oe),f.push(oe.x,oe.y,oe.z),g.push(re.x,0,re.y),m.push(.5,.5);let Te=v++;for(let xe of ee){let we=f.slice(xe*3,xe*3+3);f.push(...we),g.push(re.x,0,re.y);let Ie=m.slice(xe*2,xe*2+2);m.push(...Ie),v++}for(let xe=Te+1;xe<v-1;xe++)ue(Te,xe,xe+1);ue(Te,v-1,Te+1)}}},fF=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:0,cornerRadiusBottom:0,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 aA(0,t/2,r,s,n,a,o,l*Math.PI/180,h,u,c,0,!0):d=new Aw(t/2,r,s,n,a),d.scale(1,1,i/t),Object.assign(d,{userData:{...e,type:"ConeGeometry"}})}},mF=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:0,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 gs(t,i,r,s,n,a):h=new gF(t,i,r,s,n,a,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},Xp=Math.PI/2,gF=class extends Ve{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 Ce(u,3)),this.setAttribute("normal",new Ce(c,3)),this.setAttribute("uv",new Ce(d,2));function g(y,b,x,w,A,S,_,M,C,T,P){let O=(S-2*a)/C,D=(_-2*a)/T,k=S/2-a,W=_/2-a,X=M/2,N=C+1,j=T+1,F=0,z=0,B=new E;for(let H=0;H<j;H++){let Q=H*D-W;for(let Y=0;Y<N;Y++){let U=Y*O-k;B[y]=U*w,B[b]=Q*A,B[x]=X,u.push(B.x,B.y,B.z),B[y]=0,B[b]=0,B[x]=M>0?1:-1,c.push(B.x,B.y,B.z),d.push(Y/C),d.push(1-H/T),F+=1}}for(let H=0;H<T;H++)for(let Q=0;Q<C;Q++){let Y=p+Q+N*H,U=p+Q+N*(H+1),se=p+(Q+1)+N*(H+1),V=p+(Q+1)+N*H;h.push(Y,U,V),h.push(U,se,V),z+=6}l.addGroup(f,z,P),f+=z,p+=F}function m(y,b,x,w,A,S,_,M,C,T,P){let O=(_-2*a)/T,D=_/2-a,k=M/2-a,W=C/2,X=T+1,N=0,j=0,F=new E,z=new E;for(let B=0;B<o+1;B++){let H=B/o*Xp,Q=Math.sin(H)*a,Y=(1-Math.cos(H))*a,U=Math.sin(H),se=Math.cos(H);F[b]=(k+Q)*A,F[x]=(W-Y)*S,z[y]=0,z[b]=U*Math.sign(F[b]),z[x]=se*Math.sign(F[x]);for(let V=0;V<X;V++){let ee=V*O-D;F[y]=ee*w,u.push(F.x,F.y,F.z),c.push(z.x,z.y,z.z),d.push(V/T),d.push(0),N+=1}}for(let B=0;B<o;B++)for(let H=0;H<T;H++){let Q=p+H+X*B,Y=p+H+X*(B+1),U=p+(H+1)+X*(B+1),se=p+(H+1)+X*B;h.push(Q,Y,se),h.push(Y,U,se),j+=6}l.addGroup(f,j,P),f+=j,p+=N}function v(y,b,x){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(a);let S=[],_=y*b*x>0?(C,T,P)=>h.push(C,T,P):(C,T,P)=>h.push(C,P,T);for(let C=0;C<=o;C++){let T=[],P=Xp*(1-C/o),O=Math.cos(P),D=Math.sin(P),k=0;for(let W=0;W<=C;W++){let X=Math.cos(k),N=Math.sin(k);w.x=O*X,w.y=D,w.z=O*N;let j=A.clone().addScaledVector(w,a);u.push(y*j.x,b*j.y,x*j.z),c.push(y*w.x,b*w.y,x*w.z),d.push(0,0),T.push(p++),k+=Xp/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],P=S[C+1],O=T.length-1;_(T[0],P[1],P[0]);for(let D=1;D<=O;D++)_(T[D-1],T[D],P[D]),_(T[D],P[D+1],P[D])}}}},Qg=class extends Ve{constructor(e=[],t=[],i="",r=1,s=.2,n=4){super(),this.type="PolyhedronGeometryRound";let a=[],o=[],l=[];h(),u(),this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(l,3)),this.setAttribute("uv",new Ce(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 Ni,g=s*r,m=r-g,v=n+1,y=new E,b=(X,N)=>y.subVectors(X,N).normalize(),x=(X,N)=>Array(X).fill(void 0).map(N),w=x(e.length/3,(X,N)=>new E().fromArray(e,N*3).setLength(r)),A=[],S=1e6;for(let X=0;X<w.length;X++){let N=w[X],j=[],F,z,B,H=1e10,Q=-1;for(;(Q=t.indexOf(X,Q+1))!=-1;){let V=Q-Q%3;F=t[V+(Q+1)%3],z=t[V+(Q+2)%3],B=N.distanceToSquared(w[F]),H=Math.min(H,B),j.push([F,z,B])}H+=1e-6;let Y=[],U=0,se=j.length;for(let V=0;V<se;V++){[F,z,B]=j[U];let ee=A[F]?.includes(X)==!0;B<=H&&Y.push(F+ +ee*S),U=j.findIndex(J=>J[0]==z)}A.push(Y)}let _=[];{let X=0,N=0,j,F,z=c==3;for(let B=0;B<=n;B++){j=B*(B+1)/2,F=(B+1)*(B+2)/2;for(let H=0;H<n-B;H++)[X,N]=[j+H+B+2,F+H+B+3],_.push(j,F,...z?[N,j]:[X,F],N,X),[j,F]=[X,N];_.push(j,F,j+n+2)}}let M=d.clone(),C=d.clone(),T=d.clone(),P=d.clone(),O=d.clone(),D=[],k=x(w.length,()=>x(c,()=>d.clone()));for(let X=0;X<w.length;X++){d.copy(w[X]).normalize(),M.copy(d).multiplyScalar(m);let N=A[X];for(let Y=0;Y<N.length;Y++){let U=N[Y],se=N[(Y+1)%c];f.setFromPointsAndIndices(w,X,U%S,se%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,k[X][Y])}let j=[],F=[],z=[],B=new E;n==0&&[...k[X]].reduce((Y,U)=>Y.add(U),B).multiplyScalar(1/c);for(let Y=0;Y<c;Y++){let U=[],se=(Y-1+c)%c,V=k[X][se],ee=k[X][Y];d.copy(V).sub(M),p.copy(ee).sub(M);let J=M.angleTo(d),fe=d.angleTo(p),re=Math.cos(J)*g;n==0?C.copy(B):C.copy(M).setLength(m+re),F.push(re);let oe=[C,V,ee];for(let ue=0;ue<2;ue++){let ye=oe[ue],Te=oe[ue+1];P.subVectors(ye,M),O.subVectors(Te,M),T.crossVectors(P,O).normalize();for(let xe=0;xe<v;xe++){let we=[J,fe][ue]*xe/v;d.copy(P).applyAxisAngle(T,we).add(M),j.push(d.clone()),ue&&(b(d,M),U.push([xe==0?ye:d.clone(),y.clone()]))}ue&&(b(Te,M),U.push([Te,y.clone()]))}z.push(U)}D.push(z);let H=2*v,Q=2;for(let Y=0;Y<c;Y++){let U=H*Y,se=H*((Y+1)%c),V=[j[U]];for(let J=1;J<v;J++){P=j[U+J],O=j[se+J],V.push(P);for(let fe=1,re=J-Q+1;fe<=re;fe++)d.lerpVectors(P,O,fe/(re+1)),d.sub(M).setLength(F[Y]).add(M),V.push(d.clone());V.push(O)}for(let J=0;J<v;J++)V.push(j[J+v+U]);V.push(j[se+v]);let ee=_.map(J=>V[J]);a.push(...ee.map(J=>[J.x,J.y,J.z]).flat()),l.push(...ee.map(J=>(b(J,M),[y.x,y.y,y.z])).flat())}}let W=[];for(let X=0;X<A.length;X++)for(let N=0;N<c;N++){let j=A[X][N];if(j<S){let F=A[j].findIndex(H=>H%S==X),z=D[X][N],B=D[j][F];for(let H=0;H<v;H++){let Q=z[H],Y=B[v-H],U=z[H+1],se=B[v-(H+1)];[Q,Y,U,U,Y,se].forEach(V=>{a.push(V[0].x,V[0].y,V[0].z),l.push(V[1].x,V[1].y,V[1].z)})}W.push(z[0][0],B[v][0],z[v][0],B[0][0])}}for(;W.length;){let X,N,j,F;[X,N]=W.splice(0,2);let z=[X];for(;X!=N;)z.push(N),j=W.indexOf(N),F=j%2,N=W.splice(j-F,2)[1-F];y.subVectors(z[0],z[1]).cross(d.subVectors(z[0],z[2])).normalize();let B=y.dot(z[0])<0;B&&y.negate();for(let H=1;H<=z.length-2;H++)[z[H+ +B],z[H+1-+B],z[0]].forEach(Q=>{a.push(Q.x,Q.y,Q.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=x(c)/2/Math.PI+.5,_=w(c)/Math.PI+.5;o.push(S,1-_)}let d=new E,p=new E,f=new E,g=new E,m=new G,v=new G,y=new G,b=(A,S,_,M)=>{M<0&&A.x===1&&(o[S]=A.x-1),_.x===0&&_.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 _=x(g);b(m,S+0,d,_),b(v,S+2,p,_),b(y,S+4,f,_)}for(let A=0;A<o.length;A+=6){let S=o[A+0],_=o[A+2],M=o[A+4],C=Math.max(S,_,M),T=Math.min(S,_,M);C>.9&&T<.1&&(S<.2&&(o[A+0]+=1),_<.2&&(o[A+2]+=1),M<.2&&(o[A+4]+=1))}function x(A){return Math.atan2(A.z,-A.x)}function w(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(e){return new Qg(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},vF=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 oA(t*.5,n,a):new Sw(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},oA=class extends Qg{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 oA(e.radius,e.corner,e.cornerSides)}},Pl=1e-12,Zg=class{constructor(e){this.position=new G,this.startPosition=new G,this.uuid=rt.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 Zg(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Tm=class extends Zg{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new Tm(this.parent).copy(this)}},To=class extends Zg{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new Tm(this),new Tm(this))}static create(e,t){let i=new To(e,new G(...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 To(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 G,t=new G){let[i,r]=this.computeTangents();return i&&r&&(dx(i,e),dx(r,t)),[e,t]}computeTangent(e=new G){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new G){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function dx(e,t=new G){let i=e.length();return t.set(-e.y/i,e.x/i)}var Kg=e=>e,il=new G,Su=new G,yF=new G,xF=new G,bF=new G,wF=new G,lA=new E,hA=new E;function _F(e){let t=new G;t.addVectors(e.v0,il.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new G;return i.addVectors(e.v2,Su.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new Fr(e.v0,t,i,e.v2)}function Wl(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function AF(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function SF(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function cA(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 MF(e,t,i){return px(e,t)&&px(t,i)&&Pm(e.position,t.position,i.position)}function Pm(e,t,i){return il.copy(t).sub(e).cross(Su.copy(i).sub(e))===0}function EF(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 CF(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function TF(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 cA(t,e,i)>Math.PI&&(u*=-1),Wl(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 ux(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function px(e,t){return Pm(e.position,e.controls[1].position,t.position)&&Pm(e.position,t.controls[0].position,t.position)}function PF(e,t,i,r,s=.5){let n=il.subVectors(t,e).multiplyScalar(s).add(e),a=Su.subVectors(i,t).multiplyScalar(s).add(t),o=yF.subVectors(r,i).multiplyScalar(s).add(i),l=n,h=xF.subVectors(a,n).multiplyScalar(s).add(n),u=bF.subVectors(o,a).multiplyScalar(s).add(a),c=o,d=wF.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 DF(e,t,i=12,r=!0){let s=hA.set(0,0,0),n,a=0,o=[];for(let l=0;l<t.length;l++){let h=Kg(t[l]),u=il,c=ga(h,i);o.push(c);for(let d=0;d<=c;d++)if(h instanceof Fr||h instanceof Pn||h instanceof Gr){if(h.getPoint(d/c,u),s.set(u.x,u.y,0),n!==void 0&&SF(n,s))continue;n===void 0&&(n=lA),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 OF(e,t,i,r=12,s=!0){let n=hA.set(0,0,0),a=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,u=Kg(t[l]),c=il,d=ga(u,r);o.push(d);for(let p=0;p<=d;p++)if(u instanceof Fr||u instanceof Pn||u instanceof Gr){if(u.getPoint(p/d,c),n.set(c.x,c.y,0),h?.equals(n))continue;h===void 0?h=lA:(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 fx(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=ga(a.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}a.curveAfter!==void 0&&(o+=ga(a.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=ga(e[0].roundedCurveCorner,t)*.5),r}function ga(e,t=12){return e&&e instanceof lu?t*2:e&&(e instanceof Gr||e instanceof bw)?1:e&&e instanceof cg?t*e.points.length:t}function LF(e,t,i=12,r=!0){let s,n=0;for(let a=0;a<t.length;a++){let o=Kg(t[a]),l=ga(o,i),h=il;for(let u=0;u<=l;u++)if(o instanceof Fr||o instanceof Pn||o instanceof Gr){if(o.getPoint(u/l,h),s!==void 0&&AF(s,h,Pl))continue;s===void 0&&(s=Su),s.copy(h),e.push(h.x,h.y),n++}}return Wl(e[0],e[e.length-2],Pl)&&Wl(e[1],e[e.length-1],Pl)&&(e.pop(),e.pop()),r&&n>1&&!(Wl(e[n-1],e[1],Pl)&&Wl(e[n-2],e[0],Pl))&&(e.push(e[0],e[1]),n++),e}var qp=new G,IF=new G,RF=new G,BF=new G,NF=new G,zF=new G,zt=class extends yd{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new yr(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=rt.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new zt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>To.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>zt.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=qp.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=rt.generateUUID()){let r;e instanceof G?r=e:r=new G(e,t);let s=new To(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 DF(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=fx(this.points,e,!1),this.roundedCurveDivisions=fx(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return OF(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),LF(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=ga(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(ux(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(qp.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){ux(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&&MF(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,b=v/f,x=h.getPointAt(y,qp),w=u.getPointAt(b,IF);this._subSplitCurve(h,c,y,x,void 0),this._subSplitCurve(u,d,b,void 0,w);let A;if(this.useCubicForRoundedCorners){let S=cA(x,s.position,w)/2,_=Math.tan(S)*x.distanceTo(s.position),[M,C]=EF(x,w,_,RF,BF),T=CF(M,C,s.position),[P,O]=TF(T,x,w,_,NF,zF);A=new Fr(x.clone(),P.clone(),O.clone(),w.clone())}else A=new Pn(x.clone(),s.position.clone(),w.clone());s.roundedCurveCorner=A,this.roundedCurves.splice(i+t,0,A),t++}}}}_subSplitCurve(e,t,i,r,s){if(e instanceof Gr)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=PF(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 zt(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 To(rt.generateUUID(),new G(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 zt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(r,s)=>{s instanceof Fr&&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 Pn&&(r[n]=_F(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 Fr?(c=this.createPoint(h.v0),c.controls[1].position.copy(h.v1)):h instanceof Gr&&(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 Fr?o.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(o.v2),l=!0):o instanceof Gr&&o.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=i(e.curves),e instanceof yd&&(this.shapeHoles=e.holes.map(r=>{let s=new zt;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)}},Dm=Math.PI*2;function Yp({x:e,y:t},i,r,s,n){return{x:e*i+s,y:t*r+n}}function UF(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 mx(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 FF(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,b=(a-g)/s,x=(o-m)/n,w=(-a-g)/s,A=(-o-m)/n,S=mx(1,0,b,x),_=mx(b,x,w,A);return!h&&_>0&&(_-=Dm),h&&_<0&&(_+=Dm),{centerx:v,centery:y,ang1:S,ang2:_}}function kF({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=FF(e,t,i,r,s,n,h,u,a,o),{ang1:p,ang2:f}=d,{centerx:g,centery:m}=d,v=Math.abs(f)/(Dm/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let b=0;b<y;b++)l.push(UF(p,f)),p+=f;return l.map(b=>{let{x,y:w}=Yp(b[0],s,n,g,m),{x:A,y:S}=Yp(b[1],s,n,g,m),{x:_,y:M}=Yp(b[2],s,n,g,m);return{x1:x,y1:w,x2:A,y2:S,x:_,y:M}})}var yt;(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"})(yt||(yt={}));var Zt;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Zt||(Zt={}));function ke(e,t){if(!e)throw t||"Assertion Failed!"}var Ne=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){ke(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){ke(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){ke(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){ke(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}(),Dl=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}(),Lc=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}(),ao=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}(),gx=function(){function e(){var t=new ao,i=new Dl,r=new Lc(0),s=new Lc(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 Lc(0),r=new Lc(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;ke(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;ke(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 ao,i=new ao,r=new Dl,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 ao;this.makeVertex_(n,i,t.Org),t.Org.anEdge=t}if(!r){var a=new Dl;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 Dl;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 ao;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 Dl;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&&Ne.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&Ne.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){ke(s.prev===n),l=s.anEdge;do ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l),ke(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(ke(s.prev===n&&s.anEdge===null),o=i,o=i;(a=o.next)!==i;o=a){ke(a.prev===o),l=a.anEdge;do ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l),ke(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(ke(a.prev===o&&a.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)ke(l.Sym.next===h.Sym),ke(l.Sym!==l),ke(l.Sym.Sym===l),ke(l.Org!==null),ke(l.Dst!==null),ke(l.Lnext.Onext.Sym===l),ke(l.Onext.Sym.Lnext===l);ke(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}(),vx=function(){function e(){this.handle=null}return e}(),yx=function(){function e(){this.key=null,this.node=0}return e}(),jF=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 vx,this.handles[r]=new yx;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,ke(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 vx;for(n=this.handles.length,this.handles.length=this.max+1,s=n;s<this.handles.length;s++)this.handles[s]=new yx}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;ke(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}(),Qp=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}(),xx=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),GF=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new xx,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 xx;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}(),VF=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?Ne.vertLeq(n.Org,a.Org)?Ne.edgeSign(a.Dst,n.Org,a.Org)<=0:Ne.edgeSign(n.Dst,a.Org,n.Org)>=0:Ne.edgeSign(a.Dst,s,a.Org)<=0;if(a.Dst===s)return Ne.edgeSign(n.Dst,s,n.Org)>=0;var o=Ne.edgeEval(n.Dst,s,n.Org),l=Ne.edgeEval(a.Dst,s,a.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&ke(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){ke(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 Qp;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 yt.ODD:return(i&1)!==0;case yt.NONZERO:return i!==0;case yt.POSITIVE:return i>0;case yt.NEGATIVE:return i<0;case yt.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 ke(Ne.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,ke(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=Ne.vertL1dist(i,t),n=Ne.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(Ne.vertLeq(s.Org,n.Org)){if(Ne.edgeSign(n.Dst,s.Org,n.Org)>0)return!1;Ne.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(Ne.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(ke(!Ne.vertEq(s.Dst,n.Dst)),Ne.vertLeq(s.Dst,n.Dst)){if(Ne.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(Ne.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 ao,p,f;if(ke(!Ne.vertEq(h,l)),ke(Ne.edgeSign(l,t.event,a)<=0),ke(Ne.edgeSign(h,t.event,o)>=0),ke(a!==t.event&&o!==t.event),ke(!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(Ne.vertLeq(a,o)){if(Ne.edgeSign(h,a,o)>0)return!1}else if(Ne.edgeSign(l,o,a)<0)return!1;return e.debugEvent(t),Ne.intersect(l,a,h,o,d),ke(Math.min(a.t,l.t)<=d.t),ke(d.t<=Math.max(o.t,h.t)),ke(Math.min(h.s,l.s)<=d.s),ke(d.s<=Math.max(o.s,a.s)),Ne.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),p=Ne.vertLeq(a,o)?a:o,Ne.vertLeq(p,d)&&(d.s=p.s,d.t=p.t),Ne.vertEq(d,a)||Ne.vertEq(d,o)?(e.checkForRightSplice(t,i),!1):!Ne.vertEq(l,t.event)&&Ne.edgeSign(l,t.event,d)>=0||!Ne.vertEq(h,t.event)&&Ne.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):(Ne.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),Ne.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),Ne.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),Ne.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}Ne.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,Ne.vertEq(s.Org,r)){ke(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Ne.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}ke(!1),i=e.topRightRegion(i),l=e.regionBelow(i),a=l.eUp.Sym,n=o=a.Onext,l.fixUpperEdge&&(ke(n!==a),e.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),Ne.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 Qp;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(a=r.eUp,o=s.eUp,Ne.edgeSign(a.Dst,i,a.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(n=Ne.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);ke(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 Qp,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 GF(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||(ke(i.fixUpperEdge),ke(++r===1)),ke(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,Ne.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 jF(n,Ne.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,ke(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||!Ne.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}(),HF=function(){function e(){this.mesh=new gx,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=yt.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(;Ne.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Ne.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var n=void 0;r.Lnext!==s;)if(Ne.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Ne.edgeGoesLeft(s.Lnext)||Ne.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&&(Ne.edgeGoesRight(r.Lprev)||Ne.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===Zt.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===Zt.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 gx),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=yt.ODD),i===void 0&&(i=Zt.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_(),VF.computeInterior(this,a);var o=this.mesh;return i===Zt.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),a&&o.check(),i===Zt.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function _n(e){var t=e.windingRule,i=t===void 0?yt.ODD:t,r=e.elementType,s=r===void 0?Zt.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 HF;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 y9=yt.ODD,x9=yt.NONZERO,b9=yt.POSITIVE,w9=yt.NEGATIVE,_9=yt.ABS_GEQ_TWO,A9=Zt.POLYGONS,S9=Zt.CONNECTED_POLYGONS,M9=Zt.BOUNDARY_CONTOURS,dA=class extends Ve{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=yt.ODD,this.elementType=Zt.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:yt.ODD,elementType:Zt.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}!a&&!o&&(n=_n({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let u=n?.vertexCount??1,c=n?.elementCount??1;if(this._positionAttribute=new Xe(new Float32Array(u*3),3),this._normalAttribute=new Xe(new Float32Array(u*3),3),this._uvAttribute=new Xe(new Float32Array(u*2),2),this._indexAttribute=new Xe(new Uint32Array(c*3),1),n){let d=1/0,p=-1/0,f=1/0,g=-1/0;for(let y=0,b=u;y<b;y++){let x=y*2,w=n.vertices[x+0],A=n.vertices[x+1];w<d&&(d=w),w>p&&(p=w),A<f&&(f=A),A>g&&(g=A)}let m=p-d,v=g-f;for(let y=0,b=u;y<b;y++){let x=y*2,w=n.vertices[x+0],A=n.vertices[x+1],S=(w-d)/m,_=(A-f)/v;this._positionAttribute.setXYZ(y,w,A,0),this._normalAttribute.setXYZ(y,0,0,1),this._uvAttribute.setXY(y,S,_)}for(let y=0,b=c;y<b;y++){let x=y*3,w=n.elements[x+0],A=n.elements[x+1],S=n.elements[x+2];this._indexAttribute.setX(x+0,w),this._indexAttribute.setX(x+1,A),this._indexAttribute.setX(x+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 dA(this._shape,this._curveSegments);return e.userData=vu(this.userData),e}},Om=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*Om.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*Om.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);a.set(this.positions.slice(0,this.size*3)),o.set(this.normals.slice(0,this.size*3)),l.set(this.uvs.slice(0,this.size*2)),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)}},uA=Om;uA.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Zp=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),pA=class extends Ve{constructor(e,t,i=0,r=12,s=3,n=yt.ODD){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._bevel=i,this._curveSegments=r,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,t/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],r),o=this._shape.shapeHoles.map(w=>{let A=w.extractShapePointsToFlatArray([],r),S=[];for(let _=A.length-1;_>=1;_-=2){let M=A[_-1],C=A[_-0];S.push(M,C)}return S}),l=_n({windingRule:n,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),h=_n({windingRule:yt.ODD,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...o]});if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(h){l.elementCount+=h.elementCount;for(let w=0;w<h.elements.length;w++){let A=h.elements[w],S=w%2===0?l.vertexCount:0;l.elements.push(A+S)}for(let w=0;w<h.vertexIndices.length;w++){let A=h.vertexIndices[w],S=l.vertexCount;l.vertexIndices.push(A+S)}for(let w=0;w<h.vertices.length;w++){let A=h.vertices[w];l.vertices.push(A)}}let c=1/0,d=-1/0,p=1/0,f=-1/0;for(let w=0,A=l.vertexCount;w<A;w++){let S=w*2,_=l.vertices[S+0],M=l.vertices[S+1];_<c&&(c=_),_>d&&(d=_),M<p&&(p=M),M>f&&(f=M)}this._minX=c,this._minY=p,this._width=d-c,this._height=f-p,this._buffer=new uA(this._computeBufferEstimatedSize(l));let g=[],m=[];for(let w=l.elementCount-1;w>=0;w--){let A=w>=u,S=w*2,_=l.elements[S+0],M=l.elements[S+1],C=_+M,T={start:_,count:M,normals:[],continuous:[],concave:[]},P=_,O=C-1,D=_+1,k=this._shape.roundedCurves.length;do{let j=P-_,F=l.vertices[O*2+0],z=l.vertices[O*2+1],B=l.vertices[P*2+0],H=l.vertices[P*2+1],Q=l.vertices[D*2+0],Y=l.vertices[D*2+1],U=B-F,se=H-z,V=Math.sqrt(U*U+se*se);U/=V,se/=V;let ee=B-Q,J=H-Y,fe=Math.sqrt(ee*ee+J*J);ee/=fe,J/=fe,T.normals[j*2+0]=-J,T.normals[j*2+1]=ee,T.concave[j]=U*J-se*ee>0;let re=l.vertexIndices[P];if(Array.isArray(re))T.continuous[j]=!1;else{let[oe,ue]=this._shape.getCurveIndexFromVertexId(re-1,!0);if(ue>0&&ue<1)T.continuous[j]=!0;else{let ye=ue===1?oe+1:oe-1;ye=(ye+k)%k;let Te=ue===1?0:1,xe=this._shape.roundedCurves[oe].getTangent(ue),we=this._shape.roundedCurves[ye].getTangent(Te);T.continuous[j]=xe.dot(we)>.95}}A&&(T.normals[j*2+0]*=-1,T.normals[j*2+1]*=-1),[O,P,D]=[P,D,D+1],D>=C&&(D-=M)}while(D!==_+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(_*2,C*2),vertexCount:M,vertexIndices:new Array(M).fill(!0).map((j,F)=>[F,F]),elements:[0,M],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(_*2,C*2)});for(let j=1;j<=this._bevelSegments;j++){let F=j/this._bevelSegments*Math.PI/2,z=(1-Math.cos(F))*this._bevelSize,B=[],H=[],Q=[],Y=[],U=0;for(let V=0;V<M;V++){let ee=V*2,J=(V-1+M)%M*2,fe=l.vertices[T.start*2+ee+0],re=l.vertices[T.start*2+ee+1],oe=-T.normals[J+0]*z,ue=-T.normals[J+1]*z,ye=-T.normals[ee+0]*z,Te=-T.normals[ee+1]*z;if(T.concave[V]||!T.concave[V]&&A){let xe=Math.atan2(ue,oe),we=Math.atan2(Te,ye);we>xe&&(we-=Math.PI*2);let Ie=we-xe;if(T.continuous[V]||A){let He=xe+Ie/2,dt=Math.cos(He)*z,I=Math.sin(He)*z;B[2*U+0]=fe+dt*(A?-1:1),B[2*U+1]=re+I*(A?-1:1),Y[U]=V,U++}else{let He=Math.max(1,Math.floor(r/4*Math.abs(Ie)/Math.PI));for(let dt=0;dt<=He;dt++){let I=xe+Ie*(dt/He),L=Math.cos(I)*z,ie=Math.sin(I)*z;B[2*U+0]=fe+L,B[2*U+1]=re+ie,Y[U]=V,U++}}}else B[2*U+0]=fe+oe,B[2*U+1]=re+ue,Y[U]=V,H[V]=U,U++,B[2*U+0]=fe,B[2*U+1]=re,Y[U]=V,U++,B[2*U+0]=fe+ye,B[2*U+1]=re+Te,Y[U]=V,Q[V]=U,U++}let se=_n({windingRule:yt.POSITIVE,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[B],edgeCreateCallback:V=>{let ee=V.Org.idx,J=Y[ee],fe=Y[(ee+1)%Y.length];V.idx=[J,fe],V.Sym.idx=[fe,J]},vertexIdCallback:V=>{let ee=V.Lprev.idx;return[ee?ee[1]:0,V.idx?V.idx[0]:0]}});if(!se)throw console.log("Error"),new Error(`error generating bevel geometry for ${j}'th loop`);if(!se.vertexCount)break;for(let V=0;V<se.vertexIndices.length;V++){let[ee,J]=se.vertexIndices[V];if(ee===J)continue;let fe=J;J<ee&&(fe+=M);for(let re=ee;re<fe;re++){let oe=re%M,ue=(re+1)%M;if(!T.continuous[oe]||!T.continuous[ue]){se.vertexIndices[V]=[ee,oe],se.vertexIndices.splice(V+1,0,[ue,J]),se.vertices.splice((V+1)*2,0,se.vertices[V*2],se.vertices[V*2+1]);break}}}W.push({bevelI:j,angle:F,size:z,boundary:se,reverseMap:Y,insetPoints:B})}let X=(j,F,z)=>{let B=0,H=j.boundary.vertexIndices.length;for(;B<H&&z(j.boundary.vertexIndices[F]);)F=(F+1)%H,B++;return B},N=g.length;for(let j=1;j<W.length;j++){let F=W[j-1],z=W[j],B=F.boundary.vertexIndices.length,H=z.boundary.vertexIndices.length;if(!B||!H)break;let Q=T.concave.length,Y=0,U=Zp(Y,M);for(;!F.boundary.vertexIndices.filter(U).length||!z.boundary.vertexIndices.filter(U).length;)Y++,U=Zp(Y,M);let se=F.boundary.vertexIndices.findIndex(U),V=z.boundary.vertexIndices.findIndex(U);do se=(se+1)%B;while(U(F.boundary.vertexIndices[se]));do V=(V+1)%H;while(U(z.boundary.vertexIndices[V]));Y=(Y+1)%M;let ee=Y,J=this._buildBevelVert(T,F,(se-1+B)%B),fe=this._buildBevelVert(T,z,(V-1+H)%H),re=J,oe=fe,ue,ye,Te=!1;do{U=Zp(Y,M);let xe=X(F,se,U),we=X(z,V,U),Ie=Te;if(Te=!1,xe&&!we){for(let He=0;He<xe;He++)ue=this._buildBevelVert(T,F,(se+He)%B,He/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue;Te=!0}else if(!xe&&we)for(let He=0;He<we;He++)ye=this._buildBevelVert(T,z,(V+He)%H,He/(we-1)),g.push(oe.topN,re.topP,ye.topP),g.push(re.bottomP,oe.bottomN,ye.bottomP),oe=ye;else if(xe&&we)if(ue=this._buildBevelVert(T,F,se,0),ye=this._buildBevelVert(T,z,V,0),Ie?(g.push(re.topN,ye.topP,oe.topN),g.push(re.topN,ue.topP,ye.topP),g.push(ye.bottomP,re.bottomN,oe.bottomN),g.push(ye.bottomP,ue.bottomP,re.bottomN)):(g.push(oe.topN,re.topN,ue.topP),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,re.bottomN,oe.bottomN),g.push(ue.bottomP,oe.bottomN,ye.bottomP)),re=ue,oe=ye,xe===we)for(let He=1;He<xe;He++)ue=this._buildBevelVert(T,F,(se+He)%B,He/(xe-1)),ye=this._buildBevelVert(T,z,(V+He)%H,He/(we-1)),g.push(re.topN,ue.topP,oe.topN),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,re.bottomN,oe.bottomN),g.push(ue.bottomP,oe.bottomN,ye.bottomP),re=ue,oe=ye;else if(xe>we){let He=xe/we,dt=0;for(let I=1;I<xe;I++)ue=this._buildBevelVert(T,F,(se+I)%B,I/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue,I>(dt+1)*He&&(dt++,ye=this._buildBevelVert(T,z,(V+dt)%H,dt/(we-1)),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,oe.bottomN,ye.bottomP),oe=ye)}else{let He=we/xe,dt=0;for(let I=1;I<we;I++)ye=this._buildBevelVert(T,z,(V+I)%H,I/(we-1)),g.push(oe.topN,ue.topP,ye.topP),g.push(ue.bottomP,oe.bottomN,ye.bottomP),oe=ye,I>(dt+1)*He&&(dt++,ue=this._buildBevelVert(T,F,(se+dt)%B,dt/(xe-1)),g.push(re.topN,ue.topP,oe.topN),g.push(ue.bottomP,re.bottomN,oe.bottomN),re=ue)}se=(se+xe)%B,V=(V+we)%H,Y=(Y+1)%Q}while(Y!==ee)}if(this._buildWall(W,T,g),A){let j=[];for(let F=g.length-1;F>=N+2;F-=3){let z=g[F-2],B=g[F-1],H=g[F-0];j.push(H,B,z)}g.splice(N,g.length-N,...j)}if(A){let j=[];for(let F=W[W.length-1].boundary.vertices.length-1;F>=1;F-=2){let z=W[W.length-1].boundary.vertices[F-1],B=W[W.length-1].boundary.vertices[F-0];j.push(z,B)}m.push(j)}if(!A){let j=W[W.length-1],F=_n({windingRule:W.length>1?yt.POSITIVE:yt.ODD,elementType:Zt.POLYGONS,vertexSize:2,strict:!0,contours:[j.insetPoints,...m]});if(!F)throw new Error("Error generating geometry for surface");o.length===0&&Object.assign(this,{capStartIndex:g.length});for(let z=0;z<F.elementCount*3;z+=3){let B=this._buildSurfaceVert(F,F.elements[z+0]),H=this._buildSurfaceVert(F,F.elements[z+1]),Q=this._buildSurfaceVert(F,F.elements[z+2]);g.push(B.top,H.top,Q.top),g.push(Q.bottom,H.bottom,B.bottom)}}this.vertexCache={}}this._buffer.shrink();let v=new Xe(Uint32Array.from(g),1),y=new Xe(this._buffer.positions,3),b=new Xe(this._buffer.normals,3),x=new Xe(this._buffer.uvs,2);y.needsUpdate=!0,b.needsUpdate=!0,x.needsUpdate=!0,v.needsUpdate=!0,this.setAttribute("position",y),this.setAttribute("normal",b),this.setAttribute("uv",x),this.setIndex(v)}_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){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let r=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(r-this._minX)/this._width,a=(s-this._minY)/this._height,o=this._buffer.get(2),l=o*3,h=o*2,u={top:o+0,bottom:o+1};return this._buffer.positions[l+0]=r,this._buffer.positions[l+1]=s,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[h+0]=n,this._buffer.uvs[h+1]=a,this._buffer.positions[l+3]=r,this._buffer.positions[l+4]=s,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[h+2]=n,this._buffer.uvs[h+3]=a,this.vertexCache[i]=u,u}_buildBevelVert(e,t,i,r=1){let s=`${t.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[i],o,l,h,u;n!==a?(l=n,o=a,u=!1,h=e.continuous[l]&&e.continuous[o]):(o=n,l=(o-1+e.count)%e.count,u=e.concave[o]&&t.bevelI>0,h=e.continuous[o]||u);let c=Math.cos(t.angle),d=Math.sin(t.angle),p=i*2,f=o*2,g=l*2,m=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-d)*this._bevelSize,b=(m-this._minX)/this._width,x=(v-this._minY)/this._height,w=e.normals[f+0],A=e.normals[f+1],S=e.normals[g+0],_=e.normals[g+1];if(u){let O=S-w,D=_-A;w=w+O*(1-r),A=A+D*(1-r);let k=Math.sqrt(w*w+A*A);w/=k,A/=k}let M=this._buffer.get(h?2:4),C=M*3,T=M*2,P={i,fi:o,topP:M+0,topN:M+0,bottomP:M+1,bottomN:M+1};return this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=w*c,this._buffer.normals[C+1]=A*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=b,this._buffer.uvs[T+1]=x,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=w*c,this._buffer.normals[C+4]=A*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=x,this._buffer.uvs[T+3]=b,h||(M+=2,C+=6,T+=4,P.topP=M+0,P.bottomP=M+1,this._buffer.positions[C+0]=m,this._buffer.positions[C+1]=v,this._buffer.positions[C+2]=this._depth-y,this._buffer.normals[C+0]=S*c,this._buffer.normals[C+1]=_*c,this._buffer.normals[C+2]=d,this._buffer.uvs[T+0]=b,this._buffer.uvs[T+1]=x,this._buffer.positions[C+3]=m,this._buffer.positions[C+4]=v,this._buffer.positions[C+5]=y,this._buffer.normals[C+3]=S*c,this._buffer.normals[C+4]=_*c,this._buffer.normals[C+5]=-d,this._buffer.uvs[T+2]=x,this._buffer.uvs[T+3]=b),this.vertexCache[s]=P,P}clone(){let e=new pA(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=vu(this.userData),e}},fA=class extends pA{constructor(e,t,i=0,r=12,s=3,n=yt.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 fA(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=vu(this.userData),e}},Ca=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:yt.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 zt?(a.width!==r||a.height!==s)&&a.applySize(r,s):a=new zt(r,s).fromJSON(a),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&a.update());let l=a??new zt(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 dA(e.shape,s,{windingRule:a}):o=new fA(e.shape,t,i,s,r,a),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},mA=Math.PI*2,Jg=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 zt?e.shape:new zt,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=WF(h,u,c,s*Math.PI/180,r,n);h.isClosed=!0,h.update();let p=Ca.create({shape:h,parameters:{subdivisions:d,depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function WF(e,t,i,r,s,n){if(r>=mA)return s>30||s%4===0?(qF(e,t,i,n),Math.round(s/4)):bx(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=kF({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?XF(e,a.x,a.y,h,s,t,i,n):bx(e,r,s,t,i,n)}function XF(e,t,i,r,s,n,a,o){let l=Math.round(s/r.length);e.addPoint(Po(t,i));for(let h=0,u=r.length;h<u;h++){let c=r[h],d=e.points[h],p=Po(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?gA(e,n,a,o):e.addPoint(Po(0,0)),l}function bx(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(Po(h,u))}return t<mA?n>0?gA(e,r,s,n):e.addPoint(Po(0,0)):(e.removePoint(e.points[e.points.length-1]),n>0&&vA(e,r,s,n)),1}function qF(e,t,i,r=0,s=0,n=0){let a=.5522847498,o=t*a,l=i*a;e.addPoint(Ic(s-t,n,s-t,n-l,s-t,n+l)),e.addPoint(Ic(s,n+i,s-o,n+i,s+o,n+i)),e.addPoint(Ic(s+t,n,s+t,n+l,s+t,n-l)),e.addPoint(Ic(s,n-i,s+o,n-i,s-o,n-i)),r>0&&vA(e,t,i,r)}function Po(e,t){return new To(rt.generateUUID(),new G(e,t))}function Ic(e,t,i,r,s,n){let a=Po(e,t);return a.controls[0].position.set(i,r),a.controls[1].position.set(s,n),a}function gA(e,t,i,r){yA(e,t,i,r).forEach(s=>e.addPoint(s))}function vA(e,t,i,r){let s=yA(e,t,i,r),n=new zt;s.forEach(a=>n.addPoint(a)),n.isClosed=!0,e.shapeHoles.push(n)}function yA(e,t,i,r){let s=r*t/100,n=s*(Math.abs(i)/Math.abs(t)),a=new G(s/t,n/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=rt.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 YF=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 $g(!1,t,i,r,s,n,a,o,l,h,u,c);return Object.assign(d,{userData:{...e,type:"HelixGeometry"}})}},$g=class extends Ve{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,d=!1){super();let p=e&&n===1;p&&(c=0),u>100&&(u=100);let f=()=>new E,g=new E,m=f(),v=f(),y=f(),b,x,w,A,S,_,M,C,T=f(),P=f(),O=f(),D=f(),k=f(),W=f(),X=f(),N=f(),j=i-2*o+.001,F=j/n,z=Math.ceil(a*n),B=z+1,H=j/z,Q=-j/2,Y=h+1,U=2*Math.PI/h,se=Math.PI/2/c,V=.01,ee=Math.min((1-u/100)*o,o-V),J=o-ee,fe=0,re=2,oe=c*re+re,ue=Y*oe/re,ye=ue+Y*B,Te=Y*(B+oe),[xe,we,Ie]=[3,3,2].map(Ee=>Array(Te*Ee).fill(0)),He=[],dt=s-o;function I(Ee,_e){let Oe=Math.PI/2;_=_e*H,C=2*Math.PI*(_%F)/F+Oe,_+=Q,M=Math.sin(C)*dt,S=Math.cos(C)*dt,e?Ee.set(S,M,_):Ee.set(S,_,M)}I(g,-1e-10),I(m,0),T.copy(g),I(g,1);let L=g.distanceTo(m),ie=p?0:J+ee,pe=L*z+2*ie,me=ee,be=pe-ie;for(let Ee=0;Ee<=z;Ee++){I(v,Ee),N.subVectors(v,T).normalize(),T.copy(v),W.copy(v).setComponent(+e+1,0).normalize(),X.crossVectors(N,W).normalize();let _e=Ee===0,Oe=Ee===z,ze=_e?3*Math.PI/2:se,at=_e?me:be,Mt=_e?Y:ye,Wt=_e?0:Te-Y,q=N.clone().multiplyScalar(_e?-J:J).add(v),ne=N.clone().multiplyScalar(_e?-1:1).normalize();for(let de=0;de<Y;de++){let Ae=de*U;if(P.addVectors(g.copy(W).multiplyScalar(o*Math.cos(Ae)),m.copy(X).multiplyScalar(o*Math.sin(Ae))),O.copy(P).normalize(),_e||Oe){p||(fe=Wt+de,[0,1,2].forEach(De=>{xe[fe*3+De]=q.getComponent(De),we[fe*3+De]=ne.getComponent(De)}),Ie[fe*2]=+Oe,Ie[fe*2+1]=de/h),m.copy(O).multiplyScalar(ee),y.addVectors(v,m);for(let De=0;De<c;De++){let ot=De*se+ze;D.addVectors(g.copy(N).multiplyScalar(J*Math.sin(ot)),m.copy(O).multiplyScalar(J*Math.cos(ot))),k.copy(D).normalize(),m.addVectors(y,D),D.normalize(),fe=Mt+De*Y+de,[0,1,2].forEach(Ft=>{xe[fe*3+Ft]=m.getComponent(Ft),we[fe*3+Ft]=k.getComponent(Ft)});let Xt=+_e+Math.sin(ot);Ie[fe*2]=(at+J*Xt)/pe,Ie[fe*2+1]=de/h}}m.addVectors(v,P),fe=ue+Ee*Y+de,[0,1,2].forEach(De=>{xe[fe*3+De]=m.getComponent(De),we[fe*3+De]=O.getComponent(De)}),Ie[fe*2]=(ie+Ee*L)/pe,Ie[fe*2+1]=de/h}}let We=B+2*c+re,Me=1,[ce,Fe]=[+p,We-1];d&&(Fe-=1);for(let Ee=ce;Ee<=Fe-1;Ee++){let _e=p&&Ee===Fe-1;for(let Oe=0;Oe<Y-1;Oe++)b=Ee*Y+Oe,x=b+1,w=(_e?Oe:b)+Y,A=(_e?Oe+1:x)+Y,Ee===0?He.push(x,A,w):Ee===We-2?He.push(b,x,w):He.push(b,x,w,x,A,w)}this.setIndex(He),this.setAttribute("position",new Ce(xe,3)),this.setAttribute("normal",new Ce(we,3)),this.setAttribute("uv",new Ce(Ie,2))}},QF=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 xA(t*.5,n,a):new Pw(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},xA=class extends Qg{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 xA(e.radius,e.corner,e.cornerSides)}},ZF=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 yd;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 _w(s.extractPoints(r).shape,i);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...e,type:"LatheGeometry"}})}},Zr=new ve,Kp=new bt,Rc=new E,Yd=class extends Vi{constructor(){super(),this.uuid=rt.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 Ai().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 Zr.makeRotationX(e),this.applyMatrix4(Zr),this}rotateY(e){return Zr.makeRotationY(e),this.applyMatrix4(Zr),this}rotateZ(e){return Zr.makeRotationZ(e),this.applyMatrix4(Zr),this}translate(e,t,i){return Zr.makeTranslation(e,t,i),this.applyMatrix4(Zr),this}scale(e,t,i){return Zr.makeScale(e,t,i),this.applyMatrix4(Zr),this}lookAt(e){return Kp.lookAt(e),Kp.updateMatrix(),this.applyMatrix4(Kp.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 Ge().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 Lm(c,d,p,m,g,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new G().fromBufferAttribute(o,c),new G().fromBufferAttribute(o,d),new G().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new G().fromBufferAttribute(l,c),new G().fromBufferAttribute(l,d),new G().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(Rc).negate(),this.translate(Rc.x,Rc.y,Rc.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new ve;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 Yd;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 Kt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Mr),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 Ai().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 Lm(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let b=0,x=m.length;b<x;b++)f=m[b].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let b=0,x=v.length;b<x;b++)g=v[b],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,b=m.length;y<b;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,b=f.vertexNormals.length>0,x=f.color.r!==1||f.color.g!==1||f.color.b!==1,w=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,b),A=h(A,6,x),A=h(A,7,w),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)),b){let S=f.vertexNormals;i.push(u(S[0]),u(S[1]),u(S[2]))}if(x&&i.push(c(f.color)),w){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 Yd().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,b=m.length;y<b;y++){let x=m[y];v.push(x.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 KF().fromGeometry(this),t=new Ve,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",Bc.call(new Xe(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",Bc.call(new Xe(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",wx.call(new Xe(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",_x.call(new Xe(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",_x.call(new Xe(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 Ce(l.data.length*3,3);h.name=l.name,s.push(Bc.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Ce(e.skinIndices.length*4,4);t.setAttribute("skinIndex",Ax.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Ce(e.skinWeights.length*4,4);t.setAttribute("skinWeight",Ax.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 Ve,i=e.geometry;if(e.isPoints||e.isLine){let r=new Ce(i.vertices.length*3,3),s=new Ce(i.colors.length*3,3);if(t.setAttribute("position",Bc.call(r,i.vertices)),t.setAttribute("color",wx.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let n=new Ce(i.lineDistances.length,1);t.setAttribute("lineDistance",JF.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}};Yd.prototype.isGeometry=!0;var KF=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 x=v.normal;this.normals.push(x,x,x)}let b=v.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let x=v.color;this.colors.push(x,x,x)}if(s===!0){let x=r[0][m];x!==void 0?this.uvs.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",m),this.uvs.push(new G,new G,new G))}if(n===!0){let x=r[1][m];x!==void 0?this.uvs2.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new G,new G,new G))}for(let x=0;x<o;x++){let w=a[x].vertices;l[x].data.push(w[v.a],w[v.b],w[v.c])}for(let x=0;x<u;x++){let w=h[x].vertexNormals[m];c[x].data.push(w.a,w.b,w.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}},Lm=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 Ge,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 JF(e){return this.array.set(e),this}function wx(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 Ge),t[i++]=n.r,t[i++]=n.g,t[i++]=n.b}return this}function _x(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 G),t[i++]=n.x,t[i++]=n.y}return this}function Bc(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 Ax(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 $e),t[i++]=n.x,t[i++]=n.y,t[i++]=n.z,t[i++]=n.w}return this}var $F=["a","b","c"];function e6(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Jp(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),n=r+"_"+s;return i.get(n)}function $p(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 t6(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],$p(a.a,a.b,e,r,a,i),$p(a.b,a.c,e,r,a,i),$p(a.c,a.a,e,r,a,i)}function Nc(e,t,i,r,s){e.push(new Lm(t,i,r,void 0,void 0,s))}function Za(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function zc(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var i6=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ve?e=new Yd().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;t6(o,l,c,d);let p=[],f,g,m,v,y,b,x;for(let se of Array.from(d.keys())){for(g=d.get(se),m=new E,y=3/8,b=1/8,x=g.faces.length,x!=2&&(y=.5,b=0,x!=1),m.addVectors(g.a,g.b).multiplyScalar(y),t.set(0,0,0),n=0;n<x;n++){for(v=g.faces[n],a=0;a<3&&(f=o[e6(v,$F[a])],!(f!==g.a&&f!==g.b));a++);f&&t.add(f)}t.multiplyScalar(b),m.add(t),g.newEdge=p.length,p.push(m)}let w,A,S,_,M,C,T,P=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?w=3/16:i>3&&(w=3/(8*i)),A=1-i*Number(w),S=w,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++)_=M[n],f=_.a!==C?_.a:_.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),P.push(T)}let O=P.concat(p),D=P.length,k,W,X,N=[],j=[],F,z,B,H,Q=new G,Y=new G,U=new G;for(r=0,s=l.length;r<s;r++)v=l[r],k=Number(Jp(v.a,v.b,d).newEdge)+D,W=Number(Jp(v.b,v.c,d).newEdge)+D,X=Number(Jp(v.c,v.a,d).newEdge)+D,Nc(N,k,W,X,v.materialIndex),Nc(N,v.a,k,X,v.materialIndex),Nc(N,v.b,W,k,v.materialIndex),Nc(N,v.c,X,W,v.materialIndex),u&&(F=h[r],z=F[0],B=F[1],H=F[2],Q.set(Za(z.x,B.x),Za(z.y,B.y)),Y.set(Za(B.x,H.x),Za(B.y,H.y)),U.set(Za(z.x,H.x),Za(z.y,H.y)),zc(j,Q,Y,U),zc(j,z,Q,U),zc(j,B,Y,Q),zc(j,H,U,Y));e.vertices=O,e.faces=N,u&&(e.faceVertexUvs[0]=j)}},$t=new E,r6=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ve().copy(new gs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize($t),r={width:$t.x,height:$t.y,depth:$t.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 Ve().copy(new gs(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize($t)):$t.set(a.width,a.height,a.depth),(t!==$t.x||i!==$t.y||r!==$t.z)&&n.scale($t.x===0?1:t/$t.x,$t.y===0?1:i/$t.y,$t.z===0?1:r/$t.z);let o=n.originalGeometry;return s>0?(o===void 0||a?.subdivisions!==s)&&(o===void 0&&(o=n),n=new i6(s).modify(o).toBufferGeometry()):(o!==void 0&&(n=o),o=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),o!==void 0&&Object.assign(n,{originalGeometry:o}),delete e.geometry,Object.assign(n,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new Iw(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize($t);let n=100/$t.x;Object.assign(s.parameters,{width:100,height:$t.y*n,depth:$t.z*n}),t(this.build(s))})}},bA=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 zt?e.shape:new zt,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=Ca.create({shape:l,parameters:{roundness:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},s6=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 a6(t*.5,i,s,n,a,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Ol(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function ef(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 n6(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var a6=class extends Ve{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),b=new E(0,d,0),x=new G(e,-d),w=new G(f,-d),A=new G(0,b.y).sub(w),S=new G(0,b.y).sub(x),_=new G(A.y,-A.x).normalize(),M=new G(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 N=new E(_.x,_.y,0),j=new E(Math.cos(g)*N.x,N.y,Math.sin(g)*N.x);T=N.angleTo(j)}let P=n/Math.tan((Math.PI-A.angle())/2),O=n/Math.tan((Math.PI-T)/2),D=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),u.push(0,0);let N=c++,j=[],F=x.clone(),z=P/Math.cos(Math.PI/i);F.x-=z;for(let B=0;B<i;B++){let H=B/i*Math.PI*2+p,Q=new G(Math.sin(H),Math.cos(H));Ol(F,Q,D),l.push(D.x,D.y,D.z),h.push(0,-1,0),u.push(0,0),j.push(c++)}for(let B=0;B<j.length;B++)o.push(j[B],N,j[(B+1)%j.length])}let k=[];{let N=new E,j=new E,F=new E,z=new E,B=new E,H=new E;for(let Q=0;Q<i;Q++){let Y=Q/i*Math.PI*2+p,U=(Q+.5)/i*Math.PI*2+p,se=(Q+1)/i*Math.PI*2+p,V=new G(Math.sin(Y),Math.cos(Y)),ee=new G(Math.sin(U),Math.cos(U)),J=new G(Math.sin(se),Math.cos(se));Ol(x,V,j),Ol(x,J,F),Ol(_,ee,N),ef(b,j,F,O,O,z),l.push(z.x,z.y,z.z),ef(j,b,F,O,P,B),l.push(B.x,B.y,B.z),ef(F,j,b,P,O,H),l.push(H.x,H.y,H.z),h.push(N.x,N.y,N.z),h.push(N.x,N.y,N.z),h.push(N.x,N.y,N.z),u.push(0,0),u.push(0,0),u.push(0,0);let fe=c++,re=c++,oe=c++;if(o.push(fe,re,oe),n>0){{let Te=j.clone().add(F).multiplyScalar(.5),xe=b.clone().sub(Te).normalize(),we=y.clone().sub(Te).normalize().add(xe).normalize().multiplyScalar(-1),Ie=H.clone().sub(B);W(Te,Ie,we,A.angle())}let ue,ye;{let Te=new E;Ol(M,J,Te);let xe=H.clone().add(z).multiplyScalar(.5);xe=n6(xe,F,b);let we=H.clone().sub(z);[ue,ye]=W(xe,we,Te,T,z.y)}{let Te=ue,xe=Te.clone().setY(0).normalize(),we=new E(0,-1,0),Ie=xe.clone().cross(we);X(Te,xe,we,Ie)}k.concat(ye);{let Te=A.angle(),xe=Math.PI-Te,we=b.clone();we.y-=n/Math.sin(Te-Math.PI/2);let Ie=new E,He=[];for(let I=0;I<a;I++){let L=[],ie=Math.PI/2-xe*I/a,pe=Math.cos(ie),me=Math.sin(ie),be=U;for(let We=0;We<=I;We++){let Me=Math.cos(be),ce=Math.sin(be);N.x=pe*ce,N.y=me,N.z=pe*Me,Ie.copy(we).addScaledVector(N,n),l.push(Ie.x,Ie.y,Ie.z),h.push(N.x,N.y,N.z),u.push(0,0),L.push(c++),be+=Math.PI*2/I/i}He.push(L)}ye.reverse(),He.push(ye);let dt=He.length-1;for(let I=0;I<dt;I++){let L=He[I],ie=He[I+1],pe=L.length-1;o.push(ie[1],L[0],ie[0]);for(let me=1;me<=pe;me++)o.push(L[me],L[me-1],ie[me]),o.push(ie[me+1],L[me],ie[me])}}}}}this.setIndex(o),this.setAttribute("position",new Ce(l,3)),this.setAttribute("normal",new Ce(h,3)),this.setAttribute("uv",new Ce(u,2));function W(N,j,F,z,B){let H=-z/2,Q=(Math.PI-z)/2,Y=j.clone().normalize().cross(F);N.addScaledVector(F,-n/Math.sin(Q));let U=new E,se=new E,V=1,ee=c,J=[];for(let fe=0;fe<=a;fe++){let re=H+fe/a*z;se.set(0,0,0),se.addScaledVector(Y,Math.sin(re)),se.addScaledVector(F,Math.cos(re));for(let oe=0;oe<=V;oe++){let ue=oe/V-.5;if(U.copy(N),U.addScaledVector(j,ue),U.addScaledVector(se,n),B!=null){let ye=Math.max(0,U.y-B);U.addScaledVector(j,-ye/j.y)}l.push(U.x,U.y,U.z),h.push(se.x,se.y,se.z),u.push(0,0),oe===0&&J.push(c),c++}}for(let fe=0;fe<a;fe++)for(let re=0;re<V;re++){let oe=ee+re+(V+1)*fe,ue=oe+(V+1),ye=ue+1,Te=oe+1;o.push(oe,ue,Te),o.push(ue,ye,Te)}return[N.clone().addScaledVector(j,.5),J]}function X(N,j,F,z){let B=Math.PI/2,H=S.angle()-B,Q=[],Y=new E,U=new E;for(let V=0;V<=a;V++){let ee=[],J=V/a;for(let fe=0;fe<=V;fe++){let re=((V?fe/V:0)-.5)*v,oe=Math.cos(re),ue=Math.sin(re),ye=Math.atan(Math.tan(H)*oe),Te=(B+ye)*J,xe=Math.cos(Te),we=Math.sin(Te);Y.set(0,0,0),Y.addScaledVector(j,we*oe),Y.addScaledVector(F,xe),Y.addScaledVector(z,we*ue),U.copy(N).addScaledVector(Y,n),l.push(U.x,U.y,U.z),h.push(Y.x,Y.y,Y.z),u.push(0,0),ee.push(c++)}Q.push(ee)}let se=Q.length-1;for(let V=0;V<se;V++){let ee=Q[V],J=Q[V+1],fe=ee.length-1;o.push(ee[0],J[1],J[0]);for(let re=1;re<=fe;re++)o.push(ee[re-1],ee[re],J[re]),o.push(ee[re],J[re+1],J[re])}}}},wA=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 zt?e.shape:new zt,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(x,w,A){return w>i&&A>r?Math.min(x*i/w,x*r/A):w>i?x*i/w:A>r?x*r/A:x}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 x=0,w=t.points.length;x<w;x++)t.points[x].roundness=p[x],x>0&&p[x]!==p[x-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=n!==1,t.update();let b=Ca.create({shape:t,parameters:{depth:a,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...e,type:"RectangleGeometry"}})}},o6=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 pg(.5*t,s,n,a,o,l,h);return u.scale(1,i/t,r/t),Object.assign(u,{userData:{...e,type:"SphereGeometry"}})}},l6=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 au(t,i,r,s);return n.scale(1,1,1),Object.assign(n,{userData:{...e,type:"PlaneGeometry"}})}},h6=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 c6(t,i,r,s,n,a);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},c6=class extends Ve{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=(se=0,V=0,ee=0)=>new E(se,V,ee),p=d(),f=d(),[g,m,v]=[t/2,e/2,i/2],y=-m,b=+m,[x,w,A]=[d(y,-g,+v),d(y,-g,-v),d(y,+g,-v)],S=(se,V=!1)=>Math.sin(se-Math.PI/(1+ +V)),_=(se,V=!1)=>Math.cos(se-Math.PI/(1+ +V));A.y=Math.sin(r)*t-g;let M=Math.cos(r)*t-v,C=x.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):w.z=Math.min(w.z-M-v,x.z-h),p.subVectors(x,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,P=T*Math.tan(r/2),O=T/Math.cos(r/2),D=p.clone().normalize().add(f.normalize()).setLength(O).add(w);p.set(0,S(r,!0),_(r,!0)),u.push([A,p.clone()]);let k=(Math.PI-r)/n;for(let se=0;se<=n;se++){let V=c+r+se*k;p.set(0,Math.sin(V)*P,Math.cos(V)*P),p.add(D),f.set(0,S(V),_(V)),u.push([p.clone(),f.clone()])}u.push([x,d(0,1,0)]);let W=Math.sin(k/2)*P*2,X=u.length-1,N=u[0][0].distanceTo(u[1][0]),j=u[X-1][0].distanceTo(u[X][0]),F=N+W*n+j;u[0].push(1);for(let se=0;se<=n;se++)u[se+1].push(1-(N+se*W)/F);u[X].push(0);let[z,B,H]=u[0],Q,Y,U;for(let se=1;se<u.length;se++)[Q,Y,U]=u[se],a.push(y,z.y,z.z,y,Q.y,Q.z,b,z.y,z.z,b,z.y,z.z,y,Q.y,Q.z,b,Q.y,Q.z),o.push(0,B.y,B.z,0,Y.y,Y.z,0,B.y,B.z,0,B.y,B.z,0,Y.y,Y.z,0,Y.y,Y.z),l.push(0,H,0,U,1,H,1,H,0,U,1,U),[z,B,H]=[Q,Y,U];this.setAttribute("position",new Ce(a,3)),this.setAttribute("normal",new Ce(o,3)),this.setAttribute("uv",new Ce(l,2))}},_A=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 zt?e.shape:new zt,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 x=0;x<s;x++){let w=g*x,A=p+Math.sin(w)*c,S=f+Math.cos(w)*d;u.addPoint(u.createPoint(A,S))}}else for(let x=0;x<s;x++){let w=p+Math.cos(m)*c,A=f+Math.sin(m)*d;u.addPoint(u.createPoint(w,A)),m+=g,w=p+Math.cos(m)*v,A=f+Math.sin(m)*y,x<=s,u.addPoint(u.createPoint(w,A)),m+=g}u.isClosed=!0;for(let x=0,w=u.points.length;x<w;x++)u.points[x].roundness=n;u.roundness=n,u.update();let b=Ca.create({shape:u,parameters:{roundness:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(b,{userData:{...e,type:"StarGeometry"}})}},d6=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 au(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},u6=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=p6(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 p6(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 $g(!0,e,t,i,r,s,n,a,o,l,h,u)}var f6=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 Dw(o,i,r,s,n,a);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},m6=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 zt?e.shape:new zt,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=Ca.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function g6(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var v6=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??Jg.create({parameters:X_}).userData.shape;return{path:e.path??Bd.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:n,extrusion:{...q_,...i.extrusion}}),shapeData:a}}static build(e){if(e.path.points.length>=2){let t=new y6(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ve,{userData:{...e,type:"PathGeometry"}})}},y6=class extends Ve{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)||!g6(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=Math.max(2,Math.ceil(this.inputs.path.isClosed?i*e.length:(Math.min(r+i,1)-r)*e.length)),n=[],a=[],o=Math.floor(r*e.length);for(let b=0;b<s;b++){let x=this.inputs.path.isClosed?(b+o)%e.length:Math.min(e.length-1,b+o);n.push(e[x]),a.push(t[x])}this._isOpenEnded()&&this._isGeometryClosed()&&(s++,n.push(n[0].clone()),a.push(a[0].clone())),this._applyPathModifiers(a);let{regions:l,infos:h,vertices:u}=this._computeShapePoints(5),c=0,d=0;h.sort((b,x)=>b.start-x.start),h.forEach(b=>{b.verticesStart=c,b.verticesCount=b.count+b.continuous.reduce((x,w)=>x+(w?0:1),0),d+=b.verticesCount,c=d});let p=d*s,f,g=0;this._isOpenEnded()&&(f=_n({windingRule:yt.ODD,elementType:Zt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:l}),g=f.vertexCount);let m=p+2*g,v={positions:new Float32Array(m*3),normals:new Float32Array(m*3),uvs:new Float32Array(m*2)},y=[];h.forEach(b=>{this._extrudeRegion(b,u,a,n,v,y,this._isGeometryClosed()&&!this._isOpenEnded())}),f&&(this._closeEnd(f,p,y,v,a[0],n[0],!1),this._closeEnd(f,p+g,y,v,a[a.length-1],n[n.length-1],!0)),this.setAttribute("position",new Xe(v.positions,3)),this.setAttribute("normal",new Xe(v.normals,3)),this.setAttribute("uv",new Xe(v.uvs,2)),this.setIndex(y),this.computeVertexNormals()}_extractPathPoints(){let e=this.inputs.path.isClosed,t=sA(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let i=[t[0]];return t.forEach(r=>{i[i.length-1].distanceToSquared(r)>.001&&i.push(r)}),e&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_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-1]:g.clone().multiplyScalar(2).sub(e[1]):m=e[f-1];let v;f===i-1?v=r?e[0]:g.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=g.clone().sub(m).normalize(),b=v.clone().sub(g).normalize(),x=y.clone().add(b).normalize();a.copy(x),f===0&&(x.equals(l)||x.clone().negate().equals(l))&&l.set(0,0,1);let w=l.clone().cross(x).normalize(),A=x.clone().cross(w).normalize();l.copy(A),o.copy(w),f===0&&(s.copy(A),n.copy(x));let S=new ve().makeBasis(w,A,x);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 ve().makeRotationZ(d*f/t.length);t[f].multiply(g)}return t}_applyPathModifiers(e){let t=e.length,{angle:i,twist:r,startScale:s,endScale:n}=this.inputs.parameters.extrusion,a=new ve,o=new ve;return e.forEach((l,h)=>{let u=this._isGeometryClosed()?h/t:h/(t-1);a.makeRotationZ(rt.lerp(i,i+r,u));let c=rt.lerp(s,n,u);o.makeScale(c,c,c),l.multiply(a).multiply(o)}),e}_computeShapePoints(e=12,t=yt.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=_n({windingRule:t,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]}),a=_n({windingRule:yt.ODD,elementType:Zt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]});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,b={start:m,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};d.push(b);let x=m,w=y-1,A=m+1,S=i.roundedCurves.length;do{let _=x-m,M=n.vertices[w*2+0],C=n.vertices[w*2+1],T=n.vertices[x*2+0],P=n.vertices[x*2+1],O=n.vertices[A*2+0],D=n.vertices[A*2+1],k=T-M,W=P-C,X=Math.sqrt(k*k+W*W);k/=X,W/=X;let N=T-O,j=P-D,F=Math.sqrt(N*N+j*j);N/=F,j/=F,b.normals[_*2+0]=-j,b.normals[_*2+1]=N;let z=n.vertexIndices[x];if(Array.isArray(z))b.continuous[_]=!1;else{let[B,H]=i.getCurveIndexFromVertexId(z-1,!0);if(H>0&&H<1)b.continuous[_]=!0;else{let Q=H===1?B+1:B-1;Q=(Q+S)%S;let Y=H===1?0:1,U=i.roundedCurves[B].getTangent(H),se=i.roundedCurves[Q].getTangent(Y);b.continuous[_]=U.dot(se)>.95}}f&&(b.normals[_*2+0]*=-1,b.normals[_*2+1]*=-1),[w,x,A]=[x,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 G;i.forEach((c,d)=>{let p=r[d],f=e.verticesStart*i.length+e.verticesCount*d;for(let g=0;g<e.count;g++){let m=(e.start+g)*2;o.set(t[m+0],t[m+1],0).applyMatrix4(c).add(p),l.set(e.normals[g*2+0],e.normals[g*2+1],0).applyMatrix4(c).normalize(),h.set(g/(e.count-1),d/(i.length-1)),this._insertVertex(s,f,o,l,h),f++,e.continuous[g]||(this._insertVertex(s,f,o,l,h),f++)}});let u=a?i.length:i.length-1;for(let c=0;c<u;c++){let d=e.verticesStart*i.length+e.verticesCount*c,p=a&&c===u-1?e.verticesStart*i.length:e.verticesStart*i.length+e.verticesCount*(c+1),f=0;for(let g=0;g<e.count;g++){e.continuous[g]||f++;let m=(g+1)%e.count===0?0:f+1,v=d+f,y=d+m,b=p+m,x=p+f;e.isHole?n.push(v,b,y,v,x,b):n.push(v,y,b,v,b,x),f++}}}_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 G;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)}}};function x6(){let e=new Ve;return e.setAttribute("position",new Xe(new Float32Array([]),3)),e.setIndex(new Xe(new Uint16Array([]),1)),e}var b6=12,w6=1,AA=class extends Ve{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],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=_6(e,t,h),{shapes:c,charWidths:d,charCoords:p}=t.generateShapes(u,e),f=i*.5,g=r*.5,m=c.map(b=>new zt().fromShape(b));this.vectorShapes=m;let v=m.map(b=>Ca.create({shape:b,parameters:{depth:s,extrudeBevelSegments:a,extrudeBevelSize:n,windingRule:s<=0?yt.NONZERO:yt.ODD,subdivisions:this.isLowResolution&&s>0?w6:b6}})),y=v.length?mo(v):x6();y.translate(-f,g,0),this.dispose(),this.wrappedText=u,this.charCoords=p,this.charWidths=d,this.deleteAttribute("extrudeNormal"),Object.entries(y.attributes).forEach(([b,x])=>{this.setAttribute(b,x)}),this.setIndex(y.index),this.computeBoundingSphere()}clone(){let e=Aa(new Ve,AA.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 _6(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 SA,ev=new Promise(e=>{SA=e}),Sx=!1;async function A6(){if(Sx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.258/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});SA(s),Sx=!0}function Qd(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=zt.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 Iw().parse(e);else{if(e.type==="SubdivGeometry")return new Ii(e,i);if(e.type==="TextGeometry")return new AA(e,t)}let s;try{s=Dx(r)}catch(n){console.error(n)}if(!s){let n=zt.createFromState(Rd.defaultData(),100,100);r.shape=n,s=Dx(r)}return s}var S6=new ve;function Im(e,t,i,r){let s=e.position.array,n=e.normal.array,a=S6.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 Uc=new Kt,Ka=new E,Ue;ev.then(e=>{Ue=e});var Mx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ex=new Uint32Array([0,1,2,3]),Cx=new Uint8Array([4]),Ii=class extends Ve{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=ma.div(t,i);this.subdividedGeometry&&Im(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Im(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(Ka.fromArray(r));let n=Ka.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}=Ii.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new gs(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&&(Ii.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Mr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Uc.setFromBufferAttribute(t),Uc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Uc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Uc.getSize(Ka);let r={width:Ka.x,height:Ka.y,depth:Ka.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&&(Ue.free_bvh(t),Ue.free_subdivision_surface(t));try{s=Ii.allocate(e,r)}catch(l){console.error(l,e),s=Ii.allocate({positionWASM:Mx,indexWASM:Ex,verticesPerFaceWASM:Cx},r)}if(Ue.set_destination_refinement_level(s,0),n=Ii.buildLevel(s,!0,o),e.subdivisions>0)try{Ue.set_destination_refinement_level(s,e.subdivisions),a=Ii.buildLevel(s,!1,o)}catch{try{Ue.set_destination_refinement_level(s,e.subdivisions-1),a=Ii.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;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new $g(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:Qd(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=tv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=MA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}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=Mx,r=Ex,s=Cx);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=Ue._malloc(d),m=new Float32Array(Ue.HEAPF32.buffer,g,u),v=new Uint32Array(Ue.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(x=>x!==1)&&(y=new ve().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let b=y?Ue.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ue.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ue._free(g),b}static buildLevel(e,t,i,r,s){let n=s?Ue.get_mesh_data2(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i,s.elements):Ue.get_mesh_data(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i),a=8,o=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Ue.HEAPU32[o[h]>>2],c=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ue.HEAPU32[o[h]>>2],p=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ue.HEAPU32[o[h]>>2],g=Ue.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Ue.HEAPU32[o[h]>>2],v=Ue.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ve;if(y.setIndex(new Kl(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new Kl(g,1));let b=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(b,4))}return Ue.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,Ue.free_mesh_data(n)}static freeSubdivPointer(e){Ue.free_bvh(e),Ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ue.get_wireframe_data_for_base_level(e),s=4,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ue.HEAPU32[n[o]>>2],h=Ue.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Ue.HEAPU32[n[o]>>2],c=Ue.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new Ve;d.setAttribute("position",new Ce(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 Xe(p,3)),d.setIndex(new Kl(c,1)),Ue.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ue.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ue.set_destination_refinement_level(e,t);let s=i?Ue.get_topological_data2(e,r?Ue.Level.CONTROL:Ue.Level.REFINED,i.elements):Ue.get_topological_data(e,r?Ue.Level.CONTROL:Ue.Level.REFINED),n=6,a=Ue.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ue.HEAPU32[a[l]>>2],u=new Float32Array(Ue.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ue.HEAPU32[a[l]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ue.HEAPU32[a[l]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ue.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Tx=["getX","getY","getZ"];function tv(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[Tx[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Tx[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 Fc=new E,tf=new E,rf=new E,sf=new E;function MA(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 a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Fc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),tf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),rf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),sf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),tf.sub(Fc).normalize(),rf.sub(Fc).normalize(),sf.sub(Fc).normalize();let l=tf.cross(rf).dot(sf);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var dn={};F2(dn,{calcBoolean:()=>P6,calcBooleanTopological:()=>T6,freeMeshSet:()=>L6,getMeshSet:()=>D6,transformMeshSet:()=>O6});var EA,M6=new Promise(e=>{EA=e}),Px=!1;async function E6(){if(Px)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.258/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});EA(s),Px=!0}var tt,Do;M6.then(e=>tt=e);function C6(e,t,i){let r,{positions:s,triIndices:n}=tv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=MA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function CA(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=tt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(tt.HEAPU32.buffer,n,t):new Float32Array(tt.HEAPF32.buffer,n,t)).set(e,0),n}function TA(e){switch(e){case 0:return tt.OP.UNION;case 1:return tt.OP.INTERSECTION;case 2:return tt.OP.A_MINUS_B;case 3:return tt.OP.B_MINUS_A;case 4:return tt.OP.SYMMETRIC_DIFFERENCE;case 5:return tt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function T6(e,t){Do===void 0&&(Do=tt.init_csg());let i=CA(e),r=tt.csg_calc_topological(Do,i,e.length,TA(t));tt._free(i);let s=6,n=tt.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=tt.HEAPU32[n[o]>>2],h=new Float32Array(tt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=tt.HEAPU32[n[o]>>2],c=new Uint32Array(tt.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=tt.HEAPU32[n[o]>>2],p=new Uint8Array(tt.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return tt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function P6(e,t,i,r){Do===void 0&&(Do=tt.init_csg());let s=CA(e),n=tt.csg_calc(Do,s,e.length,r,TA(t));tt._free(s);let a=5,o=tt.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=tt.HEAPU32[o[h]>>2],c=tt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=tt.HEAPU32[o[h]>>2],p=tt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=tt.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Mr),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},tt.free_mesh_data(n),f}function D6(e,t,i){if(tt===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,b=0;v<m.verticesPerFace.length;v++){s[b++]=m.verticesPerFace[v];for(let x=0;x<m.verticesPerFace[v];x++)s[b++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=C6(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=tt._malloc(u),f=new Float32Array(tt.HEAPF32.buffer,p,l),g=new Uint32Array(tt.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),tt.get_csg_mesh(p,a,p+c,o,n)}function O6(e,t){tt.transform_csg_mesh(e,t.elements)}function L6(e){tt.free_csg_mesh(e)}var I6={ConeGeometry:fF,CubeGeometry:mF,CylinderGeometry:pF,DodecahedronGeometry:vF,EllipseGeometry:Jg,HelixGeometry:YF,IcosahedronGeometry:QF,LatheGeometry:ZF,NonParametricGeometry:r6,PolygonGeometry:bA,PyramidGeometry:s6,RectangleGeometry:wA,SphereGeometry:o6,PlaneGeometry:l6,BackdropGeometry:h6,StarGeometry:_A,TextFrameGeometry:d6,TorusGeometry:u6,TorusKnotGeometry:f6,TriangleGeometry:m6,PathGeometry:v6,VectorGeometry:Ca},Dx=e=>I6[e.type].create(e);function Ll(e){return e!==null&&"booleanOp"in e}var PA=class extends nA(er){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ve}updateVisible(){super.updateVisible(),this.visible=!Ll(this.parent)&&this.visible,Ll(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ll(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof PA&&(e.freeBooleanPointer(),Ll(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ll(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},kc=new Kt;function iv(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)}kc.min.set(n,a,o),kc.max.set(l,h,u),kc.getCenter(r),kc.getSize(s).multiplyScalar(.5)}var R6=new Ve,B6=new Ph,nr=class extends PA{constructor(e,t){super(R6,B6),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?iv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Ox=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}},Bn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=rt.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 Bn&&(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}},N6=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}},Ui=new N6,St=class extends Bn{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=rt.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}},or=class extends St{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))}},vr=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(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)}},fr=class extends or{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)}},Gi=class extends Ge{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}},na=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Gi?e:new Gi(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)}},z6=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Lx=/[a-z_0-9]+/gi,Re=class extends St{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=Lx.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&&Ui.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Ui.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Ui.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&&Ui.contains(p)&&e.include(Ui.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=z6.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(Lx);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=""}}},U6=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,DA=class extends St{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||DA.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=U6.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)}},vt=DA;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var F6=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 SA,ev=new Promise(e=>{SA=e}),Sx=!1;async function A6(){if(Sx)return;let e="https://unpkg.com/@splinetool/modelling-wasm@0.9.260/build",[t,i]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});SA(s),Sx=!0}function Qd(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=zt.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 Iw().parse(e);else{if(e.type==="SubdivGeometry")return new Ii(e,i);if(e.type==="TextGeometry")return new AA(e,t)}let s;try{s=Dx(r)}catch(n){console.error(n)}if(!s){let n=zt.createFromState(Rd.defaultData(),100,100);r.shape=n,s=Dx(r)}return s}var S6=new ve;function Im(e,t,i,r){let s=e.position.array,n=e.normal.array,a=S6.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 Uc=new Kt,Ka=new E,Ue;ev.then(e=>{Ue=e});var Mx=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ex=new Uint32Array([0,1,2,3]),Cx=new Uint8Array([4]),Ii=class extends Ve{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=ma.div(t,i);this.subdividedGeometry&&Im(this.subdividedGeometry.attributes,...r),this.originalGeometry&&Im(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(Ka.fromArray(r));let n=Ka.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}=Ii.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new gs(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&&(Ii.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Mr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;Uc.setFromBufferAttribute(t),Uc.getCenter(i),e.boundingSphere.radius=i.distanceTo(Uc.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Uc.getSize(Ka);let r={width:Ka.x,height:Ka.y,depth:Ka.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&&(Ue.free_bvh(t),Ue.free_subdivision_surface(t));try{s=Ii.allocate(e,r)}catch(l){console.error(l,e),s=Ii.allocate({positionWASM:Mx,indexWASM:Ex,verticesPerFaceWASM:Cx},r)}if(Ue.set_destination_refinement_level(s,0),n=Ii.buildLevel(s,!0,o),e.subdivisions>0)try{Ue.set_destination_refinement_level(s,e.subdivisions),a=Ii.buildLevel(s,!1,o)}catch{try{Ue.set_destination_refinement_level(s,e.subdivisions-1),a=Ii.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;if(e.type==="TorusGeometry"&&e.arc===Math.PI*2){let{width:h,height:u,depth:c,arc:d,tubularSegments:p,radialSegments:f}=e;r=new $g(!0,h,c,u,h*.5,d/(2*Math.PI),p,c/2,0,f,0,0,!0)}else r=e.shape!==void 0?t.geometry:Qd(e,i,!1);let s,n,a,o;({positions:s,triIndices:o}=tv(r.getAttribute("position"),r.getIndex()));let l;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let h=e.radialSegments*e.heightSegments*3*2,u=h+e.radialSegments*3;l=[h,u]}return{indices:n,verticesPerFace:a}=MA(s,o,r,l),{positions:s,indices:n,verticesPerFace:a}}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=Mx,r=Ex,s=Cx);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=Ue._malloc(d),m=new Float32Array(Ue.HEAPF32.buffer,g,u),v=new Uint32Array(Ue.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(x=>x!==1)&&(y=new ve().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let b=y?Ue.alloc_subdivision_surface2(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):Ue.alloc_subdivision_surface(g,o,g+p,l,g+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return Ue._free(g),b}static buildLevel(e,t,i,r,s){let n=s?Ue.get_mesh_data2(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i,s.elements):Ue.get_mesh_data(e,t?Ue.Level.CONTROL:Ue.Level.REFINED,i),a=8,o=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(4,4+4),h=0,u=Ue.HEAPU32[o[h]>>2],c=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=Ue.HEAPU32[o[h]>>2],p=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=Ue.HEAPU32[o[h]>>2],g=Ue.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let m=Ue.HEAPU32[o[h]>>2],v=Ue.HEAPU32.subarray(m>>2,(m>>2)+l[h]);if(h++,r===void 0){let y=new Ve;if(y.setIndex(new Kl(v,1)),y.setAttribute("position",new Ce(c,3)),y.setAttribute("normal",new Ce(p,3)),t){y.setAttribute("faceMap",new Kl(g,1));let b=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Xe(b,4))}return Ue.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,Ue.free_mesh_data(n)}static freeSubdivPointer(e){Ue.free_bvh(e),Ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=Ue.get_wireframe_data_for_base_level(e),s=4,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(2,2+2),o=0,l=Ue.HEAPU32[n[o]>>2],h=Ue.HEAPF32.subarray(l>>2,(l>>2)+a[o]);o++;let u=Ue.HEAPU32[n[o]>>2],c=Ue.HEAPU32.subarray(u>>2,(u>>2)+a[o]);if(t===void 0){let d=new Ve;d.setAttribute("position",new Ce(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 Xe(p,3)),d.setIndex(new Kl(c,1)),Ue.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,Ue.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||Ue.set_destination_refinement_level(e,t);let s=i?Ue.get_topological_data2(e,r?Ue.Level.CONTROL:Ue.Level.REFINED,i.elements):Ue.get_topological_data(e,r?Ue.Level.CONTROL:Ue.Level.REFINED),n=6,a=Ue.HEAPU32.subarray(s>>2,(s>>2)+n),o=a.subarray(3,3+3),l=0,h=Ue.HEAPU32[a[l]>>2],u=new Float32Array(Ue.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=Ue.HEAPU32[a[l]>>2],d=new Uint32Array(Ue.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=Ue.HEAPU32[a[l]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return Ue.free_topological_data(s),{positions:u,indices:d,verticesPerFace:f}}},Tx=["getX","getY","getZ"];function tv(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[Tx[d]](u)*o)},`;if(c in i)n.push(i[c]);else{for(let d=0;d<3;d++)a.push(e[Tx[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 Fc=new E,tf=new E,rf=new E,sf=new E;function MA(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 a=i.userData.shape.extractShapePointsToFlatArray([]),o=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&o<=24&&o%4===0&&i.userData.parameters.angle>=360){let u=a.length/2/o;a=a.filter((c,d)=>Math.floor(d/2)%u===0)}let l=0;for(let u=0;u<a.length;u+=2)l+=(a[u]-a[(u===0?a.length:u)-2])*(a[u+1]+a[(u===0?a.length:u)-1]);e.length=0;let h=0;if(l<0)for(let u=0;u<a.length;u+=2)e.push(a[u],a[u+1],0),s.push(h++);else for(let u=a.length-2;u>=0;u-=2)e.push(a[u],a[u+1],0),s.push(h++);return n.push(h),{indices:s,verticesPerFace:n}}for(let a=0,o=i.capStartIndex??t.length;a<o;)if(t[a+1]===t[a+3]&&t[a+2]===t[a+5]||t[a+0]===t[a+3]&&t[a+2]===t[a+4]){Fc.set(e[t[a]*3],e[t[a]*3+1],e[t[a]*3+2]),tf.set(e[t[a+1]*3],e[t[a+1]*3+1],e[t[a+1]*3+2]),rf.set(e[t[a+4]*3],e[t[a+4]*3+1],e[t[a+4]*3+2]),sf.set(e[t[a+5]*3],e[t[a+5]*3+1],e[t[a+5]*3+2]),tf.sub(Fc).normalize(),rf.sub(Fc).normalize(),sf.sub(Fc).normalize();let l=tf.cross(rf).dot(sf);Math.abs(l)>.005||r&&r.some((h,u)=>u%2===1?!1:a>=r[u]&&a<r[u+1])?(s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3):(s.push(t[a],t[a+1],t[a+4],t[a+5]),n.push(4),a+=6)}else s.push(t[a],t[a+1],t[a+2]),n.push(3),a+=3;if(i.capStartIndex!==void 0){let a=[],o=[],l=0,h=new Float32Array([i.userData.parameters.depth])[0];for(let u=0,c=0;u<e.length;u+=3,c++)e[u+2]===0&&(a.push(c),l++),e[u+2]===h&&o.push(c);if(i.userData.parameters.extrudeBevelSize===0){let u=o[0];o[0]=o[1],o[1]=u}a.reverse(),s.push(...a,...o),n.push(l,l)}return{indices:s,verticesPerFace:n}}var dn={};F2(dn,{calcBoolean:()=>P6,calcBooleanTopological:()=>T6,freeMeshSet:()=>L6,getMeshSet:()=>D6,transformMeshSet:()=>O6});var EA,M6=new Promise(e=>{EA=e}),Px=!1;async function E6(){if(Px)return;let e="https://unpkg.com/@splinetool/boolean-wasm@0.9.260/build",[t,i]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(n=>n.arrayBuffer())]),r=t.default,s=await r({wasmBinary:i});EA(s),Px=!0}var tt,Do;M6.then(e=>tt=e);function C6(e,t,i){let r,{positions:s,triIndices:n}=tv(e.getAttribute("position"),e.getIndex()),a;if(t&&i){let{indices:o,verticesPerFace:l}=MA(s,n,e);a=l.length,r=[];for(let h=0,u=0;h<a;h++){r.push(l[h]);for(let c=0;c<l[h];c++)r.push(o[u++])}}else{let o=n.length;r=Array(o+o/3),a=0;for(let l=0,h=0;h<r.length;)r[h++]=3,a++,r[h++]=n[l++],r[h++]=n[l++],r[h++]=n[l++]}return{positions:s,faceIndices:r,nFaces:a}}function CA(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=tt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(tt.HEAPU32.buffer,n,t):new Float32Array(tt.HEAPF32.buffer,n,t)).set(e,0),n}function TA(e){switch(e){case 0:return tt.OP.UNION;case 1:return tt.OP.INTERSECTION;case 2:return tt.OP.A_MINUS_B;case 3:return tt.OP.B_MINUS_A;case 4:return tt.OP.SYMMETRIC_DIFFERENCE;case 5:return tt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function T6(e,t){Do===void 0&&(Do=tt.init_csg());let i=CA(e),r=tt.csg_calc_topological(Do,i,e.length,TA(t));tt._free(i);let s=6,n=tt.HEAPU32.subarray(r>>2,(r>>2)+s),a=n.subarray(3,3+3),o=0,l=tt.HEAPU32[n[o]>>2],h=new Float32Array(tt.HEAPF32.subarray(l>>2,(l>>2)+a[o]));o++;let u=tt.HEAPU32[n[o]>>2],c=new Uint32Array(tt.HEAPU32.subarray(u>>2,(u>>2)+a[o]));o++;let d=tt.HEAPU32[n[o]>>2],p=new Uint8Array(tt.HEAPU32.subarray(d>>2,(d>>2)+a[o]));return tt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function P6(e,t,i,r){Do===void 0&&(Do=tt.init_csg());let s=CA(e),n=tt.csg_calc(Do,s,e.length,r,TA(t));tt._free(s);let a=5,o=tt.HEAPU32.subarray(n>>2,(n>>2)+a),l=o.subarray(2,2+3),h=0,u=tt.HEAPU32[o[h]>>2],c=tt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let d=tt.HEAPU32[o[h]>>2],p=tt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Ce(c,3)),i.setAttribute("normal",new Ce(p,3));let g=tt.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new Mr),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},tt.free_mesh_data(n),f}function D6(e,t,i){if(tt===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,b=0;v<m.verticesPerFace.length;v++){s[b++]=m.verticesPerFace[v];for(let x=0;x<m.verticesPerFace[v];x++)s[b++]=m.indices[y++]}}else({positions:r,faceIndices:s,nFaces:n}=C6(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=tt._malloc(u),f=new Float32Array(tt.HEAPF32.buffer,p,l),g=new Uint32Array(tt.HEAPU32.buffer,p+c,h);return f.set(r,0),g.set(s,0),tt.get_csg_mesh(p,a,p+c,o,n)}function O6(e,t){tt.transform_csg_mesh(e,t.elements)}function L6(e){tt.free_csg_mesh(e)}var I6={ConeGeometry:fF,CubeGeometry:mF,CylinderGeometry:pF,DodecahedronGeometry:vF,EllipseGeometry:Jg,HelixGeometry:YF,IcosahedronGeometry:QF,LatheGeometry:ZF,NonParametricGeometry:r6,PolygonGeometry:bA,PyramidGeometry:s6,RectangleGeometry:wA,SphereGeometry:o6,PlaneGeometry:l6,BackdropGeometry:h6,StarGeometry:_A,TextFrameGeometry:d6,TorusGeometry:u6,TorusKnotGeometry:f6,TriangleGeometry:m6,PathGeometry:v6,VectorGeometry:Ca},Dx=e=>I6[e.type].create(e);function Ll(e){return e!==null&&"booleanOp"in e}var PA=class extends nA(er){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new ve}updateVisible(){super.updateVisible(),this.visible=!Ll(this.parent)&&this.visible,Ll(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(dn.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ll(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof PA&&(e.freeBooleanPointer(),Ll(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ll(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}},kc=new Kt;function iv(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)}kc.min.set(n,a,o),kc.max.set(l,h,u),kc.getCenter(r),kc.getSize(s).multiplyScalar(.5)}var R6=new Ve,B6=new Ph,nr=class extends PA{constructor(e,t){super(R6,B6),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?iv(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Ox=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}},Bn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=rt.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 Bn&&(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}},N6=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}},Ui=new N6,St=class extends Bn{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=rt.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}},or=class extends St{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))}},vr=class extends or{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof G?e:new G(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)}},fr=class extends or{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)}},Gi=class extends Ge{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}},na=class extends or{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof Gi?e:new Gi(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)}},z6=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Lx=/[a-z_0-9]+/gi,Re=class extends St{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=Lx.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&&Ui.containsKeyword(c)){let f=this.keywords[c];if(!f){let g=Ui.getKeywordData(c);g.cache&&(f=e.keywords[c]),f=f||Ui.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&&Ui.contains(p)&&e.include(Ui.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=z6.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(Lx);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=""}}},U6=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,DA=class extends St{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||DA.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=U6.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)}},vt=DA;vt.PI="PI",vt.PI2="PI2",vt.RECIPROCAL_PI="RECIPROCAL_PI",vt.RECIPROCAL_PI2="RECIPROCAL_PI2",vt.LOG2="LOG2",vt.EPSILON="EPSILON";var F6=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
3141
  )*?)}`,"gim"),k6=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),OA=class extends St{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=F6.exec(e);if(t){let i=t[2],r;for(;r=k6.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},rv=class extends St{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)}};Ui.addKeyword("uv",function(){return new rv});Ui.addKeyword("uv2",function(){return new rv(1)});var oo=class extends St{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??oo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case ms:return["Linear"];case Ke:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=oo.Nodes[this.method],n=e.include(s);if(n===oo.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=oo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=oo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},ls=oo;ls.Nodes={LinearToLinear:new Re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3142
3142
  `)),sRGBToLinear:new Re(["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 Re(["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(`
@@ -4909,7 +4909,7 @@ float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
4909
4909
  vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
4910
4910
  gl_FragColor = vec4(resultColor, vColor.r);
4911
4911
  }
4912
- `,df=new ri({vertexShader:E8,fragmentShader:C8,uniforms:{depthContrast:{value:1}}}),T8=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}},Gm=new Ph;Gm.wireframe=!0;var nb=new E,yS=class extends pa{constructor(e,t){super(),this.data=e,this.backupFog=new xw(16777215,.1,2e3),this.fogUseBGColor=!1,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.bgColor=new Gi(1,1,1,1),this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new T8,this.needsRecomputeInstances=!1,this.ambientLight=new BD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=g8(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=m8(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}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}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)=>Zz(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(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}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(),ks(r)&&Sn(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r)}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),i.parent.remove(i),Sn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ks(i)&&(i.freeBooleanPointer(),r instanceof Vo&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof cv&&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();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),ks(i)&&(i.invalidateUpstreamBooleanData(),Sn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Vo&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{states:n,rest:a}=t.props;t={...t,props:a},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{f8(s,t,i,{scene:this,shared:r}),s instanceof Cr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(rr(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof ar&&this.switchActiveCamera(i)}this.expandInstances(t,!0),this.traverseEntity(i=>{Sn(i)&&i.recomputeBoolean()}),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){Ct.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ct.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){e&&e!==r.uuid&&r.find(e)&&s.forInstancesRec(o=>{o.isInstanceRoot||(o.data=Td(o.data,l=>{let h=l.events.data(a.id),u=o.goUp(n);if(u){let c=[...Q_(u.identity),e].join("-"),d=this.entityIdentityToEntity[c];if(d){let p=d.uuid;ps.zoom(h,t)[i]=p}else console.warn("cannot find instance")}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Io&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{r.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=Td(s.data,n=>{n.events.delete(r.id)}).data)}):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)),r.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,i,r)}),r.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,i,r)})):"actions"in r.data&&r.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,i,r)})})}),!0})}expandInstances(e,t){let i=new Set;this.traverseEntity(r=>{if(r instanceof Io&&r.isInstanceRoot)return r.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||r.resetBBoxNeedsUpdate(),!0});for(let r of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),dv(r)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof Io&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}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)Ct.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new ar(yS.PERSONAL_CAMERA_ID,{...zd.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;Ct.is(s)&&!s.raycastLock&&(s.visible||n?.object.data.visible)&&((ks(s)||a8(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),b8(s,e,t)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Ct.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)Ct.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)qd.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Ct.is(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=rr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=rr(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=rr(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}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=uv(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 Cr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping.pathId!==null&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),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 Kt;return i.setFromPoints(t),i.getCenter(nb),nb}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 nr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof On&&e(t.material[i]);else t.material instanceof On&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let i,r;e>=t?(i=t/e,r=1):(i=1,r=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(n=>{n.uniforms[`f${n.id}_aspectRatio`].value.x=i,n.uniforms[`f${n.id}_aspectRatio`].value.y=r})})}},rl=yS;rl.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var od=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},P8=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return O8(Math.atan2(r,i))},D8=(e,t,i)=>{let r={x:0,y:0};return i=Vm(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Vm=e=>e*(Math.PI/180),O8=e=>e*(180/Math.PI),L8=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,uf=new Map,ab=e=>{uf.has(e)&&clearTimeout(uf.get(e)),uf.set(e,setTimeout(e,100))},eu=(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)},ob=(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)},xS=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),lb=()=>{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}},Hm=(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")},pv=(e,t,i)=>{let r=bS(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},I8=(e,t)=>{let i=bS(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},bS=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},pf=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},R8=(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},Wm=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},B8=(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"&&(wS="ontouchstart"in window,_S=!!window.PointerEvent,AS=!!window.MSPointerEvent);var wS,_S,AS,Nl={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"}},yo,Mh={};_S?yo=Nl.pointer:AS?yo=Nl.MSPointer:wS?(yo=Nl.touch,Mh=Nl.mouse):yo=Nl.mouse;function Ta(){}Ta.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};Ta.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};Ta.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)})};Ta.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=R8(t.options,e))};Ta.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.')},eu(e,yo[t],i._domHandlers_[t]),Mh[t]&&eu(e,Mh[t],i._domHandlers_[t]),i};Ta.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},ob(e,yo[t],i._domHandlers_[t]),Mh[t]&&ob(e,Mh[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var fv=Ta;function ai(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=ai.id,ai.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}ai.prototype=new fv;ai.constructor=ai;ai.id=0;ai.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)};ai.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=I8("borderRadius","50%"),i=pv("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)"},pf(r.el,i),this.options.shape==="circle"&&pf(r.back,t),pf(r.front,t),this.applyStyles(r),this};ai.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};ai.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};ai.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};ai.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};ai.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};ai.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};ai.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=pv("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)};ai.prototype.restCallback=function(){var e=this,t={};t.front=pv("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};ai.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};ai.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 N8=ai;function Ht(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Ht.id,Ht.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}Ht.prototype=new fv;Ht.constructor=Ht;Ht.id=0;Ht.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}};Ht.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Ht.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)}};Ht.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 N8(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||(Hm(h.ui.el,s),Hm(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};Ht.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Ht.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)};Ht.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)};Ht.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=xS(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 Wm(e,s),t.manager.bindDocument(),!1};Ht.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=od(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Ht.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)};Ht.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(!L8(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=od(l,s.position),u=P8(l,s.position),c=Vm(u),d=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=D8(s.position,f,u)):(g=B8(l,s.position,o),f=od(g,s.position)),i.follow){if(h>o){let b=l.x-g.x,x=l.y-g.y;s.position.x+=b,s.position.y+=x,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=od(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||Hm(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:Vm(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Ht.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))};Ht.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()};Ht.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 z8=Ht;function di(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=lb(),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;eu(window,"resize",function(){ab(i)});var r=function(){t.scroll=lb()};return eu(window,"scroll",function(){ab(r)}),t.collections}di.prototype=new fv;di.constructor=di;di.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}};di.prototype.create=function(e){return this.createCollection(e)};di.prototype.createCollection=function(e){var t=this,i=new z8(t,e);return t.bindCollection(i),t.collections.push(i),i};di.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)};di.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};di.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};di.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]};di.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};di.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};di.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};di.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};di.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=xS(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),Wm(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return Wm(t,a),!1};di.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};di.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 U8=di,hb=new U8,F8={create:function(e){return hb.create(e)},factory:hb},k8=Eh(Kb());function $a(e,t){let i=new Ve;if(!e.getAttribute("position"))return i.setAttribute("position",new Ce([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=tv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Ce(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var j8=new ve,G8=new ve,$r=[[0,0,0],[0,0,0],[0,0,0]];function SS(e){let t=e.elements;$r[0][0]=t[0],$r[0][1]=t[4],$r[0][2]=t[8],$r[1][0]=t[1],$r[1][1]=t[5],$r[1][2]=t[9],$r[2][0]=t[2],$r[2][1]=t[6],$r[2][2]=t[10];let{u:i,v:r}=(0,k8.SVD)($r),s=j8.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=G8.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 V8=class extends Rw{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 Rn({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 Ve;return n.setFromPoints([t,s]),new gd(n,e)}},MS=e=>e instanceof km||e instanceof Io;function H8(e,t){return e.distance-t.distance}function ES(e,t,i){if(!(!mn(t)||!t.visible)){ks(t)&&t.raycast(e,i);for(let r of t.children)ES(e,r,i)}}function Xm(e,t,i){if(!i.some(s=>tu(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>ES(e,s,r)),r.sort(H8),r}function qm(e){let t=[];if(e.length){let i=e[0].object;mn(i)&&t.push(i);let r=i.parent;for(;r;)MS(r)&&t.push(r),r=r.parent}return t}function tu(e,t){if(ks(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(MS(t))return CS(e,t)}function CS(e,t){if(!(!mn(t)||!t.visible)){if(ks(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=CS(e,i);if(r)return r}}}function W8(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 X8=class{constructor(e,t,i,r,s,n){this.isExport=n,this.raycaster=new V8,this.raycasterNeedsUpdate=!0,this.stopRaycast=!1,this._useWindowEvents=!1,this.sharedAssets=new Mu(Hd.emptyData()),this.scene=new rl({...wm.defaultData},this.sharedAssets),this.camera=new ar,this.renderer=e,this._useWindowEvents=t.data.publish.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.stopRaycast=s,this.sharedAssets=r,this.scene=t,this.camera=i}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!==void 0&&e.touches.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(W8(t,i,r),this.camera)}},TS=(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))(TS||{}),Nn=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},PS=new Map,ih=new Map,xo=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 Yl({src:l,volume:n,delay:a,loop:o}),ih.has(i.uuid)?ih.get(i.uuid).push(this):ih.set(i.uuid,[this]),PS.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()}},Ym=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=PS.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=ih.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=[...ih.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}},bo=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new xo(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Ym(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof xo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof xo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof xo&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function q8(e,t){let i=e.material.layers.find(r=>r.uuid===t);return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var DS=new Map,rh=new Map,sh=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=q8(i,r);if(o)this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n);else throw new Error("Missing property");a!==void 0&&(this.delay=a),rh.has(i.uuid)?rh.get(i.uuid).push(this):rh.set(i.uuid,[this]),DS.set(e,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(e){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(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){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.stop(),this.videoElement.muted=!0}},Qm=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=DS.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=rh.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=[...rh.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}},iu=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new sh(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Qm(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof sh?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof sh?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},Y8="text/plain",Q8="us-ascii",cb=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),Z8=(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===Q8)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==Y8)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function K8(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 Z8(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];cb(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()])cb(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 J8=class{constructor({url:e,context:t},i){if(this.managers=i,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:K8(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){bm?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.managers.controlsManager.orbitControls?.onPointerUp(Qe[0]),Kz())}},$8=class{constructor(e,t,i,r){this.scene=t,this.sharedAssets=i,this.sceneData=e,this.managers=r}dispatch(){YS(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(e=>e.reset(!0))}},OS={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},mv={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},ej=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],ru={CSS:{},springs:{}};function cs(e,t,i){return Math.min(Math.max(e,t),i)}function nh(e,t){return e.indexOf(t)>-1}function ff(e,t){return e.apply(null,t)}var je={arr:function(e){return Array.isArray(e)},obj:function(e){return nh(Object.prototype.toString.call(e),"Object")},pth:function(e){return je.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||je.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 je.hex(e)||je.rgb(e)||je.hsl(e)},key:function(e){return!OS.hasOwnProperty(e)&&!mv.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function LS(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function IS(e,t){var i=LS(e),r=cs(je.und(i[0])?1:i[0],.1,100),s=cs(je.und(i[1])?100:i[1],.1,100),n=cs(je.und(i[2])?10:i[2],.1,100),a=cs(je.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=ru.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 ru.springs[e]=y,y}return t?d:p}function tj(e){return e===void 0&&(e=10),function(t){return Math.ceil(cs(t,1e-6,1)*e)*(1/e)}}var ij=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,b=1,x=e-1;b!==x&&f[b]<=v;++b)y+=t;--b;var w=(v-f[b])/(f[b+1]-f[b]),A=y+w*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}(),RS=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=cs(r,1,10),a=cs(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 gv(e,t){if(je.fnc(e))return e;var i=e.split("(")[0],r=RS[i],s=LS(e);switch(i){case"spring":return IS(e,t);case"cubicBezier":return ff(ij,s);case"steps":return ff(tj,s);default:return ff(r,s)}}function BS(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Tu(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 Pu(e){return e.reduce(function(t,i){return t.concat(je.arr(i)?Pu(i):i)},[])}function db(e){return je.arr(e)?e:(je.str(e)&&(e=BS(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function vv(e,t){return e.some(function(i){return i===t})}function yv(e){var t={};for(var i in e)t[i]=e[i];return t}function Zm(e,t){var i=yv(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Du(e,t){var i=yv(e);for(var r in t)i[r]=je.und(e[r])?t[r]:e[r];return i}function rj(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function sj(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 nj(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 aj(e){if(je.rgb(e))return rj(e);if(je.hex(e))return sj(e);if(je.hsl(e))return nj(e)}function Vs(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 oj(e){if(nh(e,"translate")||e==="perspective")return"px";if(nh(e,"rotate")||nh(e,"skew"))return"deg"}function Km(e,t){return je.fnc(e)?e(t.target,t.id,t.total):e}function ds(e,t){return e.getAttribute(t)}function xv(e,t,i){var r=Vs(t);if(vv([i,"deg","rad","turn"],r))return t;var s=ru.CSS[t+i];if(!je.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 ru.CSS[t+i]=h,h}function NS(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?xv(e,s,i):s}}function bv(e,t){if(je.dom(e)&&!je.inp(e)&&(ds(e,t)||je.svg(e)&&e[t]))return"attribute";if(je.dom(e)&&vv(ej,t))return"transform";if(je.dom(e)&&t!=="transform"&&NS(e,t))return"css";if(e[t]!=null)return"object"}function zS(e){if(je.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 lj(e,t,i,r){var s=nh(t,"scale")?1:0+oj(t),n=zS(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?xv(e,n,r):n}function wv(e,t,i,r){switch(bv(e,t)){case"transform":return lj(e,t,r,i);case"css":return NS(e,t,i);case"attribute":return ds(e,t);default:return e[t]||0}}function _v(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Vs(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 US(e,t){if(je.col(e))return aj(e);if(/\s/g.test(e))return e;var i=Vs(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Av(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function hj(e){return Math.PI*2*ds(e,"r")}function cj(e){return ds(e,"width")*2+ds(e,"height")*2}function dj(e){return Av({x:ds(e,"x1"),y:ds(e,"y1")},{x:ds(e,"x2"),y:ds(e,"y2")})}function FS(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=Av(r,n)),r=n}return i}function uj(e){var t=e.points;return FS(e)+Av(t.getItem(t.numberOfItems-1),t.getItem(0))}function kS(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return hj(e);case"rect":return cj(e);case"line":return dj(e);case"polyline":return FS(e);case"polygon":return uj(e)}}function pj(e){var t=kS(e);return e.setAttribute("stroke-dasharray",t),t}function fj(e){for(var t=e.parentNode;je.svg(t)&&je.svg(t.parentNode);)t=t.parentNode;return t}function jS(e,t){var i=t||{},r=i.el||fj(e),s=r.getBoundingClientRect(),n=ds(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 mj(e,t){var i=je.str(e)?BS(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:jS(i),totalLength:kS(i)*(r/100)}}}function gj(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=jS(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 ub(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=US(je.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:je.str(e)||t?r.split(i):[]}}function GS(e){var t=e?Pu(je.arr(e)?e.map(db):db(e)):[];return Tu(t,function(i,r,s){return s.indexOf(i)===r})}function VS(e){var t=GS(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:zS(i)}}})}function vj(e,t){var i=yv(t);if(/^spring/.test(i.easing)&&(i.duration=IS(i.easing)),je.arr(e)){var r=e.length,s=r===2&&!je.obj(e[0]);s?e={value:e}:je.fnc(t.duration)||(i.duration=t.duration/r)}var n=je.arr(e)?e:[e];return n.map(function(a,o){var l=je.obj(a)&&!je.pth(a)?a:{value:a};return je.und(l.delay)&&(l.delay=o?0:t.delay),je.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return Du(a,i)})}function yj(e){for(var t=Tu(Pu(e.map(function(n){return Object.keys(n)})),function(n){return je.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)je.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 xj(e,t){var i=[],r=t.keyframes;r&&(t=Du(yj(r),t));for(var s in t)je.key(s)&&i.push({name:s,tweens:vj(t[s],e)});return i}function bj(e,t){var i={};for(var r in e){var s=Km(e[r],t);je.arr(s)&&(s=s.map(function(n){return Km(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function wj(e,t){var i;return e.tweens.map(function(r){var s=bj(r,t),n=s.value,a=je.arr(n)?n[1]:n,o=Vs(a),l=wv(t.target,e.name,o,t),h=i?i.to.original:l,u=je.arr(n)?n[0]:h,c=Vs(u)||Vs(l),d=o||c;return je.und(a)&&(a=h),s.from=ub(u,d),s.to=ub(_v(a,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=gv(s.easing,s.duration),s.isPath=je.pth(n),s.isColor=je.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var HS={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 WS(e,t){var i=VS(e);i.forEach(function(r){for(var s in t){var n=Km(t[s],r),a=r.target,o=Vs(n),l=wv(a,s,o,r),h=o||Vs(l),u=_v(US(n,h),l),c=bv(a,s);HS[c](a,s,u,r.transforms,!0)}})}function _j(e,t){var i=bv(e.target,t.name);if(i){var r=wj(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 Aj(e,t){return Tu(Pu(e.map(function(i){return t.map(function(r){return _j(i,r)})})),function(i){return!je.und(i)})}function XS(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;return r(n)+a+o+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;return r(n)+a+o+n.duration*(n.loop??1)-n.endDelay})):t.endDelay,s}var pb=0;function Sj(e){var t=Zm(OS,e),i=Zm(mv,e),r=xj(i,e),s=VS(e.targets),n=Aj(s,r),a=XS(n,i),o=pb;return pb++,Du(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection})}var Sr=[],fb=[],ld,Mj=function(){function e(){ld=requestAnimationFrame(t)}function t(i){var r=Sr.length;if(r){for(var s=0;s<r;){var n=Sr[s];n.paused?(Sr.splice(s,1),r-=1):(n.tick(i),s++)}e()}else ld=cancelAnimationFrame(ld)}return e}();function Ej(e){document.hidden?(Sr.forEach(function(t){return t.pause(e.timeStamp)}),fb=Sr.slice(0),Vt.running=Sr=[]):fb.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Ej);function Vt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n,a=0,o=null;function l(x){var w=window.Promise&&new Promise(function(A){return o=A});return x.finished=w,w}var h=Sj(e),u=l(h);function c(){var x=h.direction;x!=="alternate"&&(h.direction=x!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,n.forEach(function(w){return w.reversed=h.reversed})}function d(x){return h.reversed?h.duration-x:x}function p(){t=0,i=d(h.currentTime)*(1/Vt.speed)}function f(x,w){w&&(h.reversed?w.seek(w.duration*w.loop-(x-w.timelineOffset-w.pingPongDelayCorrection)):w.seek(x-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection))}function g(x){if(h.reversed)for(var w=a;w--;)f(x,n[w]);else for(var A=0;A<a;A++)f(x,n[A])}function m(x){var w=0,A=h.animations,S=A.length;for(h.reversePlayback===!0&&h.rewind===!1&&(x=h.duration+h.delay-h.endDelay-x);w<S;){var _=A[w],M=_.animatable,C=_.tweens,T=C.length-1,P=C[T];T&&(P=Tu(C,function(ee){return x<ee.end})[0]||P);for(var O=cs(x-P.start-P.delay,0,P.duration)/P.duration,D=isNaN(O)?1:P.easing(O),k=P.to.strings,W=P.round,X=[],N=P.to.numbers.length,j=void 0,F=0;F<N;F++){var z=void 0;if(h.reversePlayback===!0&&h.rewind===!1)var H=P.to.numbers[F],B=P.from.numbers[F]||0;else var B=P.to.numbers[F],H=P.from.numbers[F]||0;P.isPath?z=gj(P.value,D*B):z=H+D*(B-H),W&&(P.isColor&&F>2||(z=Math.round(z*W)/W)),X.push(z)}var Q=k.length;if(!Q)j=X[0];else{j=k[0];for(var Y=0;Y<Q;Y++){var U=k[Y],se=k[Y+1],V=X[Y];isNaN(V)||(se?j+=V+se:j+=V+" ")}}HS[_.type](M.target,_.property,j,M.transforms),_.currentValue=j,w++}}function v(x){h[x]&&!h.passThrough&&h[x](h)}function y(){h.remaining&&h.remaining!==!0&&h.remaining--}function b(x){var w=h.duration,A=h.delay,S=w-h.endDelay,_=d(x);if(h.progress=cs(_/w*100,0,100),h.reversePlayback=_<h.currentTime,a&&g(_),!h.began&&h.currentTime>=0&&(h.began=!0,v("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,v("loopBegin")),(h.reversed||_>=0)&&_<=A&&h.currentTime!==0&&(m(0),v("change")),(_>=S&&h.currentTime!==w||!w)&&(m(w),v("change")),_>A&&_<S?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,v("changeBegin")),m(_),v("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,v("change"),a&&v("timelineChangeComplete")):h.began&&_>S&&v("changeComplete"),h.currentTime=cs(_,0,w),h.began&&v("update"),x>=w)if(y(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,v("loopComplete"),v("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{a?t+=h.duration/Vt.speed:t+=h.duration;for(let M of n)M.setStartTime(0),M.remaining=M.loop;v("loopComplete"),h.loopBegan=!1,h.direction==="alternate"&&c()}}return h.reset=function(){var x=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=x==="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||x==="alternate"&&h.loop===1)&&h.remaining++,m(h.reversed?h.duration:0)},h.setStartTime=function(x){t=x},h.set=function(x,w){return WS(x,w),h},h.tick=function(x){r=x,t||(t=r),b((r+(i-t))*Vt.speed)},h.seek=function(x){b(x-t)},h.pause=function(x){h.paused=!0,a&&(s=x??performance.now())},h.play=function(x){!h.paused||(h.completed&&h.reset(),h.paused=!1,Sr.push(h),a&&s!==void 0&&(t+=(x??performance.now())-s),ld||Mj())},h.reverse=function(){c(),h.completed=!h.reversed,p()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function mb(e,t){for(var i=t.length;i--;)vv(e,t[i].animatable.target)&&t.splice(i,1)}function Cj(e){for(var t=GS(e),i=Sr.length;i--;){var r=Sr[i],s=r.animations,n=r.children;mb(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;mb(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function Tj(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?gv(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",u=je.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=Vs(u?e[1]:e)||0,f=t.start||0+(u?c:0),g=[],m=0;return function(v,y,b){if(o&&(a=0),l&&(a=(b-1)/2),h&&(a=b-1),!g.length){for(var x=0;x<b;x++){if(!s)g.push(Math.abs(a-x));else{var w=l?(s[0]-1)/2:a%s[0],A=l?(s[1]-1)/2:Math.floor(a/s[0]),S=x%s[0],_=Math.floor(x/s[0]),M=w-S,C=A-_,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(O){return r(O/m)*m})),i==="reverse"&&(g=g.map(function(O){return n?O<0?O*-1:-O:Math.abs(m-O)}))}var P=u?(d-c)/m:c;return f+P*(Math.round(g[y]*100)/100)+p}}function Pj(e){e===void 0&&(e={});var t=Vt(e);return t.duration=0,t.add=function(i,r){var s=Sr.indexOf(t),n=t.children;s>-1&&Sr.splice(s,1);function a(d){d.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=Du(i,Zm(mv,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=je.und(r)?h:_v(r,h),a(t);var u=Vt(l);a(u),n.push(u);var c=XS(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}Vt.version="3.2.0";Vt.speed=1;Vt.running=Sr;Vt.remove=Cj;Vt.get=wv;Vt.set=WS;Vt.convertPx=xv;Vt.path=mj;Vt.setDashoffset=pj;Vt.stagger=Tj;Vt.timeline=Pj;Vt.easing=gv;Vt.penner=RS;Vt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var Dj=Vt,gb=new E,vb=new E,yb=new ct;function Oj(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 sl(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=rt.lerp(o,l,h);s?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function qS(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||Ng(l,h)))return{update:u=>{l.forEach((c,d)=>{let p=rt.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 xb(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 Lj(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 ve().fromArray(s):a.clone(),l=new E,h=new ct,u=new E;o.decompose(l,h,u);let c=new ve().fromArray(n),d=new E,p=new ct,f=new E;if(c.decompose(d,p,f),!o.equals(c))return{update:g=>{yb.slerpQuaternions(h,p,g),gb.lerpVectors(l,d,g),vb.lerpVectors(u,f,g),a.compose(gb,yb,vb)},start:()=>{a.compose(l,h,u)},end:()=>{a.compose(d,p,f)}}}function Ij(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ge().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 zn(e,t,i,r){if(typeof t[e]=="number")return sl(e,t,i??{},r);if(Array.isArray(t[e]))return qS(e,t,i??{},r)}function Rj(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=rt.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=sl("targetOffset",e,t,i);a&&r.push(a)}return r}function Bj(e,t,i,r){if(i.scaleBaked===void 0)return;let s=t.scaleBaked??e.data.geometry.scaleBaked,n=i.scaleBaked;if(ma.isEqual(s,n))return;let a=[];return a.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[rt.lerp(s[0],n[0],o),rt.lerp(s[1],n[1],o),rt.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 Nj(e,t,i){if(!i.extrusion)return;let r=e.extrusion,s=t.extrusion??{},n=i.extrusion,a=[];return Y_.forEach(o=>{let l=zn(o,r,s,n);l&&a.push(l)}),a}function zj(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 Sh){let l=Bj(e,a,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,gh(n,I1)),I1.forEach(h=>{let u=zn(h,l,a,o);u&&s.push(u)}),e instanceof cv){Object.assign(l,{extrusion:{...n.extrusion}});let h=Nj(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 Uj(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=sl("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=Ij("color",e,t,i,r);n&&s.push(n)}return s}function Fj(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(...bb(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(...bb(e.material,n,a,r))}return s}function bb(e,t,i,r){let s=[];e.transparent=Kd(i,r)||!!t.layers&&Kd(t,r);for(let n of e.layers){let a=t.layers?.data(n.uuid),o=i.layers.data(n.uuid);if(!o||!(n.visible??!0)||!(o.visible??!0))continue;let l=n.getNames().filter(h=>!W_.some(u=>h.includes(u)));for(let h of l)try{let u=n.getValue(h),c;if(h==="colors")c=Xj(n,a,o,h);else if(Array.isArray(u))h==="steps"&&(c=Wj(n,a,o,h));else if(typeof u=="number")c=kj(n,a,o,h);else{if(typeof u=="boolean")continue;u instanceof G?c=jj(n,a,o,h):u instanceof E?c=Gj(n,a,o,h):u instanceof Gi?c=Hj(n,a,o,h,r):u instanceof Ge?c=Vj(n,a,o,h,r):"isTexture"in u&&(c=qj(n,a,o,h))}c&&(Array.isArray(c)?s.push(...c):s.push(c))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${h}`,u)}}return s}function kj(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,rt.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function jj(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new G().fromArray(t[r]):s.clone(),a=new G().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function Gj(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 Vj(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ge().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Hj(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Gi(a.r,a.g,a.b,a.a);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Wj(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]=rt.lerp(h,u,c)},start:()=>{n[l]=h},end:()=>{n[l]=u}})}return s.length?s:void 0}function Xj(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]];Ld.isEqual(h,u)||s.push({update:c=>{n[l].fromArray(Ld.lerp(h,u,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(u)}})}return s.length?s:void 0}function qj(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(!fo.isEqual(o,h)||!fo.isEqual(l,u))return{update:c=>{s.repeat=fo.lerp(o,h,c),s.offset=fo.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}var mf=new E,wb=new _i;function Yj(e,t,i,r){let s=[],n=xb("position",e,t,i);n&&s.push(n);let a=xb("scale",e,t,i);a&&s.push(a);let o=Qj(e,t,i,r);o&&s.push(o);let l=Lj("hiddenMatrix",e,t,i);l&&s.push(l);let h={slide:(t.pathSnapping??e.dataPatched.pathSnapping).slide},u=sl("slide",h,t.pathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping);if(u&&s.push(u),n||a||o||l||u){let c=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),ks(e)&&Sn(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,h))};s.push({update:c,start:c,end:c})}return s}function Qj(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=mf.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new ct().setFromEuler(wb.setFromVector3(a)),u=new ct().setFromEuler(wb.setFromVector3(o));return{update:c=>{Oj(h,u,e.quaternion,c),c===1&&e instanceof ar&&(e.updateUp(),e.isUpVectorFlipped=!1)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{mf.lerpVectors(a,o,h),e.rotation.setFromVector3(mf),h===1&&e instanceof ar&&(e.updateUp(),e.isUpVectorFlipped=!1)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function Zj(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;F_.forEach(d=>{let p;d==="count"?p=sl("count",s.parameters,n,a,!0):p=zn(d,s.parameters,n??{},a),p&&r.push(p)});let o=Kj(s,n,a);o?.length&&r.push(...o);let l=Jj(s,n,a);l?.length&&r.push(...l);let h=$j(s,n,a);h?.length&&r.push(...h);let u=eG(s,n,a);u?.length&&r.push(...u);let c=tG(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function Kj(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 k_.forEach(o=>{let l=zn(o,n,r??{},s);l&&a.push(l)}),a}function Jj(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 j_.forEach(o=>{let l=zn(o,a,r??{},s);l&&n.push(l)}),n}function $j(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 G_.forEach(o=>{let l;o==="count"?l=qS(o,a,r??{},s,!0):l=zn(o,a,r??{},s),l&&n.push(l)}),n}function eG(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 V_.forEach(o=>{let l;o==="count"?l=sl(o,a,r??{},s,!0):l=zn(o,a,r??{},s),l&&n.push(l)}),n}function tG(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 H_.forEach(o=>{let l=zn(o,a,r??{},s);l&&n.push(l)}),n}function _b(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...Yj(e,t,i,s)),e.data.visible&&n.push(...Zj(e,t,i)),ks(e)?(e instanceof Cr&&e.data.visible&&n.push(...zj(e,t,i,r)),e.data.visible&&n.push(...Fj(e,t,i,r))):n8(e)?e.data.visible&&n.push(...Uj(e,t,i,r)):s8(e)&&n.push(...Rj(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 Ab=new E;function YS(e,t,i,r=!1){let s=[];t.traverseObject(n=>{if(r&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(Ab,!0),n.rigidBody?.setAngvel(Ab,!0)),!Ct.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,!o.states)return;let l=!1;s.some(h=>e.objects.isDescendantOf(a,h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&s.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let h of o.states)e.environment.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0||h.data.rotation!==void 0||h.data.hiddenMatrix!==void 0)||(n.states||(n.states={}),n.states[h.id]=oa.patch(o,h.data));iG(t,n,null,i,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0)})}function iG(e,t,i,r,s=!1){t instanceof Cr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Cr&&t.updateGeometryGroupsIfNeeded()}function rG(e){let t;switch(e.easing){case 0:t="cubicBezier( 0, 0, 1, 1 )";break;case 1:t="cubicBezier( .25, .1, .25, 1 )";break;case 2:t="cubicBezier( .42, 0, 1, 1 )";break;case 3:t="cubicBezier( 0, 0, .58, 1 )";break;case 4:t="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:i,control2:r}=e;t=`cubicBezier(
4912
+ `,df=new ri({vertexShader:E8,fragmentShader:C8,uniforms:{depthContrast:{value:1}}}),T8=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}},Gm=new Ph;Gm.wireframe=!0;var nb=new E,yS=class extends pa{constructor(e,t){super(),this.data=e,this.backupFog=new xw(16777215,.1,2e3),this.fogUseBGColor=!1,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.bgColor=new Gi(1,1,1,1),this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new T8,this.needsRecomputeInstances=!1,this.ambientLight=new BD(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=g8(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=m8(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}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}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)=>Zz(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(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}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(),ks(r)&&Sn(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r)}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),i.parent.remove(i),Sn(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ks(i)&&(i.freeBooleanPointer(),r instanceof Vo&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof cv&&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();let n=e.localIndex;s.children.splice(n,0,s.children.pop()),ks(i)&&(i.invalidateUpstreamBooleanData(),Sn(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Vo&&r.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{states:n,rest:a}=t.props;t={...t,props:a},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{f8(s,t,i,{scene:this,shared:r}),s instanceof Cr&&s.updateGeometryGroupsIfNeeded()}catch(n){console.error(n)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(rr(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof ar&&this.switchActiveCamera(i)}this.expandInstances(t,!0),this.traverseEntity(i=>{Sn(i)&&i.recomputeBoolean()}),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){Ct.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Ct.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,n,a){e&&e!==r.uuid&&r.find(e)&&s.forInstancesRec(o=>{o.isInstanceRoot||(o.data=Td(o.data,l=>{let h=l.events.data(a.id),u=o.goUp(n);if(u){let c=[...Q_(u.identity),e].join("-"),d=this.entityIdentityToEntity[c];if(d){let p=d.uuid;ps.zoom(h,t)[i]=p}else console.warn("cannot find instance")}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Io&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{r.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=Td(s.data,n=>{n.events.delete(r.id)}).data)}):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)),r.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,i,r)}),r.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,i,r)})):"actions"in r.data&&r.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,i,r)})})}),!0})}expandInstances(e,t){let i=new Set;this.traverseEntity(r=>{if(r instanceof Io&&r.isInstanceRoot)return r.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||r.resetBBoxNeedsUpdate(),!0});for(let r of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(r),dv(r)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof Io&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}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)Ct.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new ar(yS.PERSONAL_CAMERA_ID,{...zd.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],i=r=>{for(let s of r.children){let n=s.cloner;Ct.is(s)&&!s.raycastLock&&(s.visible||n?.object.data.visible)&&((ks(s)||a8(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),b8(s,e,t)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)Ct.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)Ct.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)qd.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Ct.is(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=rr(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=rr(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=rr(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}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=uv(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 Cr&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),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 Kt;return i.setFromPoints(t),i.getCenter(nb),nb}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 nr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof On&&e(t.material[i]);else t.material instanceof On&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let i,r;e>=t?(i=t/e,r=1):(i=1,r=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(n=>{n.uniforms[`f${n.id}_aspectRatio`].value.x=i,n.uniforms[`f${n.id}_aspectRatio`].value.y=r})})}},rl=yS;rl.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var od=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},P8=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return O8(Math.atan2(r,i))},D8=(e,t,i)=>{let r={x:0,y:0};return i=Vm(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Vm=e=>e*(Math.PI/180),O8=e=>e*(180/Math.PI),L8=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,uf=new Map,ab=e=>{uf.has(e)&&clearTimeout(uf.get(e)),uf.set(e,setTimeout(e,100))},eu=(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)},ob=(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)},xS=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),lb=()=>{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}},Hm=(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")},pv=(e,t,i)=>{let r=bS(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},I8=(e,t)=>{let i=bS(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},bS=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},pf=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},R8=(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},Wm=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},B8=(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"&&(wS="ontouchstart"in window,_S=!!window.PointerEvent,AS=!!window.MSPointerEvent);var wS,_S,AS,Nl={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"}},yo,Mh={};_S?yo=Nl.pointer:AS?yo=Nl.MSPointer:wS?(yo=Nl.touch,Mh=Nl.mouse):yo=Nl.mouse;function Ta(){}Ta.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};Ta.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};Ta.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)})};Ta.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=R8(t.options,e))};Ta.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.')},eu(e,yo[t],i._domHandlers_[t]),Mh[t]&&eu(e,Mh[t],i._domHandlers_[t]),i};Ta.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},ob(e,yo[t],i._domHandlers_[t]),Mh[t]&&ob(e,Mh[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var fv=Ta;function ai(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=ai.id,ai.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}ai.prototype=new fv;ai.constructor=ai;ai.id=0;ai.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)};ai.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=I8("borderRadius","50%"),i=pv("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)"},pf(r.el,i),this.options.shape==="circle"&&pf(r.back,t),pf(r.front,t),this.applyStyles(r),this};ai.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};ai.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};ai.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};ai.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};ai.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};ai.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};ai.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=pv("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)};ai.prototype.restCallback=function(){var e=this,t={};t.front=pv("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};ai.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};ai.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 N8=ai;function Ht(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=Ht.id,Ht.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}Ht.prototype=new fv;Ht.constructor=Ht;Ht.id=0;Ht.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}};Ht.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};Ht.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)}};Ht.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 N8(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||(Hm(h.ui.el,s),Hm(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};Ht.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};Ht.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)};Ht.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)};Ht.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=xS(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 Wm(e,s),t.manager.bindDocument(),!1};Ht.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=od(a,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};Ht.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)};Ht.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(!L8(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=od(l,s.position),u=P8(l,s.position),c=Vm(u),d=h/o,p={distance:h,position:l},f,g;if(s.options.shape==="circle"?(f=Math.min(h,o),g=D8(s.position,f,u)):(g=B8(l,s.position,o),f=od(g,s.position)),i.follow){if(h>o){let b=l.x-g.x,x=l.y-g.y;s.position.x+=b,s.position.y+=x,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=od(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||Hm(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:Vm(180-u),degree:180-u},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};Ht.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))};Ht.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()};Ht.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 z8=Ht;function di(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=lb(),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;eu(window,"resize",function(){ab(i)});var r=function(){t.scroll=lb()};return eu(window,"scroll",function(){ab(r)}),t.collections}di.prototype=new fv;di.constructor=di;di.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}};di.prototype.create=function(e){return this.createCollection(e)};di.prototype.createCollection=function(e){var t=this,i=new z8(t,e);return t.bindCollection(i),t.collections.push(i),i};di.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)};di.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};di.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};di.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]};di.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};di.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};di.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};di.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};di.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=xS(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),Wm(i.collections,n.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return Wm(t,a),!1};di.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};di.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 U8=di,hb=new U8,F8={create:function(e){return hb.create(e)},factory:hb},k8=Eh(Kb());function $a(e,t){let i=new Ve;if(!e.getAttribute("position"))return i.setAttribute("position",new Ce([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=tv(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Ce(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var j8=new ve,G8=new ve,$r=[[0,0,0],[0,0,0],[0,0,0]];function SS(e){let t=e.elements;$r[0][0]=t[0],$r[0][1]=t[4],$r[0][2]=t[8],$r[1][0]=t[1],$r[1][1]=t[5],$r[1][2]=t[9],$r[2][0]=t[2],$r[2][1]=t[6],$r[2][2]=t[10];let{u:i,v:r}=(0,k8.SVD)($r),s=j8.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=G8.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 V8=class extends Rw{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 Rn({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 Ve;return n.setFromPoints([t,s]),new gd(n,e)}},MS=e=>e instanceof km||e instanceof Io;function H8(e,t){return e.distance-t.distance}function ES(e,t,i){if(!(!mn(t)||!t.visible)){ks(t)&&t.raycast(e,i);for(let r of t.children)ES(e,r,i)}}function Xm(e,t,i){if(!i.some(s=>tu(e,s)!==void 0))return[];let r=[];return t.children.forEach(s=>ES(e,s,r)),r.sort(H8),r}function qm(e){let t=[];if(e.length){let i=e[0].object;mn(i)&&t.push(i);let r=i.parent;for(;r;)MS(r)&&t.push(r),r=r.parent}return t}function tu(e,t){if(ks(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(MS(t))return CS(e,t)}function CS(e,t){if(!(!mn(t)||!t.visible)){if(ks(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=CS(e,i);if(r)return r}}}function W8(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 X8=class{constructor(e,t,i,r,s,n){this.isExport=n,this.raycaster=new V8,this.raycasterNeedsUpdate=!0,this.stopRaycast=!1,this._useWindowEvents=!1,this.sharedAssets=new Mu(Hd.emptyData()),this.scene=new rl({...wm.defaultData},this.sharedAssets),this.camera=new ar,this.renderer=e,this._useWindowEvents=t.data.publish.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.stopRaycast=s,this.sharedAssets=r,this.scene=t,this.camera=i}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!==void 0&&e.touches.length>0?e.touches[0]:e,r=this.domElement.getBoundingClientRect();this.raycaster.setFromCamera(W8(t,i,r),this.camera)}},TS=(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))(TS||{}),Nn=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},PS=new Map,ih=new Map,xo=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 Yl({src:l,volume:n,delay:a,loop:o}),ih.has(i.uuid)?ih.get(i.uuid).push(this):ih.set(i.uuid,[this]),PS.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()}},Ym=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=PS.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=ih.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=[...ih.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}},bo=class{constructor(e,t,i,r){if(this.data=t,t.interaction==="play")this.interaction=new xo(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Ym(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof xo?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof xo?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof xo&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};function q8(e,t){let i=e.material.layers.find(r=>r.uuid===t);return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var DS=new Map,rh=new Map,sh=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=q8(i,r);if(o)this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,n!==void 0&&(this.videoElement.volume=n);else throw new Error("Missing property");a!==void 0&&(this.delay=a),rh.has(i.uuid)?rh.get(i.uuid).push(this):rh.set(i.uuid,[this]),DS.set(e,this),this.pause()}mute(){this.videoElement.muted=!0}unMute(){this.videoElement.muted=!1}play(e){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(()=>{this.videoElement.play(),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){this.videoElement.pause(),this.status="paused"}stop(){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.stop(),this.videoElement.muted=!0}},Qm=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=DS.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=rh.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=[...rh.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}},iu=class{constructor(e,t,i){if(this.data=t,t.interaction==="play")this.interaction=new sh(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Qm(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof sh?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof sh?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},Y8="text/plain",Q8="us-ascii",cb=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),Z8=(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===Q8)?"":`${c}${d?`=${d}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==Y8)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${n?`#${n}`:""}`};function K8(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 Z8(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];cb(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()])cb(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 J8=class{constructor({url:e,context:t},i){if(this.managers=i,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:K8(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){bm?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.managers.controlsManager.orbitControls?.onPointerUp(Qe[0]),Kz())}},$8=class{constructor(e,t,i,r){this.scene=t,this.sharedAssets=i,this.sceneData=e,this.managers=r}dispatch(){YS(this.sceneData,this.scene,this.sharedAssets,!0),this.managers.eventManager?.reset(),this.managers.controlsManager.orbitControls?.reset(),this.managers.controlsManager?.gameControls.forEach(e=>e.reset(!0))}},OS={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},mv={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},ej=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],ru={CSS:{},springs:{}};function cs(e,t,i){return Math.min(Math.max(e,t),i)}function nh(e,t){return e.indexOf(t)>-1}function ff(e,t){return e.apply(null,t)}var je={arr:function(e){return Array.isArray(e)},obj:function(e){return nh(Object.prototype.toString.call(e),"Object")},pth:function(e){return je.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||je.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 je.hex(e)||je.rgb(e)||je.hsl(e)},key:function(e){return!OS.hasOwnProperty(e)&&!mv.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function LS(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function IS(e,t){var i=LS(e),r=cs(je.und(i[0])?1:i[0],.1,100),s=cs(je.und(i[1])?100:i[1],.1,100),n=cs(je.und(i[2])?10:i[2],.1,100),a=cs(je.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=ru.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 ru.springs[e]=y,y}return t?d:p}function tj(e){return e===void 0&&(e=10),function(t){return Math.ceil(cs(t,1e-6,1)*e)*(1/e)}}var ij=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,b=1,x=e-1;b!==x&&f[b]<=v;++b)y+=t;--b;var w=(v-f[b])/(f[b+1]-f[b]),A=y+w*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}(),RS=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=cs(r,1,10),a=cs(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 gv(e,t){if(je.fnc(e))return e;var i=e.split("(")[0],r=RS[i],s=LS(e);switch(i){case"spring":return IS(e,t);case"cubicBezier":return ff(ij,s);case"steps":return ff(tj,s);default:return ff(r,s)}}function BS(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Tu(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 Pu(e){return e.reduce(function(t,i){return t.concat(je.arr(i)?Pu(i):i)},[])}function db(e){return je.arr(e)?e:(je.str(e)&&(e=BS(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function vv(e,t){return e.some(function(i){return i===t})}function yv(e){var t={};for(var i in e)t[i]=e[i];return t}function Zm(e,t){var i=yv(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Du(e,t){var i=yv(e);for(var r in t)i[r]=je.und(e[r])?t[r]:e[r];return i}function rj(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function sj(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 nj(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 aj(e){if(je.rgb(e))return rj(e);if(je.hex(e))return sj(e);if(je.hsl(e))return nj(e)}function Vs(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 oj(e){if(nh(e,"translate")||e==="perspective")return"px";if(nh(e,"rotate")||nh(e,"skew"))return"deg"}function Km(e,t){return je.fnc(e)?e(t.target,t.id,t.total):e}function ds(e,t){return e.getAttribute(t)}function xv(e,t,i){var r=Vs(t);if(vv([i,"deg","rad","turn"],r))return t;var s=ru.CSS[t+i];if(!je.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 ru.CSS[t+i]=h,h}function NS(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?xv(e,s,i):s}}function bv(e,t){if(je.dom(e)&&!je.inp(e)&&(ds(e,t)||je.svg(e)&&e[t]))return"attribute";if(je.dom(e)&&vv(ej,t))return"transform";if(je.dom(e)&&t!=="transform"&&NS(e,t))return"css";if(e[t]!=null)return"object"}function zS(e){if(je.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 lj(e,t,i,r){var s=nh(t,"scale")?1:0+oj(t),n=zS(e).get(t)||s;return i&&(i.transforms.list.set(t,n),i.transforms.last=t),r?xv(e,n,r):n}function wv(e,t,i,r){switch(bv(e,t)){case"transform":return lj(e,t,r,i);case"css":return NS(e,t,i);case"attribute":return ds(e,t);default:return e[t]||0}}function _v(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Vs(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 US(e,t){if(je.col(e))return aj(e);if(/\s/g.test(e))return e;var i=Vs(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function Av(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function hj(e){return Math.PI*2*ds(e,"r")}function cj(e){return ds(e,"width")*2+ds(e,"height")*2}function dj(e){return Av({x:ds(e,"x1"),y:ds(e,"y1")},{x:ds(e,"x2"),y:ds(e,"y2")})}function FS(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var n=t.getItem(s);s>0&&(i+=Av(r,n)),r=n}return i}function uj(e){var t=e.points;return FS(e)+Av(t.getItem(t.numberOfItems-1),t.getItem(0))}function kS(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return hj(e);case"rect":return cj(e);case"line":return dj(e);case"polyline":return FS(e);case"polygon":return uj(e)}}function pj(e){var t=kS(e);return e.setAttribute("stroke-dasharray",t),t}function fj(e){for(var t=e.parentNode;je.svg(t)&&je.svg(t.parentNode);)t=t.parentNode;return t}function jS(e,t){var i=t||{},r=i.el||fj(e),s=r.getBoundingClientRect(),n=ds(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 mj(e,t){var i=je.str(e)?BS(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:jS(i),totalLength:kS(i)*(r/100)}}}function gj(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=jS(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 ub(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=US(je.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:je.str(e)||t?r.split(i):[]}}function GS(e){var t=e?Pu(je.arr(e)?e.map(db):db(e)):[];return Tu(t,function(i,r,s){return s.indexOf(i)===r})}function VS(e){var t=GS(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:zS(i)}}})}function vj(e,t){var i=yv(t);if(/^spring/.test(i.easing)&&(i.duration=IS(i.easing)),je.arr(e)){var r=e.length,s=r===2&&!je.obj(e[0]);s?e={value:e}:je.fnc(t.duration)||(i.duration=t.duration/r)}var n=je.arr(e)?e:[e];return n.map(function(a,o){var l=je.obj(a)&&!je.pth(a)?a:{value:a};return je.und(l.delay)&&(l.delay=o?0:t.delay),je.und(l.endDelay)&&(l.endDelay=o===n.length-1?t.endDelay:0),l}).map(function(a){return Du(a,i)})}function yj(e){for(var t=Tu(Pu(e.map(function(n){return Object.keys(n)})),function(n){return je.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)je.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 xj(e,t){var i=[],r=t.keyframes;r&&(t=Du(yj(r),t));for(var s in t)je.key(s)&&i.push({name:s,tweens:vj(t[s],e)});return i}function bj(e,t){var i={};for(var r in e){var s=Km(e[r],t);je.arr(s)&&(s=s.map(function(n){return Km(n,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function wj(e,t){var i;return e.tweens.map(function(r){var s=bj(r,t),n=s.value,a=je.arr(n)?n[1]:n,o=Vs(a),l=wv(t.target,e.name,o,t),h=i?i.to.original:l,u=je.arr(n)?n[0]:h,c=Vs(u)||Vs(l),d=o||c;return je.und(a)&&(a=h),s.from=ub(u,d),s.to=ub(_v(a,u),d),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=gv(s.easing,s.duration),s.isPath=je.pth(n),s.isColor=je.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var HS={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 WS(e,t){var i=VS(e);i.forEach(function(r){for(var s in t){var n=Km(t[s],r),a=r.target,o=Vs(n),l=wv(a,s,o,r),h=o||Vs(l),u=_v(US(n,h),l),c=bv(a,s);HS[c](a,s,u,r.transforms,!0)}})}function _j(e,t){var i=bv(e.target,t.name);if(i){var r=wj(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 Aj(e,t){return Tu(Pu(e.map(function(i){return t.map(function(r){return _j(i,r)})})),function(i){return!je.und(i)})}function XS(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;return r(n)+a+o+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;return r(n)+a+o+n.duration*(n.loop??1)-n.endDelay})):t.endDelay,s}var pb=0;function Sj(e){var t=Zm(OS,e),i=Zm(mv,e),r=xj(i,e),s=VS(e.targets),n=Aj(s,r),a=XS(n,i),o=pb;return pb++,Du(t,{id:o,children:[],animatables:s,animations:n,duration:a.duration,delay:a.delay,endDelay:a.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection})}var Sr=[],fb=[],ld,Mj=function(){function e(){ld=requestAnimationFrame(t)}function t(i){var r=Sr.length;if(r){for(var s=0;s<r;){var n=Sr[s];n.paused?(Sr.splice(s,1),r-=1):(n.tick(i),s++)}e()}else ld=cancelAnimationFrame(ld)}return e}();function Ej(e){document.hidden?(Sr.forEach(function(t){return t.pause(e.timeStamp)}),fb=Sr.slice(0),Vt.running=Sr=[]):fb.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",Ej);function Vt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,n,a=0,o=null;function l(x){var w=window.Promise&&new Promise(function(A){return o=A});return x.finished=w,w}var h=Sj(e),u=l(h);function c(){var x=h.direction;x!=="alternate"&&(h.direction=x!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,n.forEach(function(w){return w.reversed=h.reversed})}function d(x){return h.reversed?h.duration-x:x}function p(){t=0,i=d(h.currentTime)*(1/Vt.speed)}function f(x,w){w&&(h.reversed?w.seek(w.duration*w.loop-(x-w.timelineOffset-w.pingPongDelayCorrection)):w.seek(x-w.timelineOffset-w.startOnceDelay-w.pingPongDelayCorrection))}function g(x){if(h.reversed)for(var w=a;w--;)f(x,n[w]);else for(var A=0;A<a;A++)f(x,n[A])}function m(x){var w=0,A=h.animations,S=A.length;for(h.reversePlayback===!0&&h.rewind===!1&&(x=h.duration+h.delay-h.endDelay-x);w<S;){var _=A[w],M=_.animatable,C=_.tweens,T=C.length-1,P=C[T];T&&(P=Tu(C,function(ee){return x<ee.end})[0]||P);for(var O=cs(x-P.start-P.delay,0,P.duration)/P.duration,D=isNaN(O)?1:P.easing(O),k=P.to.strings,W=P.round,X=[],N=P.to.numbers.length,j=void 0,F=0;F<N;F++){var z=void 0;if(h.reversePlayback===!0&&h.rewind===!1)var H=P.to.numbers[F],B=P.from.numbers[F]||0;else var B=P.to.numbers[F],H=P.from.numbers[F]||0;P.isPath?z=gj(P.value,D*B):z=H+D*(B-H),W&&(P.isColor&&F>2||(z=Math.round(z*W)/W)),X.push(z)}var Q=k.length;if(!Q)j=X[0];else{j=k[0];for(var Y=0;Y<Q;Y++){var U=k[Y],se=k[Y+1],V=X[Y];isNaN(V)||(se?j+=V+se:j+=V+" ")}}HS[_.type](M.target,_.property,j,M.transforms),_.currentValue=j,w++}}function v(x){h[x]&&!h.passThrough&&h[x](h)}function y(){h.remaining&&h.remaining!==!0&&h.remaining--}function b(x){var w=h.duration,A=h.delay,S=w-h.endDelay,_=d(x);if(h.progress=cs(_/w*100,0,100),h.reversePlayback=_<h.currentTime,a&&g(_),!h.began&&h.currentTime>=0&&(h.began=!0,v("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,v("loopBegin")),(h.reversed||_>=0)&&_<=A&&h.currentTime!==0&&(m(0),v("change")),(_>=S&&h.currentTime!==w||!w)&&(m(w),v("change")),_>A&&_<S?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,v("changeBegin")),m(_),v("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,v("change"),a&&v("timelineChangeComplete")):h.began&&_>S&&v("changeComplete"),h.currentTime=cs(_,0,w),h.began&&v("update"),x>=w)if(y(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,v("loopComplete"),v("complete"),!h.passThrough&&"Promise"in window&&(o(),u=l(h)));else{a?t+=h.duration/Vt.speed:t+=h.duration;for(let M of n)M.setStartTime(0),M.remaining=M.loop;v("loopComplete"),h.loopBegan=!1,h.direction==="alternate"&&c()}}return h.reset=function(){var x=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=x==="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||x==="alternate"&&h.loop===1)&&h.remaining++,m(h.reversed?h.duration:0)},h.setStartTime=function(x){t=x},h.set=function(x,w){return WS(x,w),h},h.tick=function(x){r=x,t||(t=r),b((r+(i-t))*Vt.speed)},h.seek=function(x){b(x-t)},h.pause=function(x){h.paused=!0,a&&(s=x??performance.now())},h.play=function(x){!h.paused||(h.completed&&h.reset(),h.paused=!1,Sr.push(h),a&&s!==void 0&&(t+=(x??performance.now())-s),ld||Mj())},h.reverse=function(){c(),h.completed=!h.reversed,p()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function mb(e,t){for(var i=t.length;i--;)vv(e,t[i].animatable.target)&&t.splice(i,1)}function Cj(e){for(var t=GS(e),i=Sr.length;i--;){var r=Sr[i],s=r.animations,n=r.children;mb(t,s);for(var a=n.length;a--;){var o=n[a],l=o.animations;mb(t,l),!l.length&&!o.children.length&&n.splice(a,1)}!s.length&&!n.length&&r.pause()}}function Tj(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?gv(t.easing):null,s=t.grid,n=t.axis,a=t.from||0,o=a==="first",l=a==="center",h=a==="last",u=je.arr(e),c=parseFloat(u?e[0]:e),d=u?parseFloat(e[1]):0,p=Vs(u?e[1]:e)||0,f=t.start||0+(u?c:0),g=[],m=0;return function(v,y,b){if(o&&(a=0),l&&(a=(b-1)/2),h&&(a=b-1),!g.length){for(var x=0;x<b;x++){if(!s)g.push(Math.abs(a-x));else{var w=l?(s[0]-1)/2:a%s[0],A=l?(s[1]-1)/2:Math.floor(a/s[0]),S=x%s[0],_=Math.floor(x/s[0]),M=w-S,C=A-_,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(O){return r(O/m)*m})),i==="reverse"&&(g=g.map(function(O){return n?O<0?O*-1:-O:Math.abs(m-O)}))}var P=u?(d-c)/m:c;return f+P*(Math.round(g[y]*100)/100)+p}}function Pj(e){e===void 0&&(e={});var t=Vt(e);return t.duration=0,t.add=function(i,r){var s=Sr.indexOf(t),n=t.children;s>-1&&Sr.splice(s,1);function a(d){d.passThrough=!0}for(var o=0;o<n.length;o++)a(n[o]);var l=Du(i,Zm(mv,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=je.und(r)?h:_v(r,h),a(t);var u=Vt(l);a(u),n.push(u);var c=XS(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}Vt.version="3.2.0";Vt.speed=1;Vt.running=Sr;Vt.remove=Cj;Vt.get=wv;Vt.set=WS;Vt.convertPx=xv;Vt.path=mj;Vt.setDashoffset=pj;Vt.stagger=Tj;Vt.timeline=Pj;Vt.easing=gv;Vt.penner=RS;Vt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var Dj=Vt,gb=new E,vb=new E,yb=new ct;function Oj(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 sl(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=rt.lerp(o,l,h);s?t[e]=Math.trunc(u):t[e]=u},start:()=>{t[e]=o},end:()=>{t[e]=l}}}function qS(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||Ng(l,h)))return{update:u=>{l.forEach((c,d)=>{let p=rt.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 xb(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 Lj(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 ve().fromArray(s):a.clone(),l=new E,h=new ct,u=new E;o.decompose(l,h,u);let c=new ve().fromArray(n),d=new E,p=new ct,f=new E;if(c.decompose(d,p,f),!o.equals(c))return{update:g=>{yb.slerpQuaternions(h,p,g),gb.lerpVectors(l,d,g),vb.lerpVectors(u,f,g),a.compose(gb,yb,vb)},start:()=>{a.compose(l,h,u)},end:()=>{a.compose(d,p,f)}}}function Ij(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ge().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 zn(e,t,i,r){if(typeof t[e]=="number")return sl(e,t,i??{},r);if(Array.isArray(t[e]))return qS(e,t,i??{},r)}function Rj(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=rt.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=sl("targetOffset",e,t,i);a&&r.push(a)}return r}function Bj(e,t,i,r){if(i.scaleBaked===void 0)return;let s=t.scaleBaked??e.data.geometry.scaleBaked,n=i.scaleBaked;if(ma.isEqual(s,n))return;let a=[];return a.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[rt.lerp(s[0],n[0],o),rt.lerp(s[1],n[1],o),rt.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 Nj(e,t,i){if(!i.extrusion)return;let r=e.extrusion,s=t.extrusion??{},n=i.extrusion,a=[];return Y_.forEach(o=>{let l=zn(o,r,s,n);l&&a.push(l)}),a}function zj(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 Sh){let l=Bj(e,a,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,gh(n,I1)),I1.forEach(h=>{let u=zn(h,l,a,o);u&&s.push(u)}),e instanceof cv){Object.assign(l,{extrusion:{...n.extrusion}});let h=Nj(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 Uj(e,t,i,r){let s=[];if(i.intensity!==void 0){let n=sl("intensity",e,t,i);n&&s.push(n)}if(i.color!==void 0){let n=Ij("color",e,t,i,r);n&&s.push(n)}return s}function Fj(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(...bb(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(...bb(e.material,n,a,r))}return s}function bb(e,t,i,r){let s=[];e.transparent=Kd(i,r)||!!t.layers&&Kd(t,r);for(let n of e.layers){let a=t.layers?.data(n.uuid),o=i.layers.data(n.uuid);if(!o||!(n.visible??!0)||!(o.visible??!0))continue;let l=n.getNames().filter(h=>!W_.some(u=>h.includes(u)));for(let h of l)try{let u=n.getValue(h),c;if(h==="colors")c=Xj(n,a,o,h);else if(Array.isArray(u))h==="steps"&&(c=Wj(n,a,o,h));else if(typeof u=="number")c=kj(n,a,o,h);else{if(typeof u=="boolean")continue;u instanceof G?c=jj(n,a,o,h):u instanceof E?c=Gj(n,a,o,h):u instanceof Gi?c=Hj(n,a,o,h,r):u instanceof Ge?c=Vj(n,a,o,h,r):"isTexture"in u&&(c=qj(n,a,o,h))}c&&(Array.isArray(c)?s.push(...c):s.push(c))}catch(u){console.error(`lerpMaterial: unexpected material layer for ${h}`,u)}}return s}function kj(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,rt.lerp(s,n,a))},start:()=>{e.setValue(r,s)},end:()=>{e.setValue(r,n)}}}function jj(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),n=t?new G().fromArray(t[r]):s.clone(),a=new G().fromArray(i[r]);if(!n.equals(a))return{update:o=>{s.lerpVectors(n,a,o)},start:()=>{s.copy(n)},end:()=>{s.copy(a)}}}function Gj(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 Vj(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Ge().setRGB(a.r,a.g,a.b);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Hj(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 Ge().setRGB(n.r,n.g,n.b):o.clone(),h=typeof a=="string"?s.getColor(a).clone():new Gi(a.r,a.g,a.b,a.a);if(l.equals(h))return;let u=o.clone();return e.setValue(r,u),{update:c=>{u.lerpColors(l,h,c)},start:()=>{u.copy(l)},end:()=>{u.copy(h)}}}function Wj(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]=rt.lerp(h,u,c)},start:()=>{n[l]=h},end:()=>{n[l]=u}})}return s.length?s:void 0}function Xj(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]];Ld.isEqual(h,u)||s.push({update:c=>{n[l].fromArray(Ld.lerp(h,u,c))},start:()=>{n[l].fromArray(h)},end:()=>{n[l].fromArray(u)}})}return s.length?s:void 0}function qj(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(!fo.isEqual(o,h)||!fo.isEqual(l,u))return{update:c=>{s.repeat=fo.lerp(o,h,c),s.offset=fo.lerp(l,u,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...u],s.updateMatrix()}}}var mf=new E,wb=new _i;function Yj(e,t,i,r){let s=[],n=xb("position",e,t,i);n&&s.push(n);let a=xb("scale",e,t,i);a&&s.push(a);let o=Qj(e,t,i,r);o&&s.push(o);let l=Lj("hiddenMatrix",e,t,i);l&&s.push(l);let h={slide:(t.pathSnapping??e.dataPatched.pathSnapping).slide},u=sl("slide",h,t.pathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping);if(u&&s.push(u),n||a||o||l||u){let c=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),ks(e)&&Sn(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,h))};s.push({update:c,start:c,end:c})}return s}function Qj(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=mf.subVectors(o,a);if(r&&l.toArray().every(h=>Math.abs(h)<2*Math.PI)){let h=new ct().setFromEuler(wb.setFromVector3(a)),u=new ct().setFromEuler(wb.setFromVector3(o));return{update:c=>{Oj(h,u,e.quaternion,c),c===1&&e instanceof ar&&(e.updateUp(),e.isUpVectorFlipped=!1)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}else return{update:h=>{mf.lerpVectors(a,o,h),e.rotation.setFromVector3(mf),h===1&&e instanceof ar&&(e.updateUp(),e.isUpVectorFlipped=!1)},start:()=>{e.rotation.setFromVector3(a)},end:()=>{e.rotation.setFromVector3(o)}}}function Zj(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;F_.forEach(d=>{let p;d==="count"?p=sl("count",s.parameters,n,a,!0):p=zn(d,s.parameters,n??{},a),p&&r.push(p)});let o=Kj(s,n,a);o?.length&&r.push(...o);let l=Jj(s,n,a);l?.length&&r.push(...l);let h=$j(s,n,a);h?.length&&r.push(...h);let u=eG(s,n,a);u?.length&&r.push(...u);let c=tG(s,n,a);return c?.length&&r.push(...c),r.length&&r.push({update:()=>{s.update()}}),r}function Kj(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 k_.forEach(o=>{let l=zn(o,n,r??{},s);l&&a.push(l)}),a}function Jj(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 j_.forEach(o=>{let l=zn(o,a,r??{},s);l&&n.push(l)}),n}function $j(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 G_.forEach(o=>{let l;o==="count"?l=qS(o,a,r??{},s,!0):l=zn(o,a,r??{},s),l&&n.push(l)}),n}function eG(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 V_.forEach(o=>{let l;o==="count"?l=sl(o,a,r??{},s,!0):l=zn(o,a,r??{},s),l&&n.push(l)}),n}function tG(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 H_.forEach(o=>{let l=zn(o,a,r??{},s);l&&n.push(l)}),n}function _b(e,t,i,r,s){let n=[];return e.data.visible&&n.push(...Yj(e,t,i,s)),e.data.visible&&n.push(...Zj(e,t,i)),ks(e)?(e instanceof Cr&&e.data.visible&&n.push(...zj(e,t,i,r)),e.data.visible&&n.push(...Fj(e,t,i,r))):n8(e)?e.data.visible&&n.push(...Uj(e,t,i,r)):s8(e)&&n.push(...Rj(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 Ab=new E;function YS(e,t,i,r=!1){let s=[];t.traverseObject(n=>{if(r&&(n.rigidBody?.setTranslation(n.position0,!0),n.rigidBody?.setRotation(n.rotation0,!0),n.rigidBody?.setLinvel(Ab,!0),n.rigidBody?.setAngvel(Ab,!0)),!Ct.is(n))return;let a=n.uuid,o=n.data;if(delete n.states,!o.states)return;let l=!1;s.some(h=>e.objects.isDescendantOf(a,h))?l=!0:o.physics?.fusedBody===!0&&o.physics.rigidBody==="dynamic"&&s.push(a),n.data=o,n.currentState=null,n.reversibleToState=null,n.currentTransitionEvent=null;for(let h of o.states)e.environment.usePhysics===!0&&o.physics&&(o.physics.rigidBody==="dynamic"||l)&&(h.data.position!==void 0||h.data.rotation!==void 0||h.data.hiddenMatrix!==void 0)||(n.states||(n.states={}),n.states[h.id]=oa.patch(o,h.data));iG(t,n,null,i,o.events.find(h=>h.data.type==="Follow"||h.data.type==="LookAt")!==void 0)})}function iG(e,t,i,r,s=!1){t instanceof Cr&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof Cr&&t.updateGeometryGroupsIfNeeded()}function rG(e){let t;switch(e.easing){case 0:t="cubicBezier( 0, 0, 1, 1 )";break;case 1:t="cubicBezier( .25, .1, .25, 1 )";break;case 2:t="cubicBezier( .42, 0, 1, 1 )";break;case 3:t="cubicBezier( 0, 0, .58, 1 )";break;case 4:t="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:i,control2:r}=e;t=`cubicBezier(
4913
4913
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
4914
4914
  )`;break;case 6:let{mass:s,stiffness:n,damping:a,velocity:o}=e;t=`spring( ${s}, ${n}, ${a}, ${o} )`;break;default:t="linear"}return{duration:e.duration,easing:t}}function QS(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=e.direction==="pingpong-rewind";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,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,t.delay!==0&&(t.pingPongDelayCorrection=t.delay)),t}var Sb=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.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.onFirstLoop=()=>{this.useCurrentState&&(this.callback=_b(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let a=hd(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=hd(this.object,t);if(!a)throw new Error("Missing property");this.from=a}if(i===void 0)throw new Error("Missing property");{let a=hd(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,...QS(r),...rG(r),change:this.onChange},this.callback=_b(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}},wo=class extends Vi{constructor(e,t,i){if(super(),this.data=e,this.scene=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=t.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=hd(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=QS(this.data.tweens[0].data),r=i.loop;t&&typeof i.loop=="number"&&i.loop--,this.timeline?.pause(),this.timeline=Dj.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 ar&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new Sb(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 ar&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let u=new Sb(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.scene,shared:this.sharedAssets}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration)}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 hd(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}}function Ln(e,t,i,r,s,n){let a={Audio:[],Video:[],Link:[],Reset:[],Transition:[]};return t.forEach(({id:o,data:l})=>{try{l.type==="Audio"?Al[e.type].includes("Audio")&&a.Audio.push(new bo(o,l,i,s)):l.type==="Video"?Al[e.type].includes("Video")&&a.Video.push(new iu(o,l,i)):l.type==="Link"?Al[e.type].includes("Link")&&a.Link.push(new J8(l,n)):l.type==="Reset"?Al[e.type].includes("Reset")&&a.Reset.push(new $8(r.data,r,s,n)):l.type==="Transition"&&Al[e.type].includes("Transition")&&a.Transition.push(new wo(l,r,s))}catch{}}),a}function In(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof bo||i instanceof iu||i instanceof wo)&&i.dispose()})})}var Sv=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],ZS=e=>Sv.find(([t,i])=>i===e)?.[0],Ou=e=>Sv.find(([t])=>t===e)?.[1],sG=(e,t)=>{let i=ZS(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},nG=class extends Nn{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[ZS(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{scene:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of Sv)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=sG(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)})})}},aG=class{constructor(e,t,i,r,s,n){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.useToggle=t.toggle,(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=Ln(t,t.actions,i,r,s,n)}disconnect(){In(this.actions)}dispatch(){let e=new Set;this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.useToggle===!1&&e.add(t)}),this.useToggle?this.actions.Transition.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.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{e.has(t)===!1&&t.play()}),this.actions.Link.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()))}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.Transition.forEach(t=>t.playFromCurrent()),this.actions.Link.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()})}},oG=class extends Nn{constructor(e,t,i){super(e),this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.onMouseDown=n=>{Qe.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseDown"))},this.onMouseUp=n=>{Qe.length>1||(this.eventContext.updateRaycaster(n),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=n=>{Qe.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent())},this.onMousePressRelease=n=>{Qe.length>1||(this.eventContext.updateRaycaster(n),this.handleMousePressEvent(!0))},this.onKeyDown=n=>{this.heldKeys[n.key]||this.handleKeyEvent(n,"KeyDown"),this.heldKeys[n.key]=!0},this.onKeyUp=n=>{this.handleKeyEvent(n,"KeyUp")},this.onKeyPressDown=n=>{this.heldKeysPress[n.key]||this.handleKeyEvent(n,"KeyPress"),this.heldKeysPress[n.key]=!0},this.onKeyPressUp=n=>{this.handleKeyEvent(n,"KeyPress",!0)},this.releaseHeldKey=n=>{delete this.heldKeys[n.key]},this.releaseHeldKeyPress=n=>{delete this.heldKeysPress[n.key]},this._onUserEvent=({eventName:n,target:a,reverse:o})=>{if(!n||!a)return;let l=Ou(n);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(a.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[a.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{scene:r,sharedAssets:s}=this.eventContext;r.traverseEntity(n=>{if(!n.data?.events.length)return;let a=n.visible?["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"]:["KeyDown","KeyUp","KeyPress"];for(let o of a){let l=this.eventsPerObjects[o];n.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:u})=>{try{let c=new aG(h,u,n,r,s,{controlsManager:t,eventManager:i});c.actions.Video.length&&(this.hasVideoAction=!0),l[n.uuid]?l[n.uuid].push(c):l[n.uuid]=[c]}catch{}}),l[n.uuid]?.length&&this.objectsPerTypes[o].push(n)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),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={},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()})})}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,scene:r}=this.eventContext,s=this.objectsPerTypes[e];if(s.length)if(t){let n=Xm(i,r,s);qm(n).forEach(a=>{this.eventsPerObjects[e][a.uuid]&&this.handleObjectMouseEventDispatch(a,e)})}else s.forEach(n=>{tu(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,scene:a}=this.eventContext;if(s){let o=Xm(n,a,i);r=qm(o)}else i.forEach(o=>{tu(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())})})}},lG=new E,hG=new E,KS=class{constructor(e,t,i,r){this.actionsIn=Ln(e,e.inActions,t,i,r),this.actionsOut=Ln(e,e.outActions,t,i,r)}disconnect(){In(this.actionsIn),In(this.actionsOut)}},cG=class extends KS{constructor(e,t,i,r,s){super(t,i,r,s),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrix=()=>{let l=lG.setFromMatrixPosition(this.objects[0].matrixWorld),h=hG.setFromMatrixPosition(this.objects[1].matrixWorld),u=l.distanceTo(h)<=this.distance?"in":"out";if(this.stage!==u){let c=u==="in"?this.actionsIn:this.actionsOut;c.Audio.forEach(d=>d.dispatchConditional()),c.Video.forEach(d=>d.dispatchConditional()),c.Transition.forEach(d=>{d.object.currentTransitionEvent!==this&&(d.object.currentTransitionEvent=this),d.init()}),c.Transition.forEach(d=>d.play()),this.stage=u}};let{distance:n,fromObject:a,toObject:o}=t.condition;this.distance=n;for(let l of[a,o]){if(!l)throw new Error("Missing property");let h=r.find(l);if(!h)throw new Error("Missing property");this.objects.push(h)}}connect(){this.objects.forEach(e=>{e.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},dG=class extends KS{constructor(e,t,i,r,s){super(t,i,r,s),this.id=e,this.data=t,this.object=i,this.onBegin=({target:o,state:l})=>{this.toState!==l&&(this.actionsOut.Audio.forEach(h=>h.dispatchConditional()),this.actionsOut.Video.forEach(h=>h.dispatchConditional()),this.actionsIn.Transition.forEach(h=>h.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(h=>h.play()))},this.onComplete=({target:o,state:l})=>{this.toState===l&&(this.actionsIn.Audio.forEach(h=>h.dispatchConditional()),this.actionsIn.Video.forEach(h=>h.dispatchConditional()),this.actionsOut.Transition.forEach(h=>h.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(h=>h.play()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let a=r.find(n.object);if(!a)throw new Error("Missing property");if(this.toObject=a,n.state&&!this.toObject.states?.[n.state])throw new Error("Missing property");this.toState=n.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},uG=class extends Nn{constructor(e){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length){for(let{id:s,data:n}of r.data.events)if(!n.disabled&&n.type==="Conditional")try{let a;n.condition.type==="Comparison"||(n.condition.type==="Distance"?a=new cG(s,n,r,t,i):n.condition.type==="State"&&(a=new dG(s,n,r,t,i))),a&&(this.eventsPerConditions[n.condition.type].push(a),(a.actionsIn.Video.length||a.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()))}},eo=new E,gf=new E,Is=new E,Rs=new E,Mb=new yr,pG=.01,fG={type:"requestRender"},mG=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}(),Eb=function(){let e=new ve;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 nr&&Sn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),gG=class{constructor(e,t,i){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={...am.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(rl.PERSONAL_CAMERA_ID):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)}},vG=class extends Nn{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(Qe.length>1)){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.onTargetChange=i=>()=>{this.updateSingleEvent(i)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="Follow"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new gG(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ir&&(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(),ir&&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}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{plane:t,limitDistance:i,limitDistanceEnabled:r}=e.data;if(e.object.getWorldPosition(Is),e.isReset)Rs.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(Rs);else{let{camera:n,raycaster:a}=this.eventContext;if(t==="custom"?(n.getWorldDirection(gf),gf.negate(),eo.copy(gf)):t==="xy"?eo.set(0,0,1):t==="xz"?eo.set(0,1,0):t==="yz"&&eo.set(1,0,0),Mb.setFromNormalAndCoplanarPoint(eo,Is),!a.ray.intersectPlane(Mb,Rs))return}if(!e.isReset){if(Rs.distanceTo(e.worldPosition0)>i&&r&&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)Rs.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&&(Rs.x=Is.x),e.data.enabledTranslation[1]===!1&&(Rs.y=Is.y),e.data.enabledTranslation[2]===!1&&(Rs.z=Is.z);let s=mG(Is,Rs,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=eo.subVectors(s,Is).divideScalar(e.currentDampingFactor);Is.add(n),Eb(e.object,Is),e.paused=n.length()<pG}else Eb(e.object,s),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(fG)}},zl=new E,Xc=new E,Ul=new ve,to=new ct,nn=new ct,Fl=new E,kl=new E,Zn=new E,Bs=new E,vf=new yr,yG=1e-6,xG={type:"requestRender"},bG={type:"changeRotation"},Cb=function(){let e=new ve;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(SS(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof nr&&Sn(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),wG=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new ct,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...om.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(e.target==="personal camera"?this.target=i.find(rl.PERSONAL_CAMERA_ID):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}},_G=class extends Nn{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=i=>{if(!(Qe.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)};let{scene:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.environment.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new wG(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),ir&&(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 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(),ir&&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 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,{camera:l,raycaster:h}=this.eventContext,{object:u,target:c}=e;if(u.getWorldPosition(Fl),!e.isReset)if(e.target)e.target.getWorldPosition(kl);else{if(s==="custom"?(l.getWorldDirection(Xc),Xc.negate(),vf.setFromNormalAndCoplanarPoint(Xc,Fl)):(s==="xy"?zl.set(0,0,1):s==="xz"?zl.set(0,1,0):s==="yz"&&zl.set(1,0,0),vf.setFromNormalAndCoplanarPoint(zl,Fl)),!h.ray.intersectPlane(vf,kl))return;r>0&&(s==="custom"||s===void 0)&&kl.addScaledVector(Xc,r)}if(e.isReset||(c?t==="target"?Zn.copy(c.up).applyMatrix4(Ul.extractRotation(c.matrixWorld)).normalize():a.some(d=>d===!1)?(i==="x"?(Bs.set(0,0,1),a[2]===!1&&Bs.set(0,1,0)):i==="y"?(Bs.set(1,0,0),a[0]===!1&&Bs.set(0,0,1)):(Bs.set(0,1,0),a[1]===!1&&Bs.set(1,0,0)),Zn.copy(Bs).applyQuaternion(e.worldQuaternion0).normalize()):Zn.set(0,1,0):s==="custom"?Zn.set(0,1,0):Zn.copy(zl)),e.isReset)nn.copy(e.worldQuaternion0);else if(Fl.distanceTo(kl)>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)nn.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;AG(Ul,kl,Fl,Zn,i,Bs),nn.setFromRotationMatrix(Ul),to.setFromUnitVectors(Bs.applyQuaternion(nn),Zn),a.some(d=>d===!1)&&t!=="target"&&nn.premultiply(to).normalize()}e.currentDampingFactor>1?(u.updateWorldMatrix(!0,!1),to.setFromRotationMatrix(SS(u.matrixWorld)),to.slerp(nn,1/e.currentDampingFactor),Cb(u,Ul.makeRotationFromQuaternion(to)),e.paused=8*(1-to.dot(nn))<yG):(Cb(u,Ul.makeRotationFromQuaternion(nn)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),u.dispatchEvent(xG),u.dispatchEvent(bG)}},ur=new E,ei=new E,Gt=new E;function AG(e,t,i,r,s,n){let a=e.elements;Gt.subVectors(t,i),Gt.lengthSq()===0&&(Gt.z=1),Gt.normalize(),ei.crossVectors(r,Gt),ei.lengthSq()===0&&(Math.abs(r.z)===1?Gt.x+=1e-4:Gt.z+=1e-4,Gt.normalize(),ei.crossVectors(r,Gt)),ei.normalize(),ur.crossVectors(Gt,ei),s==="x"?n.z===1?[ei,ur,Gt]=[Gt,ei,ur]:(ei.negate(),[ei,Gt]=[Gt,ei]):s==="y"?n.x===1?[ei,ur,Gt]=[ur,Gt,ei]:(ei.negate(),[ur,Gt]=[Gt,ur]):n.x===1&&(ei.negate(),[ei,ur]=[ur,ei]),a[0]=ei.x,a[4]=ur.x,a[8]=Gt.x,a[1]=ei.y,a[5]=ur.y,a[9]=Gt.y,a[2]=ei.z,a[6]=ur.z,a[10]=Gt.z}var SG=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=Ln(t,t.actions,i,r,s)}disconnect(){In(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()))}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()))}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.Transition.forEach(t=>t.playFromCurrent())}},MG=class extends Nn{constructor(e){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=r=>{Qe.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onMouseUp=r=>{Qe.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=r=>{Qe.length>1||(this.eventContext.updateRaycaster(r),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=Ou(r);a&&a==="MouseHover"&&(s.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[s.uuid]?.forEach(o=>o.dispatchUserEvent(n)))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length)){for(let{id:s,data:n}of r.data.events)if(!n.disabled&&n.type==="MouseHover")try{let a=new SG(s,n,r,t,i);this.eventsPerObjects[r.uuid]?this.eventsPerObjects[r.uuid].push(a):this.eventsPerObjects[r.uuid]=[a]}catch{}this.eventsPerObjects[r.uuid]?.length&&this.objects.push(r)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),ir&&(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(),ir&&(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,scene:s}=this.eventContext;if(i){let n=Xm(r,s,this.objects);t=qm(n)}else this.objects.forEach(n=>{tu(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}},EG=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=Ln(t,t.actions,i,r,s)}connect(){this.scrollCounter=0}disconnect(){In(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))}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.Transition.forEach(t=>{t.playFromCurrent()})}},CG=class{constructor(e,t,i,r,s,n){this.id=e,this.data=t,this.object=i,this.domElement=n,this.scrollStart=0,this.scrollEnd=0,this.actions=Ln(t,t.actions,i,r,s)}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.dispatch({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){In(this.actions)}handleResize(){this.computeScrollBounds()}dispatch({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))}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.Transition.forEach(t=>{t.playFromCurrent()})}},TG=class extends Nn{constructor(e){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([n,a])=>{a.forEach(o=>o.handleResize())})},this.onScroll=n=>{if(!this.isInview)return;let a={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:a}),l.forEach(h=>h.dispatch(a))})},this.onWheel=n=>{!this.isInview||n.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([a,o])=>{a.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:n.deltaY}),o.forEach(l=>l.dispatch(n.deltaY))})},this.onUserEvent=({eventName:n,target:a,reverse:o})=>{if(!n||!a)return;let l=Ou(n);l&&l==="Scroll"&&(a.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(a)?.forEach(h=>{h.dispatchUserEvent(o)}))};let{scene:t,sharedAssets:i,domElement:r,isExport:s}=this.eventContext;t.traverseEntity(n=>{if(n.data?.events.length){for(let{id:a,data:o}of n.data.events)if(!o.disabled&&o.type==="Scroll")if(o.trigger==="load"||!s){let l=new EG(a,o,n,t,i);this.wheelEventsPerObject.has(n)?this.wheelEventsPerObject.get(n)?.push(l):this.wheelEventsPerObject.set(n,[l])}else{let l=new CG(a,o,n,t,i,r);this.scrollEventsPerObject.has(n)?this.scrollEventsPerObject.get(n)?.push(l):this.scrollEventsPerObject.set(n,[l])}}}),this.intersectionObserver=new IntersectionObserver(n=>{let a=n[0];a&&(this.isInview=a.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)})}},PG=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.actions=Ln(t,t.actions,i,r,s)}disconnect(){In(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof xo?t.interaction.audioPlayer.play():t.interaction instanceof Ym&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof sh?t.interaction.play(i==="autoplay"):t.interaction instanceof Qm&&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.Transition.forEach(t=>t.playFromCurrent()),this.actions.Audio.forEach(t=>{t.interaction instanceof xo?t.interaction.audioPlayer.play():t.interaction instanceof Ym&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof sh?t.interaction.play():t.interaction instanceof Qm&&t.interaction.dispatch()})}},DG=class extends Nn{constructor(e){super(e),this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:r,isExport:s}=this.eventContext;(s?document:r).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([n,a])=>{n.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(o=>{o.dispatchAfter("any")})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.dispatchEvent({type:"beginEvent",eventName:"Start"}),s.forEach(n=>{n.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:r,target:s,reverse:n})=>{if(!r||!s)return;let a=Ou(r);a&&a==="Start"&&(s.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}),this.eventsAfterPerObject.get(s)?.forEach(o=>{o.dispatchUserEvent(n)}))};let{scene:t,sharedAssets:i}=this.eventContext;t.traverseEntity(r=>{if(r.data?.events.length)for(let{id:s,data:n}of r.data.events){if(n.disabled||n.type!=="Start")continue;let a=new PG(s,n,r,t,i);a.actions.Transition.length&&(this.eventsPerObject.has(r)?this.eventsPerObject.get(r)?.push(a):this.eventsPerObject.set(r,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(r)?this.eventsAfterPerObject.get(r)?.push(a):this.eventsAfterPerObject.set(r,[a]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.addEventListener("userEvent",this.onUserEvent)}),this.onPlay()}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.dispatchEvent({type:"beginEvent",eventName:"Start"}),t.forEach(i=>i.dispatch()),e.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),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",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())})}},OG=class{constructor(e,t,i,r,s){this.id=e,this.data=t,this.object=i,this.disabled=!0,this.actions=Ln(t,t.actions,i,r,s),this.target=t.target,this.useToggle=t.toggle}disconnect(){In(this.actions)}dispatch(){this.disabled||(this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?this.actions.Transition.forEach(e=>{e.toggle()}):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()}),this.actions.Video.forEach(e=>{e.dispatchBasic()}))}},Bt;fz.then(e=>Bt=e);var Di=new E,an=new ct,Kn=new E,yf=new _i(0,0,0,"YXZ"),LG={type:"updateMatrix"},JS={type:"beginEvent",eventName:"Collision"};function IG(e){if(e.scene.environment.usePhysics)return!0;let t=!1;return e.scene.objects.traverse((i,r)=>{for(let s of r.events)if(s.data.disabled!==!0&&s.data.type==="GameControl"&&s.data.collisionEnabled){t=!0;break}}),t}var Tb=e=>e.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0),Pb=e=>e.events.find(t=>t.data.disabled!==!0&&t.data.type==="Follow"),RG=class{constructor(e,t,i,r,s,n=!1){this.scene=t,this.sharedAssets=s,this.isExport=n,this.orbitControlsNeedsUpdate=!0,this.gameControls=[],this.gameControlStates=[],this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{},gamePads:[]},this.needsCollisionDetection=!1,this.initializationCounter=-1,this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.processRigidBody=m=>{if(m.bodyType()!==Bt.RigidBodyType.Dynamic)return;m.isSleeping()||this.nActiveRigidBodies++;let[v,y,b]=this.rigidBodyToMesh.get(m.handle);if(Di.copy(m.translation()).multiplyScalar(this.pixelsPerMeter),an.copy(m.rotation()),v.matrixWorld.compose(Di,an,y),v.hasNonUniformScale&&v.matrixWorld.multiply(v.shearScale),v.dispatchEvent(LG),b){let x=v.cloner;if(x&&x.objectForSample===void 0){x.matrixWorld.copy(v.matrixWorld);for(let w of x.children)w.updateMatrixWorld(!0)}for(let w of v.children)w.updateMatrixWorld(!0)}},this.handleCollisionEvents=(m,v,y)=>{if(y!==!1)if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[m])){let b=this.sharedGameControlGlobals.colliderToEntity[v],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else if(this.gameControls.some(b=>b.object===this.sharedGameControlGlobals.colliderToEntity[v])){let b=this.sharedGameControlGlobals.colliderToEntity[m],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x===void 0)return;for(let w of x)w.data.target==="character"&&this.dispatchCollisionEvent(w,b)}else{let b=this.sharedGameControlGlobals.colliderToEntity[m],x=this.sharedGameControlGlobals.eventsPerObjects[b.uuid];if(x!==void 0)for(let S of x)S.data.target==="scene"&&this.dispatchCollisionEvent(S,b);let w=this.sharedGameControlGlobals.colliderToEntity[v],A=this.sharedGameControlGlobals.eventsPerObjects[w?.uuid];if(A!==void 0)for(let S of A)S.data.target==="scene"&&this.dispatchCollisionEvent(S,w)}},this.onBeginState=()=>{this.orbitControls&&(this.orbitControls.enabled=!1,this.orbitControlsNeedsUpdate=!1)},this.onCompleteState=({target:m})=>{this.orbitControls&&(this.orbitControls.enabled=!0,this.orbitControls.resetTo(m.getTarget(Di),m.position,m.zoom,m.isUpVectorFlipped),this.orbitControlsNeedsUpdate=!0)},this.domElement=i.domElement;let a;e.scene.publish.playCamera===null?a=rl.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let o=this.scene.find(a),l=!1,h,u=5,c=8,d=9,p="drag";if(this.usePhysics=e.scene.environment.usePhysics??Zi.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??Zi.defaultData.pixelsPerMeter,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(m=>{m.data.disabled!==!0&&m.data.type==="GameControl"&&(h=m.data.keyAssignments,u=m.data.joystickPosLoc,c=m.data.joystickRotLoc,d=m.data.jumpTouchButtonLoc,p=m.data.rotByTouch)}),this.scene.traverseEntity(m=>{m.dataPatched.events.forEach(v=>{if(v.data.disabled||v.data.type!=="GameControl")return;let y=m;for(;(y=y.parent)?.parent!==null;)if(y.dataPatched.physics?.fusedBody)return;v.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([m,v.data])})}),this.usePhysics&&this.initPhysics(e.scene.environment.gravity??Zi.defaultData.gravity),this.gameControlStates.forEach(([m,v])=>{l=l||v.camera===o.uuid||m.uuid===o.uuid;let y=new $S(m,i.domElement,{...v,keyAssignments:h},e.scene.environment,this.sharedGameControlGlobals,m.uuid!==o.uuid&&v.camera===o.uuid,o,this.scene,s);y.addEventListener("change",r),y.addEventListener("end",r),y.addEventListener("start",r),this.gameControls.push(y),ir&&v.touchControl&&(this.joystickToGameControls[u]!==void 0?this.joystickToGameControls[u].push([y,"pos"]):this.joystickToGameControls[u]=[[y,"pos"]],v.moveMode==="walk"&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([y,"jmp"]):this.joystickToGameControls[d]=[[y,"jmp"]]),p==="joystick"&&(this.joystickToGameControls[c]!==void 0?this.joystickToGameControls[c].push([y,"rot"]):this.joystickToGameControls[c]=[[y,"rot"]]))}),l===!1){let{enableRotate:m,enablePan:v,enableZoom:y,autoRotate:b,hoverRotatePanMode:x}=e.scene.publish.orbitControls;if(m||v||y||b||x!==0){this.orbitControls=new e2(o,i.domElement,this.isExport),this.orbitControls.addEventListener("change",r),this.orbitControls.addEventListener("end",r),this.orbitControls.addEventListener("start",r),this.orbitControls.fromJSON(e.scene.publish.orbitControls,e.scene.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.connect(),this.orbitControls.update();let w=this.orbitControls.object;w.addEventListener("beginState",this.onBeginState),w.addEventListener("completeState",this.onCompleteState)}}let f=i.domElement.width/i.getPixelRatio(),g=i.domElement.height/i.getPixelRatio();this.joystickToGameControls.forEach((m,v)=>{let y=document.body.appendChild(document.createElement("div")),[b,x,w]=(e.scene.publish.joystickSizeAndXYOffset??Go.defaultData.joystickSizeAndXYOffset)[v],A=(f-5*b)/4+b,S={},_=m.some(P=>P[1]==="jmp"),M=_?0:b;v<10?(v<5?S.top=M/2:S.bottom=M/2,S.left=M/2+v%5*A):v===10?(S.left=M/2,S.top=g/2):(S.right=M/2,S.top=g/2),S.top?S.top-=x[1]:S.bottom+=x[1],S.left?S.left+=x[0]:S.right-=x[0];for(let P in S)S[P]+="px";if(_){let P=y.appendChild(document.createElement("div"));Object.assign(P.style,S,{position:"absolute",width:b+"px",height:b+"px",backgroundColor:`rgba(255,255,255,${w==="show"?.4:0})`,zIndex:"9999",borderRadius:b+"px",border:w==="show"?"solid 2px rgba(0, 0, 0, .1)":"none",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let O=b/16*16*.4;w==="show"&&(P.innerHTML=`
4915
4915
  <svg width="${O}" height="${b*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -5209,7 +5209,7 @@ outputColor=vec4(color,inputColor.a);}`,Qc={DEFAULT:0,ESKIL:1},SH=class extends
5209
5209
  void main() {
5210
5210
  gl_FragColor = vec4(0.0);
5211
5211
  }
5212
- `}),Pf=class extends Tr{constructor(e,t){super("OpaquePass",e??Yb,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Yb}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof nr&&(this.originalMaterials.set(r.id,r.material),r.material=BH)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Qb(e,t){return t&&t.enabled&&e.push(t.effect),e}var NH=e=>Object.values(nt).includes(e)?e:nt.NORMAL,zH=class extends Vi{constructor(e){super(),this.postprocessingState=bh.defaultData,this._scene=new pa,this._camera=new ar,this.effects=new Map,this._renderToScreen=!0,this.clock=new VD,this.renderer=e,this.debug=!1,this.effects.set("bloom",new MH),this.effects.set("chromaticAberration",new CH),this.effects.set("vignette",new OH),this.effects.set("noise",new DH),this.effects.set("colorAverage",new TH),this.effects.set("hueSaturation",new PH),this.effects.set("brightnessContrast",new EH),this.effects.set("depthOfField",new LH),this.effects.set("pixelation",new IH),this.effectComposer=new iH(this.renderer),this.opaquePass=new Pf(this.scene,this.camera),this.transmissionPass=new RH(this.scene,this.camera,this.renderer),this.helperPass=new Pf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Lu(!1,!0,!1),this.helperPassOnTop=new Pf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new _H({preset:ho.ULTRA,edgeDetectionMode:Mv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=i2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Ef(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Qb,[]);e.length>0&&(this.uvEffectPass=new Ef(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Qb,[]);t.length>0&&(this.effectPass=new Ef(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new ii(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:oh,wrapT:oh}),this._rt.samples=0,this._savePass=new su(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=NH(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Zb=new ci,UH=class extends yw{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new zH(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=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.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),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}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ro,magFilter:mt,wrapS:Ki,wrapT:Ki,depthBuffer:!1}),this.transmissionDepthTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Lt,magFilter:Lt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ii(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Lt,magFilter:Lt,type:vn,depthTexture:new lg(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof ar?df.uniforms.depthContrast.value=(t.far-t.near)/1e4:df.uniforms.depthContrast.value=1,e.overrideMaterial=df,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Gm:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Ot.penumbraSize.value[o]=a}),Ot.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ot.resolution.value.set(this.resolution.x,this.resolution.y):Ot.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ot.normalRenderTarget.value=this.overrideNormal,Ot.normalRenderTargetDepth.value=Zb):e.needsNormal()&&(this.createNormalRenderTarget(),Ot.normalRenderTarget.value=this.normalRenderTarget.texture,Ot.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)Ot.transmissionRenderTarget.value=this.overrideTransmission,Ot.transmissionRenderTargetDepth.value=Zb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Ot.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ot.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Gm:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},FH=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Mu(e.shared,t),this.scene=new rl(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Cr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},kH=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 jH(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 ah(e){return e instanceof Sh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function GH(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof nr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof nr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!sr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!sr.isMergable(l.material))return;n=sr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][ah(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][ah(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][ah(r)].push(l)}),i}function VH(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 HH(e,t){let i=GH(t,e),r=VH(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 nr&&(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&&jH(a[m]);let g=mo(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new er(g,l[0].material);break}default:{m=new er(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 b of y)b.children&&v(b.children),b instanceof nr&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][ah(b)]&&i[b.material.uuid][ah(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[b])};for(let y=0;y<h;y++){let b=l[y];v(b.children),s[n++]=b}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var WH=Eh(V2(),1),XH=new G;function qH(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 Cv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=g_(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=XH.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new kH({x:10,y:10})),Jz(e)}async load(e,t){qH(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 rV(e);this._data=i,i.version&&(0,WH.default)(i.version,"0.9.258")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Kx(i)&&E6(),Uk(i)&&A6(),i.scene.environment.usePhysics&&mz(),Xx(i)&&Mk()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new FH(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();HH(i,r.scene);let n=performance.now();console.log("Merged geometries in ",n-s," ms")}if(Kx(i)&&this._scene.traverse(s=>{Sn(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof $d&&s.pendingMediaLoad&&s.update()})}),Xx(i)&&IG(i)){let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n)).map(n=>n.loadingPromise);await Promise.all(s)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),YS(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new UH({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?ig:Jb,M8(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(i.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,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=s.size[0],this._viewportHeight=s.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 nV(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}if(t&&(this._scene.updateMatrixWorld(!0),this._controls=new RG(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new sV(this._renderer,this._scene,this._camera,i.scene.publish.stopRaycast,i.scene.publish.preventScroll,i.scene.publish.preventTouchScroll,i.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}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)}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 e2&&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 Gi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{Ly.unsubscribe(e)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),$z(this.canvas)}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={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Ly(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Iu=window,Ru=Iu.ShadowRoot&&(Iu.ShadyCSS===void 0||Iu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Tv=Symbol(),n2=new WeakMap,Fh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Tv)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(Ru&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=n2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&n2.set(i,t))}return t}toString(){return this.cssText}},a2=e=>new Fh(typeof e=="string"?e:e+"",void 0,Tv),Pv=(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 Fh(i,e,Tv)},Dv=(e,t)=>{Ru?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Iu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Bu=Ru?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return a2(i)})(e):e;var Ov,Nu=window,o2=Nu.trustedTypes,YH=o2?o2.emptyScript:"",l2=Nu.reactiveElementPolyfillSupport,Iv={toAttribute(e,t){switch(t){case Boolean:e=e?YH: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}},h2=(e,t)=>t!==e&&(t==t||e==e),Lv={attribute:!0,type:String,converter:Iv,reflect:!1,hasChanged:h2},Qs=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=Lv){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)||Lv}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(Bu(s))}else t!==void 0&&i.push(Bu(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 Dv(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=Lv){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:Iv).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:Iv;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||h2)(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){}};Qs.finalized=!0,Qs.elementProperties=new Map,Qs.elementStyles=[],Qs.shadowRootOptions={mode:"open"},l2?.({ReactiveElement:Qs}),((Ov=Nu.reactiveElementVersions)!==null&&Ov!==void 0?Ov:Nu.reactiveElementVersions=[]).push("1.6.0");var Rv,zu=window,al=zu.trustedTypes,c2=al?al.createPolicy("lit-html",{createHTML:e=>e}):void 0,Un=`lit$${(Math.random()+"").slice(9)}$`,v2="?"+Un,QH=`<${v2}>`,ol=document,jh=(e="")=>ol.createComment(e),Gh=e=>e===null||typeof e!="object"&&typeof e!="function",y2=Array.isArray,ZH=e=>y2(e)||typeof e?.[Symbol.iterator]=="function",kh=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,d2=/-->/g,u2=/>/g,Pa=RegExp(`>|[
5212
+ `}),Pf=class extends Tr{constructor(e,t){super("OpaquePass",e??Yb,t),this.hasTransmissionPass=!1,this.clear=!0,this.needsSwap=!1,this.originalMaterials=new Map}setCamera(e){this.camera=e}setScene(e){this.scene=e??Yb}getScene(){return this.scene}render(e,t){this.originalMaterials.clear(),this.camera.layers.enable(3),this.hasTransmissionPass&&this.scene.traverse(r=>{r.layers.isEnabled(3)&&r instanceof nr&&(this.originalMaterials.set(r.id,r.material),r.material=BH)}),this.camera.layers.enable(8),e.shadowMap.needsUpdate=!0,e.shadowMap.autoUpdate=!0;let i=this.renderToScreen?null:t;e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),this.hasTransmissionPass&&this.originalMaterials.forEach((r,s)=>{let n=this.scene.getObjectById(s);n&&(n.material=r)})}};function Qb(e,t){return t&&t.enabled&&e.push(t.effect),e}var NH=e=>Object.values(nt).includes(e)?e:nt.NORMAL,zH=class extends Vi{constructor(e){super(),this.postprocessingState=bh.defaultData,this._scene=new pa,this._camera=new ar,this.effects=new Map,this._renderToScreen=!0,this.clock=new VD,this.renderer=e,this.debug=!1,this.effects.set("bloom",new MH),this.effects.set("chromaticAberration",new CH),this.effects.set("vignette",new OH),this.effects.set("noise",new DH),this.effects.set("colorAverage",new TH),this.effects.set("hueSaturation",new PH),this.effects.set("brightnessContrast",new EH),this.effects.set("depthOfField",new LH),this.effects.set("pixelation",new IH),this.effectComposer=new iH(this.renderer),this.opaquePass=new Pf(this.scene,this.camera),this.transmissionPass=new RH(this.scene,this.camera,this.renderer),this.helperPass=new Pf(void 0,this.camera),this.helperPass.hasTransmissionPass=!1,this.helperPass.clear=!1,this.helperClearPass=new Lu(!1,!0,!1),this.helperPassOnTop=new Pf(void 0,this.camera),this.helperPassOnTop.hasTransmissionPass=!1,this.helperPassOnTop.clear=!1,this._initCopyPass(),this._initSmaa(),this._initPasses()}get scene(){return this._scene}set scene(e){this._scene=e,this.opaquePass.setScene(e),this.transmissionPass.setScene(e)}set sceneHelpers(e){this.helperPass.setScene(e)}get sceneHelpers(){return this.helperPass.getScene()}set sceneHelpersOnTop(e){this.helperPassOnTop.setScene(e)}get sceneHelpersOnTop(){return this.helperPassOnTop.getScene()}get camera(){return this._camera}set camera(e){this._camera=e,this.opaquePass.setCamera(e),this.transmissionPass.setCamera(e),this.helperPass.setCamera(e),this.helperPassOnTop.setCamera(e)}setTransmissionPassEnabled(e){this.transmissionPass.enabled=e,this.opaquePass.hasTransmissionPass=e}disableHelpers(){this.helperPass.enabled=!1,this.helperClearPass.enabled=!1,this.helperPassOnTop.enabled=!1}enableHelpers(){this.helperPass.enabled=!0,this.helperClearPass.enabled=!0,this.helperPassOnTop.enabled=!0}_initSmaa(){let e=new _H({preset:ho.ULTRA,edgeDetectionMode:Mv.COLOR}),t=()=>{e.removeEventListener("load",t),this.dispatchEvent({type:"smaaloaded"})};e.addEventListener("load",t),e.edgeDetectionMaterial.predicationMode=i2.DEPTH,e.edgeDetectionMaterial.edgeDetectionThreshold=.05,e.edgeDetectionMaterial.predicationThreshold=.002,e.edgeDetectionMaterial.predicationScale=1,this.smaaPass=new Ef(this.camera,e)}_initPasses(){if(this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.removeAllPasses(),this.transmissionPass.updatePasses(this.renderer),this.effectComposer.addPass(this.opaquePass),this.effectComposer.addPass(this.transmissionPass),this.postprocessingState.enabled){let e=[this.effects.get("pixelation")].reduce(Qb,[]);e.length>0&&(this.uvEffectPass=new Ef(this.camera,...e),this.effectComposer.addPass(this.uvEffectPass));let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Qb,[]);t.length>0&&(this.effectPass=new Ef(this.camera,...t),this.effectComposer.addPass(this.effectPass))}this.effectComposer.addPass(this.helperPass),this.effectComposer.addPass(this.helperClearPass),this.effectComposer.addPass(this.helperPassOnTop),this.effectComposer.addPass(this.smaaPass)}_initCopyPass(){if(this._savePass)return;let e=new G;this.renderer.getDrawingBufferSize(e),this._rt=new ii(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:oh,wrapT:oh}),this._rt.samples=0,this._savePass=new su(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){if(this._renderToScreen===e)return;let t=this.effectComposer;!t||(e===!0?(t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,this.postprocessingState.enabled||(this._savePass.needsDepthTexture=!0),t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}updatePostprocessing(e){let{enabled:t,...i}=e,r=!1;t!==this.postprocessingState.enabled&&(r=!0);for(let s of Object.entries(i)){let n=s[1],a=this.effects.get(s[0]);if(a){a.enabled!==n.enabled&&(r=!0),a.enabled=n.enabled;for(let[o,l]of Object.entries(n))o==="blendFunction"?a.blendFunction=NH(l):a[o]=l}}this.postprocessingState=e,r&&this._initPasses()}render(){this.effectComposer.render(this.clock.getDelta())}setScissor(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,i,r),this.effectComposer.outputBuffer.scissor.set(e,t,i,r));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,i,r)}setScissorTest(e){this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e)}setViewport(e,t,i,r){e instanceof $e?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,i,r),this.effectComposer.outputBuffer.viewport.set(e,t,i,r))}resize(e,t,i){if(this.effectComposer.setSize(e,t,i),this._rt){let r=this.renderer.getPixelRatio();this._rt.setSize(e*r,t*r)}}dispose(){this.uvEffectPass?.dispose(),this.effectPass?.dispose(),this.effectComposer.dispose()}},Zb=new ci,UH=class extends yw{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new G,this.pipeline=new zH(this),this.overrideTransmission=e?.overrideTransmission,this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this),r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=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.transmissionRenderTarget?.setSize(s*this._pixelRatio/2,n*this._pixelRatio/2),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}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{generateMipmaps:!0,minFilter:Ro,magFilter:mt,wrapS:Ki,wrapT:Ki,depthBuffer:!1}),this.transmissionDepthTarget=new ii(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Lt,magFilter:Lt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new ii(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Lt,magFilter:Lt,type:vn,depthTexture:new lg(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t){this.normalRenderTarget&&(this.setClearColor(0),t.layers.enable(8),t.layers.disable(0),t.layers.disable(3),this.setRenderTarget(this.normalRenderTarget),this.clear(),t instanceof ar?df.uniforms.depthContrast.value=(t.far-t.near)/1e4:df.uniforms.depthContrast.value=1,e.overrideMaterial=df,this.render(e,t),this.setClearColor(e.bgColor,e.bgColor.a),this.setRenderTarget(null),e.overrideMaterial=e.wireframeState?Gm:null,t.layers.enable(0),t.layers.enable(3))}renderSplineScene(e,t,i,r,s){this.setClearColor(e.bgColor,e.bgColor.a),i.penumbraSize.forEach((a,o)=>{Ot.penumbraSize.value[o]=a}),Ot.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ot.resolution.value.set(this.resolution.x,this.resolution.y):Ot.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),this.overrideNormal!==void 0?(Ot.normalRenderTarget.value=this.overrideNormal,Ot.normalRenderTargetDepth.value=Zb):e.needsNormal()&&(this.createNormalRenderTarget(),Ot.normalRenderTarget.value=this.normalRenderTarget.texture,Ot.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(e,t));let n=!1;if(this.overrideTransmission!==void 0)Ot.transmissionRenderTarget.value=this.overrideTransmission,Ot.transmissionRenderTargetDepth.value=Zb,this.pipeline.setTransmissionPassEnabled(!1);else{let a=e.needsTransmission();a&&(this.transmissionRenderTarget===void 0&&(n=!0),this.createTransmissionRenderTarget(),Ot.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ot.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(a)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=r,this.pipeline.sceneHelpersOnTop=s,this.pipeline.scene=e,this.pipeline.camera=t,n&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==e.postprocessing&&this.pipeline.updatePostprocessing(e.postprocessing),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),e.overrideMaterial=e.wireframeState?Gm:null,this.pipeline.render()}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},FH=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new Mu(e.shared,t),this.scene=new rl(e.scene,this.sharedAssets),this.scene.switchActiveCamera(this.scene.activeCamera)}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof Cr&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},kH=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 jH(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 ah(e){return e instanceof Sh?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function GH(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof nr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof nr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let n=r.material.uuid,a=t.shared.materials[n];if(a){if(!sr.isMergable(a))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!sr.isMergable(l.material))return;n=sr.getHash(l.material)}}i[n]||(i[n]={});let o=i[n][ah(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[n][ah(r)]=[r],r.cloner)for(let l of r.cloner.children)i[n][ah(r)].push(l)}),i}function VH(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 HH(e,t){let i=GH(t,e),r=VH(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 nr&&(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&&jH(a[m]);let g=mo(a.slice(0,o),!1);if(g){let m;switch(d){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),m=new er(g,l[0].material);break}default:{m=new er(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 b of y)b.children&&v(b.children),b instanceof nr&&(Array.isArray(b.material)||i[b.material.uuid]&&i[b.material.uuid][ah(b)]&&i[b.material.uuid][ah(b)].length>1||(u[c++]=b));for(let b=0;b<c;b++)t.attach(u[b])};for(let y=0;y<h;y++){let b=l[y];v(b.children),s[n++]=b}}}for(let d=0;d<n;d++)s[d].removeFromParent()}var WH=Eh(V2(),1),XH=new G;function qH(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 Cv=class{constructor(e,{renderOnDemand:t=!0}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._lastTime=performance.now(),this.time=performance.now(),this.dt=0,this._skipRender=!1,this.renderOnDemand=!0,this.disposed=!1,this.requestRender=()=>{this._skipRender=!1},this.render=i=>{!this._renderer||(this._rafId=requestAnimationFrame(this.render),this.time=i,this.dt=this.time-this._lastTime,this._lastTime=this.time,this._perfs?.start(),!(this.renderOnDemand&&this._skipRender)&&(this._skipRender=this._controls?.update(this.dt)??!0,this._eventManager&&(this._eventManager.isEnable||this._eventManager.activate(),this._eventManager.handlers.Follow.onAnimationFrameDamping(),this._eventManager.handlers.LookAt.onAnimationFrameDamping(),(this._eventManager.handlers.Start.hasVideoAction||this._eventManager.handlers.Basic.hasVideoAction||this._eventManager.handlers.Conditional.hasVideoAction)&&(this._skipRender=!1)),this._scene&&this._camera&&(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.renderSplineScene(this._scene,this._camera,this._sharedAssetsManager)),this._perfs?.end()))},this._resize=g_(()=>{!this._renderer||(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=XH.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera&&(this._frameView?.updateCamera(),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()),this.requestRender())},10),this.canvas=e,this.renderOnDemand=t,window.location.search.includes("perfs")&&(this._perfs=new kH({x:10,y:10})),Jz(e)}async load(e,t){qH(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 rV(e);this._data=i,i.version&&(0,WH.default)(i.version,"0.9.260")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([Kx(i)&&E6(),Uk(i)&&A6(),i.scene.environment.usePhysics&&mz(),Xx(i)&&Mk()].filter(Boolean)),this._eventManager&&this._eventManager.deactivate(),this._controls&&this._controls.dispose(),this._scene?.dispose();let r=new FH(i);if(this._scene=r.scene,this._sharedAssetsManager=r.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let s=performance.now();HH(i,r.scene);let n=performance.now();console.log("Merged geometries in ",n-s," ms")}if(Kx(i)&&this._scene.traverse(s=>{Sn(s)&&s.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this.requestRender(),this._scene?.traverse(s=>{s instanceof $d&&s.pendingMediaLoad&&s.update()})}),Xx(i)&&IG(i)){let s=Object.keys(i.shared.fonts).map(n=>this._sharedAssetsManager.getFont(n)).map(n=>n.loadingPromise);await Promise.all(s)}if(this._scene.rewriteEventsBeforeGoToPlayMode(),YS(i.scene,this._scene,this._sharedAssetsManager),this._renderer||(this._renderer=new UH({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this.requestRender),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=i.scene.environment.ambientLight.softShadows?ig:Jb,M8(i.scene.environment.ambientLight.softShadowQuality)),this._frameView)this._frameView.setCamera(this._camera);else{let s=Object.values(i.frames)[0];s.preset==="fullscreen"?(this._viewportMode=1,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=s.size[0],this._viewportHeight=s.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 nV(this._renderer,this._camera,new G(this._viewportWidth,this._viewportHeight),new G(window.innerWidth,window.innerHeight))}if(t&&(this._scene.updateMatrixWorld(!0),this._controls=new RG(i,this._scene,this._renderer,this.requestRender,this._sharedAssetsManager,!0),this._eventManager=new sV(this._renderer,this._scene,this._camera,i.scene.publish.stopRaycast,i.scene.publish.preventScroll,i.scene.publish.preventTouchScroll,i.scene.publish.hideCursor,this._sharedAssetsManager,this.requestRender,this._controls,!0)),this._resize(),!this._resizeObserver&&this.canvas.parentElement){let s=!0;this._resizeObserver=new ResizeObserver(()=>{if(s){s=!1;return}this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._resize()}),this._resizeObserver.observe(this.canvas.parentElement)}this._rafId===void 0?this.render(performance.now()):this.requestRender()}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)}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 e2&&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 Gi(t,i,r,s);try{n.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.setBackgroundColor(n),this.requestRender()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._rafId&&cancelAnimationFrame(this._rafId),this._proxyObjectCache.forEach(e=>{Ly.unsubscribe(e)}),this._renderer?.dispose(),this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.dispose(),$z(this.canvas)}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={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,emitEvent(r){e.dispatchEvent({type:"userEvent",eventName:r})},emitEventReverse(r){e.dispatchEvent({type:"userEvent",eventName:r,reverse:!0})}},i=Ly(t,(r,s)=>{typeof e[r]!="object"&&Object.getOwnPropertyDescriptor(e,r)?.writable&&(e[r]=s),this.requestRender(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,i),i}};var Iu=window,Ru=Iu.ShadowRoot&&(Iu.ShadyCSS===void 0||Iu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Tv=Symbol(),n2=new WeakMap,Fh=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Tv)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(Ru&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=n2.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&n2.set(i,t))}return t}toString(){return this.cssText}},a2=e=>new Fh(typeof e=="string"?e:e+"",void 0,Tv),Pv=(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 Fh(i,e,Tv)},Dv=(e,t)=>{Ru?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Iu.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},Bu=Ru?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return a2(i)})(e):e;var Ov,Nu=window,o2=Nu.trustedTypes,YH=o2?o2.emptyScript:"",l2=Nu.reactiveElementPolyfillSupport,Iv={toAttribute(e,t){switch(t){case Boolean:e=e?YH: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}},h2=(e,t)=>t!==e&&(t==t||e==e),Lv={attribute:!0,type:String,converter:Iv,reflect:!1,hasChanged:h2},Qs=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=Lv){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)||Lv}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(Bu(s))}else t!==void 0&&i.push(Bu(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 Dv(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=Lv){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:Iv).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:Iv;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||h2)(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){}};Qs.finalized=!0,Qs.elementProperties=new Map,Qs.elementStyles=[],Qs.shadowRootOptions={mode:"open"},l2?.({ReactiveElement:Qs}),((Ov=Nu.reactiveElementVersions)!==null&&Ov!==void 0?Ov:Nu.reactiveElementVersions=[]).push("1.6.0");var Rv,zu=window,al=zu.trustedTypes,c2=al?al.createPolicy("lit-html",{createHTML:e=>e}):void 0,Un=`lit$${(Math.random()+"").slice(9)}$`,v2="?"+Un,QH=`<${v2}>`,ol=document,jh=(e="")=>ol.createComment(e),Gh=e=>e===null||typeof e!="object"&&typeof e!="function",y2=Array.isArray,ZH=e=>y2(e)||typeof e?.[Symbol.iterator]=="function",kh=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,d2=/-->/g,u2=/>/g,Pa=RegExp(`>|[
5213
5213
  \f\r](?:([^\\s"'>=/]+)([
5214
5214
  \f\r]*=[
5215
5215
  \f\r]*(?:[^