@splinetool/viewer 0.9.496 → 0.9.497

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.
@@ -3135,10 +3135,10 @@ void main() {
3135
3135
  squared_mean = squared_mean / samples;
3136
3136
  float std_dev = sqrt( squared_mean - mean * mean );
3137
3137
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3138
- }`;function FO(e,t,i){let r=new Zv,s=new k,a=new k,n=new rt,o=new jS({depthPacking:TS}),l=new NO,h={},d=i.maxTextureSize,c={[fs]:Si,[Si]:fs,[Cr]:Cr},u=new Bt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:kO,fragmentShader:UO}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ue;f.setAttribute("position",new Ke(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new ur(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Hv,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),_=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(ni),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],O=P.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;s.copy(O.mapSize);let B=O.getFrameExtents();if(s.multiply(B),a.copy(O.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(a.x=Math.floor(d/B.x),s.x=a.x*B.x,O.mapSize.x=a.x),s.y>d&&(a.y=Math.floor(d/B.y),s.y=a.y*B.y,O.mapSize.y=a.y)),O.map===null){let F=this.type!==Hh?{minFilter:Rt,magFilter:Rt}:{};O.map=new Ct(s.x,s.y,F),O.map.texture.name=P.name+".shadowMap",O.camera.updateProjectionMatrix()}e.setRenderTarget(O.map),e.clear();let G=O.getViewportCount();for(let F=0;F<G;F++){let z=O.getViewport(F);n.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),C.viewport(n),O.updateMatrices(P,F),r=O.getFrustum(),x(w,A,O.camera,P,this.type)}O.isPointLightShadow!==!0&&this.type===Hh&&v(O,A),O.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(S,_,M)};function v(b,w){let A=t.update(m);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Ct(s.x,s.y)),u.uniforms.shadow_pass.value=b.map.texture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(w,null,A,u,m,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(w,null,A,p,m,null)}function y(b,w,A,S,_,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&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 D=C.uuid,P=w.uuid,O=h[D];O===void 0&&(O={},h[D]=O);let B=O[P];B===void 0&&(B=C.clone(),O[P]=B),C=B}return C.visible=w.visible,C.wireframe=w.wireframe,M===Hh?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 x(b,w,A,S,_){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&_===Hh)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,O=D.length;P<O;P++){let B=D[P],G=T[B.materialIndex];if(G&&G.visible){let F=y(b,G,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,F,b,B)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],w,A,S,_)}}function VO(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new rt,ve=null,_e=new rt(0,0,0,0);return{setMask:function(qe){ve!==qe&&!Y&&(e.colorMask(qe,qe,qe,qe),ve=qe)},setLocked:function(qe){Y=qe},setClear:function(qe,xt,Vt,Oi,_n){_n===!0&&(qe*=Oi,xt*=Oi,Vt*=Oi),ne.set(qe,xt,Vt,Oi),_e.equals(ne)===!1&&(e.clearColor(qe,xt,Vt,Oi),_e.copy(ne))},reset:function(){Y=!1,ve=null,_e.set(-1,0,0,0)}}}function a(){let Y=!1,ne=null,ve=null,_e=null;return{setTest:function(qe){qe?ie(2929):Q(2929)},setMask:function(qe){ne!==qe&&!Y&&(e.depthMask(qe),ne=qe)},setFunc:function(qe){if(ve!==qe){switch(qe){case oT:e.depthFunc(512);break;case lT:e.depthFunc(519);break;case hT:e.depthFunc(513);break;case tg:e.depthFunc(515);break;case cT:e.depthFunc(514);break;case dT:e.depthFunc(518);break;case uT:e.depthFunc(516);break;case pT:e.depthFunc(517);break;default:e.depthFunc(515)}ve=qe}},setLocked:function(qe){Y=qe},setClear:function(qe){_e!==qe&&(e.clearDepth(qe),_e=qe)},reset:function(){Y=!1,ne=null,ve=null,_e=null}}}function n(){let Y=!1,ne=null,ve=null,_e=null,qe=null,xt=null,Vt=null,Oi=null,_n=null;return{setTest:function(Ft){Y||(Ft?ie(2960):Q(2960))},setMask:function(Ft){ne!==Ft&&!Y&&(e.stencilMask(Ft),ne=Ft)},setFunc:function(Ft,Js,Ir){(ve!==Ft||_e!==Js||qe!==Ir)&&(e.stencilFunc(Ft,Js,Ir),ve=Ft,_e=Js,qe=Ir)},setOp:function(Ft,Js,Ir){(xt!==Ft||Vt!==Js||Oi!==Ir)&&(e.stencilOp(Ft,Js,Ir),xt=Ft,Vt=Js,Oi=Ir)},setLocked:function(Ft){Y=Ft},setClear:function(Ft){_n!==Ft&&(e.clearStencil(Ft),_n=Ft)},reset:function(){Y=!1,ne=null,ve=null,_e=null,qe=null,xt=null,Vt=null,Oi=null,_n=null}}}let o=new s,l=new a,h=new n,d=new WeakMap,c=new WeakMap,u={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,D=null,P=null,O=null,B=e.getParameter(35661),G=!1,F=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(z)[1]),G=F>=1):z.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),G=F>=2);let X=null,H={},j=e.getParameter(3088),N=e.getParameter(2978),q=new rt().fromArray(j),V=new rt().fromArray(N);function W(Y,ne,ve){let _e=new Uint8Array(4),qe=e.createTexture();e.bindTexture(Y,qe),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let xt=0;xt<ve;xt++)e.texImage2D(ne+xt,0,6408,1,1,0,6408,5121,_e);return qe}let U={};U[3553]=W(3553,3553,1),U[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(tg),Ee(!1),Ie(Gy),ie(2884),Me(ni);function ie(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function Q(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ve=m,_e=!1;if(Y)if(ve=f.get(ne),ve===void 0&&(ve=[],f.set(ne,ve)),Y.isWebGLMultipleRenderTargets){let qe=Y.texture;if(ve.length!==qe.length||ve[0]!==36064){for(let xt=0,Vt=qe.length;xt<Vt;xt++)ve[xt]=36064+xt;ve.length=qe.length,_e=!0}}else ve[0]!==36064&&(ve[0]=36064,_e=!0);else ve[0]!==1029&&(ve[0]=1029,_e=!0);_e&&(i.isWebGL2?e.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function pe(Y){return g!==Y?(e.useProgram(Y),g=Y,!0):!1}let oe={[Zo]:32774,[ZC]:32778,[KC]:32779};if(r)oe[Xy]=32775,oe[Yy]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(oe[Xy]=Y.MIN_EXT,oe[Yy]=Y.MAX_EXT)}let ae={[JC]:0,[$C]:1,[eT]:768,[bS]:770,[nT]:776,[sT]:774,[iT]:772,[tT]:769,[wS]:771,[aT]:775,[rT]:773};function Me(Y,ne,ve,_e,qe,xt,Vt,Oi){if(Y===ni){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==QC){if(Y!==y||Oi!==M){if((x!==Zo||A!==Zo)&&(e.blendEquation(32774),x=Zo,A=Zo),Oi)switch(Y){case dl:e.blendFuncSeparate(1,771,1,771);break;case Hy:e.blendFunc(1,1);break;case Wy:e.blendFuncSeparate(0,769,0,1);break;case qy:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case dl:e.blendFuncSeparate(770,771,1,771);break;case Hy:e.blendFunc(770,1);break;case Wy:e.blendFuncSeparate(0,769,0,1);break;case qy:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,S=null,_=null,y=Y,M=Oi}return}qe=qe||ne,xt=xt||ve,Vt=Vt||_e,(ne!==x||qe!==A)&&(e.blendEquationSeparate(oe[ne],oe[qe]),x=ne,A=qe),(ve!==b||_e!==w||xt!==S||Vt!==_)&&(e.blendFuncSeparate(ae[ve],ae[_e],ae[xt],ae[Vt]),b=ve,w=_e,S=xt,_=Vt),y=Y,M=!1}function Ae(Y,ne){Y.side===Cr?Q(2884):ie(2884);let ve=Y.side===Si;ne&&(ve=!ve),Ee(ve),Y.blending===dl&&Y.transparent===!1?Me(ni):Me(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let _e=Y.stencilWrite;h.setTest(_e),_e&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ye(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Ee(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Ie(Y){Y!==qC?(ie(2884),Y!==T&&(Y===Gy?e.cullFace(1029):Y===XC?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function be(Y){Y!==D&&(G&&e.lineWidth(Y),D=Y)}function ye(Y,ne,ve){Y?(ie(32823),(P!==ne||O!==ve)&&(e.polygonOffset(ne,ve),P=ne,O=ve)):Q(32823)}function Ne(Y){Y?ie(3089):Q(3089)}function Je(Y){Y===void 0&&(Y=33984+B-1),X!==Y&&(e.activeTexture(Y),X=Y)}function R(Y,ne,ve){ve===void 0&&(X===null?ve=33984+B-1:ve=X);let _e=H[ve];_e===void 0&&(_e={type:void 0,texture:void 0},H[ve]=_e),(_e.type!==Y||_e.texture!==ne)&&(X!==ve&&(e.activeTexture(ve),X=ve),e.bindTexture(Y,ne||U[Y]),_e.type=Y,_e.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function xe(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Be(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ce(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ze(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ze(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ve(Y){V.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),V.copy(Y))}function mt(Y,ne){let ve=c.get(ne);ve===void 0&&(ve=new WeakMap,c.set(ne,ve));let _e=ve.get(Y);_e===void 0&&(_e=e.getUniformBlockIndex(ne,Y.name),ve.set(Y,_e))}function zt(Y,ne){let ve=c.get(ne).get(Y);d.get(ne)!==ve&&(e.uniformBlockBinding(ne,ve,Y.__bindingPointIndex),d.set(ne,ve))}function ti(){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),u={},X=null,H={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,D=null,P=null,O=null,q.set(0,0,e.canvas.width,e.canvas.height),V.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:pe,setBlending:Me,setMaterial:Ae,setFlipSided:Ee,setCullFace:Ie,setLineWidth:be,setPolygonOffset:ye,setScissorTest:Ne,activeTexture:Je,bindTexture:R,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:ge,texImage2D:ze,texImage3D:Le,updateUBOMapping:mt,uniformBlockBinding:zt,texStorage2D:ue,texStorage3D:Oe,texSubImage2D:de,texSubImage3D:xe,compressedTexSubImage2D:Be,compressedTexSubImage3D:Ce,scissor:Ze,viewport:Ve,reset:ti}}function jO(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,d=s.maxTextureSize,c=s.maxSamples,u=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,m,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):Tu("canvas")}function x(R,I,$,ge){let de=1;if((R.width>ge||R.height>ge)&&(de=ge/Math.max(R.width,R.height)),de<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let xe=I?Cu:Math.floor,Be=xe(de*R.width),Ce=xe(de*R.height);m===void 0&&(m=y(Be,Ce));let ue=$?y(Be,Ce):m;return ue.width=Be,ue.height=Ce,ue.getContext("2d").drawImage(R,0,0,Be,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Be+"x"+Ce+")."),ue}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return og(R.width)&&og(R.height)}function w(R){return o?!1:R.wrapS!==Kt||R.wrapT!==Kt||R.minFilter!==Rt&&R.minFilter!==ot}function A(R,I){return R.generateMipmaps&&I&&R.minFilter!==Rt&&R.minFilter!==ot}function S(R){e.generateMipmap(R)}function _(R,I,$,ge,de=!1){if(o===!1)return I;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let xe=I;return I===6403&&($===5126&&(xe=33326),$===5131&&(xe=33325),$===5121&&(xe=33321)),I===33319&&($===5126&&(xe=33328),$===5131&&(xe=33327),$===5121&&(xe=33323)),I===6408&&($===5126&&(xe=34836),$===5131&&(xe=34842),$===5121&&(xe=ge===tt&&de===!1?35907:32856),$===32819&&(xe=32854),$===32820&&(xe=32855)),(xe===33325||xe===33326||xe===33327||xe===33328||xe===34842||xe===34836)&&t.get("EXT_color_buffer_float"),xe}function M(R,I,$){return A(R,$)===!0||R.isFramebufferTexture&&R.minFilter!==Rt&&R.minFilter!==ot?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function C(R){return R===Rt||R===Qy||R===rf?9728:9729}function T(R){let I=R.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function P(R){let I=r.get(R);if(I.__webglInit===void 0)return;let $=R.source,ge=g.get($);if(ge){let de=ge[I.__cacheKey];de.usedTimes--,de.usedTimes===0&&O(R),Object.keys(ge).length===0&&g.delete($)}r.remove(R)}function O(R){let I=r.get(R);e.deleteTexture(I.__webglTexture);let $=R.source,ge=g.get($);delete ge[I.__cacheKey],n.memory.textures--}function B(R){let I=R.texture,$=r.get(R),ge=r.get(I);if(ge.__webglTexture!==void 0&&(e.deleteTexture(ge.__webglTexture),n.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)e.deleteFramebuffer($.__webglFramebuffer[de]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[de]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let de=0;de<$.__webglColorRenderbuffer.length;de++)$.__webglColorRenderbuffer[de]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[de]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let de=0,xe=I.length;de<xe;de++){let Be=r.get(I[de]);Be.__webglTexture&&(e.deleteTexture(Be.__webglTexture),n.memory.textures--),r.remove(I[de])}r.remove(I),r.remove(R)}let G=0;function F(){G=0}function z(){let R=G;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),G+=1,R}function X(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function H(R,I){let $=r.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){let ge=R.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,R,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function j(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function N(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){re($,R,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let V={[ba]:10497,[Kt]:33071,[sg]:33648},W={[Rt]:9728,[Qy]:9984,[rf]:9986,[ot]:9729,[wT]:9985,[Cl]:9987};function U(R,I,$){if($?(e.texParameteri(R,10242,V[I.wrapS]),e.texParameteri(R,10243,V[I.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,V[I.wrapR]),e.texParameteri(R,10240,W[I.magFilter]),e.texParameteri(R,10241,W[I.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(I.wrapS!==Kt||I.wrapT!==Kt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(I.magFilter)),e.texParameteri(R,10241,C(I.minFilter)),I.minFilter!==Rt&&I.minFilter!==ot&&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 ge=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Rt||I.minFilter!==rf&&I.minFilter!==Cl||I.type===Tr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===Tl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(R,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(R,I){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",T));let ge=I.source,de=g.get(ge);de===void 0&&(de={},g.set(ge,de));let xe=X(I);if(xe!==R.__cacheKey){de[xe]===void 0&&(de[xe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,$=!0),de[xe].usedTimes++;let Be=de[R.__cacheKey];Be!==void 0&&(de[R.__cacheKey].usedTimes--,Be.usedTimes===0&&O(I)),R.__cacheKey=xe,R.__webglTexture=de[xe].texture}return $}function Q(R,I,$){let ge=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ge=35866),I.isData3DTexture&&(ge=32879);let de=ie(R,I),xe=I.source;i.bindTexture(ge,R.__webglTexture,33984+$);let Be=r.get(xe);if(xe.version!==Be.__version||de===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ce=w(I)&&b(I.image)===!1,ue=x(I.image,Ce,!1,d);ue=Je(I,ue);let Oe=b(ue)||o,ze=a.convert(I.format,I.encoding),Le=a.convert(I.type),Ze=_(I.internalFormat,ze,Le,I.encoding,I.isVideoTexture);U(ge,I,Oe);let Ve,mt=I.mipmaps,zt=o&&I.isVideoTexture!==!0,ti=Be.__version===void 0||de===!0,Y=M(I,ue,Oe);if(I.isDepthTexture)Ze=6402,o?I.type===Tr?Ze=36012:I.type===Ka?Ze=33190:I.type===Yn?Ze=35056:Ze=33189:I.type===Tr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Qn&&Ze===6402&&I.type!==AS&&I.type!==Ka&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Ka,Le=a.convert(I.type)),I.format===ro&&Ze===6402&&(Ze=34041,I.type!==Yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Yn,Le=a.convert(I.type))),ti&&(zt?i.texStorage2D(3553,1,Ze,ue.width,ue.height):i.texImage2D(3553,0,Ze,ue.width,ue.height,0,ze,Le,null));else if(I.isDataTexture)if(mt.length>0&&Oe){zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],zt?i.texSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Le,Ve.data):i.texImage2D(3553,ne,Ze,Ve.width,Ve.height,0,ze,Le,Ve.data);I.generateMipmaps=!1}else zt?(ti&&i.texStorage2D(3553,Y,Ze,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Le,ue.data)):i.texImage2D(3553,0,Ze,ue.width,ue.height,0,ze,Le,ue.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){zt&&ti&&i.texStorage3D(35866,Y,Ze,mt[0].width,mt[0].height,ue.depth);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],I.format!==jr?ze!==null?zt?i.compressedTexSubImage3D(35866,ne,0,0,0,Ve.width,Ve.height,ue.depth,ze,Ve.data,0,0):i.compressedTexImage3D(35866,ne,Ze,Ve.width,Ve.height,ue.depth,0,Ve.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?i.texSubImage3D(35866,ne,0,0,0,Ve.width,Ve.height,ue.depth,ze,Le,Ve.data):i.texImage3D(35866,ne,Ze,Ve.width,Ve.height,ue.depth,0,ze,Le,Ve.data)}else{zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],I.format!==jr?ze!==null?zt?i.compressedTexSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Ve.data):i.compressedTexImage2D(3553,ne,Ze,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?i.texSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Le,Ve.data):i.texImage2D(3553,ne,Ze,Ve.width,Ve.height,0,ze,Le,Ve.data)}else if(I.isDataArrayTexture)zt?(ti&&i.texStorage3D(35866,Y,Ze,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):i.texImage3D(35866,0,Ze,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isData3DTexture)zt?(ti&&i.texStorage3D(32879,Y,Ze,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):i.texImage3D(32879,0,Ze,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isFramebufferTexture){if(ti)if(zt)i.texStorage2D(3553,Y,Ze,ue.width,ue.height);else{let ne=ue.width,ve=ue.height;for(let _e=0;_e<Y;_e++)i.texImage2D(3553,_e,Ze,ne,ve,0,ze,Le,null),ne>>=1,ve>>=1}}else if(mt.length>0&&Oe){zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],zt?i.texSubImage2D(3553,ne,0,0,ze,Le,Ve):i.texImage2D(3553,ne,Ze,ze,Le,Ve);I.generateMipmaps=!1}else zt?(ti&&i.texStorage2D(3553,Y,Ze,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Le,ue)):i.texImage2D(3553,0,Ze,ze,Le,ue);A(I,Oe)&&S(ge),Be.__version=xe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function re(R,I,$){if(I.image.length!==6)return;let ge=ie(R,I),de=I.source;i.bindTexture(34067,R.__webglTexture,33984+$);let xe=r.get(de);if(de.version!==xe.__version||ge===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Be=I.isCompressedTexture||I.image[0].isCompressedTexture,Ce=I.image[0]&&I.image[0].isDataTexture,ue=[];for(let ne=0;ne<6;ne++)!Be&&!Ce?ue[ne]=x(I.image[ne],!1,!0,h):ue[ne]=Ce?I.image[ne].image:I.image[ne],ue[ne]=Je(I,ue[ne]);let Oe=ue[0],ze=b(Oe)||o,Le=a.convert(I.format,I.encoding),Ze=a.convert(I.type),Ve=_(I.internalFormat,Le,Ze,I.encoding),mt=o&&I.isVideoTexture!==!0,zt=xe.__version===void 0||ge===!0,ti=M(I,Oe,ze);U(34067,I,ze);let Y;if(Be){mt&&zt&&i.texStorage2D(34067,ti,Ve,Oe.width,Oe.height);for(let ne=0;ne<6;ne++){Y=ue[ne].mipmaps;for(let ve=0;ve<Y.length;ve++){let _e=Y[ve];I.format!==jr?Le!==null?mt?i.compressedTexSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Le,_e.data):i.compressedTexImage2D(34069+ne,ve,Ve,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):mt?i.texSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Le,Ze,_e.data):i.texImage2D(34069+ne,ve,Ve,_e.width,_e.height,0,Le,Ze,_e.data)}}}else{Y=I.mipmaps,mt&&zt&&(Y.length>0&&ti++,i.texStorage2D(34067,ti,Ve,ue[0].width,ue[0].height));for(let ne=0;ne<6;ne++)if(Ce){mt?i.texSubImage2D(34069+ne,0,0,0,ue[ne].width,ue[ne].height,Le,Ze,ue[ne].data):i.texImage2D(34069+ne,0,Ve,ue[ne].width,ue[ne].height,0,Le,Ze,ue[ne].data);for(let ve=0;ve<Y.length;ve++){let _e=Y[ve].image[ne].image;mt?i.texSubImage2D(34069+ne,ve+1,0,0,_e.width,_e.height,Le,Ze,_e.data):i.texImage2D(34069+ne,ve+1,Ve,_e.width,_e.height,0,Le,Ze,_e.data)}}else{mt?i.texSubImage2D(34069+ne,0,0,0,Le,Ze,ue[ne]):i.texImage2D(34069+ne,0,Ve,Le,Ze,ue[ne]);for(let ve=0;ve<Y.length;ve++){let _e=Y[ve];mt?i.texSubImage2D(34069+ne,ve+1,0,0,Le,Ze,_e.image[ne]):i.texImage2D(34069+ne,ve+1,Ve,Le,Ze,_e.image[ne])}}}A(I,ze)&&S(34067),xe.__version=de.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,$,ge,de){let xe=a.convert($.format,$.encoding),Be=a.convert($.type),Ce=_($.internalFormat,xe,Be,$.encoding);r.get(I).__hasExternalTextures||(de===32879||de===35866?i.texImage3D(de,0,Ce,I.width,I.height,I.depth,0,xe,Be,null):i.texImage2D(de,0,Ce,I.width,I.height,0,xe,Be,null)),i.bindFramebuffer(36160,R),ye(I)?u.framebufferTexture2DMultisampleEXT(36160,ge,de,r.get($).__webglTexture,0,be(I)):(de===3553||de>=34069&&de<=34074)&&e.framebufferTexture2D(36160,ge,de,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function pe(R,I,$){if(e.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let ge=33189;if($||ye(I)){let de=I.depthTexture;de&&de.isDepthTexture&&(de.type===Tr?ge=36012:de.type===Ka&&(ge=33190));let xe=be(I);ye(I)?u.renderbufferStorageMultisampleEXT(36161,xe,ge,I.width,I.height):e.renderbufferStorageMultisample(36161,xe,ge,I.width,I.height)}else e.renderbufferStorage(36161,ge,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let ge=be(I);$&&ye(I)===!1?e.renderbufferStorageMultisample(36161,ge,35056,I.width,I.height):ye(I)?u.renderbufferStorageMultisampleEXT(36161,ge,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let ge=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let de=0;de<ge.length;de++){let xe=ge[de],Be=a.convert(xe.format,xe.encoding),Ce=a.convert(xe.type),ue=_(xe.internalFormat,Be,Ce,xe.encoding),Oe=be(I);$&&ye(I)===!1?e.renderbufferStorageMultisample(36161,Oe,ue,I.width,I.height):ye(I)?u.renderbufferStorageMultisampleEXT(36161,Oe,ue,I.width,I.height):e.renderbufferStorage(36161,ue,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function oe(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,ge=be(I);if(I.depthTexture.format===Qn)ye(I)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,ge):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===ro)ye(I)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,ge):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function ae(R){let I=r.get(R),$=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");oe(I.__webglFramebuffer,R)}else if($){I.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)i.bindFramebuffer(36160,I.__webglFramebuffer[ge]),I.__webglDepthbuffer[ge]=e.createRenderbuffer(),pe(I.__webglDepthbuffer[ge],R,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),pe(I.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function Me(R,I,$){let ge=r.get(R);I!==void 0&&Z(ge.__webglFramebuffer,R,R.texture,36064,3553),$!==void 0&&ae(R)}function Ae(R){let I=R.texture,$=r.get(R),ge=r.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=e.createTexture()),ge.__version=I.version,n.memory.textures++);let de=R.isWebGLCubeRenderTarget===!0,xe=R.isWebGLMultipleRenderTargets===!0,Be=b(R)||o;if(de){$.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)$.__webglFramebuffer[Ce]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),xe)if(s.drawBuffers){let Ce=R.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=r.get(Ce[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&ye(R)===!1){let Ce=xe?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let ue=0;ue<Ce.length;ue++){let Oe=Ce[ue];$.__webglColorRenderbuffer[ue]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[ue]);let ze=a.convert(Oe.format,Oe.encoding),Le=a.convert(Oe.type),Ze=_(Oe.internalFormat,ze,Le,Oe.encoding,R.isXRRenderTarget===!0),Ve=be(R);e.renderbufferStorageMultisample(36161,Ve,Ze,R.width,R.height),e.framebufferRenderbuffer(36160,36064+ue,36161,$.__webglColorRenderbuffer[ue])}e.bindRenderbuffer(36161,null),R.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),pe($.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(de){i.bindTexture(34067,ge.__webglTexture),U(34067,I,Be);for(let Ce=0;Ce<6;Ce++)Z($.__webglFramebuffer[Ce],R,I,36064,34069+Ce);A(I,Be)&&S(34067),i.unbindTexture()}else if(xe){let Ce=R.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=Ce[ue],Le=r.get(ze);i.bindTexture(3553,Le.__webglTexture),U(3553,ze,Be),Z($.__webglFramebuffer,R,ze,36064+ue,3553),A(ze,Be)&&S(3553)}i.unbindTexture()}else{let Ce=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Ce=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ce,ge.__webglTexture),U(Ce,I,Be),Z($.__webglFramebuffer,R,I,36064,Ce),A(I,Be)&&S(Ce),i.unbindTexture()}R.depthBuffer&&ae(R)}function Ee(R){let I=b(R)||o,$=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ge=0,de=$.length;ge<de;ge++){let xe=$[ge];if(A(xe,I)){let Be=R.isWebGLCubeRenderTarget?34067:3553,Ce=r.get(xe).__webglTexture;i.bindTexture(Be,Ce),S(Be),i.unbindTexture()}}}function Ie(R){if(o&&R.samples>0&&ye(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],$=R.width,ge=R.height,de=16384,xe=[],Be=R.stencilBuffer?33306:36096,Ce=r.get(R),ue=R.isWebGLMultipleRenderTargets===!0;if(ue)for(let Oe=0;Oe<I.length;Oe++)i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,null),i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,null,0);i.bindFramebuffer(36008,Ce.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ce.__webglFramebuffer);for(let Oe=0;Oe<I.length;Oe++){xe.push(36064+Oe),R.depthBuffer&&xe.push(Be);let ze=Ce.__ignoreDepthValues!==void 0?Ce.__ignoreDepthValues:!1;if(ze===!1&&(R.depthBuffer&&(de|=256),R.stencilBuffer&&(de|=1024)),ue&&e.framebufferRenderbuffer(36008,36064,36161,Ce.__webglColorRenderbuffer[Oe]),ze===!0&&(e.invalidateFramebuffer(36008,[Be]),e.invalidateFramebuffer(36009,[Be])),ue){let Le=r.get(I[Oe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Le,0)}e.blitFramebuffer(0,0,$,ge,0,0,$,ge,de,9728),p&&e.invalidateFramebuffer(36008,xe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ue)for(let Oe=0;Oe<I.length;Oe++){i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,Ce.__webglColorRenderbuffer[Oe]);let ze=r.get(I[Oe]).__webglTexture;i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,ze,0)}i.bindFramebuffer(36009,Ce.__webglMultisampledFramebuffer)}}function be(R){return Math.min(c,R.samples)}function ye(R){let I=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ne(R){let I=n.render.frame;f.get(R)!==I&&(f.set(R,I),R.update())}function Je(R,I){let $=R.encoding,ge=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===ng||$!==Gs&&($===tt?o===!1?t.has("EXT_sRGB")===!0&&ge===jr?(R.format=ng,R.minFilter=ot,R.generateMipmaps=!1):I=OS.sRGBToLinear(I):(ge!==jr||de!==ji)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=j,this.setTexture3D=N,this.setTextureCube=q,this.rebindTextures=Me,this.setupRenderTarget=Ae,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ye}function GO(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===ji)return 5121;if(a===MT)return 32819;if(a===ET)return 32820;if(a===_T)return 5120;if(a===ST)return 5122;if(a===AS)return 5123;if(a===AT)return 5124;if(a===Ka)return 5125;if(a===Tr)return 5126;if(a===Tl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===CT)return 6406;if(a===jr)return 6408;if(a===TT)return 6409;if(a===PT)return 6410;if(a===Qn)return 6402;if(a===ro)return 34041;if(a===ng)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===DT)return 6403;if(a===IT)return 36244;if(a===MS)return 33319;if(a===OT)return 33320;if(a===LT)return 36249;if(a===sf||a===af||a===nf||a===of)if(n===tt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===sf)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===af)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===nf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===of)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===sf)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===af)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===nf)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===of)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Zy||a===Ky||a===Jy||a===$y)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Zy)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Ky)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Jy)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===$y)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===RT)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===e1||a===t1)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===e1)return n===tt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===t1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===i1||a===r1||a===s1||a===a1||a===n1||a===o1||a===l1||a===h1||a===c1||a===d1||a===u1||a===p1||a===f1||a===m1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===i1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===r1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===s1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===a1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===n1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===o1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===l1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===h1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===c1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===d1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===u1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===p1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===f1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===m1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===lf)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===lf)return n===tt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===BT||a===g1||a===v1||a===y1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===lf)return o.COMPRESSED_RED_RGTC1_EXT;if(a===g1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===v1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===y1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Yn?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var HO=class extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},al=class extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}},WO={type:"move"},Rf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new al,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 al,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 al,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,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],c=h.position.distanceTo(d.position),u=.02,p=.005;l.inputState.pinching&&c>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=u-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));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(WO)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new al;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Dl=class extends fi{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:Qn,h!==Qn&&h!==ro)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Qn&&(i=Ka),i===void 0&&h===ro&&(i=Yn),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:Rt,this.minFilter=o!==void 0?o:Rt,this.flipY=!1,this.generateMipmaps=!1}},qO=class extends Ii{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,d=null,c=null,u=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,b=new Map,w=new zi;w.layers.enable(1),w.viewport=new rt;let A=new zi;A.layers.enable(2),A.viewport=new rt;let S=[w,A],_=new HO;_.layers.enable(1),_.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getTargetRaySpace()},this.getControllerGrip=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getGripSpace()},this.getHand=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getHandSpace()};function T(j){let N=y.indexOf(j.inputSource);if(N===-1)return;let q=v[N];q!==void 0&&q.dispatchEvent({type:j.type,data:j.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",P);for(let j=0;j<v.length;j++){let N=y[j];N!==null&&(y[j]=null,v[j].disconnect(N))}M=null,C=null,e.setRenderTarget(m),u=null,c=null,d=null,r=null,g=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){n=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},this.getBaseLayer=function(){return c!==null?c:u},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(j){if(r=j,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let N={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,N),r.updateRenderState({baseLayer:u}),g=new Ct(u.framebufferWidth,u.framebufferHeight,{format:jr,type:ji,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let N=null,q=null,V=null;f.depth&&(V=f.stencil?35056:33190,N=f.stencil?ro:Qn,q=f.stencil?Yn:Ka);let W={colorFormat:32856,depthFormat:V,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(W),r.updateRenderState({layers:[c]}),g=new Ct(c.textureWidth,c.textureHeight,{format:jr,type:ji,depthTexture:new Dl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,N),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(g);U.__ignoreDepthValues=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(j){for(let N=0;N<j.removed.length;N++){let q=j.removed[N],V=y.indexOf(q);V>=0&&(y[V]=null,v[V].disconnect(q))}for(let N=0;N<j.added.length;N++){let q=j.added[N],V=y.indexOf(q);if(V===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(q),V=U;break}else if(y[U]===null){y[U]=q,V=U;break}if(V===-1)break}let W=v[V];W&&W.connect(q)}}let O=new E,B=new E;function G(j,N,q){O.setFromMatrixPosition(N.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let V=O.distanceTo(B),W=N.projectionMatrix.elements,U=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],pe=(W[8]-1)/W[0],oe=(U[8]+1)/U[0],ae=ie*pe,Me=ie*oe,Ae=V/(-pe+oe),Ee=Ae*-pe;N.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ee),j.translateZ(Ae),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let Ie=ie+Ae,be=Q+Ae,ye=ae-Ee,Ne=Me+(V-Ee),Je=re*Q/be*Ie,R=Z*Q/be*Ie;j.projectionMatrix.makePerspective(ye,Ne,Je,R,Ie,be)}function F(j,N){N===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(N.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;_.near=A.near=w.near=j.near,_.far=A.far=w.far=j.far,(M!==_.near||C!==_.far)&&(r.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,C=_.far);let N=j.parent,q=_.cameras;F(_,N);for(let W=0;W<q.length;W++)F(q[W],N);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),j.matrix.copy(_.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale);let V=j.children;for(let W=0,U=V.length;W<U;W++)V[W].updateMatrixWorld(!0);q.length===2?G(_,w,A):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(j){o=j,c!==null&&(c.fixedFoveation=j),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=j)},this.getPlanes=function(){return x};let z=null;function X(j,N){if(h=N.getViewerPose(l||a),p=N,h!==null){let q=h.views;u!==null&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let V=!1;q.length!==_.cameras.length&&(_.cameras.length=0,V=!0);for(let W=0;W<q.length;W++){let U=q[W],ie=null;if(u!==null)ie=u.getViewport(U);else{let re=d.getViewSubImage(c,U);ie=re.viewport,W===0&&(e.setRenderTargetTextures(g,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(g))}let Q=S[W];Q===void 0&&(Q=new zi,Q.layers.enable(W),Q.viewport=new rt,S[W]=Q),Q.matrix.fromArray(U.transform.matrix),Q.projectionMatrix.fromArray(U.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&_.matrix.copy(Q.matrix),V===!0&&_.cameras.push(Q)}}for(let q=0;q<v.length;q++){let V=y[q],W=v[q];V!==null&&W!==void 0&&W.update(V,N,l||a)}if(z&&z(j,N),N.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:N.detectedPlanes});let q=null;for(let V of x)N.detectedPlanes.has(V)||(q===null&&(q=[]),q.push(V));if(q!==null)for(let V of q)x.delete(V),b.delete(V),i.dispatchEvent({type:"planeremoved",data:V});for(let V of N.detectedPlanes)if(!x.has(V))x.add(V),b.set(V,N.lastChangedTime),i.dispatchEvent({type:"planeadded",data:V});else{let W=b.get(V);V.lastChangedTime>W&&(b.set(V,V.lastChangedTime),i.dispatchEvent({type:"planechanged",data:V}))}}p=null}let H=new NS;H.setAnimationLoop(X),this.setAnimationLoop=function(j){z=j},this.dispose=function(){}}};function XO(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,zS(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,v,y,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(m,g):g.isMeshToonMaterial?(s(m,g),d(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g)):g.isMeshStandardMaterial?(s(m,g),c(m,g),g.isMeshPhysicalMaterial&&u(m,g,x)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),f(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,v,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===Si&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===Si&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v=t.get(g).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,v,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix))}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function c(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function u(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Si&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function YO(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=d(y),s[y.id]=b,y.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(y,w);let A=t.render.frame;a[y.id]!==A&&(u(y),a[y.id]=A)}function d(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(n.indexOf(y)===-1)return n.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],b=y.uniforms,w=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let _=b[A];if(p(_,A,w)===!0){let M=_.__offset,C=Array.isArray(_.value)?_.value:[_.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],O=m(P);typeof P=="number"?(_.__data[0]=P,e.bufferSubData(35345,M+T,_.__data)):P.isMatrix3?(_.__data[0]=P.elements[0],_.__data[1]=P.elements[1],_.__data[2]=P.elements[2],_.__data[3]=P.elements[0],_.__data[4]=P.elements[3],_.__data[5]=P.elements[4],_.__data[6]=P.elements[5],_.__data[7]=P.elements[0],_.__data[8]=P.elements[6],_.__data[9]=P.elements[7],_.__data[10]=P.elements[8],_.__data[11]=P.elements[0]):(P.toArray(_.__data,T),T+=O.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,_.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let w=y.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let A=Array.isArray(w)?w:[w],S=[];for(let _=0;_<A.length;_++)S.push(A[_].clone());b[x]=S}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],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 x=y.uniforms,b=0,w=16,A=0;for(let S=0,_=x.length;S<_;S++){let M=x[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let O=T[D],B=m(O);C.boundary+=B.boundary,C.storage+=B.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,S>0){A=b%w;let D=w-A;A!==0&&D-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),y.__size=b,y.__cache={},this}function m(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function g(y){let x=y.target;x.removeEventListener("dispose",g);let b=n.indexOf(x.__bindingPointIndex);n.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function QO(){let e=Tu("canvas");return e.style.display="block",e}function GS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:QO(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=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,d;i!==null?d=i.getContextAttributes().alpha:d=e.alpha!==void 0?e.alpha:!1;let c=null,u=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=Gs,this.physicallyCorrectLights=!1,this.toneMapping=_a,this.toneMappingExposure=1;let m=this,g=!1,v=0,y=0,x=null,b=-1,w=null,A=new rt,S=new rt,_=null,M=t.width,C=t.height,T=1,D=null,P=null,O=new rt(0,0,M,C),B=new rt(0,0,M,C),G=!1,F=new Zv,z=!1,X=!1,H=null,j=new me,N=new k,q=new E,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let U=i;function ie(L,ee){for(let le=0;le<L.length;le++){let J=L[le],he=t.getContext(J,ee);if(he!==null)return he}return null}try{let L={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Hl}`),t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",Ve,!1),t.addEventListener("webglcontextcreationerror",mt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),U=ie(ee,L),U===null)throw ie(ee)?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(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Q,re,Z,pe,oe,ae,Me,Ae,Ee,Ie,be,ye,Ne,Je,R,I,$,ge,de,xe,Be,Ce,ue,Oe;function ze(){Q=new lI(U),re=new iI(U,Q,e),Q.init(re),Ce=new GO(U,Q,re),Z=new VO(U,Q,re),pe=new dI,oe=new TO,ae=new jO(U,Q,Z,oe,re,Ce,pe),Me=new sI(m),Ae=new oI(m),Ee=new b3(U,re),ue=new eI(U,Q,Ee,re),Ie=new hI(U,Ee,pe,ue),be=new mI(U,Ie,Ee,pe),de=new fI(U,re,ae),I=new rI(oe),ye=new CO(m,Me,Ae,Q,re,ue,I),Ne=new XO(m,oe),Je=new DO,R=new zO(Q,re),ge=new $D(m,Me,Ae,Z,be,d,n),$=new FO(m,be,re),Oe=new YO(U,pe,re,Z),xe=new tI(U,Q,pe,re),Be=new cI(U,Q,pe,re),pe.programs=ye.programs,m.capabilities=re,m.extensions=Q,m.properties=oe,m.renderLists=Je,m.shadowMap=$,m.state=Z,m.info=pe}ze();let Le=new qO(m,U);this.xr=Le,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let L=Q.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=Q.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(L){L!==void 0&&(T=L,this.setSize(M,C,!1))},this.getSize=function(L){return L.set(M,C)},this.setSize=function(L,ee,le){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=L,C=ee,t.width=Math.floor(L*T),t.height=Math.floor(ee*T),le!==!1&&(t.style.width=L+"px",t.style.height=ee+"px"),this.setViewport(0,0,L,ee)},this.getDrawingBufferSize=function(L){return L.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(L,ee,le){M=L,C=ee,T=le,t.width=Math.floor(L*le),t.height=Math.floor(ee*le),this.setViewport(0,0,L,ee)},this.getCurrentViewport=function(L){return L.copy(A)},this.getViewport=function(L){return L.copy(O)},this.setViewport=function(L,ee,le,J){L.isVector4?O.set(L.x,L.y,L.z,L.w):O.set(L,ee,le,J),Z.viewport(A.copy(O).multiplyScalar(T).floor())},this.getScissor=function(L){return L.copy(B)},this.setScissor=function(L,ee,le,J){L.isVector4?B.set(L.x,L.y,L.z,L.w):B.set(L,ee,le,J),Z.scissor(S.copy(B).multiplyScalar(T).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(L){Z.setScissorTest(G=L)},this.setOpaqueSort=function(L){D=L},this.setTransparentSort=function(L){P=L},this.getClearColor=function(L){return L.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(L=!0,ee=!0,le=!0){let J=0;L&&(J|=16384),ee&&(J|=256),le&&(J|=1024),U.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",Ve,!1),t.removeEventListener("webglcontextcreationerror",mt,!1),Je.dispose(),R.dispose(),oe.dispose(),Me.dispose(),Ae.dispose(),be.dispose(),ue.dispose(),Oe.dispose(),ye.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",_e),Le.removeEventListener("sessionend",qe),H&&(H.dispose(),H=null),xt.stop()};function Ze(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ve(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=pe.autoReset,ee=$.enabled,le=$.autoUpdate,J=$.needsUpdate,he=$.type;ze(),pe.autoReset=L,$.enabled=ee,$.autoUpdate=le,$.needsUpdate=J,$.type=he}function mt(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function zt(L){let ee=L.target;ee.removeEventListener("dispose",zt),ti(ee)}function ti(L){Y(L),oe.remove(L)}function Y(L){let ee=oe.get(L).programs;ee!==void 0&&(ee.forEach(function(le){ye.releaseProgram(le)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,ee,le,J,he,ke){ee===null&&(ee=V);let at=he.isMesh&&he.matrixWorld.determinant()<0,ht=_C(L,ee,le,J,he);Z.setMaterial(J,at);let dt=le.index,Ot=1;J.wireframe===!0&&(dt=Ie.getWireframeAttribute(le),Ot=2);let bt=le.drawRange,gt=le.attributes.position,Li=bt.start*Ot,br=(bt.start+bt.count)*Ot;ke!==null&&(Li=Math.max(Li,ke.start*Ot),br=Math.min(br,(ke.start+ke.count)*Ot)),dt!==null?(Li=Math.max(Li,0),br=Math.min(br,dt.count)):gt!=null&&(Li=Math.max(Li,0),br=Math.min(br,gt.count));let $s=br-Li;if($s<0||$s===1/0)return;ue.setup(he,J,ht,le,dt);let Sn,ii=xe;if(dt!==null&&(Sn=Ee.get(dt),ii=Be,ii.setIndex(Sn)),he.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),ii.setMode(1)):ii.setMode(4);else if(he.isLine){let vt=J.linewidth;vt===void 0&&(vt=1),Z.setLineWidth(vt*W()),he.isLineSegments?ii.setMode(1):he.isLineLoop?ii.setMode(2):ii.setMode(3)}else he.isPoints?ii.setMode(0):he.isSprite&&ii.setMode(4);if(he.isInstancedMesh)ii.renderInstances(Li,$s,he.count);else if(le.isInstancedBufferGeometry){let vt=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,Kp=Math.min(le.instanceCount,vt);ii.renderInstances(Li,$s,Kp)}else ii.render(Li,$s)},this.compile=function(L,ee){function le(J,he,ke){J.transparent===!0&&J.side===Cr&&J.forceSinglePass===!1?(J.side=Si,J.needsUpdate=!0,Ir(J,he,ke),J.side=fs,J.needsUpdate=!0,Ir(J,he,ke),J.side=Cr):Ir(J,he,ke)}u=R.get(L),u.init(),f.push(u),L.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(m.physicallyCorrectLights),L.traverse(function(J){let he=J.material;if(he)if(Array.isArray(he))for(let ke=0;ke<he.length;ke++){let at=he[ke];le(at,L,J)}else le(he,L,J)}),f.pop(),u=null};let ne=null;function ve(L){ne&&ne(L)}function _e(){xt.stop()}function qe(){xt.start()}let xt=new NS;xt.setAnimationLoop(ve),typeof self<"u"&&xt.setContext(self),this.setAnimationLoop=function(L){ne=L,Le.setAnimationLoop(L),L===null?xt.stop():xt.start()},Le.addEventListener("sessionstart",_e),Le.addEventListener("sessionend",qe),this.render=function(L,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(ee),ee=Le.getCamera()),L.isScene===!0&&L.onBeforeRender(m,L,ee,x),u=R.get(L,f.length),u.init(),f.push(u),j.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),F.setFromProjectionMatrix(j),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Je.get(L,p.length),c.init(),p.push(c),Vt(L,ee,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let le=u.state.shadowsArray;if($.render(le,L,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(c,L),u.setupLights(m.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let he=0,ke=J.length;he<ke;he++){let at=J[he];Oi(c,L,at,at.viewport)}}else Oi(c,L,ee);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),L.isScene===!0&&L.onAfterRender(m,L,ee),ue.resetDefaultState(),b=-1,w=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Vt(L,ee,le,J){if(L.visible===!1)return;if(L.layers.test(ee.layers)){if(L.isGroup)le=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(ee);else if(L.isLight)u.pushLight(L),L.castShadow&&u.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||F.intersectsSprite(L)){J&&q.setFromMatrixPosition(L.matrixWorld).applyMatrix4(j);let ke=be.update(L),at=L.material;at.visible&&c.push(L,ke,at,le,q.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==pe.render.frame&&(L.skeleton.update(),L.skeleton.frame=pe.render.frame),!L.frustumCulled||F.intersectsObject(L))){J&&q.setFromMatrixPosition(L.matrixWorld).applyMatrix4(j);let ke=be.update(L),at=L.material;if(Array.isArray(at)){let ht=ke.groups;for(let dt=0,Ot=ht.length;dt<Ot;dt++){let bt=ht[dt],gt=at[bt.materialIndex];gt&&gt.visible&&c.push(L,ke,gt,le,q.z,bt)}}else at.visible&&c.push(L,ke,at,le,q.z,null)}}let he=L.children;for(let ke=0,at=he.length;ke<at;ke++)Vt(he[ke],ee,le,J)}function Oi(L,ee,le,J){let he=L.opaque,ke=L.transmissive,at=L.transparent;u.setupLightsView(le),z===!0&&I.setGlobalState(m.clippingPlanes,le),ke.length>0&&_n(he,ee,le),J&&Z.viewport(A.copy(J)),he.length>0&&Ft(he,ee,le),ke.length>0&&Ft(ke,ee,le),at.length>0&&Ft(at,ee,le),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function _n(L,ee,le){let J=re.isWebGL2;H===null&&(H=new Ct(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?Tl:ji,minFilter:Cl,samples:J&&a===!0?4:0})),m.getDrawingBufferSize(N),J?H.setSize(N.x,N.y):H.setSize(Cu(N.x),Cu(N.y));let he=m.getRenderTarget();m.setRenderTarget(H),m.clear();let ke=m.toneMapping;m.toneMapping=_a,Ft(L,ee,le),m.toneMapping=ke,ae.updateMultisampleRenderTarget(H),ae.updateRenderTargetMipmap(H),m.setRenderTarget(he)}function Ft(L,ee,le){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,ke=L.length;he<ke;he++){let at=L[he],ht=at.object,dt=at.geometry,Ot=J===null?at.material:J,bt=at.group;ht.layers.test(le.layers)&&Js(ht,ee,le,dt,Ot,bt)}}function Js(L,ee,le,J,he,ke){L.onBeforeRender(m,ee,le,J,he,ke),L.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),he.onBeforeRender(m,ee,le,J,L,ke),he.transparent===!0&&he.side===Cr&&he.forceSinglePass===!1?(he.side=Si,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,L,ke),he.side=fs,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,L,ke),he.side=Cr):m.renderBufferDirect(le,ee,J,he,L,ke),L.onAfterRender(m,ee,le,J,he,ke)}function Ir(L,ee,le){ee.isScene!==!0&&(ee=V);let J=oe.get(L),he=u.state.lights,ke=u.state.shadowsArray,at=he.state.version,ht=ye.getParameters(L,he.state,ke,ee,le),dt=ye.getProgramCacheKey(ht),Ot=J.programs;J.environment=L.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(L.isMeshStandardMaterial?Ae:Me).get(L.envMap||J.environment),Ot===void 0&&(L.addEventListener("dispose",zt),Ot=new Map,J.programs=Ot);let bt=Ot.get(dt);if(bt!==void 0){if(J.currentProgram===bt&&J.lightsStateVersion===at)return ky(L,ht),bt}else ht.uniforms=ye.getUniforms(L),L.onBuild(le,ht,m),L.onBeforeCompile(ht,m),bt=ye.acquireProgram(ht,dt),Ot.set(dt,bt),J.uniforms=ht.uniforms;let gt=J.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(gt.clippingPlanes=I.uniform),ky(L,ht),J.needsLights=AC(L),J.lightsStateVersion=at,J.needsLights&&(gt.ambientLightColor.value=he.state.ambient,gt.lightProbe.value=he.state.probe,gt.directionalLights.value=he.state.directional,gt.directionalLightShadows.value=he.state.directionalShadow,gt.spotLights.value=he.state.spot,gt.spotLightShadows.value=he.state.spotShadow,gt.rectAreaLights.value=he.state.rectArea,gt.ltc_1.value=he.state.rectAreaLTC1,gt.ltc_2.value=he.state.rectAreaLTC2,gt.pointLights.value=he.state.point,gt.pointLightShadows.value=he.state.pointShadow,gt.hemisphereLights.value=he.state.hemi,gt.directionalShadowMap.value=he.state.directionalShadowMap,gt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,gt.spotShadowMap.value=he.state.spotShadowMap,gt.spotLightMatrix.value=he.state.spotLightMatrix,gt.spotLightMap.value=he.state.spotLightMap,gt.pointShadowMap.value=he.state.pointShadowMap,gt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Li=bt.getUniforms(),br=uu.seqWithValue(Li.seq,gt);return J.currentProgram=bt,J.uniformsList=br,bt}function ky(L,ee){let le=oe.get(L);le.outputEncoding=ee.outputEncoding,le.instancing=ee.instancing,le.skinning=ee.skinning,le.morphTargets=ee.morphTargets,le.morphNormals=ee.morphNormals,le.morphColors=ee.morphColors,le.morphTargetsCount=ee.morphTargetsCount,le.numClippingPlanes=ee.numClippingPlanes,le.numIntersection=ee.numClipIntersection,le.vertexAlphas=ee.vertexAlphas,le.vertexTangents=ee.vertexTangents,le.toneMapping=ee.toneMapping}function _C(L,ee,le,J,he){ee.isScene!==!0&&(ee=V),ae.resetTextureUnits();let ke=ee.fog,at=J.isMeshStandardMaterial?ee.environment:null,ht=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Gs,dt=(J.isMeshStandardMaterial?Ae:Me).get(J.envMap||at),Ot=J.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,bt=!!J.normalMap&&!!le.attributes.tangent,gt=!!le.morphAttributes.position,Li=!!le.morphAttributes.normal,br=!!le.morphAttributes.color,$s=J.toneMapped?m.toneMapping:_a,Sn=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,ii=Sn!==void 0?Sn.length:0,vt=oe.get(J),Kp=u.state.lights;if(z===!0&&(X===!0||L!==w)){let wr=L===w&&J.id===b;I.setState(J,L,wr)}let Jp=!1;J.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==Kp.state.version||vt.outputEncoding!==ht||he.isInstancedMesh&&vt.instancing===!1||!he.isInstancedMesh&&vt.instancing===!0||he.isSkinnedMesh&&vt.skinning===!1||!he.isSkinnedMesh&&vt.skinning===!0||vt.envMap!==dt||J.fog===!0&&vt.fog!==ke||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==I.numPlanes||vt.numIntersection!==I.numIntersection)||vt.vertexAlphas!==Ot||vt.vertexTangents!==bt||vt.morphTargets!==gt||vt.morphNormals!==Li||vt.morphColors!==br||vt.toneMapping!==$s||re.isWebGL2===!0&&vt.morphTargetsCount!==ii)&&(Jp=!0):(Jp=!0,vt.__version=J.version);let An=vt.currentProgram;Jp===!0&&(An=Ir(J,ee,he));let Uy=!1,uh=!1,$p=!1,Ti=An.getUniforms(),Mn=vt.uniforms;if(Z.useProgram(An.program)&&(Uy=!0,uh=!0,$p=!0),J.id!==b&&(b=J.id,uh=!0),Uy||w!==L){if(Ti.setValue(U,"projectionMatrix",L.projectionMatrix),re.logarithmicDepthBuffer&&Ti.setValue(U,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),w!==L&&(w=L,uh=!0,$p=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let wr=Ti.map.cameraPosition;wr!==void 0&&wr.setValue(U,q.setFromMatrixPosition(L.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ti.setValue(U,"isOrthographic",L.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||he.isSkinnedMesh)&&Ti.setValue(U,"viewMatrix",L.matrixWorldInverse)}if(he.isSkinnedMesh){Ti.setOptional(U,he,"bindMatrix"),Ti.setOptional(U,he,"bindMatrixInverse");let wr=he.skeleton;wr&&(re.floatVertexTextures?(wr.boneTexture===null&&wr.computeBoneTexture(),Ti.setValue(U,"boneTexture",wr.boneTexture,ae),Ti.setValue(U,"boneTextureSize",wr.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 ef=le.morphAttributes;if((ef.position!==void 0||ef.normal!==void 0||ef.color!==void 0&&re.isWebGL2===!0)&&de.update(he,le,J,An),(uh||vt.receiveShadow!==he.receiveShadow)&&(vt.receiveShadow=he.receiveShadow,Ti.setValue(U,"receiveShadow",he.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(Mn.envMap.value=dt,Mn.flipEnvMap.value=dt.isCubeTexture&&dt.isRenderTargetTexture===!1?-1:1),uh&&(Ti.setValue(U,"toneMappingExposure",m.toneMappingExposure),vt.needsLights&&SC(Mn,$p),ke&&J.fog===!0&&Ne.refreshFogUniforms(Mn,ke),Ne.refreshMaterialUniforms(Mn,J,T,C,H),uu.upload(U,vt.uniformsList,Mn,ae)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(uu.upload(U,vt.uniformsList,Mn,ae),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ti.setValue(U,"center",he.center),Ti.setValue(U,"modelViewMatrix",he.modelViewMatrix),Ti.setValue(U,"normalMatrix",he.normalMatrix),Ti.setValue(U,"modelMatrix",he.matrixWorld),he.previousModelViewMatrix&&Ti.setValue(U,"previousModelViewMatrix",he.previousModelViewMatrix),L.previousProjectionMatrix&&Ti.setValue(U,"previousProjectionMatrix",L.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let wr=J.uniformsGroups;for(let tf=0,MC=wr.length;tf<MC;tf++)if(re.isWebGL2){let Fy=wr[tf];Oe.update(Fy,An),Oe.bind(Fy,An)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return An}function SC(L,ee){L.ambientLightColor.needsUpdate=ee,L.lightProbe.needsUpdate=ee,L.directionalLights.needsUpdate=ee,L.directionalLightShadows.needsUpdate=ee,L.pointLights.needsUpdate=ee,L.pointLightShadows.needsUpdate=ee,L.spotLights.needsUpdate=ee,L.spotLightShadows.needsUpdate=ee,L.rectAreaLights.needsUpdate=ee,L.hemisphereLights.needsUpdate=ee}function AC(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(L,ee,le){oe.get(L.texture).__webglTexture=ee,oe.get(L.depthTexture).__webglTexture=le;let J=oe.get(L);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=le===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,ee){let le=oe.get(L);le.__webglFramebuffer=ee,le.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(L,ee=0,le=0){x=L,v=ee,y=le;let J=!0,he=null,ke=!1,at=!1;if(L){let ht=oe.get(L);ht.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ht.__webglFramebuffer===void 0?ae.setupRenderTarget(L):ht.__hasExternalTextures&&ae.rebindTextures(L,oe.get(L.texture).__webglTexture,oe.get(L.depthTexture).__webglTexture);let dt=L.texture;(dt.isData3DTexture||dt.isDataArrayTexture||dt.isCompressedArrayTexture)&&(at=!0);let Ot=oe.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(he=Ot[ee],ke=!0):re.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?he=oe.get(L).__webglMultisampledFramebuffer:he=Ot,A.copy(L.viewport),S.copy(L.scissor),_=L.scissorTest}else A.copy(O).multiplyScalar(T).floor(),S.copy(B).multiplyScalar(T).floor(),_=G;if(Z.bindFramebuffer(36160,he)&&re.drawBuffers&&J&&Z.drawBuffers(L,he),Z.viewport(A),Z.scissor(S),Z.setScissorTest(_),ke){let ht=oe.get(L.texture);U.framebufferTexture2D(36160,36064,34069+ee,ht.__webglTexture,le)}else if(at){let ht=oe.get(L.texture),dt=ee||0;U.framebufferTextureLayer(36160,36064,ht.__webglTexture,le||0,dt)}b=-1},this.readRenderTargetPixels=function(L,ee,le,J,he,ke,at){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=oe.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&at!==void 0&&(ht=ht[at]),ht){Z.bindFramebuffer(36160,ht);try{let dt=L.texture,Ot=dt.format,bt=dt.type;if(Ot!==jr&&Ce.convert(Ot)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=bt===Tl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(bt!==ji&&Ce.convert(bt)!==U.getParameter(35738)&&!(bt===Tr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=L.width-J&&le>=0&&le<=L.height-he&&U.readPixels(ee,le,J,he,Ce.convert(Ot),Ce.convert(bt),ke)}finally{let dt=x!==null?oe.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,dt)}}},this.copyFramebufferToTexture=function(L,ee,le=0){let J=Math.pow(2,-le),he=Math.floor(ee.image.width*J),ke=Math.floor(ee.image.height*J);ae.setTexture2D(ee,0),U.copyTexSubImage2D(3553,le,0,0,L.x,L.y,he,ke),Z.unbindTexture()},this.copyTextureToTexture=function(L,ee,le,J=0){let he=ee.image.width,ke=ee.image.height,at=Ce.convert(le.format),ht=Ce.convert(le.type);ae.setTexture2D(le,0),U.pixelStorei(37440,le.flipY),U.pixelStorei(37441,le.premultiplyAlpha),U.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,L.x,L.y,he,ke,at,ht,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,L.x,L.y,ee.mipmaps[0].width,ee.mipmaps[0].height,at,ee.mipmaps[0].data):U.texSubImage2D(3553,J,L.x,L.y,at,ht,ee.image),J===0&&le.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(L,ee,le,J,he=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ke=L.max.x-L.min.x+1,at=L.max.y-L.min.y+1,ht=L.max.z-L.min.z+1,dt=Ce.convert(J.format),Ot=Ce.convert(J.type),bt;if(J.isData3DTexture)ae.setTexture3D(J,0),bt=32879;else if(J.isDataArrayTexture)ae.setTexture2DArray(J,0),bt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let gt=U.getParameter(3314),Li=U.getParameter(32878),br=U.getParameter(3316),$s=U.getParameter(3315),Sn=U.getParameter(32877),ii=le.isCompressedTexture?le.mipmaps[0]:le.image;U.pixelStorei(3314,ii.width),U.pixelStorei(32878,ii.height),U.pixelStorei(3316,L.min.x),U.pixelStorei(3315,L.min.y),U.pixelStorei(32877,L.min.z),le.isDataTexture||le.isData3DTexture?U.texSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,Ot,ii.data):le.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,ii.data)):U.texSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,Ot,ii),U.pixelStorei(3314,gt),U.pixelStorei(32878,Li),U.pixelStorei(3316,br),U.pixelStorei(3315,$s),U.pixelStorei(32877,Sn),he===0&&J.generateMipmaps&&U.generateMipmap(bt),Z.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?ae.setTextureCube(L,0):L.isData3DTexture?ae.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?ae.setTexture2DArray(L,0):ae.setTexture2D(L,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var ZO=class extends GS{};ZO.prototype.isWebGL1Renderer=!0;var HS=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new He(e),this.near=t,this.far=i}clone(){return new HS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},nn=class extends Tt{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}},KO=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ag,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Hr()}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=Hr()),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=Hr()),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}}},Hi=new E,hg=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++)Hi.fromBufferAttribute(this,t),Hi.applyMatrix4(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Hi.fromBufferAttribute(this,t),Hi.applyNormalMatrix(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Hi.fromBufferAttribute(this,t),Hi.transformDirection(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Lt(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=wa(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=wa(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=wa(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=wa(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Lt(t,this.array),i=Lt(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=Lt(t,this.array),i=Lt(i,this.array),r=Lt(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=Lt(t,this.array),i=Lt(i,this.array),r=Lt(r,this.array),s=Lt(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 Ke(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 hg(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}}},WS=class extends Tt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Pu=class extends fi{constructor(e=null,t=1,i=1,r,s,a,n,o,l=Rt,h=Rt,d,c){super(null,a,n,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},$1=new me,JO=new me,$v=class{constructor(e=[],t=[]){this.uuid=Hr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new me)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new me;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:JO;$1.multiplyMatrices(n,t[s]),$1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new $v(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=PS(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Pu(t,e,e,jr,Tr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new WS),this.bones.push(a),this.boneInverses.push(new me().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},$O=class extends Ke{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}},vn=class extends Oc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(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}},ex=new E,tx=new E,ix=new me,Bf=new Wl,fd=new vr,Du=class extends Tt{constructor(e=new Ue,t=new vn){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++)ex.fromBufferAttribute(t,r-1),tx.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ex.distanceTo(tx);e.setAttribute("lineDistance",new Te(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,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),fd.copy(i.boundingSphere),fd.applyMatrix4(r),fd.radius+=s,e.ray.intersectsSphere(fd)===!1)return;ix.copy(r).invert(),Bf.copy(e.ray).applyMatrix4(ix);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new E,h=new E,d=new E,c=new E,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=u){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),Bf.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let w=e.ray.origin.distanceTo(c);w<e.near||w>e.far||t.push({distance:w,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Bf.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:d.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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},rx=new E,sx=new E,Rc=class extends Du{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)rx.fromBufferAttribute(t,r),sx.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+rx.distanceTo(sx);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},eL=class extends fi{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:ot,this.magFilter=s!==void 0?s:ot,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}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)}},Qs=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 a=1;a<=e;a++)i=this.getPoint(a/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,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],d=i[r+1]-h,c=(a-h)/d;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),a=this.getPoint(r),n=t||(s.isVector2?new k:new E);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],a=[],n=new E,o=new me;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new E)}s[0]=new E,a[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),c<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(pi(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(n,p))}a[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(pi(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}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}},wp=class extends Qs{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!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=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),c=o-this.aX,u=l-this.aY;o=c*h-u*d+this.aX,l=c*d+u*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}},tL=class extends wp{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function e0(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,d,c){let u=(n-a)/h-(o-a)/(h+d)+(o-n)/d,p=(o-n)/d-(l-n)/(d+c)+(l-o)/c;u*=d,p*=d,s(n,o,u,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var md=new E,zf=new e0,Nf=new e0,kf=new e0,iL=class extends Qs{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,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(md.subVectors(r[0],r[1]).add(r[0]),l=md);let d=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(md.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=md),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),u),f=Math.pow(d.distanceToSquared(c),u),m=Math.pow(c.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),zf.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,f,m),Nf.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,f,m),kf.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(zf.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),Nf.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),kf.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(zf.calc(o),Nf.calc(o),kf.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 ax(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function rL(e,t){let i=1-e;return i*i*t}function sL(e,t){return 2*(1-e)*e*t}function aL(e,t){return e*e*t}function tc(e,t,i,r){return rL(e,t)+sL(e,i)+aL(e,r)}function nL(e,t){let i=1-e;return i*i*i*t}function oL(e,t){let i=1-e;return 3*i*i*e*t}function lL(e,t){return 3*(1-e)*e*e*t}function hL(e,t){return e*e*e*t}function ic(e,t,i,r,s){return nL(e,t)+oL(e,i)+lL(e,r)+hL(e,s)}var ls=class extends Qs{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ic(e,r.x,s.x,a.x,n.x),ic(e,r.y,s.y,a.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.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}},pu=class extends Qs{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,a=this.v2,n=this.v3;return i.set(ic(e,r.x,s.x,a.x,n.x),ic(e,r.y,s.y,a.y,n.y),ic(e,r.z,s.z,a.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.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}},ps=class extends Qs{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},qS=class extends Qs{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}},un=class extends Qs{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(tc(e,r.x,s.x,a.x),tc(e,r.y,s.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}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}},cL=class extends Qs{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,a=this.v2;return i.set(tc(e,r.x,s.x,a.x),tc(e,r.y,s.y,a.y),tc(e,r.z,s.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}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}},t0=class extends Qs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return i.set(ax(n,o.x,l.x,h.x,d.x),ax(n,o.y,l.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},dL=Object.freeze({__proto__:null,ArcCurve:tL,CatmullRomCurve3:iL,CubicBezierCurve:ls,CubicBezierCurve3:pu,EllipseCurve:wp,LineCurve:ps,LineCurve3:qS,QuadraticBezierCurve:un,QuadraticBezierCurve3:cL,SplineCurve:t0}),XS=class extends Qs{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 ps(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.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 a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);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 dL[r.type]().fromJSON(r))}return this}},Iu=class extends XS{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ps(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new un(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new ls(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new t0(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new wp(e,t,i,r,s,a,n,o);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.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}},YS=class extends Ue{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=pi(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,d=new E,c=new k,u=new E,p=new E,f=new E,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),b=Math.cos(y);for(let w=0;w<=e.length-1;w++){d.x=e[w].x*x,d.y=e[w].y,d.z=e[w].x*b,a.push(d.x,d.y,d.z),c.x=v/t,c.y=w/(e.length-1),n.push(c.x,c.y);let A=o[3*w+0]*x,S=o[3*w+1],_=o[3*w+0]*b;l.push(A,S,_)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,w=x+e.length,A=x+e.length+1,S=x+1;s.push(b,w,S),s.push(A,S,w)}this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("uv",new Te(n,2)),this.setAttribute("normal",new Te(l,3))}static fromJSON(e){return new YS(e.points,e.segments,e.phiStart,e.phiLength)}},i0=class extends Ue{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],d=[],c=[],u=[],p=0,f=[],m=i/2,g=0;v(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function v(){let x=new E,b=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 D=T/r,P=D*o+n,O=Math.sin(P),B=Math.cos(P);b.x=C*O,b.y=-M*i+m,b.z=C*B,d.push(b.x,b.y,b.z),x.set(O,A,B).normalize(),c.push(x.x,x.y,x.z),u.push(D,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],D=f[_][S+1];h.push(M,C,D),h.push(C,T,D),w+=6}l.addGroup(g,w,0),g+=w}function y(x){let b=p,w=new k,A=new E,S=0,_=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,m*M,0),c.push(0,M,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+n,P=Math.cos(D),O=Math.sin(D);A.x=_*O,A.y=m*M,A.z=_*P,d.push(A.x,A.y,A.z),c.push(0,M,0),w.x=P*.5+.5,w.y=O*.5*M+.5,u.push(w.x,w.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(g,S,x===!0?1:2),g+=S}}static fromJSON(e){return new i0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},QS=class extends i0{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new QS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},r0=class extends Ue{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let y=new E,x=new E,b=new E;for(let w=0;w<t.length;w+=3)u(t[w+0],y),u(t[w+1],x),u(t[w+2],b),o(y,x,b,v)}function o(v,y,x,b){let w=b+1,A=[];for(let S=0;S<=w;S++){A[S]=[];let _=v.clone().lerp(x,S/w),M=y.clone().lerp(x,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 x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=m(v)/2/Math.PI+.5,b=g(v)/Math.PI+.5;a.push(x,1-b)}p(),d()}function d(){for(let v=0;v<a.length;v+=6){let y=a[v+0],x=a[v+2],b=a[v+4],w=Math.max(y,x,b),A=Math.min(y,x,b);w>.9&&A<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),b<.2&&(a[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,w=new k,A=new k,S=new k;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]),x.set(s[_+6],s[_+7],s[_+8]),w.set(a[M+0],a[M+1]),A.set(a[M+2],a[M+3]),S.set(a[M+4],a[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=m(b);f(w,M+0,v,C),f(A,M+2,y,C),f(S,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(a[y]=v.x-1),x.x===0&&x.z===0&&(a[y]=b/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new r0(e.vertices,e.indices,e.radius,e.details)}},ZS=class extends r0{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],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ZS(e.radius,e.detail)}},Ou=class extends Iu{constructor(e){super(e),this.uuid=Hr(),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 Iu().fromJSON(r))}return this}},uL={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=KS(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,d,c,u,p;if(r&&(a=vL(e,t,a,i)),e.length>80*i){o=h=e[0],l=d=e[1];for(let f=i;f<s;f+=i)c=e[f],u=e[f+1],c<o&&(o=c),u<l&&(l=u),c>h&&(h=c),u>d&&(d=u);p=Math.max(h-o,d-l),p=p!==0?32767/p:0}return pc(a,n,i,o,l,p,0),n}};function KS(e,t,i,r,s){let a,n;if(s===TL(e,t,i,r)>0)for(a=t;a<i;a+=r)n=nx(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=nx(a,e[a],e[a+1],n);return n&&_p(n,n.next)&&(mc(n),n=n.next),n}function so(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(_p(i,i.next)||jt(i.prev,i,i.next)===0)){if(mc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function pc(e,t,i,r,s,a,n){if(!e)return;!n&&a&&_L(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?fL(e,r,s,a):pL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),mc(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=mL(so(e),t,i),pc(e,t,i,r,s,a,2)):n===2&&gL(e,t,i,r,s,a):pc(so(e),t,i,r,s,a,1);break}}}function pL(e){let t=e.prev,i=e,r=e.next;if(jt(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,d=s<a?s<n?s:n:a<n?a:n,c=o<l?o<h?o:h:l<h?l:h,u=s>a?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=d&&f.x<=u&&f.y>=c&&f.y<=p&&nl(s,o,a,l,n,h,f.x,f.y)&&jt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function fL(e,t,i,r){let s=e.prev,a=e,n=e.next;if(jt(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,d=s.y,c=a.y,u=n.y,p=o<l?o<h?o:h:l<h?l:h,f=d<c?d<u?d:u:c<u?c:u,m=o>l?o>h?o:h:l>h?l:h,g=d>c?d>u?d:u:c>u?c:u,v=cg(p,f,t,i,r),y=cg(m,g,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&nl(o,d,l,c,h,u,x.x,x.y)&&jt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&nl(o,d,l,c,h,u,b.x,b.y)&&jt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&nl(o,d,l,c,h,u,x.x,x.y)&&jt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&nl(o,d,l,c,h,u,b.x,b.y)&&jt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function mL(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!_p(s,a)&&JS(s,r,r.next,a)&&fc(s,a)&&fc(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),mc(r),mc(r.next),r=e=a),r=r.next}while(r!==e);return so(r)}function gL(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&ML(n,o)){let l=$S(n,o);n=so(n,n.next),l=so(l,l.next),pc(n,t,i,r,s,a,0),pc(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function vL(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=KS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(AL(h));for(s.sort(yL),a=0;a<s.length;a++)i=xL(s[a],i);return i}function yL(e,t){return e.x-t.x}function xL(e,t){let i=bL(e,t);if(!i)return t;let r=$S(i,e);return so(r,r.next),so(i,i.next)}function bL(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=a&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===a))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,d=1/0,c;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&nl(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),fc(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&wL(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function wL(e,t){return jt(e.prev,e,t.prev)<0&&jt(t.next,e,e.next)<0}function _L(e,t,i,r){let s=e;do s.z===0&&(s.z=cg(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,SL(s)}function SL(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,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--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function cg(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 AL(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 nl(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function ML(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!EL(e,t)&&(fc(e,t)&&fc(t,e)&&CL(e,t)&&(jt(e.prev,e,t.prev)||jt(e,t.prev,t))||_p(e,t)&&jt(e.prev,e,e.next)>0&&jt(t.prev,t,t.next)>0)}function jt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function _p(e,t){return e.x===t.x&&e.y===t.y}function JS(e,t,i,r){let s=vd(jt(e,t,i)),a=vd(jt(e,t,r)),n=vd(jt(i,r,e)),o=vd(jt(i,r,t));return!!(s!==a&&n!==o||s===0&&gd(e,i,t)||a===0&&gd(e,r,t)||n===0&&gd(i,e,r)||o===0&&gd(i,t,r))}function gd(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 vd(e){return e>0?1:e<0?-1:0}function EL(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&&JS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function fc(e,t){return jt(e.prev,e,e.next)<0?jt(e,t,e.next)>=0&&jt(e,e.prev,t)>=0:jt(e,t,e.prev)<0||jt(e,e.next,t)<0}function CL(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function $S(e,t){let i=new dg(e.i,e.x,e.y),r=new dg(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function nx(e,t,i,r){let s=new dg(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 mc(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 dg(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 TL(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var eA=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 eA.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];ox(e),lx(i,e);let a=e.length;t.forEach(ox);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,lx(i,t[o]);let n=uL.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function ox(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function lx(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var tA=class extends r0{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 tA(e.radius,e.detail)}},s0=class extends Ue{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],d=new E,c=new E,u=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],y=g/i,x=0;g==0&&a==0?x=.5/t:g==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let w=b/t;d.x=-e*Math.cos(r+w*s)*Math.sin(a+y*n),d.y=e*Math.cos(a+y*n),d.z=e*Math.sin(r+w*s)*Math.sin(a+y*n),p.push(d.x,d.y,d.z),c.copy(d).normalize(),f.push(c.x,c.y,c.z),m.push(w+x,1-y),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let y=h[g][v+1],x=h[g][v],b=h[g+1][v],w=h[g+1][v+1];(g!==0||a>0)&&u.push(y,x,w),(g!==i-1||o<Math.PI)&&u.push(x,b,w)}this.setIndex(u),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(m,2))}static fromJSON(e){return new s0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},iA=class extends Ue{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],d=new E,c=new E,u=new E,p=new E,f=new E,m=new E,g=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,a,e,u),v(x+.01,s,a,e,p),m.subVectors(p,u),g.addVectors(p,u),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let b=0;b<=r;++b){let w=b/r*Math.PI*2,A=-t*Math.cos(w),S=t*Math.sin(w);d.x=u.x+(A*g.x+S*f.x),d.y=u.y+(A*g.y+S*f.y),d.z=u.z+(A*g.z+S*f.z),o.push(d.x,d.y,d.z),c.subVectors(d,u).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),w=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;n.push(b,w,S),n.push(w,A,S)}this.setIndex(n),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(h,2));function v(y,x,b,w,A){let S=Math.cos(y),_=Math.sin(y),M=b/x*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 iA(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function za(e,t,i){return rA(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function yd(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 rA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function PL(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function hx(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function sA(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var Sp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+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 a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},DL=class extends Sp{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:il,endingEnd:il}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case rl:s=e,n=2*t-i;break;case Mu:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case rl:a=e,o=2*i-t;break;case Mu:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,d=this._offsetNext,c=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-u)*m+(1.5+u)*f+.5*p,x=u*m-u*f;for(let b=0;b!==n;++b)s[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[d+b];return s}},aA=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),d=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*d+a[o+c]*h;return s}},IL=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Zs=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=yd(t,this.TimeBufferType),this.values=yd(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:yd(e.times,Array),values:yd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new IL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new aA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new DL(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Su:t=this.InterpolantFactoryMethodDiscrete;break;case Au:t=this.InterpolantFactoryMethodLinear;break;case hf: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 Su;case this.InterpolantFactoryMethodLinear:return Au;case this.InterpolantFactoryMethodSmooth:return hf}}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,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=za(i,s,a),this.values=za(this.values,s*n,a*n)}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 a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&rA(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=za(this.times),t=za(this.values),i=this.getValueSize(),r=this.getInterpolation()===hf,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let d=n*i,c=d-i,u=d+i;for(let p=0;p!==i;++p){let f=t[d+p];if(f!==t[c+p]||f!==t[u+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let d=n*i,c=a*i;for(let u=0;u!==i;++u)t[c+u]=t[d+u]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=za(e,0,a),this.values=za(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=za(this.times,0),t=za(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Zs.prototype.TimeBufferType=Float32Array;Zs.prototype.ValueBufferType=Float32Array;Zs.prototype.DefaultInterpolation=Au;var Ql=class extends Zs{};Ql.prototype.ValueTypeName="bool";Ql.prototype.ValueBufferType=Array;Ql.prototype.DefaultInterpolation=Su;Ql.prototype.InterpolantFactoryMethodLinear=void 0;Ql.prototype.InterpolantFactoryMethodSmooth=void 0;var nA=class extends Zs{};nA.prototype.ValueTypeName="color";var Lu=class extends Zs{};Lu.prototype.ValueTypeName="number";var OL=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)it.slerpFlat(s,0,a,l-n,a,l,o);return s}},Bc=class extends Zs{InterpolantFactoryMethodLinear(e){return new OL(this.times,this.values,this.getValueSize(),e)}};Bc.prototype.ValueTypeName="quaternion";Bc.prototype.DefaultInterpolation=Au;Bc.prototype.InterpolantFactoryMethodSmooth=void 0;var Zl=class extends Zs{};Zl.prototype.ValueTypeName="string";Zl.prototype.ValueBufferType=Array;Zl.prototype.DefaultInterpolation=Su;Zl.prototype.InterpolantFactoryMethodLinear=void 0;Zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ru=class extends Zs{};Ru.prototype.ValueTypeName="vector";var ug=class{constructor(e,t=-1,i,r=qv){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Hr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(RL(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Zs.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=PL(o);o=hx(o,1,h),l=hx(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new Lu(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let d=h[1],c=r[d];c||(r[d]=c=[]),c.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,c,u,p){if(c.length!==0){let f=[],m=[];sA(c,f,m,u),f.length!==0&&p.push(new h(d,f,m))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let c={},u;for(u=0;u<d.length;u++)if(d[u].morphTargets)for(let p=0;p<d[u].morphTargets.length;p++)c[d[u].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let g=0;g!==d[u].morphTargets.length;++g){let v=d[u];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new Lu(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(Ru,c+".position",d,"pos",r),i(Bc,c+".quaternion",d,"rot",r),i(Ru,c+".scale",d,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function LL(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Lu;case"vector":case"vector2":case"vector3":case"vector4":return Ru;case"color":return nA;case"quaternion":return Bc;case"bool":case"boolean":return Ql;case"string":return Zl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=LL(e.type);if(e.times===void 0){let i=[],r=[];sA(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var cx={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={}}},oA=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(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,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,c=l.length;d<c;d+=2){let u=l[d],p=l[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},BL=new oA,a0=class{constructor(e){this.manager=e!==void 0?e:BL,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}},aa={},zL=class extends Error{constructor(e,t){super(e),this.response=t}},pg=class extends a0{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=cx.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(aa[e]!==void 0){aa[e].push({onLoad:t,onProgress:i,onError:r});return}aa[e]=[],aa[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).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=aa[e],d=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=c?parseInt(c):0,p=u!==0,f=0,m=new ReadableStream({start(g){v();function v(){d.read().then(({done:y,value:x})=>{if(y)g.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let w=0,A=h.length;w<A;w++){let S=h[w];S.onProgress&&S.onProgress(b)}g.enqueue(x),v()}})}}});return new Response(m)}else throw new zL(`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,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),d=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(d);return l.arrayBuffer().then(u=>c.decode(u))}}}).then(l=>{cx.add(e,l);let h=aa[e];delete aa[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=aa[e];if(h===void 0)throw this.manager.itemError(e),l;delete aa[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onError&&u.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}},zc=class extends Tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new He(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}},NL=class extends zc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new He(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Uf=new me,dx=new E,ux=new E,n0=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zv,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;dx.setFromMatrixPosition(e.matrixWorld),t.position.copy(dx),ux.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ux),t.updateMatrixWorld(),Uf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Uf)}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}},kL=class extends n0{constructor(){super(new zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=uc*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}},UL=class extends zc{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new kL}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}},px=new me,_h=new E,Ff=new E,FL=class extends n0{constructor(){super(new zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(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()),_h.setFromMatrixPosition(e.matrixWorld),i.position.copy(_h),Ff.copy(i.position),Ff.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Ff),i.updateMatrixWorld(),r.makeTranslation(-_h.x,-_h.y,-_h.z),px.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(px)}},VL=class extends zc{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 FL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},jL=class extends n0{constructor(){super(new Kv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},GL=class extends zc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new jL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},HL=class extends Ue{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}},lA=class extends a0{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new pg(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,u){if(t[u]!==void 0)return t[u];let p=c.interleavedBuffers[u],f=s(c,p.buffer),m=Qc(p.type,f),g=new KO(m,p.stride);return g.uuid=p.uuid,t[u]=g,g}function s(c,u){if(i[u]!==void 0)return i[u];let p=c.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let a=e.isInstancedBufferGeometry?new HL:new Ue,n=e.data.index;if(n!==void 0){let c=Qc(n.type,n.array);a.setIndex(new Ke(c,1))}let o=e.data.attributes;for(let c in o){let u=o[c],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new hg(f,u.itemSize,u.offset,u.normalized)}else{let f=Qc(u.type,u.array),m=u.isInstancedBufferAttribute?$O:Ke;p=new m(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),a.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let u=l[c],p=[];for(let f=0,m=u.length;f<m;f++){let g=u[f],v;if(g.isInterleavedBufferAttribute){let y=r(e.data,g.data);v=new hg(y,g.itemSize,g.offset,g.normalized)}else{let y=Qc(g.type,g.array);v=new Ke(y,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,u=h.length;c!==u;++c){let p=h[c];a.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let c=new E;d.center!==void 0&&c.fromArray(d.center),a.boundingSphere=new vr(c,d.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},WL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=fx(),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=fx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function fx(){return(typeof performance>"u"?Date:performance).now()}var qL=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;it.multiplyQuaternionsFlat(e,a,e,t,e,i),it.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},o0="\\[\\]\\.:\\/",XL=new RegExp("["+o0+"]","g"),l0="[^"+o0+"]",YL="[^"+o0.replace("\\.","")+"]",QL=/((?:WC+[\/:])*)/.source.replace("WC",l0),ZL=/(WCOD+)?/.source.replace("WCOD",YL),KL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",l0),JL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",l0),$L=new RegExp("^"+QL+ZL+KL+JL+"$"),e4=["material","materials","bones","map"],t4=class{constructor(e,t,i){let r=i||Dt.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()}},Dt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Dt.parseTrackName(t),this.node=Dt.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 Dt.Composite(e,t,i):new Dt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(XL,"")}static parseTrackName(e){let t=$L.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);e4.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 a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.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=Dt.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 a=e[r];if(a===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 n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=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=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Dt.Composite=t4;Dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Dt.prototype.GetterByBindingType=[Dt.prototype._getValue_direct,Dt.prototype._getValue_array,Dt.prototype._getValue_arrayElement,Dt.prototype._getValue_toArray];Dt.prototype.SetterByBindingTypeAndVersioning=[[Dt.prototype._setValue_direct,Dt.prototype._setValue_direct_setNeedsUpdate,Dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_array,Dt.prototype._setValue_array_setNeedsUpdate,Dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_arrayElement,Dt.prototype._setValue_arrayElement_setNeedsUpdate,Dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_fromArray,Dt.prototype._setValue_fromArray_setNeedsUpdate,Dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var i4=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:il,endingEnd:il};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=CS,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case zT:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case qv:default:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===Wv;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===ES){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=rl,r.endingEnd=rl):(e?r.endingStart=this.zeroSlopeAtStart?rl:il:r.endingStart=Mu,t?r.endingEnd=this.zeroSlopeAtEnd?rl:il:r.endingEnd=Mu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},r4=new Float32Array(1),s4=class extends Ii{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let d=0;d!==s;++d){let c=r[d],u=c.name,p=h[u];if(p!==void 0)++p.referenceCount,a[d]=p;else{if(p=a[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[d].binding.parsedPath;p=new qL(Dt.create(i,u,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),a[d]=p}n[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let d=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete d[c],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new aA(new Float32Array(2),new Float32Array(2),1,r4),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?ug.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=qv),o!==void 0){let d=o.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new i4(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?ug.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},fe=class{constructor(e){this.value=e}clone(){return new fe(this.value.clone===void 0?this.value:this.value.clone())}},hA=class{constructor(e,t,i=0,r=1/0){this.ray=new Wl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Yv,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 fg(e,this,i,t),i.sort(mx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)fg(e[r],this,i,t);return i.sort(mx),i}};function mx(e,t){return e.distance-t.distance}function fg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)fg(s[a],t,i,!0)}}var gx=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(pi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},vx=new k,cA=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=vx.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 vx.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)}},yx=new E,xd=new E,Wr=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){yx.subVectors(e,this.start),xd.subVectors(this.end,this.start);let i=xd.dot(xd),r=xd.dot(yx)/i;return t&&(r=pi(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)}},xx=new E,a4=class extends Tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ue,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 a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Te(r,3));let s=new vn({fog:!1,toneMapped:!1});this.cone=new Rc(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),xx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(xx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},n4=class extends ur{constructor(e,t,i){let r=new s0(t,4,2),s=new Lc({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)}},bx=new E,bd=new E,wx=new E,o4=class extends Tt{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 Ue;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new vn({fog:!1,toneMapped:!1});this.lightPlane=new Du(r,s),this.add(this.lightPlane),r=new Ue,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Du(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),bx.setFromMatrixPosition(this.light.matrixWorld),bd.setFromMatrixPosition(this.light.target.matrixWorld),wx.subVectors(bd,bx),this.lightPlane.lookAt(bd),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(bd),this.targetLine.scale.z=wx.length()}},wd=new E,Gt=new Xl,Bu=class extends Rc{constructor(e){let t=new Ue,i=new vn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(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=a,this.update();let l=new He(16755200),h=new He(16711680),d=new He(43775),c=new He(16777215),u=new He(3355443);this.setColors(l,h,d,c,u)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;Gt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Yt("c",t,e,Gt,0,0,-1),Yt("t",t,e,Gt,0,0,1),Yt("n1",t,e,Gt,-i,-r,-1),Yt("n2",t,e,Gt,i,-r,-1),Yt("n3",t,e,Gt,-i,r,-1),Yt("n4",t,e,Gt,i,r,-1),Yt("f1",t,e,Gt,-i,-r,1),Yt("f2",t,e,Gt,i,-r,1),Yt("f3",t,e,Gt,-i,r,1),Yt("f4",t,e,Gt,i,r,1),Yt("u1",t,e,Gt,i*.7,r*1.1,-1),Yt("u2",t,e,Gt,-i*.7,r*1.1,-1),Yt("u3",t,e,Gt,0,r*2,-1),Yt("cf1",t,e,Gt,-i,0,1),Yt("cf2",t,e,Gt,i,0,1),Yt("cf3",t,e,Gt,0,-r,1),Yt("cf4",t,e,Gt,0,r,1),Yt("cn1",t,e,Gt,-i,0,-1),Yt("cn2",t,e,Gt,i,0,-1),Yt("cn3",t,e,Gt,0,-r,-1),Yt("cn4",t,e,Gt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Yt(e,t,i,r,s,a,n){wd.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,d=o.length;h<d;h++)l.setXYZ(o[h],wd.x,wd.y,wd.z)}}var zu=class extends Rc{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 Ue;s.setIndex(new Ke(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new vn({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()}},l4=class extends Rc{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 Ue;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new vn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new He,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:Hl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Hl);var Sh=".",h0=Symbol("target"),dA=Symbol("unsubscribe");function mg(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function h4(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var zs=Array.isArray;function c0(e){return typeof e=="symbol"}var c4={after:(e,t)=>zs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>zs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Sh),c0(t)?e+t.toString():e+t):e,initial:e=>{if(zs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Sh);return t===-1?"":e.slice(0,t)},last:e=>{if(zs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Sh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(zs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Sh);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(Sh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Ur=c4;function d4(e){return typeof e=="object"&&typeof e.next=="function"}function u4(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[h0].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function _x(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&c0(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var p4=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],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Ur.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 a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?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 gg(e){return toString.call(e)==="[object Object]"}function _d(){return!0}function Oo(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var uA=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),f4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),pA={push:_d,pop:_d,shift:_d,unshift:_d,copyWithin:Oo,reverse:Oo,sort:Oo,splice:Oo,flat:Oo,fill:Oo},m4=new Set([...uA,...f4,...Object.keys(pA)]);function Sd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var fA=["keys","values","entries"],mA=new Set(["has","toString"]),gA={add:Sd,clear:Sd,delete:Sd,forEach:Sd},g4=new Set([...mA,...Object.keys(gA),...fA]);function Ad(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 v4=new Set([...mA,"get"]),vA={set:Ad,clear:Ad,delete:Ad,forEach:Ad},y4=new Set([...v4,...Object.keys(vA),...fA]),pn=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 uA.has(e)}_shallowClone(e){let t=e;if(gg(e))t={...e};else if(zs(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?(zs(r)?this._onIsChanged=pA[t]:r instanceof Set?this._onIsChanged=gA[t]:r instanceof Map&&(this._onIsChanged=vA[t]),r):i}update(e,t,i){let r=Ur.after(e,this._path);if(t!=="length"){let s=this.clone;Ur.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),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],Ur.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Sx=class extends pn{static isHandledMethod(e){return m4.has(e)}},x4=class extends pn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Ax=class extends pn{static isHandledMethod(e){return g4.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)}},Mx=class extends pn{static isHandledMethod(e){return y4.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)}},b4=class extends pn{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)}},w4=class extends pn{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)}},Ko=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gg(e)||zs(e)||mg(e)}static isHandledMethod(e,t){return gg(e)?pn.isHandledMethod(t):zs(e)?Sx.isHandledMethod(t):e instanceof Set?Ax.isHandledMethod(t):e instanceof Map?Mx.isHandledMethod(t):mg(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=pn;zs(e)?r=Sx:e instanceof Date?r=x4:e instanceof Set?r=Ax:e instanceof Map?r=Mx:e instanceof WeakSet?r=b4:e instanceof WeakMap&&(r=w4),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=Ko.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}},_4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},d0=(e,t,i={})=>{i={..._4,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new p4(s),h=typeof i.onValidate=="function",d=new Ko(h),c=(y,x,b,w,A)=>!h||d.isCloning||i.onValidate(Ur.concat(l.getPath(y),x),b,w,A)===!0,u=(y,x,b,w)=>{!_x(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,b,w)},p=(y,x,b,w,A)=>{d.isCloning?d.update(y,x,w):t(Ur.concat(y,x),b,w,A)},f=y=>y&&(y[r]||y),m=(y,x,b,w)=>h4(y)||b==="constructor"||a&&!Ko.isHandledMethod(x,b)||_x(l,i,b)||l.isGetInvariant(x,b)||n&&l.isDetached(x,e)?y:(w===void 0&&(w=l.getPath(x)),l.getProxy(y,Ur.concat(w,b),g,r)),g={get(y,x,b){if(c0(x)){if(x===r||x===h0)return y;if(x===dA&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=mg(y)?Reflect.get(y,x):Reflect.get(y,x,b);return m(w,y,x)},set(y,x,b,w){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let _=c(y,x,b,S);return _&&l.setProperty(A,x,b,w,S)?(u(y,x,y[x],S),!0):!_},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let w=y[x];c(y,x,b.value,w)&&l.defineProperty(y,x,b,w)&&u(y,x,b.value,w)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),w=c(y,x,void 0,b);return w&&l.deleteProperty(y,x,b)?(u(y,x,void 0,b),!0):!w},apply(y,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,w,b);if((o===!1||o!==!0&&!o.includes(y.name))&&Ko.isHandledType(w)){let A=Ur.initial(l.getPath(y)),S=Ko.isHandledMethod(w,y.name);d.start(w,A,b);let _=Reflect.apply(y,d.preferredThisArg(y,x,w),S?b.map(T=>f(T)):b),M=d.isChanged(w,s),C=d.stop();if(Ko.isHandledType(_)&&S&&(x instanceof Map&&y.name==="get"&&(A=Ur.concat(A,b[0])),_=l.getProxy(_,A,g)),M){let T={name:y.name,args:b,result:_},D=d.isCloning?Ur.initial(A):A,P=d.isCloning?Ur.last(A):"";c(Ur.get(e,D),P,w,C,T)?p(D,P,w,C,T):d.undo(w)}return(x instanceof Map||x instanceof Set)&&d4(_)?u4(_,y,x,A,m):_}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};d0.target=e=>e&&e[h0]||e;d0.unsubscribe=e=>e[dA]||e;var Ex=d0,S4=typeof global=="object"&&global&&global.Object===Object&&global,yA=S4,A4=typeof self=="object"&&self&&self.Object===Object&&self,M4=yA||A4||Function("return this")(),gs=M4,E4=gs.Symbol,Xr=E4,xA=Object.prototype,C4=xA.hasOwnProperty,T4=xA.toString,Ah=Xr?Xr.toStringTag:void 0;function P4(e){var t=C4.call(e,Ah),i=e[Ah];try{e[Ah]=void 0;var r=!0}catch{}var s=T4.call(e);return r&&(t?e[Ah]=i:delete e[Ah]),s}var D4=P4,I4=Object.prototype,O4=I4.toString;function L4(e){return O4.call(e)}var R4=L4,B4="[object Null]",z4="[object Undefined]",Cx=Xr?Xr.toStringTag:void 0;function N4(e){return e==null?e===void 0?z4:B4:Cx&&Cx in Object(e)?D4(e):R4(e)}var lo=N4;function k4(e){return e!=null&&typeof e=="object"}var Ea=k4,U4="[object Symbol]";function F4(e){return typeof e=="symbol"||Ea(e)&&lo(e)==U4}var Ap=F4;function V4(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 bA=V4,j4=Array.isArray,Ws=j4,G4=1/0,Tx=Xr?Xr.prototype:void 0,Px=Tx?Tx.toString:void 0;function wA(e){if(typeof e=="string")return e;if(Ws(e))return bA(e,wA)+"";if(Ap(e))return Px?Px.call(e):"";var t=e+"";return t=="0"&&1/e==-G4?"-0":t}var H4=wA,W4=/\s/;function q4(e){for(var t=e.length;t--&&W4.test(e.charAt(t)););return t}var X4=q4,Y4=/^\s+/;function Q4(e){return e&&e.slice(0,X4(e)+1).replace(Y4,"")}var Z4=Q4;function K4(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ms=K4,Dx=0/0,J4=/^[-+]0x[0-9a-f]+$/i,$4=/^0b[01]+$/i,eR=/^0o[0-7]+$/i,tR=parseInt;function iR(e){if(typeof e=="number")return e;if(Ap(e))return Dx;if(ms(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ms(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Z4(e);var i=$4.test(e);return i||eR.test(e)?tR(e.slice(2),i?2:8):J4.test(e)?Dx:+e}var Ix=iR;function rR(e){return e}var sR=rR,aR="[object AsyncFunction]",nR="[object Function]",oR="[object GeneratorFunction]",lR="[object Proxy]";function hR(e){if(!ms(e))return!1;var t=lo(e);return t==nR||t==oR||t==aR||t==lR}var _A=hR,cR=gs["__core-js_shared__"],Vf=cR,Ox=function(){var e=/[^.]+$/.exec(Vf&&Vf.keys&&Vf.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function dR(e){return!!Ox&&Ox in e}var uR=dR,pR=Function.prototype,fR=pR.toString;function mR(e){if(e!=null){try{return fR.call(e)}catch{}try{return e+""}catch{}}return""}var ho=mR,gR=/[\\^$.*+?()[\]{}|]/g,vR=/^\[object .+?Constructor\]$/,yR=Function.prototype,xR=Object.prototype,bR=yR.toString,wR=xR.hasOwnProperty,_R=RegExp("^"+bR.call(wR).replace(gR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function SR(e){if(!ms(e)||uR(e))return!1;var t=_A(e)?_R:vR;return t.test(ho(e))}var AR=SR;function MR(e,t){return e?.[t]}var ER=MR;function CR(e,t){var i=ER(e,t);return AR(i)?i:void 0}var co=CR,TR=co(gs,"WeakMap"),vg=TR,Lx=Object.create,PR=function(){function e(){}return function(t){if(!ms(t))return{};if(Lx)return Lx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),DR=PR;function IR(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 OR=IR;function LR(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var RR=LR,BR=800,zR=16,NR=Date.now;function kR(e){var t=0,i=0;return function(){var r=NR(),s=zR-(r-i);if(i=r,s>0){if(++t>=BR)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var UR=kR;function FR(e){return function(){return e}}var VR=FR,jR=function(){try{var e=co(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Nu=jR,GR=Nu?function(e,t){return Nu(e,"toString",{configurable:!0,enumerable:!1,value:VR(t),writable:!0})}:sR,HR=GR,WR=UR(HR),qR=WR;function XR(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var YR=XR,QR=9007199254740991,ZR=/^(?:0|[1-9]\d*)$/;function KR(e,t){var i=typeof e;return t=t??QR,!!t&&(i=="number"||i!="symbol"&&ZR.test(e))&&e>-1&&e%1==0&&e<t}var u0=KR;function JR(e,t,i){t=="__proto__"&&Nu?Nu(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var SA=JR;function $R(e,t){return e===t||e!==e&&t!==t}var p0=$R,eB=Object.prototype,tB=eB.hasOwnProperty;function iB(e,t,i){var r=e[t];(!(tB.call(e,t)&&p0(r,i))||i===void 0&&!(t in e))&&SA(e,t,i)}var f0=iB;function rB(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?SA(i,o,l):f0(i,o,l)}return i}var Nc=rB,Rx=Math.max;function sB(e,t,i){return t=Rx(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=Rx(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),OR(e,this,o)}}var aB=sB,nB=9007199254740991;function oB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=nB}var m0=oB;function lB(e){return e!=null&&m0(e.length)&&!_A(e)}var AA=lB,hB=Object.prototype;function cB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||hB;return e===i}var g0=cB;function dB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uB=dB,pB="[object Arguments]";function fB(e){return Ea(e)&&lo(e)==pB}var Bx=fB,MA=Object.prototype,mB=MA.hasOwnProperty,gB=MA.propertyIsEnumerable,vB=Bx(function(){return arguments}())?Bx:function(e){return Ea(e)&&mB.call(e,"callee")&&!gB.call(e,"callee")},v0=vB;function yB(){return!1}var xB=yB,EA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zx=EA&&typeof module=="object"&&module&&!module.nodeType&&module,bB=zx&&zx.exports===EA,Nx=bB?gs.Buffer:void 0,wB=Nx?Nx.isBuffer:void 0,_B=wB||xB,ku=_B,SB="[object Arguments]",AB="[object Array]",MB="[object Boolean]",EB="[object Date]",CB="[object Error]",TB="[object Function]",PB="[object Map]",DB="[object Number]",IB="[object Object]",OB="[object RegExp]",LB="[object Set]",RB="[object String]",BB="[object WeakMap]",zB="[object ArrayBuffer]",NB="[object DataView]",kB="[object Float32Array]",UB="[object Float64Array]",FB="[object Int8Array]",VB="[object Int16Array]",jB="[object Int32Array]",GB="[object Uint8Array]",HB="[object Uint8ClampedArray]",WB="[object Uint16Array]",qB="[object Uint32Array]",Ut={};Ut[kB]=Ut[UB]=Ut[FB]=Ut[VB]=Ut[jB]=Ut[GB]=Ut[HB]=Ut[WB]=Ut[qB]=!0;Ut[SB]=Ut[AB]=Ut[zB]=Ut[MB]=Ut[NB]=Ut[EB]=Ut[CB]=Ut[TB]=Ut[PB]=Ut[DB]=Ut[IB]=Ut[OB]=Ut[LB]=Ut[RB]=Ut[BB]=!1;function XB(e){return Ea(e)&&m0(e.length)&&!!Ut[lo(e)]}var YB=XB;function QB(e){return function(t){return e(t)}}var y0=QB,CA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rc=CA&&typeof module=="object"&&module&&!module.nodeType&&module,ZB=rc&&rc.exports===CA,jf=ZB&&yA.process,KB=function(){try{var e=rc&&rc.require&&rc.require("util").types;return e||jf&&jf.binding&&jf.binding("util")}catch{}}(),Il=KB,kx=Il&&Il.isTypedArray,JB=kx?y0(kx):YB,TA=JB,$B=Object.prototype,ez=$B.hasOwnProperty;function tz(e,t){var i=Ws(e),r=!i&&v0(e),s=!i&&!r&&ku(e),a=!i&&!r&&!s&&TA(e),n=i||r||s||a,o=n?uB(e.length,String):[],l=o.length;for(var h in e)(t||ez.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||u0(h,l)))&&o.push(h);return o}var PA=tz;function iz(e,t){return function(i){return e(t(i))}}var DA=iz,rz=DA(Object.keys,Object),sz=rz,az=Object.prototype,nz=az.hasOwnProperty;function oz(e){if(!g0(e))return sz(e);var t=[];for(var i in Object(e))nz.call(e,i)&&i!="constructor"&&t.push(i);return t}var lz=oz;function hz(e){return AA(e)?PA(e):lz(e)}var x0=hz;function cz(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var dz=cz,uz=Object.prototype,pz=uz.hasOwnProperty;function fz(e){if(!ms(e))return dz(e);var t=g0(e),i=[];for(var r in e)r=="constructor"&&(t||!pz.call(e,r))||i.push(r);return i}var mz=fz;function gz(e){return AA(e)?PA(e,!0):mz(e)}var b0=gz,vz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yz=/^\w*$/;function xz(e,t){if(Ws(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Ap(e)?!0:yz.test(e)||!vz.test(e)||t!=null&&e in Object(t)}var bz=xz,wz=co(Object,"create"),gc=wz;function _z(){this.__data__=gc?gc(null):{},this.size=0}var Sz=_z;function Az(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Mz=Az,Ez="__lodash_hash_undefined__",Cz=Object.prototype,Tz=Cz.hasOwnProperty;function Pz(e){var t=this.__data__;if(gc){var i=t[e];return i===Ez?void 0:i}return Tz.call(t,e)?t[e]:void 0}var Dz=Pz,Iz=Object.prototype,Oz=Iz.hasOwnProperty;function Lz(e){var t=this.__data__;return gc?t[e]!==void 0:Oz.call(t,e)}var Rz=Lz,Bz="__lodash_hash_undefined__";function zz(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=gc&&t===void 0?Bz:t,this}var Nz=zz;function Kl(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])}}Kl.prototype.clear=Sz;Kl.prototype.delete=Mz;Kl.prototype.get=Dz;Kl.prototype.has=Rz;Kl.prototype.set=Nz;var Ux=Kl;function kz(){this.__data__=[],this.size=0}var Uz=kz;function Fz(e,t){for(var i=e.length;i--;)if(p0(e[i][0],t))return i;return-1}var Mp=Fz,Vz=Array.prototype,jz=Vz.splice;function Gz(e){var t=this.__data__,i=Mp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():jz.call(t,i,1),--this.size,!0}var Hz=Gz;function Wz(e){var t=this.__data__,i=Mp(t,e);return i<0?void 0:t[i][1]}var qz=Wz;function Xz(e){return Mp(this.__data__,e)>-1}var Yz=Xz;function Qz(e,t){var i=this.__data__,r=Mp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Zz=Qz;function Jl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Jl.prototype.clear=Uz;Jl.prototype.delete=Hz;Jl.prototype.get=qz;Jl.prototype.has=Yz;Jl.prototype.set=Zz;var Ep=Jl,Kz=co(gs,"Map"),vc=Kz;function Jz(){this.size=0,this.__data__={hash:new Ux,map:new(vc||Ep),string:new Ux}}var $z=Jz;function e5(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var t5=e5;function i5(e,t){var i=e.__data__;return t5(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Cp=i5;function r5(e){var t=Cp(this,e).delete(e);return this.size-=t?1:0,t}var s5=r5;function a5(e){return Cp(this,e).get(e)}var n5=a5;function o5(e){return Cp(this,e).has(e)}var l5=o5;function h5(e,t){var i=Cp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var c5=h5;function $l(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])}}$l.prototype.clear=$z;$l.prototype.delete=s5;$l.prototype.get=n5;$l.prototype.has=l5;$l.prototype.set=c5;var Tp=$l,d5="Expected a function";function w0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(d5);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(w0.Cache||Tp),i}w0.Cache=Tp;var u5=w0,p5=500;function f5(e){var t=u5(e,function(r){return i.size===p5&&i.clear(),r}),i=t.cache;return t}var m5=f5,g5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,v5=/\\(\\)?/g,y5=m5(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(g5,function(i,r,s,a){t.push(s?a.replace(v5,"$1"):r||i)}),t}),x5=y5;function b5(e){return e==null?"":H4(e)}var w5=b5;function _5(e,t){return Ws(e)?e:bz(e,t)?[e]:x5(w5(e))}var eh=_5,S5=1/0;function A5(e){if(typeof e=="string"||Ap(e))return e;var t=e+"";return t=="0"&&1/e==-S5?"-0":t}var Pp=A5;function M5(e,t){t=eh(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Pp(t[i++])];return i&&i==r?e:void 0}var IA=M5;function E5(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var _0=E5,Fx=Xr?Xr.isConcatSpreadable:void 0;function C5(e){return Ws(e)||v0(e)||!!(Fx&&e&&e[Fx])}var T5=C5;function OA(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=T5),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?OA(o,t-1,i,r,s):_0(s,o):r||(s[s.length]=o)}return s}var P5=OA;function D5(e){var t=e==null?0:e.length;return t?P5(e,1):[]}var I5=D5;function O5(e){return qR(aB(e,void 0,I5),e+"")}var LA=O5,L5=DA(Object.getPrototypeOf,Object),S0=L5,R5="[object Object]",B5=Function.prototype,z5=Object.prototype,RA=B5.toString,N5=z5.hasOwnProperty,k5=RA.call(Object);function U5(e){if(!Ea(e)||lo(e)!=R5)return!1;var t=S0(e);if(t===null)return!0;var i=N5.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&RA.call(i)==k5}var F5=U5;function V5(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 a=Array(s);++r<s;)a[r]=e[r+t];return a}var j5=V5;function G5(){this.__data__=new Ep,this.size=0}var H5=G5;function W5(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var q5=W5;function X5(e){return this.__data__.get(e)}var Y5=X5;function Q5(e){return this.__data__.has(e)}var Z5=Q5,K5=200;function J5(e,t){var i=this.__data__;if(i instanceof Ep){var r=i.__data__;if(!vc||r.length<K5-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Tp(r)}return i.set(e,t),this.size=i.size,this}var $5=J5;function th(e){var t=this.__data__=new Ep(e);this.size=t.size}th.prototype.clear=H5;th.prototype.delete=q5;th.prototype.get=Y5;th.prototype.has=Z5;th.prototype.set=$5;var fu=th;function eN(e,t){return e&&Nc(t,x0(t),e)}var tN=eN;function iN(e,t){return e&&Nc(t,b0(t),e)}var rN=iN,BA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vx=BA&&typeof module=="object"&&module&&!module.nodeType&&module,sN=Vx&&Vx.exports===BA,jx=sN?gs.Buffer:void 0,Gx=jx?jx.allocUnsafe:void 0;function aN(e,t){if(t)return e.slice();var i=e.length,r=Gx?Gx(i):new e.constructor(i);return e.copy(r),r}var nN=aN;function oN(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var lN=oN;function hN(){return[]}var zA=hN,cN=Object.prototype,dN=cN.propertyIsEnumerable,Hx=Object.getOwnPropertySymbols,uN=Hx?function(e){return e==null?[]:(e=Object(e),lN(Hx(e),function(t){return dN.call(e,t)}))}:zA,A0=uN;function pN(e,t){return Nc(e,A0(e),t)}var fN=pN,mN=Object.getOwnPropertySymbols,gN=mN?function(e){for(var t=[];e;)_0(t,A0(e)),e=S0(e);return t}:zA,NA=gN;function vN(e,t){return Nc(e,NA(e),t)}var yN=vN;function xN(e,t,i){var r=t(e);return Ws(e)?r:_0(r,i(e))}var kA=xN;function bN(e){return kA(e,x0,A0)}var yg=bN;function wN(e){return kA(e,b0,NA)}var UA=wN,_N=co(gs,"DataView"),xg=_N,SN=co(gs,"Promise"),bg=SN,AN=co(gs,"Set"),wg=AN,Wx="[object Map]",MN="[object Object]",qx="[object Promise]",Xx="[object Set]",Yx="[object WeakMap]",Qx="[object DataView]",EN=ho(xg),CN=ho(vc),TN=ho(bg),PN=ho(wg),DN=ho(vg),Bn=lo;(xg&&Bn(new xg(new ArrayBuffer(1)))!=Qx||vc&&Bn(new vc)!=Wx||bg&&Bn(bg.resolve())!=qx||wg&&Bn(new wg)!=Xx||vg&&Bn(new vg)!=Yx)&&(Bn=function(e){var t=lo(e),i=t==MN?e.constructor:void 0,r=i?ho(i):"";if(r)switch(r){case EN:return Qx;case CN:return Wx;case TN:return qx;case PN:return Xx;case DN:return Yx}return t});var yc=Bn,IN=Object.prototype,ON=IN.hasOwnProperty;function LN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&ON.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var RN=LN,BN=gs.Uint8Array,Uu=BN;function zN(e){var t=new e.constructor(e.byteLength);return new Uu(t).set(new Uu(e)),t}var M0=zN;function NN(e,t){var i=t?M0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var kN=NN,UN=/\w*$/;function FN(e){var t=new e.constructor(e.source,UN.exec(e));return t.lastIndex=e.lastIndex,t}var VN=FN,Zx=Xr?Xr.prototype:void 0,Kx=Zx?Zx.valueOf:void 0;function jN(e){return Kx?Object(Kx.call(e)):{}}var GN=jN;function HN(e,t){var i=t?M0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var WN=HN,qN="[object Boolean]",XN="[object Date]",YN="[object Map]",QN="[object Number]",ZN="[object RegExp]",KN="[object Set]",JN="[object String]",$N="[object Symbol]",ek="[object ArrayBuffer]",tk="[object DataView]",ik="[object Float32Array]",rk="[object Float64Array]",sk="[object Int8Array]",ak="[object Int16Array]",nk="[object Int32Array]",ok="[object Uint8Array]",lk="[object Uint8ClampedArray]",hk="[object Uint16Array]",ck="[object Uint32Array]";function dk(e,t,i){var r=e.constructor;switch(t){case ek:return M0(e);case qN:case XN:return new r(+e);case tk:return kN(e,i);case ik:case rk:case sk:case ak:case nk:case ok:case lk:case hk:case ck:return WN(e,i);case YN:return new r;case QN:case JN:return new r(e);case ZN:return VN(e);case KN:return new r;case $N:return GN(e)}}var uk=dk;function pk(e){return typeof e.constructor=="function"&&!g0(e)?DR(S0(e)):{}}var fk=pk,mk="[object Map]";function gk(e){return Ea(e)&&yc(e)==mk}var vk=gk,Jx=Il&&Il.isMap,yk=Jx?y0(Jx):vk,xk=yk,bk="[object Set]";function wk(e){return Ea(e)&&yc(e)==bk}var _k=wk,$x=Il&&Il.isSet,Sk=$x?y0($x):_k,Ak=Sk,Mk=1,Ek=2,Ck=4,FA="[object Arguments]",Tk="[object Array]",Pk="[object Boolean]",Dk="[object Date]",Ik="[object Error]",VA="[object Function]",Ok="[object GeneratorFunction]",Lk="[object Map]",Rk="[object Number]",jA="[object Object]",Bk="[object RegExp]",zk="[object Set]",Nk="[object String]",kk="[object Symbol]",Uk="[object WeakMap]",Fk="[object ArrayBuffer]",Vk="[object DataView]",jk="[object Float32Array]",Gk="[object Float64Array]",Hk="[object Int8Array]",Wk="[object Int16Array]",qk="[object Int32Array]",Xk="[object Uint8Array]",Yk="[object Uint8ClampedArray]",Qk="[object Uint16Array]",Zk="[object Uint32Array]",Nt={};Nt[FA]=Nt[Tk]=Nt[Fk]=Nt[Vk]=Nt[Pk]=Nt[Dk]=Nt[jk]=Nt[Gk]=Nt[Hk]=Nt[Wk]=Nt[qk]=Nt[Lk]=Nt[Rk]=Nt[jA]=Nt[Bk]=Nt[zk]=Nt[Nk]=Nt[kk]=Nt[Xk]=Nt[Yk]=Nt[Qk]=Nt[Zk]=!0;Nt[Ik]=Nt[VA]=Nt[Uk]=!1;function mu(e,t,i,r,s,a){var n,o=t&Mk,l=t&Ek,h=t&Ck;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!ms(e))return e;var d=Ws(e);if(d){if(n=RN(e),!o)return RR(e,n)}else{var c=yc(e),u=c==VA||c==Ok;if(ku(e))return nN(e,o);if(c==jA||c==FA||u&&!s){if(n=l||u?{}:fk(e),!o)return l?yN(e,rN(n,e)):fN(e,tN(n,e))}else{if(!Nt[c])return s?e:{};n=uk(e,c,o)}}a||(a=new fu);var p=a.get(e);if(p)return p;a.set(e,n),Ak(e)?e.forEach(function(g){n.add(mu(g,t,i,g,e,a))}):xk(e)&&e.forEach(function(g,v){n.set(v,mu(g,t,i,v,e,a))});var f=h?l?UA:yg:l?b0:x0,m=d?void 0:f(e);return YR(m||e,function(g,v){m&&(v=g,g=e[v]),f0(n,v,mu(g,t,i,v,e,a))}),n}var GA=mu,Kk=1,Jk=4;function $k(e){return GA(e,Kk|Jk)}var Dp=$k,eU="__lodash_hash_undefined__";function tU(e){return this.__data__.set(e,eU),this}var iU=tU;function rU(e){return this.__data__.has(e)}var sU=rU;function Fu(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Tp;++t<i;)this.add(e[t])}Fu.prototype.add=Fu.prototype.push=iU;Fu.prototype.has=sU;var aU=Fu;function nU(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 oU=nU;function lU(e,t){return e.has(t)}var hU=lU,cU=1,dU=2;function uU(e,t,i,r,s,a){var n=i&cU,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),d=a.get(t);if(h&&d)return h==t&&d==e;var c=-1,u=!0,p=i&dU?new aU:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var g=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(g!==void 0){if(g)continue;u=!1;break}if(p){if(!oU(t,function(v,y){if(!hU(p,y)&&(f===v||s(f,v,i,r,a)))return p.push(y)})){u=!1;break}}else if(!(f===m||s(f,m,i,r,a))){u=!1;break}}return a.delete(e),a.delete(t),u}var HA=uU;function pU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var fU=pU;function mU(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var gU=mU,vU=1,yU=2,xU="[object Boolean]",bU="[object Date]",wU="[object Error]",_U="[object Map]",SU="[object Number]",AU="[object RegExp]",MU="[object Set]",EU="[object String]",CU="[object Symbol]",TU="[object ArrayBuffer]",PU="[object DataView]",eb=Xr?Xr.prototype:void 0,Gf=eb?eb.valueOf:void 0;function DU(e,t,i,r,s,a,n){switch(i){case PU:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case TU:return!(e.byteLength!=t.byteLength||!a(new Uu(e),new Uu(t)));case xU:case bU:case SU:return p0(+e,+t);case wU:return e.name==t.name&&e.message==t.message;case AU:case EU:return e==t+"";case _U:var o=fU;case MU:var l=r&vU;if(o||(o=gU),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=yU,n.set(e,t);var d=HA(o(e),o(t),r,s,a,n);return n.delete(e),d;case CU:if(Gf)return Gf.call(e)==Gf.call(t)}return!1}var IU=DU,OU=1,LU=Object.prototype,RU=LU.hasOwnProperty;function BU(e,t,i,r,s,a){var n=i&OU,o=yg(e),l=o.length,h=yg(t),d=h.length;if(l!=d&&!n)return!1;for(var c=l;c--;){var u=o[c];if(!(n?u in t:RU.call(t,u)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var g=n;++c<l;){u=o[c];var v=e[u],y=t[u];if(r)var x=n?r(y,v,u,t,e,a):r(v,y,u,e,t,a);if(!(x===void 0?v===y||s(v,y,i,r,a):x)){m=!1;break}g||(g=u=="constructor")}if(m&&!g){var b=e.constructor,w=t.constructor;b!=w&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return a.delete(e),a.delete(t),m}var zU=BU,NU=1,tb="[object Arguments]",ib="[object Array]",Md="[object Object]",kU=Object.prototype,rb=kU.hasOwnProperty;function UU(e,t,i,r,s,a){var n=Ws(e),o=Ws(t),l=n?ib:yc(e),h=o?ib:yc(t);l=l==tb?Md:l,h=h==tb?Md:h;var d=l==Md,c=h==Md,u=l==h;if(u&&ku(e)){if(!ku(t))return!1;n=!0,d=!1}if(u&&!d)return a||(a=new fu),n||TA(e)?HA(e,t,i,r,s,a):IU(e,t,l,i,r,s,a);if(!(i&NU)){var p=d&&rb.call(e,"__wrapped__"),f=c&&rb.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return a||(a=new fu),s(m,g,i,r,a)}}return u?(a||(a=new fu),zU(e,t,i,r,s,a)):!1}var FU=UU;function WA(e,t,i,r,s){return e===t?!0:e==null||t==null||!Ea(e)&&!Ea(t)?e!==e&&t!==t:FU(e,t,i,r,WA,s)}var VU=WA;function jU(e,t){return e!=null&&t in Object(e)}var GU=jU;function HU(e,t,i){t=eh(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=Pp(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&m0(s)&&u0(n,s)&&(Ws(e)||v0(e)))}var WU=HU;function qU(e,t){return e!=null&&WU(e,t,GU)}var XU=qU,YU=function(){return gs.Date.now()},Hf=YU,QU="Expected a function",ZU=Math.max,KU=Math.min;function JU(e,t,i){var r,s,a,n,o,l,h=0,d=!1,c=!1,u=!0;if(typeof e!="function")throw new TypeError(QU);t=Ix(t)||0,ms(i)&&(d=!!i.leading,c="maxWait"in i,a=c?ZU(Ix(i.maxWait)||0,t):a,u="trailing"in i?!!i.trailing:u);function p(A){var S=r,_=s;return r=s=void 0,h=A,n=e.apply(_,S),n}function f(A){return h=A,o=setTimeout(v,t),d?p(A):n}function m(A){var S=A-l,_=A-h,M=t-S;return c?KU(M,a-_):M}function g(A){var S=A-l,_=A-h;return l===void 0||S>=t||S<0||c&&_>=a}function v(){var A=Hf();if(g(A))return y(A);o=setTimeout(v,m(A))}function y(A){return o=void 0,u&&r?p(A):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?n:y(Hf())}function w(){var A=Hf(),S=g(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)),n}return w.cancel=x,w.flush=b,w}var E0=JU;function $U(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var eF=$U;function tF(e,t){return t.length<2?e:IA(e,j5(t,0,-1))}var iF=tF;function rF(e,t){return VU(e,t)}var qA=rF;function sF(e,t){return t=eh(t,e),e=iF(e,t),e==null||delete e[Pp(eF(t))]}var aF=sF;function nF(e){return F5(e)?void 0:e}var oF=nF,lF=1,hF=2,cF=4,dF=LA(function(e,t){var i={};if(e==null)return i;var r=!1;t=bA(t,function(a){return a=eh(a,e),r||(r=a.length>1),a}),Nc(e,UA(e),i),r&&(i=GA(i,lF|hF|cF,oF));for(var s=t.length;s--;)aF(i,t[s]);return i}),_g=dF;function uF(e,t,i,r){if(!ms(e))return e;t=eh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=Pp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var d=o[l];h=r?r(d,l,o):void 0,h===void 0&&(h=ms(d)?d:u0(t[s+1])?[]:{})}f0(o,l,h),o=o[l]}return e}var pF=uF;function fF(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=IA(e,n);i(o,n)&&pF(a,eh(n,e),o)}return a}var mF=fF;function gF(e,t){return mF(e,t,function(i,r){return XU(e,r)})}var vF=gF,yF=LA(function(e,t){return e==null?{}:vF(e,t)}),Sa=yF,xF="Expected a function";function bF(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(xF);return ms(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),E0(e,t,{leading:r,maxWait:t,trailing:s})}var wF=bF;function _F(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ca(e,t){return Object.setPrototypeOf(e,t),e}var SF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),AF=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),MF=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ip&&"ontouchend"in document,EF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,CF=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,TF=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},PF=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},DF=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},IF=SF(),yY=IF?DF():void 0,Ip=AF(),XA=MF(),OF=EF(),Pr=CF(),sb=TF(),ab=Number(PF());function YA(e){return Array.isArray(e)?e:[e]}function LF(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 Ed(e){return Ip?e.metaKey:e.ctrlKey}var Xe=[],Vu={},qh={},gu={};function QA(e){Xe.includes(e)||Xe.push(e)}function pl(e){delete Vu[e.pointerId];for(let t=0;t<Xe.length;t++)if(Xe[t].pointerId===e.pointerId){Xe.splice(t,1);break}}function RF(){Xe.splice(0,Xe.length)}function ju(e){if(e.pointerType!=="touch")return;let t=Vu[e.pointerId];t===void 0&&(t={x:0,y:0},Vu[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Wf(e){let t=e.pointerId===Xe[0].pointerId?Xe[1]:Xe[0];return Vu[t.pointerId]}function ZA(e){qh[e.key]=!0,gu[e.key]=gu[e.key]===void 0?1:gu[e.key]+1}function KA(e){if(Ip&&qh.Meta)for(let t in qh)qh[t]=!1;else qh[e.key]=!1;gu={}}function BF(e){e.addEventListener("pointerdown",QA,!0),e.addEventListener("pointerdown",ju,!0),e.addEventListener("pointermove",ju,!0),e.addEventListener("pointerup",pl,!0),e.addEventListener("pointercancel",pl,!0),e.addEventListener("pointerleave",pl,!0),window.addEventListener("keydown",ZA,!0),window.addEventListener("keyup",KA,!0)}function zF(e){e.removeEventListener("pointerdown",QA,!0),e.removeEventListener("pointerdown",ju,!0),e.removeEventListener("pointermove",ju,!0),e.removeEventListener("pointerup",pl,!0),e.removeEventListener("pointercancel",pl,!0),e.removeEventListener("pointerleave",pl,!0),window.removeEventListener("keydown",ZA,!0),window.removeEventListener("keyup",KA,!0)}var JA,NF=new Promise(e=>{JA=e}),Cd;function kF(){if(Cd)return Cd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.496/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});JA(n)}return Cd=e(),Cd}var $A,UF=new Promise(e=>{$A=e}),Td;function FF(){if(Td)return Td;async function e(){let t=await import("./physics.js");await t.init(),$A(t)}return Td=e(),Td}var nt=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,nt.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:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,nt.prototype),{data:n,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,nt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function C0(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"&&C0(r)}return Object.freeze(e)}function VF(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 e2=class extends Error{};function qf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Ja(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 a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function T0(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 jF(){return typeof process<"u"}function t2(e,t){for(let i of e)t(i.id,i.data)!==!0&&t2(i.children,t)}function i2(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)i2(i,t)}var mr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,mr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)C0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&i2(i,t)}}traverse(e){t2(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(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,mr.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:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,d)=>h.fi-d.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,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(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,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 e2("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let d=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,u)=>c.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,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)=>VF(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 Ja(0,i,i);{let s=r[0].fi;return Ja(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return Ja(n,n+i,i)}else return Ja(s.fi,a.fi,i)}}},Gu;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(Gu||(Gu={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)C0(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(a=>a.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,We.prototype);let t=e;return jF()||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,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.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 a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,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 Ja(0,t,t);{let r=i[0].fi;return Ja(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return Ja(a,a+t,t)}else return Ja(r.fi,s.fi,t)}}};function Ol(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&&!Ol(i))return null;r+=1}i=i?qf(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=qf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=qf(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 a=Object.setPrototypeOf(i,mi.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},on;(e=>{function t(s,a){return xc(s,a)??s}e.apply=t;function i(s,a){return D0(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=Zi.zoomOnce(l,o[n]),l===void 0)return a;if(!Ol(l))return;n+=1}if(l===void 0)return a;if(Ol(l))if(a.type===0){let h={...a.props};for(let d of Object.keys(l))delete h[d];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=P0([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(on||(on={}));function P0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=xc(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=P0(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function GF(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=xc(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function xc(e,t){if(!Ol(t))return t;if(e instanceof mr){let i=P0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return GF(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=xc(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof mi)return D0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=xc(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function D0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ol(t))return t;if(!Ol(e))return on.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 a=D0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function HF(e,t){let i={cur:[],result:[],len:0};return e=bc(e,t,i)??e,[e,i.result]}function Hu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Wu(e){e&&(e.len-=1)}function WF(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function r2(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=bc(a.data,t,Hu(i,n));Wu(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=r2(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function qF(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=bc(a.data,t,Hu(i,n));return Wu(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function bc(e,t,i){if(e instanceof mr){let r=r2(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return qF(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=bc(a,t,Hu(i,n));return Wu(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!T0(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=bc(n,t,Hu(i,a));Wu(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&WF(i),r}else return}}var Sg;(e=>{function t(i,r){let s=Zi.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(Sg||(Sg={}));var ki;(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 d=h.path;for(var c=[];;){let u;if(l instanceof mi&&h.type===0&&(u=l.runOp({...h,path:d.slice(c.length)}),u===null&&(u=void 0)),u===void 0&&c.length===d.length&&(l instanceof mr||l instanceof We||l instanceof nt?u=l.runOp(h):u=Gu.runOp(l,h)),u!==void 0)if(u!==null){let m=u.data;for(let g=c.length-1;g>=0;g--){let v=d[g],y=c[g];if(y instanceof mr){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof We){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof nt){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof mi){let x={...y,[v]:m};m=Object.setPrototypeOf(x,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 x=m;m=[...y],m[v]=x}else m={...y,[v]:m};else return null}return{data:m,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],f;if(l instanceof mr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof We){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 d=0;d<l.length&&d<h.length;d++)if(l[d]!==h[d])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==h[d])return!1;return!0}e.pathEq=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(d=>h.props[d]!==void 0):!1}e.subsumed=o})(ki||(ki={}));var Ag;(e=>{function t(){return[]}e.empty=t;function i(h,d){let c=[];for(let u of h){let[p,...f]=u.path;p===d&&c.push({...u,path:f})}return c}e.removePrefix=i;function r(h,d){return h.map(c=>({...c,path:[d,...c.path]}))}e.addPrefix=r;function s(h,d){return[...h,...d]}e.concat=s;function a(h,d){return[...h.filter(c=>!d.some(u=>ki.subsumed(c,u))),...d]}e.compress=a;function n(h,d){return h.every(c=>d.every(u=>ki.commutative(c,u)))}e.commutative=n;function o(h,d){for(let c of d){let u=l(h,c);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,d){var c=h;let u=[],p=[];for(let f of d)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=Zi.zoom(c,[...f.path,f.id]),v=ki.apply(c,{...f,type:2})):(m=Zi.zoom(c,[...f.path,f.id,"value"]),v=ki.apply(c,f)),v!==null){c=v.data;let[y,x]=HF(c,{[f.id]:m});c=y;for(let b=0;b<x.length;b++){let w=x[b],A=w.pop();if(typeof A=="number"){let S=[A];for(let M=b+1;M<x.length;M++){let C=x[M],T=C[C.length-1];if(typeof T=="number"&&Zi.equal(w,C.slice(0,C.length-1)))S.push(T),x.splice(M,1);else break}let _=Zi.zoom(c,w);g=_.map((M,C)=>S.includes(C)?f.id:M),m=_,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let S=m,_=Zi.zoom(c,w.slice(0,w.length-2)),M=_.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:S}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(_.layers)),_.layers=M}g=f.id}u.push({type:0,path:w,props:{[A]:m}}),p.push({type:0,path:w,props:{[A]:g}})}p.push(v.reverse),u.push(v.actual)}}else{let m=ki.apply(c,f);m!==null&&(u.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof e2)return null;throw m}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(Ag||(Ag={}));var s2=Symbol(),XF=Symbol(),Op=Symbol(),kc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof n2);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Op];i&&i(),delete this._children[e]}}}},YF=class extends kc{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,Gu.runOp(this._current,e),e.path)}},QF=class extends kc{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,nt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},a2={get(e,t){if(t===Op)return()=>{e._parent=null};if(t===s2)return e._current;if(t===XF)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 a=i[t],n=Lp(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},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]}}},ZF={...a2,set(e,t,i){let r={type:0,props:{[t]:oi(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}},KF={...a2,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}},I0=class extends kc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Op]=()=>{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,a=Lp(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}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)}},O0=class extends kc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Op]=()=>{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,a=Lp(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 Xf(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Zi.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var n2=class extends kc{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){Xf(this.ts,t,e),Xf(this.actual,i,e),Xf(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Lp(e,t,i){return i instanceof mr?new I0(e,t,i):i instanceof We?new O0(e,t,i):i instanceof nt?new Proxy(new QF(e,t,i),KF):i!==null&&typeof i=="object"?T0(i)?i:new Proxy(new YF(e,t,i),ZF):i}function o2(e){let t=new n2(e);return[Lp(t,"",e),t]}function wc(e,t){let[i,r]=o2(e);return t(i),r.result()}function oi(e){return e instanceof I0||e instanceof O0?e._current:e!==null&&typeof e=="object"?e[s2]:e}var Zi;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(d=>{delete h[d]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof mr||a instanceof I0)&&typeof n=="string"||(a instanceof We||a instanceof O0)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(Zi||(Zi={}));function JF(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 Gr(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 l2=class{},nb=class extends l2{constructor(e){super(),this.id=e}},ob=class extends l2{constructor(e){super(),this.data=e}},Mg;try{Mg=new TextDecoder}catch{}var De,ln,K=0,h2=[],Eg=h2,Cg=0,cr={},wt,$a,Fr=0,Ns=0,Mr,Aa,ir=[],St,lb={useRecords:!1,mapsAsObjects:!0},c2=class{},d2=new c2;d2.name="MessagePack 0xC1";var Ll=!1,qu=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(De)return v2(()=>(Pg(),this?this.unpack(e,t):qu.prototype.unpack.call(lb,e,t)));ln=t>-1?t:e.length,K=0,Cg=0,Ns=0,$a=null,Eg=h2,Mr=null,De=e;try{St=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw De=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 qu){if(cr=this,this.structures)return wt=this.structures,Pd();(!wt||wt.length>0)&&(wt=[])}else cr=lb,(!wt||wt.length>0)&&(wt=[]);return Pd()}unpackMultiple(e,t){let i,r=0;try{Ll=!0;let s=e.length,a=this?this.unpack(e,s):Bp.unpack(e,s);if(t){for(t(a);K<s;)if(r=K,t(Pd())===!1)return}else{for(i=[a];K<s;)r=K,i.push(Pd());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Ll=!1,Pg()}}_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 Pd(){try{if(!cr.trusted&&!Ll){let t=wt.sharedLength||0;t<wt.length&&(wt.length=t)}let e=Wt();if(K==ln)wt.restoreStructures&&hb(),wt=null,De=null,Aa&&(Aa=null);else if(K>ln){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ll)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw wt.restoreStructures&&hb(),Pg(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function hb(){for(let e in wt.restoreStructures)wt[e]=wt.restoreStructures[e];wt.restoreStructures=null}function Wt(){let e=De[K++];if(e<160)if(e<128){if(e<64)return e;{let t=wt[e&63]||cr.getStructures&&u2()[e&63];return t?(t.read||(t.read=L0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,cr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[f2()]=Wt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Wt(),Wt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Wt();return t}else if(e<192){let t=e-160;if(Ns>=K)return $a.slice(K-Fr,(K+=t)-Fr);if(Ns==0&&ln<140){let i=t<16?R0(t):p2(t);if(i!=null)return i}return Tg(t)}else{let t;switch(e){case 192:return null;case 193:return Mr?(t=Wt(),t>0?Mr[1].slice(Mr.position1,Mr.position1+=t):Mr[0].slice(Mr.position0,Mr.position0-=t)):d2;case 194:return!1;case 195:return!0;case 196:return Yf(De[K++]);case 197:return t=St.getUint16(K),K+=2,Yf(t);case 198:return t=St.getUint32(K),K+=4,Yf(t);case 199:return Pn(De[K++]);case 200:return t=St.getUint16(K),K+=2,Pn(t);case 201:return t=St.getUint32(K),K+=4,Pn(t);case 202:if(t=St.getFloat32(K),cr.useFloat32>2){let i=B0[(De[K]&127)<<1|De[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=St.getFloat64(K),K+=8,t;case 204:return De[K++];case 205:return t=St.getUint16(K),K+=2,t;case 206:return t=St.getUint32(K),K+=4,t;case 207:return cr.int64AsNumber?(t=St.getUint32(K)*4294967296,t+=St.getUint32(K+4)):t=St.getBigUint64(K),K+=8,t;case 208:return St.getInt8(K++);case 209:return t=St.getInt16(K),K+=2,t;case 210:return t=St.getInt32(K),K+=4,t;case 211:return cr.int64AsNumber?(t=St.getInt32(K)*4294967296,t+=St.getUint32(K+4)):t=St.getBigInt64(K),K+=8,t;case 212:if(t=De[K++],t==114)return fb(De[K++]&63);{let i=ir[t];if(i)return i.read?(K++,i.read(Wt())):i.noBuffer?(K++,i()):i(De.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=De[K],t==114?(K++,fb(De[K++]&63,De[K++])):Pn(2);case 214:return Pn(4);case 215:return Pn(8);case 216:return Pn(16);case 217:return t=De[K++],Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):e6(t);case 218:return t=St.getUint16(K),K+=2,Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):t6(t);case 219:return t=St.getUint32(K),K+=4,Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):i6(t);case 220:return t=St.getUint16(K),K+=2,db(t);case 221:return t=St.getUint32(K),K+=4,db(t);case 222:return t=St.getUint16(K),K+=2,ub(t);case 223:return t=St.getUint32(K),K+=4,ub(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 $F=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function L0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>$F.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Wt);return e.highByte===0&&(e.read=cb(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Wt()}return r}return i.count=0,e.highByte===0?cb(t,i):i}var cb=(e,t)=>function(){let i=De[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=wt[r]||u2()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=L0(s,e)),s.read()};function u2(){let e=v2(()=>(De=null,cr.getStructures()));return wt=cr._mergeStructures(e,wt)}var Tg=Rp,e6=Rp,t6=Rp,i6=Rp;function Rp(e){let t;if(e<16&&(t=R0(e)))return t;if(e>64&&Mg)return Mg.decode(De.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=De[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=De[K++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=De[K++]&63,n=De[K++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=De[K++]&63,n=De[K++]&63,o=De[K++]&63,l=(s&7)<<18|a<<12|n<<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+=wi.apply(String,r),r.length=0)}return r.length>0&&(t+=wi.apply(String,r)),t}function db(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Wt();return t}function ub(e){if(cr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[f2()]=Wt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Wt(),Wt());return t}}var wi=String.fromCharCode;function p2(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=De[K++];if((s&128)>0){K=t;return}i[r]=s}return wi.apply(String,i)}function R0(e){if(e<4)if(e<2){if(e===0)return"";{let t=De[K++];if((t&128)>1){K-=1;return}return wi(t)}}else{let t=De[K++],i=De[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return wi(t,i);let r=De[K++];if((r&128)>0){K-=3;return}return wi(t,i,r)}else{let t=De[K++],i=De[K++],r=De[K++],s=De[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return wi(t,i,r,s);{let a=De[K++];if((a&128)>0){K-=5;return}return wi(t,i,r,s,a)}}else if(e<8){let a=De[K++],n=De[K++];if((a&128)>0||(n&128)>0){K-=6;return}if(e<7)return wi(t,i,r,s,a,n);let o=De[K++];if((o&128)>0){K-=7;return}return wi(t,i,r,s,a,n,o)}else{let a=De[K++],n=De[K++],o=De[K++],l=De[K++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return wi(t,i,r,s,a,n,o,l);{let h=De[K++];if((h&128)>0){K-=9;return}return wi(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=De[K++],d=De[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return wi(t,i,r,s,a,n,o,l,h,d);let c=De[K++];if((c&128)>0){K-=11;return}return wi(t,i,r,s,a,n,o,l,h,d,c)}else{let h=De[K++],d=De[K++],c=De[K++],u=De[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return wi(t,i,r,s,a,n,o,l,h,d,c,u);{let p=De[K++];if((p&128)>0){K-=13;return}return wi(t,i,r,s,a,n,o,l,h,d,c,u,p)}}else{let p=De[K++],f=De[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return wi(t,i,r,s,a,n,o,l,h,d,c,u,p,f);let m=De[K++];if((m&128)>0){K-=15;return}return wi(t,i,r,s,a,n,o,l,h,d,c,u,p,f,m)}}}}}function Yf(e){return cr.copyBuffers?Uint8Array.prototype.slice.call(De,K,K+=e):De.subarray(K,K+=e)}function Pn(e){let t=De[K++];if(ir[t])return ir[t](De.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var pb=new Array(4096);function f2(){let e=De[K++];if(e>=160&&e<192){if(e=e-160,Ns>=K)return $a.slice(K-Fr,(K+=e)-Fr);if(!(Ns==0&&ln<180))return Tg(e)}else return K--,Wt();let t=(e<<5^(e>1?St.getUint16(K):e>0?De[K]:0))&4095,i=pb[t],r=K,s=K+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=St.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=De[r++],a!=i[n++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],pb[t]=i,i.bytes=e;r<s;)a=St.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=De[r++],i.push(a);let o=e<16?R0(e):p2(e);return o!=null?i.string=o:i.string=Tg(e)}var fb=(e,t)=>{var i=Wt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=wt[e];return s&&s.isShared&&((wt.restoreStructures||(wt.restoreStructures=[]))[e]=s),wt[e]=i,i.read=L0(i,r),i.read()},m2=typeof self=="object"?self:global;ir[0]=()=>{};ir[0].noBuffer=!0;ir[101]=()=>{let e=Wt();return(m2[e[0]]||Error)(e[1])};ir[105]=e=>{let t=St.getUint32(K-4);Aa||(Aa=new Map);let i=De[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Aa.set(t,s);let a=Wt();return s.used?Object.assign(r,a):(s.target=a,a)};ir[112]=e=>{let t=St.getUint32(K-4),i=Aa.get(t);return i.used=!0,i.target};ir[115]=()=>new Set(Wt());var g2=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");ir[116]=e=>{let t=e[0],i=g2[t];if(!i)throw new Error("Could not find typed array for code "+t);return new m2[i](Uint8Array.prototype.slice.call(e,1).buffer)};ir[120]=()=>{let e=Wt();return new RegExp(e[0],e[1])};ir[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,Mr=[Wt(),Wt()],Mr.position0=0,Mr.position1=0;let r=K;K=i;try{return Wt()}finally{K=r}};ir[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 v2(e){let t=ln,i=K,r=Cg,s=Fr,a=Ns,n=$a,o=Eg,l=Aa,h=Mr,d=new Uint8Array(De.slice(0,ln)),c=wt,u=wt.slice(0,wt.length),p=cr,f=Ll,m=e();return ln=t,K=i,Cg=r,Fr=s,Ns=a,$a=n,Eg=o,Aa=l,Mr=h,De=d,Ll=f,wt=c,wt.splice(0,wt.length,...u),cr=p,St=new DataView(De.buffer,De.byteOffset,De.byteLength),m}function Pg(){De=null,Aa=null,wt=null}function r6(e){e.unpack?ir[e.type]=e.unpack:ir[e.type]=e}var B0=new Array(147);for(let e=0;e<256;e++)B0[e]=+("1e"+Math.floor(45.15-e*.30103));var Bp=new qu({useRecords:!1}),xY=Bp.unpack,bY=Bp.unpackMultiple,wY=Bp.unpack,s6={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},a6=new Float32Array(1),_Y=new Uint8Array(a6.buffer,0,4),vu;try{vu=new TextEncoder}catch{}var Xu,z0,zp=typeof Buffer<"u",Qf=zp?Buffer.allocUnsafeSlow:Uint8Array,y2=zp?Buffer:Uint8Array,mb=zp?4294967296:2144337920,ce,Qt,te=0,bs,ws=null,n6=/[\u0080-\uFFFF]/,Mh=Symbol("record-id"),x2=class extends qu{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=y2.prototype.utf8Write?function(S,_,M){return ce.utf8Write(S,_,M)}:vu&&vu.encodeInto?function(S,_){return vu.encodeInto(S,ce.subarray(_)).written}:!1,h=this;e||(e={});let d=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),d&&!e.saveStructures&&(this.structures=[]);let f=u>32||p+u>64,m=u+64,g=u+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,_){if(ce||(ce=new Qf(8192),Qt=new DataView(ce.buffer,0,8192),te=0),bs=ce.length-10,bs-te<2048?(ce=new Qf(ce.length),Qt=new DataView(ce.buffer,0,ce.length),bs=ce.length-10,te=0):te=te+7&2147483640,i=te,n=h.structuredClone?new Map:null,h.bundleStrings?(ws=["",""],ce[te++]=214,ce[te++]=98,ws.position=te-i,te+=4):ws=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let O=0,B=T.length;O<B;O++){let G=T[O];D=P[G],D||(D=P[G]=Object.create(null)),P=D}P[Mh]=C+64}o=M}d||(r.nextId=M+64)}s&&(s=!1),a=r||[];try{if(b(S),ws){Qt.setUint32(ws.position+i,te-ws.position-i);let M=ws;ws=null,b(M[0]),b(M[1])}if(h.offset=te,n&&n.idsToInsert){te+=n.idsToInsert.length*6,te>bs&&A(te),h.offset=te;let M=l6(ce.subarray(i,te),n.idsToInsert);return n=null,M}return _&h6?(ce.start=i,ce.end=te,ce):ce.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,C=v.length;M<C;M++)v[M][Mh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||u;r.length>M&&(r=r.slice(0,M));let C=ce.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}_&c6&&(te=i)}};let b=S=>{te>bs&&(ce=A(te));var _=typeof S,M;if(_==="string"){let C=S.length;if(ws&&C>=8&&C<4096){let P=n6.test(S);ws[P?0:1]+=S,ce[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>bs&&(ce=A(te+D)),C<64||!l){let P,O,B,G=te+T;for(P=0;P<C;P++)O=S.charCodeAt(P),O<128?ce[G++]=O:O<2048?(ce[G++]=O>>6|192,ce[G++]=O&63|128):(O&64512)===55296&&((B=S.charCodeAt(P+1))&64512)===56320?(O=65536+((O&1023)<<10)+(B&1023),P++,ce[G++]=O>>18|240,ce[G++]=O>>12&63|128,ce[G++]=O>>6&63|128,ce[G++]=O&63|128):(ce[G++]=O>>12|224,ce[G++]=O>>6&63|128,ce[G++]=O&63|128);M=G-te-T}else M=l(S,te+T,D);M<32?ce[te++]=160|M:M<256?(T<2&&ce.copyWithin(te+2,te+1,te+1+M),ce[te++]=217,ce[te++]=M):M<65536?(T<3&&ce.copyWithin(te+3,te+2,te+2+M),ce[te++]=218,ce[te++]=M>>8,ce[te++]=M&255):(T<5&&ce.copyWithin(te+5,te+3,te+3+M),ce[te++]=219,Qt.setUint32(te,M),te+=4),te+=M}else if(_==="number")if(S>>>0===S)S<64?ce[te++]=S:S<256?(ce[te++]=204,ce[te++]=S):S<65536?(ce[te++]=205,ce[te++]=S>>8,ce[te++]=S&255):(ce[te++]=206,Qt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?ce[te++]=256+S:S>=-128?(ce[te++]=208,ce[te++]=S+256):S>=-32768?(ce[te++]=209,Qt.setInt16(te,S),te+=2):(ce[te++]=210,Qt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){ce[te++]=202,Qt.setFloat32(te,S);let T;if(C<4||(T=S*B0[(ce[te]&127)<<1|ce[te+1]>>7])>>0===T){te+=4;return}else te--}ce[te++]=203,Qt.setFloat64(te,S),te+=8}else if(_==="object")if(!S)ce[te++]=192;else{if(n){let T=n.get(S);if(T){if(!T.id){let D=n.idsToInsert||(n.idsToInsert=[]);T.id=D.push(T)}ce[te++]=214,ce[te++]=112,Qt.setUint32(te,T.id),te+=4;return}else n.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)w(S,!0);else if(C===Array){M=S.length,M<16?ce[te++]=144|M:M<65536?(ce[te++]=220,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=221,Qt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(S[T])}else if(C===Map){M=S.size,M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,Qt.setUint32(te,M),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Xu.length;T<D;T++){let P=z0[T];if(S instanceof P){let O=Xu[T];if(O.write){O.type&&(ce[te++]=212,ce[te++]=O.type,ce[te++]=0),b(O.write.call(this,S));return}let B=ce,G=Qt,F=te;ce=null;let z;try{z=O.pack.call(this,S,X=>(ce=B,B=null,te+=X,te>bs&&A(te),{target:ce,targetView:Qt,position:te-X}),b)}finally{B&&(ce=B,Qt=G,te=F,bs=ce.length-10)}z&&(z.length+te>bs&&A(z.length+te),te=o6(z,ce,te,O.type));return}}w(S,!S.hasOwnProperty)}}else if(_==="boolean")ce[te++]=S?195:194;else if(_==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))ce[te++]=211,Qt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)ce[te++]=207,Qt.setBigUint64(te,S);else if(this.largeBigIntToFloat)ce[te++]=203,Qt.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?ce[te++]=192:(ce[te++]=212,ce[te++]=0,ce[te++]=0);else if(_==="function")b(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?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,Qt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=_[T]),b(S[C])}:(S,_)=>{ce[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(_||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);ce[M+++i]=C>>8,ce[M+i]=C&255}:S=>{let _=Object.keys(S),M,C=a.transitions||(a.transitions=Object.create(null)),T=0;for(let P=0,O=_.length;P<O;P++){let B=_[P];M=C[B],M||(M=C[B]=Object.create(null),T++),C=M}let D=C[Mh];if(D)D>=96&&f?(ce[te++]=((D-=96)&31)+96,ce[te++]=D>>5):ce[te++]=D;else{D=a.nextId,D||(D=64),D<m&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(D=a.nextOwnId,D<g||(D=m),a.nextOwnId=D+1):(D>=g&&(D=m),a.nextId=D+1);let P=_.highByte=D>=96&&f?D-96>>5:-1;C[Mh]=D,a[D-64]=_,D<m?(_.isShared=!0,a.sharedLength=D-63,s=!0,P>=0?(ce[te++]=(D&31)+96,ce[te++]=P):ce[te++]=D):(P>=0?(ce[te++]=213,ce[te++]=114,ce[te++]=(D&31)+96,ce[te++]=P):(ce[te++]=212,ce[te++]=114,ce[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[Mh]=0),v.push(C),b(_))}for(let P=0,O=_.length;P<O;P++)b(S[_[P]])},A=S=>{let _;if(S>16777216){if(S-i>mb)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(mb,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(S-i<<2,ce.length-1)>>12)+1<<12;let M=new Qf(_);return Qt=new DataView(M.buffer,0,_),ce.copy?ce.copy(M,0,i,S):M.set(ce.slice(i,S)),te-=i,i=0,bs=M.length-10,ce=M}}useBuffer(e){ce=e,Qt=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),te=0}};z0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,c2];Xu=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=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?gb(e,16,t):vb(zp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==y2&&this.structuredClone?gb(e,g2.indexOf(i.name),t):vb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function gb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function vb(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:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function o6(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 l6(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function ih(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)");z0.unshift(e.Class),Xu.unshift(e)}r6(e)}var b2=new x2({useRecords:!1}),SY=b2.pack,AY=b2.pack,{NEVER:MY,ALWAYS:EY,DECIMAL_ROUND:CY,DECIMAL_FIT:TY}=s6,h6=512,c6=1024,yb=new x2({structuredClone:!0});ih({Class:nt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,nt.prototype),e}});ih({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});ih({Class:mr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,mr.prototype),e}});ih({Class:nb.prototype.constructor,type:4,write(e){return e.id},read(e){return new nb(e)}});ih({Class:ob.prototype.constructor,type:5,write(e){return e.data},read(e){return new ob(e)}});ih({Class:mi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,mi.prototype),e}});function d6(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 Dg(e){if(T0(e))return e;if(Array.isArray(e))return e.map(Dg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Dg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Ig;(e=>{function t(s){return yb.pack(s)}e.serialize=t;function i(s){return yb.unpack(s)}e.deserialize=i;function r(s){return d6(t(Dg(s))).toString()}e.checksum=r})(Ig||(Ig={}));var xb;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(xb||(xb={}));var Ar={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Create","Conditional"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},bb;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new We}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new We}}e.defaultData=i})(bb||(bb={}));var Yu;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Yu||(Yu={}));var Og;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Yu.propertyDefaultData(s),rOperand:{...Yu.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(Og||(Og={}));var wb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:Og.distanceDefaultData(r)}}e.defaultData=i})(wb||(wb={}));var _b;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(_b||(_b={}));var Lg;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(Lg||(Lg={}));var Rg;(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})(Rg||(Rg={}));var Sb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(Sb||(Sb={}));var Ab;(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 We}}e.defaultData=i})(Ab||(Ab={}));var Mb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(Mb||(Mb={}));var Eb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new We}}e.defaultData=i})(Eb||(Eb={}));var Cb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(Cb||(Cb={}));var Bg;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Re.generateUUID(),fi:0,data:n},{id:Re.generateUUID(),fi:1,data:o},{id:Re.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(Bg||(Bg={}));var zg;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(zg||(zg={}));var rh="personal camera",sc="a218fcc3-276b-49b9-b485-49037fd14f5f",u6=2960946,Yr=5526619,ol;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a]}e.lerp=i})(ol||(ol={}));var Kn;(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 a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,d){return[l[0]+(h[0]-l[0])*d,l[1]+(h[1]-l[1])*d,l[2]+(h[2]-l[2])*d]}e.lerp=o})(Kn||(Kn={}));var Qu;(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,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(Qu||(Qu={}));var Rl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})(Rl||(Rl={}));var Yi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Yi||(Yi={}));var hs;(e=>{e.white={...Yi.white,a:1},e.transparent={...Yi.white,a:0};function t(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}e.from0to1=t;function i(n,o){return{...Yi.fromHex(n),a:o}}e.fromHexAndA=i;function r(n){return{r:Math.round(n.r*255),g:Math.round(n.g*255),b:Math.round(n.b*255),a:n.a}}e.toRgb255a1=r;function s(n,o){return Yi.equals(n,o)&&n.a===o.a}e.equals=s;function a(n,o,l){return{r:n.r+(o.r-n.r)*l,g:n.g+(o.g-n.g)*l,b:n.b+(o.b-n.b)*l,a:n.a+(o.a-n.a)*l}}e.lerp=a})(hs||(hs={}));var Ng;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Ng||(Ng={}));var Tb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Tb||(Tb={}));var Pb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(Pb||(Pb={}));var qa;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(qa||(qa={}));function p6(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var ao;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(ao||(ao={}));var Bl;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Bl||(Bl={}));var en;(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(a=>a*(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 a={...r};if(w2.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;_2.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;S2.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;A2.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;M2.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;E2.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(en||(en={}));var kg;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(kg||(kg={}));var w2=["count"],_2=["radius","start","end","position","scale","rotation"],S2=["position","scale","rotation"],A2=["count","size"],M2=["count","position","scale","rotation"],E2=["strength","scale","rotation","position","movement","seed","freqScale"],Ug;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Ug||(Ug={}));var Fg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:hs.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:hs.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:hs.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Fg||(Fg={}));var zl;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(zl||(zl={}));var Vg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Vg||(Vg={}));var jg;(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})(jg||(jg={}));var Gg;(e=>e.defaultData={...jg.defaultData,...Vg.defaultData})(Gg||(Gg={}));var Db;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(Db||(Db={}));var Zu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Zu||(Zu={}));var Ib;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(Ib||(Ib={}));function f6(e){return e.type!=="displace"}var Ob;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(Ob||(Ob={}));var C2=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],m6=["wrapping","image","video","name"],lr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Zu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...n,type:"color",color:Yi.fromHex(Yr)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Yi.fromHex(6710886),a:1},colorB:{...Yi.fromHex(6710886),a:1},colorC:{...Yi.fromHex(16777215),a:1},colorD:{...Yi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:hs.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:hs.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:hs.fromHexAndA(0,1),contourColor:hs.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Yi.fromHex(0),a:1},colorB:{...Yi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(lr||(lr={}));var Fi;(e=>{function t(h){return!h.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(h){let d="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([u,p])=>{d+=`${u}${p}`,Array.isArray(p)?p.forEach(f=>d+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?d+=`${f.toFixed(4)}`:d+=`${f}`}):d+=`${p}`})}),d}e.getHash=i;function r(){return{layers:new We}}e.defaultEmptyData=r;function s(h="layer1",d="layer2"){return n("phong",h,d)}e.defaultData=s;function a(h,d){return{...h,name:d}}e.withName=a;function n(h,d="layer1",c="layer2"){let u=new We;return u.push({fi:0,data:lr.defaultData("light",h),id:d}),u.push({fi:1,data:lr.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=n;function o(h,d="phong",c="layer1",u="layer2"){let p=lr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new We;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:lr.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=lr.defaultData("video");Object.assign(p.texture,{video:h});let f=new We;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:lr.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(Fi||(Fi={}));var Ku;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Ku||(Ku={}));var Ju;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Ju||(Ju={}));var T2={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Hg;(e=>{function t(i,r){let s={...i};return D2.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(Hg||(Hg={}));var P2={shape:T2,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},D2=["depth","offset","angle","twist","startScale","endScale"],$u;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})($u||($u={}));var Wg;(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,Hg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Wg||(Wg={}));var fl;(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:Ju.defaultData(),extrusion:P2};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Ku.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:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(fl||(fl={}));var Lb=["width","height","depth"],qg;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Yi.white,near:.1,far:2e3})(qg||(qg={}));var ep;(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}}})(ep||(ep={}));var Xg;(e=>e.defaultData={softShadowQuality:"low"})(Xg||(Xg={}));var Yg;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Yg||(Yg={}));var Qg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qg||(Qg={}));var Nl;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Nl||(Nl={}));var Zg;(e=>e.defaultData={playCamera:rh,gameControlObject:null})(Zg||(Zg={}));var Kg;(e=>e.defaultData={backgroundColor:hs.fromHexAndA(u6,1),postprocessing:ep.defaultData,fog:qg.defaultData,globalPhysics:Nl.defaultData,ambient:Yg.defaultData,ao:Qg.defaultData,shadow:Xg.defaultData,publish:Zg.defaultData})(Kg||(Kg={}));var Rb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(Rb||(Rb={}));var kl;(e=>{e.identity={...Ng.identity,hiddenMatrix:Rl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return _F({position:Kn.isEqual(s.position,a.position)?void 0:a.position,rotation:Kn.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:Kn.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Rl.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(kl||(kl={}));var tr;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:zl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...kl.identity,cloner:null})(tr||(tr={}));var Jg;(e=>e.defaultData={type:"Empty",...tr.defaultData})(Jg||(Jg={}));var Bb;(e=>e.defaultData={type:"Component",...tr.defaultData})(Bb||(Bb={}));var ml;(e=>e.defaultData={type:"Mesh",...tr.defaultData,...Gg.defaultData})(ml||(ml={}));var _c;(e=>e.defaultData={...tr.defaultData,...kl.identity,position:[0,0,Bl.DefaultTargetOffset],...Bl.defaultData})(_c||(_c={}));var $g;(e=>{function t(i){return{...tr.defaultData,...Fg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($g||($g={}));var tp;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(tp||(tp={}));var tn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...tr.defaultData,...s,component:r,overrides:new mi,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=kl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(tn||(tn={}));var Ul;(e=>e.defaultData={type:"Page",...tr.defaultData,physics:{...zl.defaultData,fusedBody:!1},...Kg.defaultData,camera:_c.defaultData})(Ul||(Ul={}));var ev;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Rl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:zl.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Bl.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",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("RectangleGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("BooleanGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("TextGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var Gn;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new mi}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new mi})))):ao.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=wc(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&lr.patch(c,d)}}).data),o.materials&&n.materials&&(o.materials=wc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[c,u]of Object.entries(d.layers)){let p=l[h]?.layers?.data(c);p&&lr.patch(p,u)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function d(c,u){for(let[p,f]of Object.entries(u.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...c,"layers",p],props:g,type:0};l.push(v)}}}for(let[c,u]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...kg.toOps(u,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:u.slide,offset:u.offset},type:0});else if(c==="material")d(["material"],u);else if(c==="materials")for(let[p,f]of Object.entries(u))d(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&u.extrusion!==void 0){let p={path:[c,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[c],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=u;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,kl.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),ao.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;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(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:Wg.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:en.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:en.merge(o.cloner,n.cloner)});else if(Ug.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Yi.clone(l.color))}return o}e.patch=s})(Gn||(Gn={}));var ip;(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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ip||(ip={}));var Jn;(e=>e.defaultData={orbitControls:ip.defaultData,playPage:sc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Jn||(Jn={}));var tv;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(tv||(tv={}));var iv;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(iv||(iv={}));var gl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...tv.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:iv.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(gl||(gl={}));var Sc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=np.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Sc||(Sc={}));var vl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=ev.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:$g.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new mr;return o.push({fi:1,id:sc,data:{...Ul.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:Jn.defaultData,styles:gl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new mr,publish:Jn.defaultData,styles:gl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Jn.defaultData,styles:gl.defaultData()}};function i(s){return{...e.defaultData,objects:Ca(s,mr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(vl||(vl={}));var ac;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ac||(ac={}));var rp;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(rp||(rp={}));var Dr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(Dr||(Dr={}));var rv;(e=>e.all=["images","videos","colors","audios","fonts","materials","variables"])(rv||(rv={}));var zb;(e=>e.all=[...rv.all,"components"])(zb||(zb={}));var Nb;(e=>{function t(){return{images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,materials:new nt,components:new nt,variables:new nt}}e.defaultData=t})(Nb||(Nb={}));var Fl;(e=>{function t(){return{images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,materials:new nt,components:new nt,variables:new nt}}e.defaultData=t})(Fl||(Fl={}));var ns;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ca(n,nt.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...rp.emptyImage,name:"AI generated image"}),Ca(o,nt.prototype)}e.defaultImages=i;function r(){return{catelogs:new nt,materials:new nt,images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,variables:new We,lib:Fl.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),d=Math.round(n-l*3600-h*60);return{textValue:[l,h,d]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(ns||(ns={}));var sp;(e=>e.list=["idle","move","jump","run"])(sp||(sp={}));var ap;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:hs.fromHexAndA(3728051,1)}}))(ap||(ap={}));function kb(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]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Sa(oi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...oi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Xa(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Ya(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Fi.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Fi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Fi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function g6(e){Object.assign(e.scene.publish,{orbitControls:{...ip.defaultData,...oi(e.scene.publish.orbitControls)}})}function v6(e){Object.assign(e.scene.publish.settings,{video:{...Jn.defaultData.settings.video,...oi(e.scene.publish.settings.video)}})}function y6(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((C2.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(m6.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function x6(e){e.scene.publish.withBackground=!0}function b6(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function w6(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 _6(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 S6(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=oi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=oi(i).booleanExclude!==!0)}})}function A6(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 M6(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(a=>{let n=a;if(n.material){let o=oi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=oi(l).layers;i(h),l.layers=h}})})}function Ub(e){e.layers===void 0&&Object.assign(e,Fi.defaultTwoLayerData("lambert"))}function Zf(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={...oi(t),colors:i,steps:r};Object.assign(t,s)}})}function E6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Fb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Zf(r)}):"material"in i&&typeof i.material!="string"&&Zf(i.material)}),Object.values(e.shared.materials).forEach(t=>Zf(t))}function C6(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 T6(e){e.shared.audios=Ca({},nt.prototype)}function P6(e){e.shared.videos=Ca({},nt.prototype)}function D6(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 I6(e){Object.entries(oi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(oi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function O6(e){e.scene.publish.settings.web.preload=!1}function Vb(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 jb(e){e.layers&&e.layers.forEach(t=>{f6(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function L6(e){e.shared.fonts=Ca({},nt.prototype)}function R6(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 B6(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Fi.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=R6(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...tr.defaultData,...ml.defaultData,flatShading:!1,wireframe:!1,geometry:{...fl.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:a,states:oi(s.states),events:oi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=oi(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 z6(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 We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Re.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(d,Sa(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(d,{control1:{...n.control1},control2:{...n.control2}});let c={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...c,...d},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Re.generateUUID(),data:h},{fi:1,id:Re.generateUUID(),data:u})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function N6(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new We,o=[];if(i.events.forEach((l,h,d)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...Sa(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={...Sa(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:d,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Re.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Gb(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=lr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Hb(e){Xa(e,Gb),Ya(e,Gb)}function k6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function U6(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 F6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Fi.defaultTwoLayerData("phong"))})}function V6(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 j6(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 G6(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function H6(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function W6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function q6(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function X6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=ap.defaultDataThirdPerson.navmesh)})})}function Y6(e){e.scene.styles||(e.scene.styles=gl.defaultData())}function Wb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Q6(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Ya(e,Wb),Xa(e,Wb)}function Z6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function K6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function qb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function J6(e,t){if(t<1&&(Ya(e,kb),Xa(e,kb),e.schema=1),t<2&&(g6(e),e.schema=2),t<3&&(y6(e),e.schema=3),t<4&&(x6(e),e.schema=4),t<5&&(b6(e),e.schema=5),t<6&&(w6(e),e.schema=6),t<7&&(_6(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Fb(e),e.schema=9),t<10&&(E6(e),e.schema=10),t<11&&(C6(e),e.schema=11),t<12&&(Fb(e),e.schema=12),t<13&&(T6(e),e.schema=13),t<14&&(D6(e),e.schema=14),t<15&&(I6(e),e.schema=15),t<16&&(O6(e),e.schema=16),t<17&&(Ya(e,Vb),Xa(e,Vb),e.schema=17),t<18&&(Ya(e,Ub),Xa(e,Ub),e.schema=18),t<19&&(v6(e),e.schema=19),t<20&&(L6(e),B6(e),e.schema=20),t<21&&(z6(e),N6(e),e.schema=21),t<22&&(Hb(e),e.schema=22),t<23&&(k6(e),e.schema=23),t<24&&(U6(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(P6(e),t<25&&(e.schema=25)),t<26&&(S6(e),e.schema=26),t<27&&(A6(e),e.schema=27),t<28&&(Hb(e),e.schema=28),t<29&&(M6(e),e.schema=29),t<30&&(F6(e),e.schema=30),t<31&&(V6(e),e.schema=31),t<33&&(j6(e),e.schema=33),t<34&&(G6(e),e.schema=34),t<35&&(H6(e),e.schema=35),t<36&&(W6(e),e.schema=36),t<37&&(q6(e),e.schema=37),t<38&&(Ya(e,jb),Xa(e,jb),e.schema=38),t<39&&(X6(e),e.schema=39),t<40&&(Y6(e),e.schema=40),t<41&&(Q6(e),e.schema=41),t<42&&(Z6(e),e.schema=42),t<43&&(K6(e),e.schema=43),t<99){Ya(e,qb),Xa(e,qb),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=rh);let i=oi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=sc,r.insertBefore(null,null,[{id:sc,data:{...Ul.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Sa(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Sa(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Nl.defaultData,...Sa(e.scene.environment,"usePhysics","gravity")},camera:oi(e.scene.ownerCamera)??Ul.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==vl.TRASH_CAN_ID&&r.move(sc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,zl.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function Xb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function $6(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var Jo=180/Math.PI;function Yb(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Jo)}function I2(e){Yb(e),e.type==="Page"&&Yb(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Jo))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=t.thetaLength*Jo),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Jo),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Jo,t.extrusion.twist*=Jo),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(oi(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Once")})}function eV(e){e.shared.variables=Ca({},nt.prototype)}function tV(e){let t=oi(e.shared.variables);e.shared.variables=Ca(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var Qa=107;function O2(e,t){t(e.data);for(let i of e.children)O2(i,t)}function iV(e){let t=e.schema??104;t!==Qa&&t<105&&(O2(e.asset,I2),e.schema=105)}function L2(e){let t=e.schema??0;if(t!==Qa){console.warn("updating from ",t,"to ",Qa),J6(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Jn.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Ya(e,Xb),Xa(e,Xb),e.schema=101),t<102&&($6(e),e.schema=102),t<104&&(e.shared.catelogs=new nt,e.shared.lib=Fl.defaultData(),e.schema=104),t<105&&(eV(e),e.scene.objects.traverse((i,r)=>{I2(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))iV(i);t<106&&(tV(e),e.schema=106),t<107&&(e.shared.lib.variables=Fl.defaultData().variables,e.schema=107)}}var np;(e=>{e.defaultData={schema:Qa,scene:vl.defaultData,frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:{...ns.emptyData(),colors:ns.defaultColors()}},e.emptyDataForImports=function(s){let a=vl.emptyDataWithPage(s);return{schema:Qa,scene:a,frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:{...ns.emptyData(),colors:ns.defaultColors(),images:ns.defaultImages(s)}}},e.emptyData=function(){return{schema:Qa,scene:vl.emptyDataWithPage(),frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:ns.emptyData()}},e.collabHelper={...Ag,updateSchema(s){return(s.schema??0)<Qa?wc(s,L2):(s.schema??0)-Qa}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Fl.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(np||(np={}));function Hn(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)),a={},n={},o=e[0].morphTargetsRelative,l=new Ue,h=0;for(let d=0;d<e.length;++d){let c=e[d],u=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". 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 "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". 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 "+d+". .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 "+d+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[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 "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,d),h+=p}}if(i){let d=0,c=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+d);d+=e[u].attributes.position.count}l.setIndex(c)}for(let d in a){let c=Qb(a[d]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,c)}for(let d in n){let c=n[d][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<c;++u){let p=[];for(let m=0;m<n[d].length;++m)p.push(n[d][m][u]);let f=Qb(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(f)}}return l}function Qb(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 a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Ke(a,i,r)}var rV=Math.pow(2,-24),Dd=class{constructor(){}};function ks(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function Zb(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Kb(e,t){t.set(e)}function Jb(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function Id(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Eh(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 sV(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 Ke(s,1));for(let a=0;a<i;a++)s[a]=a}}function aV(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,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function Kf(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0,c=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],w=e[y+1],A=b-w,S=b+w;A<a&&(a=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let _=e[y+2],M=e[y+3],C=_-M,T=_+M;C<n&&(n=C),T>h&&(h=T),v&&_<u&&(u=_),v&&_>m&&(m=_);let D=e[y+4],P=e[y+5],O=D-P,B=D+P;O<o&&(o=O),B>d&&(d=B),v&&D<p&&(p=D),v&&D>g&&(g=D)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=d,v&&(s[0]=c,s[1]=u,s[2]=p,s[3]=f,s[4]=m,s[5]=g)}function nV(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let d=t*6,c=(t+i)*6;d<c;d+=6){let u=e[d+0];u<s&&(s=u),u>o&&(o=u);let p=e[d+2];p<a&&(a=p),p>l&&(l=p);let f=e[d+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function oV(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let d=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=d;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;let u=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=u}a++,n--}else return a}}var da=32,lV=(e,t)=>e.candidate-t.candidate,Na=new Array(da).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Od=new Float32Array(6);function hV(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=Zb(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=Zb(e),n!==-1&&(o=cV(i,r,s,n));else if(a===2){let l=Eh(e),h=1.25*s,d=r*6,c=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/da;if(s<da/4){let m=[...Na];m.length=s;let g=0;for(let y=d;y<c;y+=6,g++){let x=m[g];x.candidate=i[y+2*u],x.count=0;let{bounds:b,leftCacheBounds:w,rightCacheBounds:A}=x;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,b[S]=1/0,b[S+3]=-1/0;Id(y,i,b)}m.sort(lV);let v=s;for(let y=0;y<v;y++){let x=m[y];for(;y+1<v&&m[y+1].candidate===x.candidate;)m.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let b=0;b<v;b++){let w=m[b];x>=w.candidate?Id(y,i,w.rightCacheBounds):(Id(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let x=m[y],b=x.count,w=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,_=0;b!==0&&(_=Eh(A)/l);let M=0;w!==0&&(M=Eh(S)/l);let C=1+1.25*(_*b+M*w);C<h&&(n=u,h=C,o=x.candidate)}}else{for(let v=0;v<da;v++){let y=Na[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/f);y>=da&&(y=da-1);let x=Na[y];x.count++,Id(v,i,x.bounds)}let m=Na[da-1];Kb(m.bounds,m.rightCacheBounds);for(let v=da-2;v>=0;v--){let y=Na[v],x=Na[v+1];Jb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let g=0;for(let v=0;v<da-1;v++){let y=Na[v],x=y.count,b=y.bounds,w=Na[v+1].rightCacheBounds;x!==0&&(g===0?Kb(b,Od):Jb(b,Od,Od)),g+=x;let A=0,S=0;g!==0&&(A=Eh(Od)/l);let _=s-g;_!==0&&(S=Eh(w)/l);let M=1+1.25*(A*g+S*_);M<h&&(n=u,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function cV(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function dV(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let d=["getX","getY","getZ"];for(let c=0;c<s;c++){let u=c*3,p=c*6,f,m,g;n?(f=r[u+0],m=r[u+1],g=r[u+2]):(f=r[u+0]*h+l,m=r[u+1]*h+l,g=r[u+2]*h+l);for(let v=0;v<3;v++){let y,x,b;n?(y=i[d[v]](f),x=i[d[v]](m),b=i[d[v]](g)):(y=o[f+v],x=o[m+v],b=o[g+v]);let w=y;x<w&&(w=x),b<w&&(w=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-w)/2,_=v*2;a[p+_+0]=w+S,a[p+_+1]=S+(Math.abs(w)+S)*rV,w<t[v]&&(t[v]=w),A>t[v+3]&&(t[v+3]=A)}}return a}function uV(e,t){function i(v){u&&u(v/p)}function r(v,y,x,b=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))),x<=d||w>=l)return i(y+x),v.offset=y,v.count=x,v;let A=hV(v.boundingData,b,n,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=oV(o,n,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let _=new Dd,M=y,C=S-y;v.left=_,_.boundingData=new Float32Array(6),Kf(n,M,C,_.boundingData,a),r(_,M,C,a,w+1);let T=new Dd,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Kf(n,D,P,T.boundingData,a),r(T,D,P,a,w+1)}return v}sV(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=dV(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,d=t.maxLeafTris,c=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,m=[],g=aV(e);if(g.length===1){let v=g[0],y=new Dd;y.boundingData=s,nV(n,v.offset,v.count,a),r(y,v.offset,v.count,a),m.push(y)}else for(let v of g){let y=new Dd;y.boundingData=new Float32Array(6),Kf(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),m.push(y)}return m}function pV(e,t){let i=uV(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let d=0;d<i.length;d++){let c=i[d],u=l(c),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,c),n.push(p)}return n;function l(d){return d.count?1:1+l(d.left)+l(d.right)}function h(d,c){let u=d/4,p=d/2,f=!!c.count,m=c.boundingData;for(let g=0;g<6;g++)r[u+g]=m[g];if(f){let g=c.offset,v=c.count;return s[u+6]=g,a[p+14]=v,a[p+15]=65535,d+32}else{let g=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var qs=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);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}};qs.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-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 d=t.dot(e);a=Math.min(d,a),n=Math.max(d,n)}this.min=a,this.max=n}}();var PY=function(){let e=new qs;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let d=a[h],c=s[h];if(e.setFromPoints(c,n),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=l[h],c=o[h];if(e.setFromPoints(c,r),d.isSeparated(e))return!1}}}(),fV=function(){let e=new E,t=new E,i=new E;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=i.dot(h),c=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-c*c,m,g;f!==0?m=(d*c-p*u)/f:m=0,g=(d+m*c)/u,a.x=m,a.y=g}}(),N0=function(){let e=new k,t=new E,i=new E;return function(r,s,a,n){fV(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let d;l<0?d=s.start:d=s.end;let c=t,u=i;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(d)<=u.distanceToSquared(h)){a.copy(c),n.copy(d);return}else{a.copy(h),n.copy(u);return}}}}(),mV=function(){let e=new E,t=new E,i=new Er,r=new Wr;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:d}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let u=c.projectPoint(o,t);if(a.containsPoint(u))return!0}return!1}}(),gV=1e-15;function Lo(e){return Math.abs(e)<gV}var Ta=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 qs),this.points=[this.a,this.b,this.c],this.sphere=new vr,this.plane=new Er,this.needsUpdate=!0}intersectsSphere(e){return mV(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let d=s[2],c=a[2];d.subVectors(t,i),c.setFromPoints(d,r);let u=s[3],p=a[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};Ta.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new Wr;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,d=1/0;for(let c=0;c<3;c++){let u=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[u]),N0(i,r,e,t),h=e.distanceToSquared(t),h<d&&(d=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(d)}}();Ta.prototype.intersectsTriangle=function(){let e=new Ta,t=new Array(3),i=new Array(3),r=new qs,s=new qs,a=new E,n=new E,o=new E,l=new E,h=new Wr,d=new Wr,c=new Wr;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let m=this.plane,g=u.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let w=0;w<4;w++){let A=v[w],S=y[w];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=u.satBounds,b=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],S=b[w];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let w=0;w<4;w++){let A=y[w];for(let S=0;S<4;S++){let _=b[S];if(a.crossVectors(A,_),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let O=v[P],B=v[(P+1)%3];h.start.copy(O),h.end.copy(B),h.delta(n);let G=y?d.start:d.end,F=Lo(g.distanceToPoint(O));if(Lo(g.normal.dot(n))&&F){d.copy(h),x=2;break}if((g.intersectLine(h,G)||F)&&!Lo(G.distanceTo(B))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(x!==2)return!1;let b=u.points,w=!1,A=0;for(let P=0;P<3;P++){let O=b[P],B=b[(P+1)%3];h.start.copy(O),h.end.copy(B),h.delta(o);let G=w?c.start:c.end,F=Lo(m.distanceToPoint(O));if(Lo(m.normal.dot(o))&&F){c.copy(h),A=2;break}if((m.intersectLine(h,G)||F)&&!Lo(G.distanceTo(B))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(d.delta(n),c.delta(o),n.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=d.start.dot(n),_=d.end.dot(n),M=c.start.dot(n),C=c.end.dot(n),T=_<M,D=S<C;return S!==C&&M!==_&&T===D?!1:(p&&(l.subVectors(d.start,c.start),l.dot(n)>0?p.start.copy(d.start):p.start.copy(c.start),l.subVectors(d.end,c.end),l.dot(n)<0?p.end.copy(d.end):p.end.copy(c.end)),!0)}}}();Ta.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ta.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new Wr,s=new Wr;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let d=0;d<3;d++){let c,u=i[d],p=a[u];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[u];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.copy(f),o&&o.copy(e))}for(let d=0;d<3;d++){let c=i[d],u=i[(d+1)%3];r.set(this[c],this[u]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];s.set(a[f],a[m]),N0(r,s,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Xs=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new me,this.invMatrix=new me,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 qs),this.alignedSatBounds=new Array(3).fill().map(()=>new qs),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Xs.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 d=0;d<=1;d++){let c=1*l|2*h|4*d,u=r[c];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],d=s[l],c=1<<l,u=r[c];h.subVectors(n,u),d.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}}();Xs.prototype.intersectsBox=function(){let e=new qs;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Xs.prototype.intersectsTriangle=function(){let e=new Ta,t=new Array(3),i=new qs,r=new qs,s=new E;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let c=0;c<3;c++){let u=n[c],p=o[c];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,d=this.points;for(let c=0;c<3;c++){let u=l[c],p=h[c];if(i.setFromPoints(p,d),u.isSeparated(i))return!1}for(let c=0;c<3;c++){let u=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(u,f),i.setFromPoints(s,t),r.setFromPoints(s,d),i.isSeparated(r))return!1}}return!0}}();Xs.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}}();Xs.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Xs.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Wr),i=new Array(12).fill().map(()=>new Wr),r=new E,s=new E;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,d=a.min,c=a.max,u=this.points,p=1/0;for(let m=0;m<8;m++){let g=u[m];s.copy(g).clamp(d,c);let v=g.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let y=(m+1)%3,x=(m+2)%3,b=g<<y|v<<x,w=1<<m|g<<y|v<<x,A=u[b],S=u[w];t[f].set(A,S);let _=e[m],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[_]=d[_],D[M]=g?d[M]:c[M],D[C]=v?d[C]:c[M],P[_]=c[_],P[M]=g?d[M]:c[M],P[C]=v?d[C]:c[M],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=m?c.x:d.x,s.y=g?c.y:d.y,s.z=v?c.z:d.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 m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let y=i[v];N0(g,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Ro=new E,Bo=new E,zo=new E,Ld=new k,Rd=new k,Bd=new k,$b=new E,ew=new E,tw=new E,zd=new E;function vV(e,t,i,r,s,a){let n;return a===Si?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Cr,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function yV(e,t,i,r,s,a,n,o,l){Ro.fromBufferAttribute(t,a),Bo.fromBufferAttribute(t,n),zo.fromBufferAttribute(t,o);let h=vV(e,Ro,Bo,zo,zd,l);if(h){r&&(Ld.fromBufferAttribute(r,a),Rd.fromBufferAttribute(r,n),Bd.fromBufferAttribute(r,o),h.uv=Ni.getInterpolation(zd,Ro,Bo,zo,Ld,Rd,Bd,new k)),s&&(Ld.fromBufferAttribute(s,a),Rd.fromBufferAttribute(s,n),Bd.fromBufferAttribute(s,o),h.uv1=Ni.getInterpolation(zd,Ro,Bo,zo,Ld,Rd,Bd,new k)),i&&($b.fromBufferAttribute(i,a),ew.fromBufferAttribute(i,n),tw.fromBufferAttribute(i,o),h.normal=Ni.getInterpolation(zd,Ro,Bo,zo,$b,ew,tw,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:n,c:o,normal:new E,materialIndex:0};Ni.getNormal(Ro,Bo,zo,d.normal),h.face=d,h.faceIndex=a}return h}function R2(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:d,uv:c,uv1:u}=e.attributes,p=yV(i,h,d,c,u,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function xV(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)R2(e,t,i,n,a)}function bV(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=R2(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Rs(e,t,i,r){let s=e.a,a=e.b,n=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),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function iw(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,d=t+e;h<d;h++)if(Rs(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var B2=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 Za(e,t){return t[e+15]===65535}function yl(e,t){return t[e+6]}function Ac(e,t){return t[e+14]}function Mc(e){return e+8}function Ec(e,t){return t[e+6]}function wV(e,t){return t[e+7]}var ll=new $t,op=new E,_V=["x","y","z"];function sv(e,t,i,r,s){let a=e*2,n=sh,o=hn,l=cn;if(Za(a,o)){let h=yl(e,l),d=Ac(a,o);xV(t,i,r,h,d,s)}else{let h=Mc(e);lp(h,n,r,op)&&sv(h,t,i,r,s);let d=Ec(e,l);lp(d,n,r,op)&&sv(d,t,i,r,s)}}function av(e,t,i,r){let s=e*2,a=sh,n=hn,o=cn;if(Za(s,n)){let l=yl(e,o),h=Ac(s,n);return bV(t,i,r,l,h)}else{let l=wV(e,o),h=_V[l],d=r.direction[h]>=0,c,u;d?(c=Mc(e),u=Ec(e,o)):(c=Ec(e,o),u=Mc(e));let p=lp(c,a,r,op)?av(c,t,i,r):null;if(p){let m=p.point[h];if(d?m<=a[u+l]:m>=a[u+l+3])return p}let f=lp(u,a,r,op)?av(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var SV=function(){let e,t,i=[],r=new B2(()=>new $t);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);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]),n};function s(a,n,o,l,h=null,d=0,c=0){function u(y){let x=y*2,b=hn,w=cn;for(;!Za(x,b);)y=Mc(y),x=y*2;return yl(y,w)}function p(y){let x=y*2,b=hn,w=cn;for(;!Za(x,b);)y=Ec(y,w),x=y*2;return yl(y,w)+Ac(x,b)}let f=a*2,m=sh,g=hn,v=cn;if(Za(f,g)){let y=yl(a,v),x=Ac(f,g);return ks(a,m,e),l(y,x,!1,c,d+a,e)}else{let y=Mc(a),x=Ec(a,v),b=y,w=x,A,S,_,M;if(h&&(_=e,M=t,ks(b,m,_),ks(w,m,M),A=h(_),S=h(M),S<A)){b=x,w=y;let G=A;A=S,S=G,_=M}_||(_=e,ks(b,m,_));let C=Za(b*2,g),T=o(_,C,A,c+1,d+b),D;if(T===2){let G=u(b),F=p(b)-G;D=l(G,F,!0,c+1,d+b,_)}else D=T&&s(b,n,o,l,h,d,c+1);if(D)return!0;M=t,ks(w,m,M);let P=Za(w*2,g),O=o(M,P,S,c+1,d+w),B;if(O===2){let G=u(w),F=p(w)-G;B=l(G,F,!0,c+1,d+w,M)}else B=O&&s(w,n,o,l,h,d,c+1);return!!B}}}(),AV=function(){let e=new Ta,t=new Ta,i=new me,r=new Xs,s=new Xs;return function a(n,o,l,h,d=null){let c=n*2,u=sh,p=hn,f=cn;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),Za(c,p)){let m=o,g=m.index,v=m.attributes.position,y=l.index,x=l.attributes.position,b=yl(n,f),w=Ac(c,p);if(i.copy(h).invert(),l.boundsTree)return ks(n,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,_=(w+b)*3;S<_;S+=3)if(Rs(t,S,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=w+b*3;A<S;A+=3){Rs(e,A,g,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(Rs(t,_,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return ks(m,u,ll),!!(d.intersectsBox(ll)&&a(m,o,l,h,d)||(ks(g,u,ll),d.intersectsBox(ll)&&a(g,o,l,h,d)))}}}();function lp(e,t,i,r){return ks(e,t,ll),i.intersectBox(ll,r)}var nv=[],yu,sh,hn,cn;function Xh(e){yu&&nv.push(yu),yu=e,sh=new Float32Array(e),hn=new Uint16Array(e),cn=new Uint32Array(e)}function Nd(){yu=null,sh=null,hn=null,cn=null,nv.length&&Xh(nv.pop())}var Jf=Symbol("skip tree generation"),$f=new $t,em=new $t,No=new me,Dn=new Xs,Ch=new Xs,Th=new E,kd=new E,MV=new E,EV=new E,CV=new E,rw=new $t,_s=new B2(()=>new Ta),nc=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."),nc.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(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}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."),nc.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new nc(t,{...i,[Jf]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ke(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}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,[Jf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Jf]||(this._roots=pV(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t))),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,a,n,o,l=0,h=this._roots;for(let c=0,u=h.length;c<u;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),d(0,l),l+=s.byteLength;function d(c,u,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],g=n[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,w=-1/0,A=-1/0;for(let S=3*m,_=3*(m+g);S<_;S++){let M=i[S],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>w&&(w=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==w||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=w,o[c+5]=A,!0):!1}else{let m=c+8,g=a[c+6],v=m+u,y=g+u,x=p,b=!1,w=!1;e?x||(b=e.has(v),w=e.has(y),x=!b&&!w):(b=!0,w=!0);let A=x||b,S=x||w,_=!1;A&&(_=d(m,u,x));let M=!1;S&&(M=d(g,u,x));let C=_||M;if(C)for(let T=0;T<3;T++){let D=m+T,P=g+T,O=o[D],B=o[D+3],G=o[P],F=o[P+3];o[c+T]=O<G?O:G,o[c+T+3]=B>F?B:F}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let d=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),d,c)}else{let d=n+8,c=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(a(d,o+1),a(c,o+1))}}}raycast(e,t=fs){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=n?t[o[h].materialIndex].side:l,u=s.length;if(Xh(i[h]),sv(0,r,c,e,s),Nd(),n){let p=o[h].materialIndex;for(let f=u,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=fs){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=a?t[o[h].materialIndex].side:l;Xh(i[h]);let u=av(0,r,c,e);Nd(),u!=null&&(n==null||u.distance<n.distance)&&(n=u,a&&(u.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Xh(s),r=AV(0,i,e,t),Nd(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(u,p,f,m)=>{let g=p*3;return c(u,g,g+1,g+2,f,m)}}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=_s.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,f,m,g)=>c(u,p,f,m,g)?!0:iw(u,p,r,l,f,m,s)}else o||(l?o=(c,u,p,f)=>iw(c,u,r,l,p,f,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(Xh(c),h=SV(0,r,n,o,a,d),Nd(),h)break;d+=c.byteLength}return _s.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;No.copy(t).invert();let h=_s.getPrimitive(),d=_s.getPrimitive();if(s){let u=function(p,f,m,g,v,y,x,b){for(let w=m,A=m+g;w<A;w++){Rs(d,w*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=p,_=p+f;S<_;S++)if(Rs(h,S*3,a,n),h.needsUpdate=!0,s(h,d,S,w,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,y,x,b,w){return p(f,m,g,v,y,x,b,w)?!0:u(f,m,g,v,y,x,b,w)}}else r=u}e.getBoundingBox(em),em.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>em.intersectsBox(u),intersectsRange:(u,p,f,m,g,v)=>($f.copy(v),$f.applyMatrix4(No),e.shapecast({intersectsBounds:y=>$f.intersectsBox(y),intersectsRange:(y,x,b,w,A)=>r(u,p,y,x,m,g,w,A)}))});return _s.releasePrimitive(h),_s.releasePrimitive(d),c}intersectsBox(e,t){return Dn.set(e.min,e.max,t),Dn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Dn.intersectsBox(i),intersectsTriangle:i=>Dn.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Dn.set(e.boundingBox.min,e.boundingBox.max,t),Dn.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,d=e.index,c=_s.getPrimitive(),u=_s.getPrimitive(),p=kd,f=MV,m=null,g=null;r&&(m=EV,g=CV);let v=1/0,y=null,x=null;return No.copy(t).invert(),Ch.matrix.copy(No),this.shapecast({boundsTraverseOrder:b=>Dn.distanceToBox(b),intersectsBounds:(b,w,A)=>A<v&&A<a?(w&&(Ch.min.copy(b.min),Ch.max.copy(b.max),Ch.needsUpdate=!0),!0):!1,intersectsRange:(b,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Ch.distanceToBox(A),intersectsBounds:(A,S,_)=>_<v&&_<a,intersectsRange:(A,S)=>{for(let _=A*3,M=(A+S)*3;_<M;_+=3){Rs(u,_,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=b*3,T=(b+w)*3;C<T;C+=3){Rs(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(u,p,m);if(D<v&&(f.copy(p),g&&g.copy(m),v=D,y=C/3,x=_/3),D<s)return!0}}}});{let A=d?d.count:h.count;for(let S=0,_=A;S<_;S+=3){Rs(u,S,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let M=b*3,C=(b+w)*3;M<C;M+=3){Rs(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,y=M/3,x=S/3),T<s)return!0}}}}}),_s.releasePrimitive(c),_s.releasePrimitive(u),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(g):r.point=g.clone(),r.point.applyMatrix4(No),f.applyMatrix4(No),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Th.copy(e).clamp(h.min,h.max),Th.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<n&&c<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Th);let c=e.distanceToSquared(Th);return c<n&&(kd.copy(Th),n=c,o=d),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(kd):t.point=kd.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ks(0,new Float32Array(t),rw),e.union(rw)}),e}},Ph=gn(UC()),TV=.5*(Math.sqrt(3)-1),Dh=(3-Math.sqrt(3))/6,PV=1/3,Ss=1/6,DY=(Math.sqrt(5)-1)/4,IY=(5-Math.sqrt(5))/20,oc=e=>Math.floor(e)|0,sw=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]),tm=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 im(e=Math.random){let t=z2(e),i=new Float64Array(t).map(s=>sw[s%12*2]),r=new Float64Array(t).map(s=>sw[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*TV,d=oc(s+h),c=oc(a+h),u=(d+c)*Dh,p=d-u,f=c-u,m=s-p,g=a-f,v,y;m>g?(v=1,y=0):(v=0,y=1);let x=m-v+Dh,b=g-y+Dh,w=m-1+2*Dh,A=g-1+2*Dh,S=d&255,_=c&255,M=.5-m*m-g*g;if(M>=0){let D=S+t[_],P=i[D],O=r[D];M*=M,n=M*M*(P*m+O*g)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[_+y],P=i[D],O=r[D];C*=C,o=C*C*(P*x+O*b)}let T=.5-w*w-A*A;if(T>=0){let D=S+1+t[_+1],P=i[D],O=r[D];T*=T,l=T*T*(P*w+O*A)}return 70*(n+o+l)}}function DV(e=Math.random){let t=z2(e),i=new Float64Array(t).map(a=>tm[a%12*3]),r=new Float64Array(t).map(a=>tm[a%12*3+1]),s=new Float64Array(t).map(a=>tm[a%12*3+2]);return function(a,n,o){let l,h,d,c,u=(a+n+o)*PV,p=oc(a+u),f=oc(n+u),m=oc(o+u),g=(p+f+m)*Ss,v=p-g,y=f-g,x=m-g,b=a-v,w=n-y,A=o-x,S,_,M,C,T,D;b>=w?w>=A?(S=1,_=0,M=0,C=1,T=1,D=0):b>=A?(S=1,_=0,M=0,C=1,T=0,D=1):(S=0,_=0,M=1,C=1,T=0,D=1):w<A?(S=0,_=0,M=1,C=0,T=1,D=1):b<A?(S=0,_=1,M=0,C=0,T=1,D=1):(S=0,_=1,M=0,C=1,T=1,D=0);let P=b-S+Ss,O=w-_+Ss,B=A-M+Ss,G=b-C+2*Ss,F=w-T+2*Ss,z=A-D+2*Ss,X=b-1+3*Ss,H=w-1+3*Ss,j=A-1+3*Ss,N=p&255,q=f&255,V=m&255,W=.6-b*b-w*w-A*A;if(W<0)l=0;else{let re=N+t[q+t[V]];W*=W,l=W*W*(i[re]*b+r[re]*w+s[re]*A)}let U=.6-P*P-O*O-B*B;if(U<0)h=0;else{let re=N+S+t[q+_+t[V+M]];U*=U,h=U*U*(i[re]*P+r[re]*O+s[re]*B)}let ie=.6-G*G-F*F-z*z;if(ie<0)d=0;else{let re=N+C+t[q+T+t[V+D]];ie*=ie,d=ie*ie*(i[re]*G+r[re]*F+s[re]*z)}let Q=.6-X*X-H*H-j*j;if(Q<0)c=0;else{let re=N+1+t[q+1+t[V+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*j)}return 32*(l+h+d+c)}}function z2(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 $r=new Ni,IV=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;$r.a.fromBufferAttribute(e,r),$r.b.fromBufferAttribute(e,r+1),$r.c.fromBufferAttribute(e,r+2),s*=$r.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 a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),$r.a.fromBufferAttribute(this.positionAttribute,e*3),$r.b.fromBufferAttribute(this.positionAttribute,e*3+1),$r.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector($r.a,r).addScaledVector($r.b,s).addScaledVector($r.c,1-(r+s)),$r.getNormal(i),this}},OV=gn(xS()),LV=new me,RV=new me,BV=new me,Cc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Cc||(Cc={}));var k0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Tt&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)Cc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Cc.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:a}=(0,OV.SVD)(i),n=LV.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=RV.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=BV.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},zV=class extends k0(Tt){},NV=e=>e.type==="Mesh",Ui=class extends zV{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Ui(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return NV(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}},Un=new E,Fn=new E,xl=new me,N2=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],kV=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],UV=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],aw=(e,t,i)=>{e.updateEntityBoxSize(Un,Fn),xl.copy(t).multiply(e.matrixWorld),Fn.x===0&&Fn.y===0&&Fn.z===0?i.push(new E(Un.x,Un.y,Un.z).applyMatrix4(xl)):N2.forEach(r=>{i.push(r.clone().multiply(Fn).add(Un).applyMatrix4(xl))})},nw=class extends $t{constructor(){super(...arguments),this.matrix=new me,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 me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}aw(s,t,r)}}):aw(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(xl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Fn).multiplyScalar(.5),this.getCenter(Un),xl.copy(this.matrix).setPosition(Un),this.vertices=N2.map(e=>e.clone().multiply(Fn).applyMatrix4(xl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=kV.map(([e,t])=>new Wr(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=UV.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},rn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},FV=class extends XS{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),d=o.getPoints(h);for(let c=0;c<d.length;c++){let u=d[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},ov=.001;function lv(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=ov}function rm(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),a=new E(...t.position);return lv(i,r,a)&&lv(i,s,a)}function k2(e){let t=e.points.map(d=>new E(...d.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)lv(r,t[d],t[d+1])||(i.push(e.points[d]),r=t[d]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let d=0;d<n;d++){let c=i[d].data,u=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),m={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(d===0||d===n-1)){o[d]={...m,removedLength:0};continue}let g=s&&d==0?n-1:d-1,v=s&&d==n-1?0:d+1,y=i[g].data,x=i[v].data,b=new E(...y.position),w=new E(...x.position),A=b.clone().sub(u).normalize(),S=w.clone().sub(u).normalize();Object.assign(m,{prevDir:A,nextDir:S});let _=rm(y,c),M=rm(c,x);if(!_||!M)o[d]={...m,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[d]={...m,tan:T,removedLength:c.roundness/T}}}for(let d=0;d<a;d++){let c=d,u=s&&d===n-1?0:d+1,p=o[c],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let d=0;d<a;d++){let c=d,u=s&&d===n-1?0:d+1,p=o[c],f=o[u],m=null;if(!rm(i[c].data,i[u].data))p.position.distanceTo(f.position)>ov&&(m=new pu(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>ov&&(m=new pu(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*d+1]=m}for(let d=0;d<n;d++){let c=o[d];if(c.removedLength===0){l[2*d]=null;continue}let u=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(u),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(u),m=c.tan*c.removedLength,g=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(y,2))).add(v),b=g.clone().multiplyScalar(-m).add(x),w=u.distanceTo(b)/u.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*u.distanceTo(p)).add(u),S=A.clone().lerp(b,2),_=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*d]=new pu(p,_,M,f)}let h=new FV;return l.forEach(d=>{d&&h.add(d)}),h}var ut;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ut||(ut={}));var va=e=>ut.is(e),VV={type:"completeState",isfromEntity:!0},jV=["x","y","z"],sm=new E,GV=new E().set(0,1,0),U0=e=>class extends k0(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new nw,this._recursiveBBox=new nw,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ut.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ut.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ut.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)Gn.toOps(this.data,s.data).forEach(a=>{let n=Sg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Gn.patch(this.data,s),Gn.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),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=>{va(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(ut.is(i[r]))return i[r];if(ut.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ut.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)va(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ut.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)va(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)va(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)va(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>va(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*Re.RAD2DEG,this.rotation.y*Re.RAD2DEG,this.rotation.z*Re.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return _g(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,jV[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(sm.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Re.DEG2RAD),this.rotation.setFromVector3(sm),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Rl.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ut.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ut.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return _g(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Gr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Zi.zoom(d,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(h[u]=c[u])}}n={...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:d,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:d,...c}=l;l=c}let h=Zi.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Gn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Gr(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 d of Object.keys(t.props)){l[l.length-1]=d;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[d],c.updateState(on.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Zi.zoom(d.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=c[p]);t={...t,props:u}}d.overrideData=tp.resolve(i.overrides,l),d.updateByOp(t,ki.applySimple(d.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let d of tn.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of tn.rootOverrideProps)if(Gr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=on.filterOp(h.overrideData,l);d&&h.updateByOp(d,ki.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=on.filterOp(h.overrideData,t);if(d){let c;a===h.data&&t===d?c=i:c=ki.applySimple(h.data,d),h.updateByOp(d,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!ao.is(t.props.type)&&rn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){rn.changeEntityProptotype(this,i,r);for(let s of this.children)ut.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),Gr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Gr(t.path,["cloner"])!==null){let s=ki.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.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=k2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let d=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;n.updateMatrixWorld();let u=new me().multiplyMatrices(c.clone().invert(),n.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new me().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(d),g=new me().lookAt(d,m,GV),v=sm.setFromEuler(new _i().setFromRotationMatrix(g)).multiplyScalar(Re.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(VV)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof rn.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 rn.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)}},U2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=Re.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=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:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new Ue,f.setAttribute("position",new Te([],3))):c||p?f=new F2(h,d,r,s,a,n,o,l*Math.PI/180,c,c,u,p):f=new i0(h,d,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function ka(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function ow(e){return new k(e.y,-e.x)}var F2=class extends Ue{constructor(e,t,i,r,s,a,n,o,l,h,d,c,u=!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,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,y=i/2,x=new E,b=new E;u&&e==0&&(e=l),u&&t==0&&(t=h);let w=new k(e,y),A=new k(t,-y),S=null,_=null,M=null,C=null,T=w.clone().sub(A),D=0,P=0,O=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,O=t-D);let B=w.clone();B.x-=D;let G=Math.PI-T.angle(),F=T.angle(),z=Math.tan(F/2),X=Math.tan(G/2),H=z+X,j=c?H:X,N=c?H:z;if(l=Math.min(l,(e-P)/j,T.length()/H),h=Math.min(h,(t-O)/N,T.length()/H),l>0){let Q=l/z;S=w.clone().sub(new k(Q,l)),c&&(M=S.clone(),M.x-=D-H*l),w.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;_=A.clone().sub(new k(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=_.clone(),C.x-=D-H*h,B.sub(T.clone().setLength(Q)))}T=w.clone().sub(A);let q=T.length()<.5,V=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,pe=Z*o+n,oe=new k(Math.sin(pe),Math.cos(pe));C&&_?(W(re,Z,oe,G,h,C,-1,!0),W(re,Z,oe,F,h,_,-1,!1)):_?(U(re,oe,_.x,0,-1),W(re,Z,oe,F,h,_,-1,!1)):a||U(re,oe,t,O,-1);let ae=ow(T).normalize();if(ka(ae,oe,x),!q)for(let Me=0;Me<=s;Me++){let Ae=Me/s,Ee=T.clone().multiplyScalar(Ae).add(A);ka(Ee,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}if(M&&S?(W(re,Z,oe,G,l,S,1,!1),W(re,Z,oe,F,l,M,1,!0)):S?(W(re,Z,oe,G,l,S,1,!1),U(re,oe,S.x,0,1)):a||U(re,oe,e,P,1),c&&!q){let Me=ow(T).multiplyScalar(-1).normalize();ka(Me,oe,x);for(let Ae=0;Ae<=s;Ae++){let Ee=Ae/s,Ie=T.clone().multiplyScalar(-Ee).add(B);ka(Ie,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}}c&&!a&&re.push(re[0]),V.push(re)}for(let Q=0;Q<V.length-1;Q++)for(let re=0;re<V[0].length-1;re++){if(a&&c&&re==s)continue;let Z=V[Q][re],pe=V[Q+1][re],oe=V[Q+1][re+1],ae=V[Q][re+1],Me=f[oe*3+0],Ae=f[oe*3+2];p.push(Z,pe,ae),(Me!=0||Ae!=0)&&p.push(pe,oe,ae)}o<Math.PI*2&&(ie(-1,V[0],n),ie(1,V[V.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new Te(f,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2));function W(Q,re,Z,pe,oe,ae,Me,Ae){for(let Ee=0;Ee<d+1;Ee++){let Ie=Ee/d,be=Me<0?Ie:1-Ie;Ae&&(be-=1),be*=pe;let ye=new k(Math.sin(be),Math.cos(be)*Me),Ne=ye.clone().multiplyScalar(oe).add(ae);ka(Ne,Z,b),f.push(b.x,b.y,b.z),ka(ye,Z,x),m.push(x.x,x.y,x.z),g.push(re,.5+b.y/i),Q.push(v++)}}function U(Q,re,Z,pe,oe){let ae=new E,Me=new k,Ae=[Z,pe];oe<0&&Ae.reverse();for(let Ee of Ae)Me.set(Ee,y*oe),ka(Me,re,ae),f.push(ae.x,ae.y,ae.z),m.push(0,oe,0),g.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let pe=new k(Math.sin(Z),Math.cos(Z)),oe=new k(-Math.cos(Z),Math.sin(Z)),ae=new E,Me=Q<0?(Ie,be,ye)=>p.push(Ie,be,ye):(Ie,be,ye)=>p.push(Ie,ye,be),Ae=new k((e+t+P+O)/4,0);ka(Ae,pe,ae),f.push(ae.x,ae.y,ae.z),m.push(oe.x,0,oe.y),g.push(.5,.5);let Ee=v++;for(let Ie of re){let be=f.slice(Ie*3,Ie*3+3);f.push(...be),m.push(oe.x,0,oe.y);let ye=g.slice(Ie*2,Ie*2+2);g.push(...ye),v++}for(let Ie=Ee+1;Ie<v-1;Ie++)Me(Ee,Ie,Ie+1);Me(Ee,v-1,Ee+1)}}},HV=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,360),{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:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters,u;return l===0?(u=new Ue,u.setAttribute("position",new Te([],3))):h>0||d>0||l<360?u=new F2(0,t/2,r,s,a,n,o,l*Math.PI/180,h,d,c,0,!0):u=new QS(t/2,r,s,a,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},WV=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Hs(t,i,r,s,a,n):h=new qV(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},am=Math.PI/2,qV=class extends Ue{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],d=[],c=[],u=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,a,0),g("z","y","x",1,-1,-1,i,t,e,a,1),g("z","y","x",-1,1,-1,i,t,e,a,1),g("z","y","x",1,1,1,i,t,e,a,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,s,0),g("y","x","z",1,-1,-1,t,e,i,s,1),g("y","x","z",1,1,1,t,e,i,s,1),g("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 Te(d,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function m(y,x,b,w,A,S,_,M,C,T,D){let P=(S-2*n)/C,O=(_-2*n)/T,B=S/2-n,G=_/2-n,F=M/2,z=C+1,X=T+1,H=0,j=0,N=new E;for(let q=0;q<X;q++){let V=q*O-G;for(let W=0;W<z;W++){let U=W*P-B;N[y]=U*w,N[x]=V*A,N[b]=F,d.push(N.x,N.y,N.z),N[y]=0,N[x]=0,N[b]=M>0?1:-1,c.push(N.x,N.y,N.z),u.push(W/C),u.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let V=0;V<C;V++){let W=p+V+z*q,U=p+V+z*(q+1),ie=p+(V+1)+z*(q+1),Q=p+(V+1)+z*q;h.push(W,U,Q),h.push(U,ie,Q),j+=6}l.addGroup(f,j,D),f+=j,p+=H}function g(y,x,b,w,A,S,_,M,C,T,D){let P=(_-2*n)/T,O=_/2-n,B=M/2-n,G=C/2,F=T+1,z=0,X=0,H=new E,j=new E;for(let N=0;N<o+1;N++){let q=N/o*am,V=Math.sin(q)*n,W=(1-Math.cos(q))*n,U=Math.sin(q),ie=Math.cos(q);H[x]=(B+V)*A,H[b]=(G-W)*S,j[y]=0,j[x]=U*Math.sign(H[x]),j[b]=ie*Math.sign(H[b]);for(let Q=0;Q<F;Q++){let re=Q*P-O;H[y]=re*w,d.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),u.push(Q/T),u.push(0),z+=1}}for(let N=0;N<o;N++)for(let q=0;q<T;q++){let V=p+q+F*N,W=p+q+F*(N+1),U=p+(q+1)+F*(N+1),ie=p+(q+1)+F*N;h.push(V,W,ie),h.push(W,U,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(n);let S=[],_=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=am*(1-C/o),P=Math.cos(D),O=Math.sin(D),B=0;for(let G=0;G<=C;G++){let F=Math.cos(B),z=Math.sin(B);w.x=P*F,w.y=O,w.z=P*z;let X=A.clone().addScaledVector(w,n);d.push(y*X.x,x*X.y,b*X.z),c.push(y*w.x,x*w.y,b*w.z),u.push(0,0),T.push(p++),B+=am/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],D=S[C+1],P=T.length-1;_(T[0],D[1],D[0]);for(let O=1;O<=P;O++)_(T[O-1],T[O],D[O]),_(T[O],D[O+1],D[O])}}}},F0=class extends Ue{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),d(),this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new E,p=u.clone(),f=new Ni,m=s*r,g=r-m,v=a+1,y=new E,x=(F,z)=>y.subVectors(F,z).normalize(),b=(F,z)=>Array(F).fill(void 0).map(z),w=b(e.length/3,(F,z)=>new E().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let F=0;F<w.length;F++){let z=w[F],X=[],H,j,N,q=1e10,V=-1;for(;(V=t.indexOf(F,V+1))!=-1;){let Q=V-V%3;H=t[Q+(V+1)%3],j=t[Q+(V+2)%3],N=z.distanceToSquared(w[H]),q=Math.min(q,N),X.push([H,j,N])}q+=1e-6;let W=[],U=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,j,N]=X[U];let re=A[H]?.includes(F)==!0;N<=q&&W.push(H+ +re*S),U=X.findIndex(Z=>Z[0]==j)}A.push(W)}let _=[];{let F=0,z=0,X,H,j=c==3;for(let N=0;N<=a;N++){X=N*(N+1)/2,H=(N+1)*(N+2)/2;for(let q=0;q<a-N;q++)[F,z]=[X+q+N+2,H+q+N+3],_.push(X,H,...j?[z,X]:[F,H],z,F),[X,H]=[F,z];_.push(X,H,X+a+2)}}let M=u.clone(),C=u.clone(),T=u.clone(),D=u.clone(),P=u.clone(),O=[],B=b(w.length,()=>b(c,()=>u.clone()));for(let F=0;F<w.length;F++){u.copy(w[F]).normalize(),M.copy(u).multiplyScalar(g);let z=A[F];for(let W=0;W<z.length;W++){let U=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(w,F,U%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,B[F][W])}let X=[],H=[],j=[],N=new E;a==0&&[...B[F]].reduce((W,U)=>W.add(U),N).multiplyScalar(1/c);for(let W=0;W<c;W++){let U=[],ie=(W-1+c)%c,Q=B[F][ie],re=B[F][W];u.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(u),pe=u.angleTo(p),oe=Math.cos(Z)*m;a==0?C.copy(N):C.copy(M).setLength(g+oe),H.push(oe);let ae=[C,Q,re];for(let Me=0;Me<2;Me++){let Ae=ae[Me],Ee=ae[Me+1];D.subVectors(Ae,M),P.subVectors(Ee,M),T.crossVectors(D,P).normalize();for(let Ie=0;Ie<v;Ie++){let be=[Z,pe][Me]*Ie/v;u.copy(D).applyAxisAngle(T,be).add(M),X.push(u.clone()),Me&&(x(u,M),U.push([Ie==0?Ae:u.clone(),y.clone()]))}Me&&(x(Ee,M),U.push([Ee,y.clone()]))}j.push(U)}O.push(j);let q=2*v,V=2;for(let W=0;W<c;W++){let U=q*W,ie=q*((W+1)%c),Q=[X[U]];for(let Z=1;Z<v;Z++){D=X[U+Z],P=X[ie+Z],Q.push(D);for(let pe=1,oe=Z-V+1;pe<=oe;pe++)u.lerpVectors(D,P,pe/(oe+1)),u.sub(M).setLength(H[W]).add(M),Q.push(u.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+U]);Q.push(X[ie+v]);let re=_.map(Z=>Q[Z]);n.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let G=[];for(let F=0;F<A.length;F++)for(let z=0;z<c;z++){let X=A[F][z];if(X<S){let H=A[X].findIndex(q=>q%S==F),j=O[F][z],N=O[X][H];for(let q=0;q<v;q++){let V=j[q],W=N[v-q],U=j[q+1],ie=N[v-(q+1)];[V,W,U,U,W,ie].forEach(Q=>{n.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}G.push(j[0][0],N[v][0],j[v][0],N[0][0])}}for(;G.length;){let F,z,X,H;[F,z]=G.splice(0,2);let j=[F];for(;F!=z;)j.push(z),X=G.indexOf(z),H=X%2,z=G.splice(X-H,2)[1-H];y.subVectors(j[0],j[1]).cross(u.subVectors(j[0],j[2])).normalize();let N=y.dot(j[0])<0;N&&y.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +N],j[q+1-+N],j[0]].forEach(V=>{n.push(V.x,V.y,V.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new E;for(let A=0;A<n.length;A+=3){c.x=n[A+0],c.y=n[A+1],c.z=n[A+2];let S=b(c)/2/Math.PI+.5,_=w(c)/Math.PI+.5;o.push(S,1-_)}let u=new E,p=new E,f=new E,m=new E,g=new k,v=new k,y=new k,x=(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<n.length;A+=9,S+=6){u.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),m.copy(u).add(p).add(f).divideScalar(3);let _=b(m);x(g,S+0,u,_),x(v,S+2,p,_),x(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 b(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 F0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},XV=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new V2(t*.5,a,n):new ZS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},V2=class extends F0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-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],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],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new V2(e.radius,e.corner,e.cornerSides)}},Ih=1e-12,V0=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=Re.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 V0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},hv=class extends V0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new hv(this.parent).copy(this)}},bl=class extends V0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new hv(this),new hv(this))}static create(e,t){let i=new bl(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new bl(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(lw(i,e),lw(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function lw(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var j0=e=>e,ah=new k,Np=new k,YV=new k,QV=new k,ZV=new k,KV=new k,j2=new E,G2=new E;function JV(e){let t=new k;t.addVectors(e.v0,ah.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Np.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new ls(e.v0,t,i,e.v2)}function Yh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function $V(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function e8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function H2(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)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function t8(e,t,i){return cw(e,t)&&cw(t,i)&&cv(e.position,t.position,i.position)}function cv(e,t,i){return ah.copy(t).sub(e).cross(Np.copy(i).sub(e))===0}function i8(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function r8(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function s8(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,d=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return H2(t,e,i)>Math.PI&&(d*=-1),Yh(h,o)?c=(o+h)*(r/d-.5)*8/3/(n-l):c=(n+l)*(r/d-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function hw(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function cw(e,t){return cv(e.position,e.controls[1].position,t.position)&&cv(e.position,t.controls[0].position,t.position)}function a8(e,t,i,r,s=.5){let a=ah.subVectors(t,e).multiplyScalar(s).add(e),n=Np.subVectors(i,t).multiplyScalar(s).add(t),o=YV.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=QV.subVectors(n,a).multiplyScalar(s).add(a),d=ZV.subVectors(o,n).multiplyScalar(s).add(n),c=o,u=KV.subVectors(d,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,d.x,d.y,c.x,c.y,r.x,r.y]}function n8(e,t,i=12,r=!0){let s=G2.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=j0(t[l]),d=ah,c=$n(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof ls||h instanceof un||h instanceof ps){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),a!==void 0&&e8(a,s))continue;a===void 0&&(a=j2),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function o8(e,t,i,r=12,s=!0){let a=G2.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=j0(t[l]),c=ah,u=$n(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof ls||d instanceof un||d instanceof ps){if(d.getPoint(p/u,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=j2:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function dw(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=$n(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=$n(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=$n(e[0].roundedCurveCorner,t)*.5),r}function $n(e,t=12){return e&&e instanceof wp?t*2:e&&(e instanceof ps||e instanceof qS)?1:e&&e instanceof t0?t*e.points.length:t}function l8(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=j0(t[n]),l=$n(o,i),h=ah;for(let d=0;d<=l;d++)if(o instanceof ls||o instanceof un||o instanceof ps){if(o.getPoint(d/l,h),s!==void 0&&$V(s,h,Ih))continue;s===void 0&&(s=Np),s.copy(h),e.push(h.x,h.y),a++}}return Yh(e[0],e[e.length-2],Ih)&&Yh(e[1],e[e.length-1],Ih)&&(e.pop(),e.pop()),r&&a>1&&!(Yh(e[a-1],e[1],Ih)&&Yh(e[a-2],e[0],Ih))&&(e.push(e[0],e[1]),a++),e}var nm=new k,h8=new k,c8=new k,d8=new k,u8=new k,p8=new k,qt=class extends Ou{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Er(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Re.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new qt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>bl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>qt.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,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.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],a=e-t;if(a<=s.points.length-1)return s.points[a];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],a=s.points.indexOf(e);if(a>=0)return t+a;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=nm.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.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=Re.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new bl(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 n8(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=dw(this.points,e,!1),this.roundedCurveDivisions=dw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return o8(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),l8(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=$n(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-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],a=this.curveDivisions,n=a[e];if(hw(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(nm.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){hw(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],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&t8(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,d=s.curveAfter;if(h===void 0||d===void 0)continue;let c=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),f=d.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),y=1-v/p,x=v/f,b=h.getPointAt(y,nm),w=d.getPointAt(x,h8);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(d,u,x,void 0,w);let A;if(this.useCubicForRoundedCorners){let S=H2(b,s.position,w)/2,_=Math.tan(S)*b.distanceTo(s.position),[M,C]=i8(b,w,_,c8,d8),T=r8(M,C,s.position),[D,P]=s8(T,b,w,_,u8,p8);A=new ls(b.clone(),D.clone(),P.clone(),w.clone())}else A=new un(b.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 ps)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=a8(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new qt(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],a=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],d=e.points[r+6],c=new bl(Re.generateUUID(),new k(s,a));c.controls[0].position.set(n,o),c.controls[1].position.set(l,h),c.roundness=d,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new qt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof ls&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof un&&(s[n]=JV(s[n]));for(n=0,o=s.length;n<o;n++){let d=s[n],c=n>0?s[n-1]:null,u;d instanceof ls?(u=this.createPoint(d.v0),u.controls[1].position.copy(d.v1)):d instanceof ps&&(u=this.createPoint(d.v1)),u!==void 0&&(c!==null&&i(u,c),a.push(u))}let l=s[s.length-1],h=!1;return l instanceof ls?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof ps&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof Ou&&(this.shapeHoles=e.holes.map(s=>{let a=new qt;return a.fromShape(s),a})),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)}},dv=Math.PI*2;function om({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function f8(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),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function uw(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function m8(e,t,i,r,s,a,n,o,l,h){let d=Math.pow(s,2),c=Math.pow(a,2),u=Math.pow(n,2),p=Math.pow(o,2),f=d*c-d*p-c*u;f<0&&(f=0),f/=d*p+c*u,f=Math.sqrt(f)*(l===h?-1:1);let m=f*s/a*o,g=f*-a/s*n,v=m+(e+i)/2,y=g+(t+r)/2,x=(n-m)/s,b=(o-g)/a,w=(-n-m)/s,A=(-o-g)/a,S=uw(1,0,x,b),_=uw(x,b,w,A);return!h&&_>0&&(_-=dv),h&&_<0&&(_+=dv),{centerx:v,centery:y,ang1:S,ang2:_}}function g8({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,d=(t-r)/2;if(h===0&&d===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(d,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let u=m8(e,t,i,r,s,a,h,d,n,o),{ang1:p,ang2:f}=u,{centerx:m,centery:g}=u,v=Math.abs(f)/(dv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(f8(p,f)),p+=f;return l.map(x=>{let{x:b,y:w}=om(x[0],s,a,m,g),{x:A,y:S}=om(x[1],s,a,m,g),{x:_,y:M}=om(x[2],s,a,m,g);return{x1:b,y1:w,x2:A,y2:S,x:_,y:M}})}var Et;(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"})(Et||(Et={}));var ai;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ai||(ai={}));function Ye(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ye(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Ye(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Ye(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Ye(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a: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,a){var n,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)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.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)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Oh=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}(),Ud=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}(),$o=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}(),pw=function(){function e(){var t=new $o,i=new Oh,r=new Ud(0),s=new Ud(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 Ud(0),r=new Ud(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;Ye(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ye(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==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 a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new $o,i=new $o,r=new Oh,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 a=new $o;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Oh;this.makeFace_(n,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 Oh;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 $o;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),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new Oh;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,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)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.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,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&Fe.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Ye(s.prev===a),l=s.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ye(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Ye(n.prev===o),l=n.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Ye(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ye(l.Sym.next===h.Sym),Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Org!==null),Ye(l.Dst!==null),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l);Ye(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}(),fw=function(){function e(){this.handle=null}return e}(),mw=function(){function e(){this.key=null,this.node=0}return e}(),v8=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 fw,this.handles[r]=new mw;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,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Ye(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},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,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new fw;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new mw}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;Ye(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}(),lm=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}(),gw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),y8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new gw,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 gw;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}(),x8=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,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Fe.vertLeq(a.Org,n.Org)?Fe.edgeSign(n.Dst,a.Org,n.Org)<=0:Fe.edgeSign(a.Dst,n.Org,a.Org)>=0:Fe.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Fe.edgeSign(a.Dst,s,a.Org)>=0;var o=Fe.edgeEval(a.Dst,s,a.Org),l=Fe.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ye(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ye(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 lm;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 Et.ODD:return(i&1)!==0;case Et.NONZERO:return i!==0;case Et.POSITIVE:return i>0;case Et.NEGATIVE:return i<0;case Et.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,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,d,c=!0;h=r;do Ye(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,d=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.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,d),e.deleteRegion(t,l),t.mesh.delete(d)),c=!1,l=o,d=h;l.dirty=!0,Ye(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),a=Fe.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Fe.vertLeq(s.Org,a.Org)){if(Fe.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Fe.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Ye(!Fe.vertEq(s.Dst,a.Dst)),Fe.vertLeq(s.Dst,a.Dst)){if(Fe.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Fe.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,d,c,u=new $o,p,f;if(Ye(!Fe.vertEq(h,l)),Ye(Fe.edgeSign(l,t.event,n)<=0),Ye(Fe.edgeSign(h,t.event,o)>=0),Ye(n!==t.event&&o!==t.event),Ye(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(d=Math.min(n.t,l.t),c=Math.max(o.t,h.t),d>c))return!1;if(Fe.vertLeq(n,o)){if(Fe.edgeSign(h,n,o)>0)return!1}else if(Fe.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Fe.intersect(l,n,h,o,u),Ye(Math.min(n.t,l.t)<=u.t),Ye(u.t<=Math.max(o.t,h.t)),Ye(Math.min(h.s,l.s)<=u.s),Ye(u.s<=Math.max(o.s,n.s)),Fe.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Fe.vertLeq(n,o)?n:o,Fe.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Fe.vertEq(u,n)||Fe.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,u)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.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(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Fe.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Fe.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,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,a;;){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,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Fe.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){Ye(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ye(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Ye(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Fe.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new lm;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Fe.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Fe.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var d=t.mesh.connect(o.Dnext,i.anEdge);l=d.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,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);Ye(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new lm,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new y8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ye(i.fixUpperEdge),Ye(++r===1)),Ye(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Fe.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new v8(a,Fe.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Ye(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Fe.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),b8=function(){function e(){this.mesh=new pw,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=Et.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,a,n,o,l=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)a=i.coords[g],h[g]=a,f[g]=i,l[g]=a,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],a<h[v]&&(h[v]=a,f[v]=i),a>l[v]&&(l[v]=a,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],d[0]=r.coords[0]-s.coords[0],d[1]=r.coords[1]-s.coords[1],d[2]=r.coords[2]-s.coords[2],i=m.next;i!==m;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],u[0]=d[1]*c[2]-d[2]*c[1],u[1]=d[2]*c[0]-d[0]*c[2],u[2]=d[0]*c[1]-d[1]*c[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<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,a=!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),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>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);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.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,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.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 a,n=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 d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){a=d.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=n,++n}this.elementCount=n,i===ai.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*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 u=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(d.inside){a=d.anEdge,l=0;do{var h=a.Org;this.elements[u++]=h.n,l++,a=a.Lnext}while(a!==d.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===ai.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=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,d=0;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=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,n++,r=r.Lnext;while(r!==s);this.elements[d++]=a,this.elements[d++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new pw),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,a,n){if(t===void 0&&(t=Et.ODD),i===void 0&&(i=ai.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),x8.computeInterior(this,n);var o=this.mesh;return i===ai.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===ai.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function sn(e){var t=e.windingRule,i=t===void 0?Et.ODD:t,r=e.elementType,s=r===void 0?ai.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,d=h===void 0?[0,0,1]:h,c=e.contours,u=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new b8;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,n,l,d,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var OY=Et.ODD,LY=Et.NONZERO,RY=Et.POSITIVE,BY=Et.NEGATIVE,zY=Et.ABS_GEQ_TWO,NY=ai.POLYGONS,kY=ai.CONNECTED_POLYGONS,UY=ai.BOUNDARY_CONTOURS,uv=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*uv.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*uv.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,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)}},W2=uv;W2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var w8=gn(VC()),G0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},q2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},X2={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},hm=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),H0=class extends Ue{constructor(e,t,i=0,r=12,s=3,a=Et.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],O=C[D-0];T.push(P,O)}return T}),h=[],d=[];for(let M=0;M<o.length;M+=2)d.push([o[M],o[M+1]]);h.push(d);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c;e.isText?c=new cA().setFromPoints(e.points.map(M=>M.position)).getSize(new k).length()*.1:h[0].length===0?c=i:c=(0,w8.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let u;try{u=sn({windingRule:a,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=G0}let p;try{p=sn({windingRule:Et.ODD,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=q2}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?u.vertexCount:0;u.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=u.vertexCount;u.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];u.vertices.push(C)}}let m=1/0,g=-1/0,v=1/0,y=-1/0;for(let M=0,C=u.vertexCount;M<C;M++){let T=M*2,D=u.vertices[T+0],P=u.vertices[T+1];D<m&&(m=D),D>g&&(g=D),P<v&&(v=P),P>y&&(y=P)}this._minX=m,this._minY=v,this._width=g-m,this._height=y-v,this._buffer=new W2(this._computeBufferEstimatedSize(u));let x=[],b=[];for(let M=u.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=u.elements[T+0],P=u.elements[T+1],O=D+P,B={start:D,count:P,normals:[],continuous:[],concave:[]},G=D,F=O-1,z=D+1,X=this._shape.roundedCurves.length;do{let V=G-D,W=u.vertices[F*2+0],U=u.vertices[F*2+1],ie=u.vertices[G*2+0],Q=u.vertices[G*2+1],re=u.vertices[z*2+0],Z=u.vertices[z*2+1],pe=ie-W,oe=Q-U,ae=Math.sqrt(pe*pe+oe*oe);pe/=ae,oe/=ae;let Me=ie-re,Ae=Q-Z,Ee=Math.sqrt(Me*Me+Ae*Ae);Me/=Ee,Ae/=Ee,B.normals[V*2+0]=-Ae,B.normals[V*2+1]=Me,B.concave[V]=pe*Ae-oe*Me>0;let Ie=u.vertexIndices[G];if(Array.isArray(Ie))B.continuous[V]=!1;else{let[be,ye]=this._shape.getCurveIndexFromVertexId(Ie-1,!0);if(ye>0&&ye<1)B.continuous[V]=!0;else{let Ne=ye===1?be+1:be-1;Ne=(Ne+X)%X;let Je=ye===1?0:1,R=this._shape.roundedCurves[be].getTangent(ye),I=this._shape.roundedCurves[Ne].getTangent(Je);B.continuous[V]=R.dot(I)>.95}}C&&(B.normals[V*2+0]*=-1,B.normals[V*2+1]*=-1),[F,G,z]=[G,z,z+1],z>=O&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,O*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((V,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,O*2)});let j=0;for(let V=1;V<=this._bevelSegments;V++){let W=V/this._bevelSegments*Math.PI/2,U=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],pe=0;for(let ae=0;ae<P;ae++){let Me=ae*2,Ae=(ae-1+P)%P*2,Ee=u.vertices[B.start*2+Me+0],Ie=u.vertices[B.start*2+Me+1],be=-B.normals[Ae+0]*U,ye=-B.normals[Ae+1]*U,Ne=-B.normals[Me+0]*U,Je=-B.normals[Me+1]*U;if(B.concave[ae]||!B.concave[ae]&&C){let R=Math.atan2(ye,be),I=Math.atan2(Je,Ne);I>R&&(I-=Math.PI*2);let $=I-R;if(B.continuous[ae]||C){let ge=R+$/2,de=Math.cos(ge)*U,xe=Math.sin(ge)*U;ie[2*pe+0]=Ee+de*(C?-1:1),ie[2*pe+1]=Ie+xe*(C?-1:1),Z[pe]=ae,pe++}else{let ge=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let de=0;de<=ge;de++){let xe=R+$*(de/ge),Be=Math.cos(xe)*U,Ce=Math.sin(xe)*U;ie[2*pe+0]=Ee+Be,ie[2*pe+1]=Ie+Ce,Z[pe]=ae,pe++}}}else ie[2*pe+0]=Ee+be,ie[2*pe+1]=Ie+ye,Z[pe]=ae,Q[ae]=pe,pe++,ie[2*pe+0]=Ee,ie[2*pe+1]=Ie,Z[pe]=ae,pe++,ie[2*pe+0]=Ee+Ne,ie[2*pe+1]=Ie+Je,Z[pe]=ae,re[ae]=pe,pe++}let oe=sn({windingRule:Et.POSITIVE,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:ae=>{let Me=ae.Org.idx,Ae=Z[Me],Ee=Z[(Me+1)%Z.length];ae.idx=[Ae,Ee],ae.Sym.idx=[Ee,Ae]},vertexIdCallback:ae=>{let Me=ae.Lprev.idx;return[Me?Me[1]:0,ae.idx?ae.idx[0]:0]}});if(!oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!oe.vertexCount){let ae=(V-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<oe.vertexIndices.length;ae++){let[Me,Ae]=oe.vertexIndices[ae];if(Me===Ae)continue;let Ee=Ae;Ae<Me&&(Ee+=P);for(let Ie=Me;Ie<Ee;Ie++){let be=Ie%P,ye=(Ie+1)%P;if(!B.continuous[be]||!B.continuous[ye]){oe.vertexIndices[ae]=[Me,be],oe.vertexIndices.splice(ae+1,0,[ye,Ae]),oe.vertices.splice((ae+1)*2,0,oe.vertices[ae*2],oe.vertices[ae*2+1]);break}}}H.push({bevelI:V,angle:W,size:U,boundary:oe,reverseMap:Z,insetPoints:ie})}let N=(V,W,U)=>{let ie=0,Q=V.boundary.vertexIndices.length;for(;ie<Q&&U(V.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let V=1;V<H.length;V++){let W=H[V-1],U=H[V],ie=W.boundary.vertexIndices.length,Q=U.boundary.vertexIndices.length;if(!ie||!Q)break;let re=B.concave.length,Z=0,pe=hm(Z,P);for(;!W.boundary.vertexIndices.filter(pe).length||!U.boundary.vertexIndices.filter(pe).length;)Z++,pe=hm(Z,P);let oe=W.boundary.vertexIndices.findIndex(pe),ae=U.boundary.vertexIndices.findIndex(pe);do oe=(oe+1)%ie;while(pe(W.boundary.vertexIndices[oe]));do ae=(ae+1)%Q;while(pe(U.boundary.vertexIndices[ae]));Z=(Z+1)%P;let Me=Z,Ae=0,Ee=this._buildBevelVert(B,W,(oe-1+ie)%ie,void 0,Ae),Ie=this._buildBevelVert(B,U,(ae-1+Q)%Q,void 0,Ae),be=Ee,ye=Ie,Ne,Je,R=!1;do{Ae=(Z||re)/re,pe=hm(Z,P);let I=N(W,oe,pe),$=N(U,ae,pe),ge=R;if(R=!1,I&&!$){for(let de=0;de<I;de++)Ne=this._buildBevelVert(B,W,(oe+de)%ie,de/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne;R=!0}else if(!I&&$)for(let de=0;de<$;de++)Je=this._buildBevelVert(B,U,(ae+de)%Q,de/($-1),Ae),x.push(ye.topN,be.topP,Je.topP),n===!1&&x.push(be.bottomP,ye.bottomN,Je.bottomP),ye=Je;else if(I&&$)if(Ne=this._buildBevelVert(B,W,oe,0,Ae),Je=this._buildBevelVert(B,U,ae,0,Ae),ge?(x.push(be.topN,Je.topP,ye.topN),x.push(be.topN,Ne.topP,Je.topP),n===!1&&(x.push(Je.bottomP,be.bottomN,ye.bottomN),x.push(Je.bottomP,Ne.bottomP,be.bottomN))):(x.push(ye.topN,be.topN,Ne.topP),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&(x.push(Ne.bottomP,be.bottomN,ye.bottomN),x.push(Ne.bottomP,ye.bottomN,Je.bottomP))),be=Ne,ye=Je,I===$)for(let de=1;de<I;de++)Ne=this._buildBevelVert(B,W,(oe+de)%ie,de/(I-1),Ae),Je=this._buildBevelVert(B,U,(ae+de)%Q,de/($-1),Ae),x.push(be.topN,Ne.topP,ye.topN),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&(x.push(Ne.bottomP,be.bottomN,ye.bottomN),x.push(Ne.bottomP,ye.bottomN,Je.bottomP)),be=Ne,ye=Je;else if(I>$){let de=I/$,xe=0;for(let Be=1;Be<I;Be++)Ne=this._buildBevelVert(B,W,(oe+Be)%ie,Be/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne,Be>(xe+1)*de&&(xe++,Je=this._buildBevelVert(B,U,(ae+xe)%Q,xe/($-1),Ae),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&x.push(Ne.bottomP,ye.bottomN,Je.bottomP),ye=Je)}else{let de=$/I,xe=0;for(let Be=1;Be<$;Be++)Je=this._buildBevelVert(B,U,(ae+Be)%Q,Be/($-1),Ae),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&x.push(Ne.bottomP,ye.bottomN,Je.bottomP),ye=Je,Be>(xe+1)*de&&(xe++,Ne=this._buildBevelVert(B,W,(oe+xe)%ie,xe/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne)}oe=(oe+I)%ie,ae=(ae+$)%Q,Z=(Z+1)%re}while(Z!==Me)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(H,B,x),C){let V=[];for(let W=x.length-1;W>=q+2;W-=3){let U=x[W-2],ie=x[W-1],Q=x[W-0];V.push(Q,ie,U)}x.splice(q,x.length-q,...V)}if(C){let V=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let U=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];V.push(U,ie)}b.push(V)}if(!C){let V=H[H.length-1],W;try{W=sn({windingRule:H.length>1?Et.POSITIVE:Et.ODD,elementType:ai.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...b]})}catch{W=X2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let U=0;U<W.elementCount*3;U+=3){let ie=this._buildSurfaceVert(W,W.elements[U+0],j),Q=this._buildSurfaceVert(W,W.elements[U+1],j),re=this._buildSurfaceVert(W,W.elements[U+2],j);x.push(ie.top,Q.top,re.top),n===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ke(Uint32Array.from(x),1),A=new Ke(this._buffer.positions,3),S=new Ke(this._buffer.normals,3),_=new Ke(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(w)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,d=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=n,this._buffer.uvs[d+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=n,this._buffer.uvs[d+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,d,c;n!==o?(h=n,l=o,c=!1,d=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||c);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,w=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),w=1);let A=e.normals[m+0],S=e.normals[m+1],_=e.normals[g+0],M=e.normals[g+1];if(c){let O=_-A,B=M-S;A=A+O*(1-r),S=S+B*(1-r);let G=Math.sqrt(A*A+S*S);A/=G,S/=G}let C=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*u,this._buffer.normals[T+1]=S*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*u,this._buffer.normals[T+4]=S*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b),d||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=_*u,this._buffer.normals[T+1]=M*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=_*u,this._buffer.normals[T+4]=M*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b)),this.vertexCache[a]=P,P}clone(){let e=new H0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Dp(this.userData),e}},Y2=class extends Ue{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Et.ODD,this.elementType=ai.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Et.ODD,elementType:ai.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),a,n=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let f=u*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{a=sn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=G0}let d=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new Ke(new Float32Array(d*3),3),this._normalAttribute=new Ke(new Float32Array(d*3),3),this._uvAttribute=new Ke(new Float32Array(d*2),2),this._indexAttribute=new Ke(new Uint32Array(c*3),1),a){let u=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,x=d;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1];w<u&&(u=w),w>p&&(p=w),A<f&&(f=A),A>m&&(m=A)}let g=p-u,v=m-f;for(let y=0,x=d;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1],S=(w-u)/g,_=(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,x=c;y<x;y++){let b=y*3,w=a.elements[b+0],A=a.elements[b+1],S=a.elements[b+2];this._indexAttribute.setX(b+0,w),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Y2(this._shape,this._curveSegments);return e.userData=Dp(this.userData),e}},Q2=class extends H0{constructor(e,t,i=0,r=12,s=3,a=Et.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new Q2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Dp(this.userData),e}},uo=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:Et.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof qt?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new qt(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new qt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new Y2(e.shape,s,{windingRule:n}):o=new Q2(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},Z2=Math.PI*2,W0=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 i.angle=Re.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof qt?e.shape:new qt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,d=t*.5,c=i*.5,u=_8(h,d,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ue,p.setAttribute("position",new Te([],3))):p=uo.create({shape:h,parameters:{subdivisions:u,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function _8(e,t,i,r,s,a){if(r>=Z2)return s>30||s%4===0?(A8(e,t,i,a),Math.round(s/4)):vw(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=g8({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?S8(e,n.x,n.y,h,s,t,i,a):vw(e,r,s,t,i,a)}function S8(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(wl(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=wl(c.x,c.y);u.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?K2(e,a,n,o):e.addPoint(wl(0,0)),l}function vw(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,d=Math.cos(l)*s;e.addPoint(wl(h,d))}return t<Z2?a>0?K2(e,r,s,a):e.addPoint(wl(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&J2(e,r,s,a)),1}function A8(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Fd(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(Fd(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(Fd(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(Fd(s,a-i,s+o,a-i,s-o,a-i)),r>0&&J2(e,t,i,r)}function wl(e,t){return new bl(Re.generateUUID(),new k(e,t))}function Fd(e,t,i,r,s,a){let n=wl(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function K2(e,t,i,r){$2(e,t,i,r).forEach(s=>e.addPoint(s))}function J2(e,t,i,r){let s=$2(e,t,i,r),a=new qt;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function $2(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new k(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Re.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),d=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(d),l.controls[1].position.copy(h)}),o}var M8=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),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,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:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:d,cornerSegments:c}=e.parameters,u=new eM(!1,t,i,r,s,a,n,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},cm=new ul([0,0,0],1),eM=class extends Ue{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,d=1,c=1){if(super(),a===0)return;let u=e&&a===1;u&&(c=0),d>100&&(d=100),d===0&&(c=0);let p=()=>new E,f=new E,m=p(),g=p(),v=p(),y,x,b,w,A,S,_,M,C=p(),T=p(),D=p(),P=p(),O=p(),B=p(),G=p(),F=p(),z=i-2*o+.001,X=z/a,H=Math.ceil(n*a),j=H+1,N=z/H,q=-z/2,V=h+1,W=2*Math.PI/h,U=Math.PI/2/c,ie=.01,Q=Math.min((1-d/100)*o,o-ie),re=o-Q,Z=0,pe=2,oe=c*pe+pe,ae=V*oe/pe,Me=ae+V*j,Ae=Math.max(0,V*(j+oe)),[Ee,Ie,be]=[3,3,2].map(Oe=>Array(Ae*Oe).fill(0)),ye=[],Ne=s-o;function Je(Oe,ze){let Le=Math.PI/2;S=ze*N,M=2*Math.PI*(S%X)/X+Le,S+=q,_=Math.sin(M)*Ne,A=Math.cos(M)*Ne,e?Oe.set(A,_,S):Oe.set(A,S,_)}Je(f,-1e-10),Je(m,0),C.copy(f),Je(f,1);let R=f.distanceTo(m),I=u?0:re+Q,$=R*H+2*I,ge=Q,de=$-I;for(let Oe=0;Oe<=H;Oe++){Je(g,Oe),F.subVectors(g,C).normalize(),C.copy(g),B.copy(g).setComponent(+e+1,0).normalize(),G.crossVectors(F,B).normalize();let ze=Oe===0,Le=Oe===H,Ze=ze?3*Math.PI/2:U,Ve=ze?ge:de,mt=ze?V:Me,zt=ze?0:Ae-V,ti=F.clone().multiplyScalar(ze?-re:re).add(g),Y=F.clone().multiplyScalar(ze?-1:1).normalize();for(let ne=0;ne<V;ne++){let ve=ne*W;if(T.addVectors(f.copy(B).multiplyScalar(o*Math.cos(ve)),m.copy(G).multiplyScalar(o*Math.sin(ve))),D.copy(T).normalize(),ze||Le){u||(Z=zt+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=ti.getComponent(_e),Ie[Z*3+_e]=Y.getComponent(_e)}),be[Z*2]=+Le,be[Z*2+1]=ne/h),m.copy(D).multiplyScalar(Q),v.addVectors(g,m);for(let _e=0;_e<c;_e++){let qe=_e*U+Ze;P.addVectors(f.copy(F).multiplyScalar(re*Math.sin(qe)),m.copy(D).multiplyScalar(re*Math.cos(qe))),O.copy(P).normalize(),m.addVectors(v,P),P.normalize(),Z=mt+_e*V+ne,[0,1,2].forEach(Vt=>{Ee[Z*3+Vt]=m.getComponent(Vt),Ie[Z*3+Vt]=O.getComponent(Vt)});let xt=+ze+Math.sin(qe);be[Z*2]=(Ve+re*xt)/$,be[Z*2+1]=ne/h}}m.addVectors(g,T),Z=ae+Oe*V+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=m.getComponent(_e),Ie[Z*3+_e]=D.getComponent(_e)}),be[Z*2]=(I+Oe*R)/$,be[Z*2+1]=ne/h}}let xe=j+2*c+pe,Be=1,[Ce,ue]=[+u,xe-1];for(let Oe=Ce;Oe<=ue-1;Oe++){let ze=u&&Oe===ue-1;for(let Le=0;Le<V-1;Le++)y=Oe*V+Le,x=y+1,b=(ze?Le:y)+V,w=(ze?Le+1:x)+V,Oe===0?ye.push(x,w,b):Oe===xe-2?ye.push(y,x,b):ye.push(y,x,b,x,w,b)}this.setIndex(ye),this.setAttribute("position",new Te(Ee,3)),this.setAttribute("normal",new Te(Ie,3)),this.setAttribute("uv",new Te(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(d?c:s)+i,o=(d?c+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,cm.array=r,cm.count=r.length,cm}},E8=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new tM(t*.5,a,n):new tA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},tM=class extends F0{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],a=[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],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new tM(e.radius,e.corner,e.cornerSides)}},C8=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 Ou;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 a=new YS(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},As=new me,dm=new Tt,Vd=new E,hp=class extends Ii{constructor(){super(),this.uuid=Re.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 a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return As.makeRotationX(e),this.applyMatrix4(As),this}rotateY(e){return As.makeRotationY(e),this.applyMatrix4(As),this}rotateZ(e){return As.makeRotationZ(e),this.applyMatrix4(As),this}translate(e,t,i){return As.makeTranslation(e,t,i),this.applyMatrix4(As),this}scale(e,t,i){return As.makeScale(e,t,i),this.applyMatrix4(As),this}lookAt(e){return dm.lookAt(e),dm.updateMatrix(),this.applyMatrix4(dm.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,a=r.normal,n=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)),n!==void 0&&t.colors.push(new He().fromBufferAttribute(n,c));function h(c,u,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],g=a===void 0?[]:[new E().fromBufferAttribute(a,c),new E().fromBufferAttribute(a,u),new E().fromBufferAttribute(a,p)],v=new pv(c,u,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,u),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,u),new k().fromBufferAttribute(l,p)])}let d=e.groups;if(d.length>0)for(let c=0;c<d.length;c++){let u=d[c],p=u.start,f=u.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),u.materialIndex):h(m,m+1,m+2,u.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(Vd).negate(),this.translate(Vd.x,Vd.y,Vd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;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],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),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,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.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],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[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,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new hp;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,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.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 $t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vr),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,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,d=e.colors;t!==void 0&&(r=new Ai().getNormalMatrix(t));for(let c=0,u=n.length;c<u;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let c=0,u=d.length;c<u;c++)h.push(d[c].clone());for(let c=0,u=l.length;c<u;c++){let p=l[c],f,m,g=p.vertexNormals,v=p.vertexColors,y=new pv(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=g.length;x<b;x++)f=g[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)m=v[x],y.vertexColors.push(m.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++)v.push(g[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],d=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[d]===void 0?(t[d]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[d]]}let a=[];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 d=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(d[c]===d[(c+1)%3]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}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],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}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={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,w=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),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(u(S[0]),u(S[1]),u(S[2]))}if(y&&i.push(d(f.normal)),x){let S=f.vertexNormals;i.push(d(S[0]),d(S[1]),d(S[2]))}if(b&&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,m){return m?p|1<<f:p&~(1<<f)}function d(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 n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[f]}function u(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,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new hp().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,u=t.length;c<u;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,u=i.length;c<u;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,u=r.length;c<u;c++)this.faces.push(r[c].clone());for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++){let b=g[y];v.push(b.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,u=s.length;c<u;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,u=a.length;c<u;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let g=a[c].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,u=n.length;c<u;c++)this.skinWeights.push(n[c].clone());let o=e.skinIndices;for(let c=0,u=o.length;c<u;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,u=l.length;c<u;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.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 T8().fromGeometry(this),t=new Ue,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",jd.call(new Ke(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",jd.call(new Ke(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",yw.call(new Ke(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",xw.call(new Ke(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",xw.call(new Ke(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new Te(l.data.length*3,3);h.name=l.name,s.push(jd.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Te(e.skinIndices.length*4,4);t.setAttribute("skinIndex",bw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Te(e.skinWeights.length*4,4);t.setAttribute("skinWeight",bw.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 Ue,i=e.geometry;if(e.isPoints||e.isLine){let r=new Te(i.vertices.length*3,3),s=new Te(i.colors.length*3,3);if(t.setAttribute("position",jd.call(r,i.vertices)),t.setAttribute("color",yw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Te(i.lineDistances.length,1);t.setAttribute("lineDistance",P8.call(a,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}};hp.prototype.isGeometry=!0;var T8=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,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.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,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let g=0;g<d;g++)c[g]={name:h[g].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new k,new k,new k))}if(a===!0){let b=r[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new k,new k,new k))}for(let b=0;b<o;b++){let w=n[b].vertices;l[b].data.push(w[v.a],w[v.b],w[v.c])}for(let b=0;b<d;b++){let w=h[b].vertexNormals[g];c[b].data.push(w.a,w.b,w.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),m&&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}},pv=class{constructor(e,t,i,r,s,a=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 He,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}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 P8(e){return this.array.set(e),this}function yw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new He),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function xw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new k),t[i++]=a.x,t[i++]=a.y}return this}function jd(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new E),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function bw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new rt),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var D8=["a","b","c"];function I8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function um(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function pm(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let d=i[n],c=i[o];h={a:d,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function O8(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],pm(n.a,n.b,e,r,n,i),pm(n.b,n.c,e,r,n,i),pm(n.c,n.a,e,r,n,i)}function Gd(e,t,i,r,s){e.push(new pv(t,i,r,void 0,void 0,s))}function ko(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Hd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var L8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ue?e=new hp().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,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],d=h!==void 0&&h.length>0,c=[],u=new Map;O8(o,l,c,u);let p=[],f,m,g,v,y,x,b;for(let ie of Array.from(u.keys())){for(m=u.get(ie),g=new E,y=3/8,x=1/8,b=m.faces.length,b!=2&&(y=.5,x=0,b!=1),g.addVectors(m.a,m.b).multiplyScalar(y),t.set(0,0,0),a=0;a<b;a++){for(v=m.faces[a],n=0;n<3&&(f=o[I8(v,D8[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(x),g.add(t),m.newEdge=p.length,p.push(g)}let w,A,S,_,M,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?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),a=0;a<i;a++)_=M[a],f=_.a!==C?_.a:_.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),O=D.length,B,G,F,z=[],X=[],H,j,N,q,V=new k,W=new k,U=new k;for(r=0,s=l.length;r<s;r++)v=l[r],B=Number(um(v.a,v.b,u).newEdge)+O,G=Number(um(v.b,v.c,u).newEdge)+O,F=Number(um(v.c,v.a,u).newEdge)+O,Gd(z,B,G,F,v.materialIndex),Gd(z,v.a,B,F,v.materialIndex),Gd(z,v.b,G,B,v.materialIndex),Gd(z,v.c,F,G,v.materialIndex),d&&(H=h[r],j=H[0],N=H[1],q=H[2],V.set(ko(j.x,N.x),ko(j.y,N.y)),W.set(ko(N.x,q.x),ko(N.y,q.y)),U.set(ko(j.x,q.x),ko(j.y,q.y)),Hd(X,V,W,U),Hd(X,j,V,U),Hd(X,N,W,V),Hd(X,q,U,W));e.vertices=P,e.faces=z,d&&(e.faceVertexUvs[0]=X)}},ci=new E,R8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ue().copy(new Hs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ci),r={width:ci.x,height:ci.y,depth:ci.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,a=e.geometry??new Ue().copy(new Hs(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(ci)):ci.set(n.width,n.height,n.depth),(t!==ci.x||i!==ci.y||r!==ci.z)&&a.scale(ci.x===0?1:t/ci.x,ci.y===0?1:i/ci.y,ci.z===0?1:r/ci.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new L8(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new lA(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ci);let a=100/ci.x;Object.assign(s.parameters,{width:100,height:ci.y*a,depth:ci.z*a}),t(this.build(s))})}},iM=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 qt?e.shape:new qt,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:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5,c=0,u=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=c+Math.sin(g)*h,y=u+Math.cos(g)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=uo.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},B8=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:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new N8(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Lh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function fm(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function z8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var N8=class extends Ue{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],d=[],c=0,u=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,y=new E(0,-u,0),x=new E(0,u,0),b=new k(e,-u),w=new k(f,-u),A=new k(0,x.y).sub(w),S=new k(0,x.y).sub(b),_=new k(A.y,-A.x).normalize(),M=new k(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,C);let T;{let z=new E(_.x,_.y,0),X=new E(Math.cos(m)*z.x,z.y,Math.sin(m)*z.x);T=z.angleTo(X)}let D=a/Math.tan((Math.PI-A.angle())/2),P=a/Math.tan((Math.PI-T)/2),O=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,X=[],H=b.clone(),j=D/Math.cos(Math.PI/i);H.x-=j;for(let N=0;N<i;N++){let q=N/i*Math.PI*2+p,V=new k(Math.sin(q),Math.cos(q));Lh(H,V,O),l.push(O.x,O.y,O.z),h.push(0,-1,0),d.push(0,0),X.push(c++)}for(let N=0;N<X.length;N++)o.push(X[N],z,X[(N+1)%X.length])}let B=[];{let z=new E,X=new E,H=new E,j=new E,N=new E,q=new E;for(let V=0;V<i;V++){let W=V/i*Math.PI*2+p,U=(V+.5)/i*Math.PI*2+p,ie=(V+1)/i*Math.PI*2+p,Q=new k(Math.sin(W),Math.cos(W)),re=new k(Math.sin(U),Math.cos(U)),Z=new k(Math.sin(ie),Math.cos(ie));Lh(b,Q,X),Lh(b,Z,H),Lh(_,re,z),fm(x,X,H,P,P,j),l.push(j.x,j.y,j.z),fm(X,x,H,P,D,N),l.push(N.x,N.y,N.z),fm(H,X,x,D,P,q),l.push(q.x,q.y,q.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),d.push(0,0),d.push(0,0),d.push(0,0);let pe=c++,oe=c++,ae=c++;if(o.push(pe,oe,ae),a>0){{let Ee=X.clone().add(H).multiplyScalar(.5),Ie=x.clone().sub(Ee).normalize(),be=y.clone().sub(Ee).normalize().add(Ie).normalize().multiplyScalar(-1),ye=q.clone().sub(N);G(Ee,ye,be,A.angle())}let Me,Ae;{let Ee=new E;Lh(M,Z,Ee);let Ie=q.clone().add(j).multiplyScalar(.5);Ie=z8(Ie,H,x);let be=q.clone().sub(j);[Me,Ae]=G(Ie,be,Ee,T,j.y)}{let Ee=Me,Ie=Ee.clone().setY(0).normalize(),be=new E(0,-1,0),ye=Ie.clone().cross(be);F(Ee,Ie,be,ye)}B.concat(Ae);{let Ee=A.angle(),Ie=Math.PI-Ee,be=x.clone();be.y-=a/Math.sin(Ee-Math.PI/2);let ye=new E,Ne=[];for(let R=0;R<n;R++){let I=[],$=Math.PI/2-Ie*R/n,ge=Math.cos($),de=Math.sin($),xe=U;for(let Be=0;Be<=R;Be++){let Ce=Math.cos(xe),ue=Math.sin(xe);z.x=ge*ue,z.y=de,z.z=ge*Ce,ye.copy(be).addScaledVector(z,a),l.push(ye.x,ye.y,ye.z),h.push(z.x,z.y,z.z),d.push(0,0),I.push(c++),xe+=Math.PI*2/R/i}Ne.push(I)}Ae.reverse(),Ne.push(Ae);let Je=Ne.length-1;for(let R=0;R<Je;R++){let I=Ne[R],$=Ne[R+1],ge=I.length-1;o.push($[1],I[0],$[0]);for(let de=1;de<=ge;de++)o.push(I[de],I[de-1],$[de]),o.push($[de+1],I[de],$[de])}}}}}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function G(z,X,H,j,N){let q=-j/2,V=(Math.PI-j)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-a/Math.sin(V));let U=new E,ie=new E,Q=1,re=c,Z=[];for(let pe=0;pe<=n;pe++){let oe=q+pe/n*j;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(oe)),ie.addScaledVector(H,Math.cos(oe));for(let ae=0;ae<=Q;ae++){let Me=ae/Q-.5;if(U.copy(z),U.addScaledVector(X,Me),U.addScaledVector(ie,a),N!=null){let Ae=Math.max(0,U.y-N);U.addScaledVector(X,-Ae/X.y)}l.push(U.x,U.y,U.z),h.push(ie.x,ie.y,ie.z),d.push(0,0),ae===0&&Z.push(c),c++}}for(let pe=0;pe<n;pe++)for(let oe=0;oe<Q;oe++){let ae=re+oe+(Q+1)*pe,Me=ae+(Q+1),Ae=Me+1,Ee=ae+1;o.push(ae,Me,Ee),o.push(Me,Ae,Ee)}return[z.clone().addScaledVector(X,.5),Z]}function F(z,X,H,j){let N=Math.PI/2,q=S.angle()-N,V=[],W=new E,U=new E;for(let Q=0;Q<=n;Q++){let re=[],Z=Q/n;for(let pe=0;pe<=Q;pe++){let oe=((Q?pe/Q:0)-.5)*v,ae=Math.cos(oe),Me=Math.sin(oe),Ae=Math.atan(Math.tan(q)*ae),Ee=(N+Ae)*Z,Ie=Math.cos(Ee),be=Math.sin(Ee);W.set(0,0,0),W.addScaledVector(X,be*ae),W.addScaledVector(H,Ie),W.addScaledVector(j,be*Me),U.copy(z).addScaledVector(W,a),l.push(U.x,U.y,U.z),h.push(W.x,W.y,W.z),d.push(0,0),re.push(c++)}V.push(re)}let ie=V.length-1;for(let Q=0;Q<ie;Q++){let re=V[Q],Z=V[Q+1],pe=re.length-1;o.push(re[0],Z[1],Z[0]);for(let oe=1;oe<=pe;oe++)o.push(re[oe-1],re[oe],Z[oe]),o.push(re[oe],Z[oe+1],Z[oe])}}}},rM=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 qt?e.shape:new qt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function u(b,w,A){return w>i&&A>r?Math.min(b*i/w,b*r/A):w>i?b*i/w:A>r?b*r/A:b}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,m=c.x,g=c.y,v=d.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=uo.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},k8=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:180},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,180),{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:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,d;return h===0?(d=new Ue,d.setAttribute("position",new Te([],3))):d=new s0(.5*t,s,a,n,o,l,h*Re.DEG2RAD),d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},U8=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,a=new xp(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},F8=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:a,cornerSegments:n}=e.parameters,o=new V8(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},V8=class extends Ue{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let d=[],c=Math.PI/2,u=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=u(),f=u(),[m,g,v]=[t/2,e/2,i/2],y=-g,x=+g,[b,w,A]=[u(y,-m,+v),u(y,-m,-v),u(y,+m,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),_=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):w.z=Math.min(w.z-M-v,b.z-h),p.subVectors(b,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),O=p.clone().normalize().add(f.normalize()).setLength(P).add(w);p.set(0,S(r,!0),_(r,!0)),d.push([A,p.clone()]);let B=(Math.PI-r)/a;for(let ie=0;ie<=a;ie++){let Q=c+r+ie*B;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(O),f.set(0,S(Q),_(Q)),d.push([p.clone(),f.clone()])}d.push([b,u(0,1,0)]);let G=Math.sin(B/2)*D*2,F=d.length-1,z=d[0][0].distanceTo(d[1][0]),X=d[F-1][0].distanceTo(d[F][0]),H=z+G*a+X;d[0].push(1);for(let ie=0;ie<=a;ie++)d[ie+1].push(1-(z+ie*G)/H);d[F].push(0);let[j,N,q]=d[0],V,W,U;for(let ie=1;ie<d.length;ie++)[V,W,U]=d[ie],n.push(y,j.y,j.z,y,V.y,V.z,x,j.y,j.z,x,j.y,j.z,y,V.y,V.z,x,V.y,V.z),o.push(0,N.y,N.z,0,W.y,W.z,0,N.y,N.z,0,N.y,N.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,U,1,q,1,q,0,U,1,U),[j,N,q]=[V,W,U];this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(o,3)),this.setAttribute("uv",new Te(l,2))}},sM=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 qt?e.shape:new qt,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:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,d=e.shape,c=t*.5,u=i*.5,p=0,f=0,m=n*Math.PI/360/s,g=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let w=m*b,A=p+Math.sin(w)*c,S=f+Math.cos(w)*u;d.addPoint(d.createPoint(A,S))}}else for(let b=0;b<s;b++){let w=p+Math.cos(g)*c,A=f+Math.sin(g)*u;d.addPoint(d.createPoint(w,A)),g+=m,w=p+Math.cos(g)*v,A=f+Math.sin(g)*y,b<=s,d.addPoint(d.createPoint(w,A)),g+=m}d.isClosed=!0;for(let b=0,w=d.points.length;b<w;b++)d.points[b].roundness=a;d.roundness=a,d.update();let x=uo.create({shape:d,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},j8=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 xp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},G8=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:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=H8(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function H8(e,t,i,r,s,a,n,o,l,h,d){[t,i]=[i,t],n=t/2;let c=Re.clamp(s/360,0,1);if(c===0){let u=new Ue;return u.setAttribute("position",new Te([],3)),u}return c===1&&(h=0),new eM(!0,e,t,i,r,c,a,n,o,l,h,d)}var W8=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:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new iA(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},q8=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 qt?e.shape:new qt,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:a,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5;o?(l.addPoint(l.createPoint(-h,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let c=uo.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function X8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var Y8=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},Q8=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},se=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+se.version}static addUnaryOp(e){return se.max_unop_len=Math.max(e.length,se.max_unop_len),se.unary_ops[e]=1,se}static addBinaryOp(e,t,i){return se.max_binop_len=Math.max(e.length,se.max_binop_len),se.binary_ops[e]=t,i?se.right_associative.add(e):se.right_associative.delete(e),se}static addIdentifierChar(e){return se.additional_identifier_chars.add(e),se}static addLiteral(e,t){return se.literals[e]=t,se}static removeUnaryOp(e){return delete se.unary_ops[e],e.length===se.max_unop_len&&(se.max_unop_len=se.getMaxKeyLen(se.unary_ops)),se}static removeAllUnaryOps(){return se.unary_ops={},se.max_unop_len=0,se}static removeIdentifierChar(e){return se.additional_identifier_chars.delete(e),se}static removeBinaryOp(e){return delete se.binary_ops[e],e.length===se.max_binop_len&&(se.max_binop_len=se.getMaxKeyLen(se.binary_ops)),se.right_associative.delete(e),se}static removeAllBinaryOps(){return se.binary_ops={},se.max_binop_len=0,se}static removeLiteral(e){return delete se.literals[e],se}static removeAllLiterals(){return se.literals={},se}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new se(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return se.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!se.binary_ops[String.fromCharCode(e)]||se.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return se.isIdentifierStart(e)||se.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(se.hooks[e]){let i={context:this,node:t};return se.hooks.run(e,i),i.node}return t}searchHook(e){if(se.hooks[e]){let t={context:this};return se.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===se.SPACE_CODE||e===se.TAB_CODE||e===se.LF_CODE||e===se.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:se.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===se.SEMCOL_CODE||i===se.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,se.max_binop_len),t=e.length;for(;t>0;){if(se.binary_ops.hasOwnProperty(e)&&(!se.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:se.binaryPrecedence(t),right_a:se.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=se.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:se.right_associative.has(t)},l=t;let h=d=>s.right_a&&d.right_a?i>d.prec:i<=d.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:se.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:se.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,se.isDecimalDigit(e)||e===se.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===se.SQUOTE_CODE||e===se.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===se.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,se.max_unop_len),i=t.length;i>0;){if(se.unary_ops.hasOwnProperty(t)&&(!se.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:se.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}se.isIdentifierStart(e)?(r=this.gobbleIdentifier(),se.literals.hasOwnProperty(r.name)?r={type:se.LITERAL,value:se.literals[r.name],raw:r.name}:r.name===se.this_str&&(r={type:se.THIS_EXP})):e===se.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===se.PERIOD_CODE||t===se.OBRACK_CODE||t===se.OPAREN_CODE||t===se.QUMARK_CODE;){let i;if(t===se.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==se.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===se.OBRACK_CODE?(e={type:se.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==se.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===se.OPAREN_CODE?e={type:se.CALL_EXP,arguments:this.gobbleArguments(se.CPAREN_CODE),callee:e}:(t===se.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:se.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===se.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,se.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===se.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===se.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:se.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
3138
+ }`;function FO(e,t,i){let r=new Zv,s=new k,a=new k,n=new rt,o=new jS({depthPacking:TS}),l=new NO,h={},d=i.maxTextureSize,c={[fs]:Si,[Si]:fs,[Cr]:Cr},u=new Bt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new k},radius:{value:4}},vertexShader:kO,fragmentShader:UO}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ue;f.setAttribute("position",new Ke(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new ur(f,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Hv,this.render=function(b,w,A){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let S=e.getRenderTarget(),_=e.getActiveCubeFace(),M=e.getActiveMipmapLevel(),C=e.state;C.setBlending(ni),C.buffers.color.setClear(1,1,1,1),C.buffers.depth.setTest(!0),C.setScissorTest(!1);for(let T=0,D=b.length;T<D;T++){let P=b[T],O=P.shadow;if(O===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(O.autoUpdate===!1&&O.needsUpdate===!1)continue;s.copy(O.mapSize);let B=O.getFrameExtents();if(s.multiply(B),a.copy(O.mapSize),(s.x>d||s.y>d)&&(s.x>d&&(a.x=Math.floor(d/B.x),s.x=a.x*B.x,O.mapSize.x=a.x),s.y>d&&(a.y=Math.floor(d/B.y),s.y=a.y*B.y,O.mapSize.y=a.y)),O.map===null){let F=this.type!==Hh?{minFilter:Rt,magFilter:Rt}:{};O.map=new Ct(s.x,s.y,F),O.map.texture.name=P.name+".shadowMap",O.camera.updateProjectionMatrix()}e.setRenderTarget(O.map),e.clear();let G=O.getViewportCount();for(let F=0;F<G;F++){let z=O.getViewport(F);n.set(a.x*z.x,a.y*z.y,a.x*z.z,a.y*z.w),C.viewport(n),O.updateMatrices(P,F),r=O.getFrustum(),x(w,A,O.camera,P,this.type)}O.isPointLightShadow!==!0&&this.type===Hh&&v(O,A),O.needsUpdate=!1}g.needsUpdate=!1,e.setRenderTarget(S,_,M)};function v(b,w){let A=t.update(m);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Ct(s.x,s.y)),u.uniforms.shadow_pass.value=b.map.texture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,e.setRenderTarget(b.mapPass),e.clear(),e.renderBufferDirect(w,null,A,u,m,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,e.setRenderTarget(b.map),e.clear(),e.renderBufferDirect(w,null,A,p,m,null)}function y(b,w,A,S,_,M){let C=null,T=A.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(T!==void 0)C=T;else if(C=A.isPointLight===!0?l:o,e.localClippingEnabled&&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 D=C.uuid,P=w.uuid,O=h[D];O===void 0&&(O={},h[D]=O);let B=O[P];B===void 0&&(B=C.clone(),O[P]=B),C=B}return C.visible=w.visible,C.wireframe=w.wireframe,M===Hh?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 x(b,w,A,S,_){if(b.visible===!1)return;if(b.layers.test(w.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&_===Hh)&&(!b.frustumCulled||r.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,b.matrixWorld);let C=t.update(b),T=b.material;if(Array.isArray(T)){let D=C.groups;for(let P=0,O=D.length;P<O;P++){let B=D[P],G=T[B.materialIndex];if(G&&G.visible){let F=y(b,G,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,F,b,B)}}}else if(T.visible){let D=y(b,T,S,A.near,A.far,_);e.renderBufferDirect(A,null,C,D,b,null)}}let M=b.children;for(let C=0,T=M.length;C<T;C++)x(M[C],w,A,S,_)}}function VO(e,t,i){let r=i.isWebGL2;function s(){let Y=!1,ne=new rt,ve=null,_e=new rt(0,0,0,0);return{setMask:function(qe){ve!==qe&&!Y&&(e.colorMask(qe,qe,qe,qe),ve=qe)},setLocked:function(qe){Y=qe},setClear:function(qe,xt,Vt,Oi,_n){_n===!0&&(qe*=Oi,xt*=Oi,Vt*=Oi),ne.set(qe,xt,Vt,Oi),_e.equals(ne)===!1&&(e.clearColor(qe,xt,Vt,Oi),_e.copy(ne))},reset:function(){Y=!1,ve=null,_e.set(-1,0,0,0)}}}function a(){let Y=!1,ne=null,ve=null,_e=null;return{setTest:function(qe){qe?ie(2929):Q(2929)},setMask:function(qe){ne!==qe&&!Y&&(e.depthMask(qe),ne=qe)},setFunc:function(qe){if(ve!==qe){switch(qe){case oT:e.depthFunc(512);break;case lT:e.depthFunc(519);break;case hT:e.depthFunc(513);break;case tg:e.depthFunc(515);break;case cT:e.depthFunc(514);break;case dT:e.depthFunc(518);break;case uT:e.depthFunc(516);break;case pT:e.depthFunc(517);break;default:e.depthFunc(515)}ve=qe}},setLocked:function(qe){Y=qe},setClear:function(qe){_e!==qe&&(e.clearDepth(qe),_e=qe)},reset:function(){Y=!1,ne=null,ve=null,_e=null}}}function n(){let Y=!1,ne=null,ve=null,_e=null,qe=null,xt=null,Vt=null,Oi=null,_n=null;return{setTest:function(Ft){Y||(Ft?ie(2960):Q(2960))},setMask:function(Ft){ne!==Ft&&!Y&&(e.stencilMask(Ft),ne=Ft)},setFunc:function(Ft,Js,Ir){(ve!==Ft||_e!==Js||qe!==Ir)&&(e.stencilFunc(Ft,Js,Ir),ve=Ft,_e=Js,qe=Ir)},setOp:function(Ft,Js,Ir){(xt!==Ft||Vt!==Js||Oi!==Ir)&&(e.stencilOp(Ft,Js,Ir),xt=Ft,Vt=Js,Oi=Ir)},setLocked:function(Ft){Y=Ft},setClear:function(Ft){_n!==Ft&&(e.clearStencil(Ft),_n=Ft)},reset:function(){Y=!1,ne=null,ve=null,_e=null,qe=null,xt=null,Vt=null,Oi=null,_n=null}}}let o=new s,l=new a,h=new n,d=new WeakMap,c=new WeakMap,u={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,D=null,P=null,O=null,B=e.getParameter(35661),G=!1,F=0,z=e.getParameter(7938);z.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(z)[1]),G=F>=1):z.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),G=F>=2);let X=null,H={},j=e.getParameter(3088),N=e.getParameter(2978),q=new rt().fromArray(j),V=new rt().fromArray(N);function W(Y,ne,ve){let _e=new Uint8Array(4),qe=e.createTexture();e.bindTexture(Y,qe),e.texParameteri(Y,10241,9728),e.texParameteri(Y,10240,9728);for(let xt=0;xt<ve;xt++)e.texImage2D(ne+xt,0,6408,1,1,0,6408,5121,_e);return qe}let U={};U[3553]=W(3553,3553,1),U[34067]=W(34067,34069,6),o.setClear(0,0,0,1),l.setClear(1),h.setClear(0),ie(2929),l.setFunc(tg),Ee(!1),Ie(Gy),ie(2884),Me(ni);function ie(Y){u[Y]!==!0&&(e.enable(Y),u[Y]=!0)}function Q(Y){u[Y]!==!1&&(e.disable(Y),u[Y]=!1)}function re(Y,ne){return p[Y]!==ne?(e.bindFramebuffer(Y,ne),p[Y]=ne,r&&(Y===36009&&(p[36160]=ne),Y===36160&&(p[36009]=ne)),!0):!1}function Z(Y,ne){let ve=m,_e=!1;if(Y)if(ve=f.get(ne),ve===void 0&&(ve=[],f.set(ne,ve)),Y.isWebGLMultipleRenderTargets){let qe=Y.texture;if(ve.length!==qe.length||ve[0]!==36064){for(let xt=0,Vt=qe.length;xt<Vt;xt++)ve[xt]=36064+xt;ve.length=qe.length,_e=!0}}else ve[0]!==36064&&(ve[0]=36064,_e=!0);else ve[0]!==1029&&(ve[0]=1029,_e=!0);_e&&(i.isWebGL2?e.drawBuffers(ve):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(ve))}function pe(Y){return g!==Y?(e.useProgram(Y),g=Y,!0):!1}let oe={[Zo]:32774,[ZC]:32778,[KC]:32779};if(r)oe[Xy]=32775,oe[Yy]=32776;else{let Y=t.get("EXT_blend_minmax");Y!==null&&(oe[Xy]=Y.MIN_EXT,oe[Yy]=Y.MAX_EXT)}let ae={[JC]:0,[$C]:1,[eT]:768,[bS]:770,[nT]:776,[sT]:774,[iT]:772,[tT]:769,[wS]:771,[aT]:775,[rT]:773};function Me(Y,ne,ve,_e,qe,xt,Vt,Oi){if(Y===ni){v===!0&&(Q(3042),v=!1);return}if(v===!1&&(ie(3042),v=!0),Y!==QC){if(Y!==y||Oi!==M){if((x!==Zo||A!==Zo)&&(e.blendEquation(32774),x=Zo,A=Zo),Oi)switch(Y){case dl:e.blendFuncSeparate(1,771,1,771);break;case Hy:e.blendFunc(1,1);break;case Wy:e.blendFuncSeparate(0,769,0,1);break;case qy:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}else switch(Y){case dl:e.blendFuncSeparate(770,771,1,771);break;case Hy:e.blendFunc(770,1);break;case Wy:e.blendFuncSeparate(0,769,0,1);break;case qy:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Y);break}b=null,w=null,S=null,_=null,y=Y,M=Oi}return}qe=qe||ne,xt=xt||ve,Vt=Vt||_e,(ne!==x||qe!==A)&&(e.blendEquationSeparate(oe[ne],oe[qe]),x=ne,A=qe),(ve!==b||_e!==w||xt!==S||Vt!==_)&&(e.blendFuncSeparate(ae[ve],ae[_e],ae[xt],ae[Vt]),b=ve,w=_e,S=xt,_=Vt),y=Y,M=!1}function Ae(Y,ne){Y.side===Cr?Q(2884):ie(2884);let ve=Y.side===Si;ne&&(ve=!ve),Ee(ve),Y.blending===dl&&Y.transparent===!1?Me(ni):Me(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst,Y.blendEquationAlpha,Y.blendSrcAlpha,Y.blendDstAlpha,Y.premultipliedAlpha),l.setFunc(Y.depthFunc),l.setTest(Y.depthTest),l.setMask(Y.depthWrite),o.setMask(Y.colorWrite);let _e=Y.stencilWrite;h.setTest(_e),_e&&(h.setMask(Y.stencilWriteMask),h.setFunc(Y.stencilFunc,Y.stencilRef,Y.stencilFuncMask),h.setOp(Y.stencilFail,Y.stencilZFail,Y.stencilZPass)),ye(Y.polygonOffset,Y.polygonOffsetFactor,Y.polygonOffsetUnits),Y.alphaToCoverage===!0?ie(32926):Q(32926)}function Ee(Y){C!==Y&&(Y?e.frontFace(2304):e.frontFace(2305),C=Y)}function Ie(Y){Y!==qC?(ie(2884),Y!==T&&(Y===Gy?e.cullFace(1029):Y===XC?e.cullFace(1028):e.cullFace(1032))):Q(2884),T=Y}function be(Y){Y!==D&&(G&&e.lineWidth(Y),D=Y)}function ye(Y,ne,ve){Y?(ie(32823),(P!==ne||O!==ve)&&(e.polygonOffset(ne,ve),P=ne,O=ve)):Q(32823)}function Ne(Y){Y?ie(3089):Q(3089)}function Je(Y){Y===void 0&&(Y=33984+B-1),X!==Y&&(e.activeTexture(Y),X=Y)}function R(Y,ne,ve){ve===void 0&&(X===null?ve=33984+B-1:ve=X);let _e=H[ve];_e===void 0&&(_e={type:void 0,texture:void 0},H[ve]=_e),(_e.type!==Y||_e.texture!==ne)&&(X!==ve&&(e.activeTexture(ve),X=ve),e.bindTexture(Y,ne||U[Y]),_e.type=Y,_e.texture=ne)}function I(){let Y=H[X];Y!==void 0&&Y.type!==void 0&&(e.bindTexture(Y.type,null),Y.type=void 0,Y.texture=void 0)}function $(){try{e.compressedTexImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ge(){try{e.compressedTexImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function de(){try{e.texSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function xe(){try{e.texSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Be(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ce(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ue(){try{e.texStorage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Oe(){try{e.texStorage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function ze(){try{e.texImage2D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Le(){try{e.texImage3D.apply(e,arguments)}catch(Y){console.error("THREE.WebGLState:",Y)}}function Ze(Y){q.equals(Y)===!1&&(e.scissor(Y.x,Y.y,Y.z,Y.w),q.copy(Y))}function Ve(Y){V.equals(Y)===!1&&(e.viewport(Y.x,Y.y,Y.z,Y.w),V.copy(Y))}function mt(Y,ne){let ve=c.get(ne);ve===void 0&&(ve=new WeakMap,c.set(ne,ve));let _e=ve.get(Y);_e===void 0&&(_e=e.getUniformBlockIndex(ne,Y.name),ve.set(Y,_e))}function zt(Y,ne){let ve=c.get(ne).get(Y);d.get(ne)!==ve&&(e.uniformBlockBinding(ne,ve,Y.__bindingPointIndex),d.set(ne,ve))}function ti(){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),u={},X=null,H={},p={},f=new WeakMap,m=[],g=null,v=!1,y=null,x=null,b=null,w=null,A=null,S=null,_=null,M=!1,C=null,T=null,D=null,P=null,O=null,q.set(0,0,e.canvas.width,e.canvas.height),V.set(0,0,e.canvas.width,e.canvas.height),o.reset(),l.reset(),h.reset()}return{buffers:{color:o,depth:l,stencil:h},enable:ie,disable:Q,bindFramebuffer:re,drawBuffers:Z,useProgram:pe,setBlending:Me,setMaterial:Ae,setFlipSided:Ee,setCullFace:Ie,setLineWidth:be,setPolygonOffset:ye,setScissorTest:Ne,activeTexture:Je,bindTexture:R,unbindTexture:I,compressedTexImage2D:$,compressedTexImage3D:ge,texImage2D:ze,texImage3D:Le,updateUBOMapping:mt,uniformBlockBinding:zt,texStorage2D:ue,texStorage3D:Oe,texSubImage2D:de,texSubImage3D:xe,compressedTexSubImage2D:Be,compressedTexSubImage3D:Ce,scissor:Ze,viewport:Ve,reset:ti}}function jO(e,t,i,r,s,a,n){let o=s.isWebGL2,l=s.maxTextures,h=s.maxCubemapSize,d=s.maxTextureSize,c=s.maxSamples,u=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,m,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):Tu("canvas")}function x(R,I,$,ge){let de=1;if((R.width>ge||R.height>ge)&&(de=ge/Math.max(R.width,R.height)),de<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let xe=I?Cu:Math.floor,Be=xe(de*R.width),Ce=xe(de*R.height);m===void 0&&(m=y(Be,Ce));let ue=$?y(Be,Ce):m;return ue.width=Be,ue.height=Ce,ue.getContext("2d").drawImage(R,0,0,Be,Ce),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Be+"x"+Ce+")."),ue}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return og(R.width)&&og(R.height)}function w(R){return o?!1:R.wrapS!==Kt||R.wrapT!==Kt||R.minFilter!==Rt&&R.minFilter!==ot}function A(R,I){return R.generateMipmaps&&I&&R.minFilter!==Rt&&R.minFilter!==ot}function S(R){e.generateMipmap(R)}function _(R,I,$,ge,de=!1){if(o===!1)return I;if(R!==null){if(e[R]!==void 0)return e[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let xe=I;return I===6403&&($===5126&&(xe=33326),$===5131&&(xe=33325),$===5121&&(xe=33321)),I===33319&&($===5126&&(xe=33328),$===5131&&(xe=33327),$===5121&&(xe=33323)),I===6408&&($===5126&&(xe=34836),$===5131&&(xe=34842),$===5121&&(xe=ge===tt&&de===!1?35907:32856),$===32819&&(xe=32854),$===32820&&(xe=32855)),(xe===33325||xe===33326||xe===33327||xe===33328||xe===34842||xe===34836)&&t.get("EXT_color_buffer_float"),xe}function M(R,I,$){return A(R,$)===!0||R.isFramebufferTexture&&R.minFilter!==Rt&&R.minFilter!==ot?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function C(R){return R===Rt||R===Qy||R===rf?9728:9729}function T(R){let I=R.target;I.removeEventListener("dispose",T),P(I),I.isVideoTexture&&f.delete(I)}function D(R){let I=R.target;I.removeEventListener("dispose",D),B(I)}function P(R){let I=r.get(R);if(I.__webglInit===void 0)return;let $=R.source,ge=g.get($);if(ge){let de=ge[I.__cacheKey];de.usedTimes--,de.usedTimes===0&&O(R),Object.keys(ge).length===0&&g.delete($)}r.remove(R)}function O(R){let I=r.get(R);e.deleteTexture(I.__webglTexture);let $=R.source,ge=g.get($);delete ge[I.__cacheKey],n.memory.textures--}function B(R){let I=R.texture,$=r.get(R),ge=r.get(I);if(ge.__webglTexture!==void 0&&(e.deleteTexture(ge.__webglTexture),n.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)e.deleteFramebuffer($.__webglFramebuffer[de]),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer[de]);else{if(e.deleteFramebuffer($.__webglFramebuffer),$.__webglDepthbuffer&&e.deleteRenderbuffer($.__webglDepthbuffer),$.__webglMultisampledFramebuffer&&e.deleteFramebuffer($.__webglMultisampledFramebuffer),$.__webglColorRenderbuffer)for(let de=0;de<$.__webglColorRenderbuffer.length;de++)$.__webglColorRenderbuffer[de]&&e.deleteRenderbuffer($.__webglColorRenderbuffer[de]);$.__webglDepthRenderbuffer&&e.deleteRenderbuffer($.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let de=0,xe=I.length;de<xe;de++){let Be=r.get(I[de]);Be.__webglTexture&&(e.deleteTexture(Be.__webglTexture),n.memory.textures--),r.remove(I[de])}r.remove(I),r.remove(R)}let G=0;function F(){G=0}function z(){let R=G;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),G+=1,R}function X(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.wrapR||0),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function H(R,I){let $=r.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&$.__version!==R.version){let ge=R.image;if(ge===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ge.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q($,R,I);return}}i.bindTexture(3553,$.__webglTexture,33984+I)}function j(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(35866,$.__webglTexture,33984+I)}function N(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){Q($,R,I);return}i.bindTexture(32879,$.__webglTexture,33984+I)}function q(R,I){let $=r.get(R);if(R.version>0&&$.__version!==R.version){re($,R,I);return}i.bindTexture(34067,$.__webglTexture,33984+I)}let V={[ba]:10497,[Kt]:33071,[sg]:33648},W={[Rt]:9728,[Qy]:9984,[rf]:9986,[ot]:9729,[wT]:9985,[Cl]:9987};function U(R,I,$){if($?(e.texParameteri(R,10242,V[I.wrapS]),e.texParameteri(R,10243,V[I.wrapT]),(R===32879||R===35866)&&e.texParameteri(R,32882,V[I.wrapR]),e.texParameteri(R,10240,W[I.magFilter]),e.texParameteri(R,10241,W[I.minFilter])):(e.texParameteri(R,10242,33071),e.texParameteri(R,10243,33071),(R===32879||R===35866)&&e.texParameteri(R,32882,33071),(I.wrapS!==Kt||I.wrapT!==Kt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(R,10240,C(I.magFilter)),e.texParameteri(R,10241,C(I.minFilter)),I.minFilter!==Rt&&I.minFilter!==ot&&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 ge=t.get("EXT_texture_filter_anisotropic");if(I.magFilter===Rt||I.minFilter!==rf&&I.minFilter!==Cl||I.type===Tr&&t.has("OES_texture_float_linear")===!1||o===!1&&I.type===Tl&&t.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||r.get(I).__currentAnisotropy)&&(e.texParameterf(R,ge.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,s.getMaxAnisotropy())),r.get(I).__currentAnisotropy=I.anisotropy)}}function ie(R,I){let $=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",T));let ge=I.source,de=g.get(ge);de===void 0&&(de={},g.set(ge,de));let xe=X(I);if(xe!==R.__cacheKey){de[xe]===void 0&&(de[xe]={texture:e.createTexture(),usedTimes:0},n.memory.textures++,$=!0),de[xe].usedTimes++;let Be=de[R.__cacheKey];Be!==void 0&&(de[R.__cacheKey].usedTimes--,Be.usedTimes===0&&O(I)),R.__cacheKey=xe,R.__webglTexture=de[xe].texture}return $}function Q(R,I,$){let ge=3553;(I.isDataArrayTexture||I.isCompressedArrayTexture)&&(ge=35866),I.isData3DTexture&&(ge=32879);let de=ie(R,I),xe=I.source;i.bindTexture(ge,R.__webglTexture,33984+$);let Be=r.get(xe);if(xe.version!==Be.__version||de===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Ce=w(I)&&b(I.image)===!1,ue=x(I.image,Ce,!1,d);ue=Je(I,ue);let Oe=b(ue)||o,ze=a.convert(I.format,I.encoding),Le=a.convert(I.type),Ze=_(I.internalFormat,ze,Le,I.encoding,I.isVideoTexture);U(ge,I,Oe);let Ve,mt=I.mipmaps,zt=o&&I.isVideoTexture!==!0,ti=Be.__version===void 0||de===!0,Y=M(I,ue,Oe);if(I.isDepthTexture)Ze=6402,o?I.type===Tr?Ze=36012:I.type===Ka?Ze=33190:I.type===Yn?Ze=35056:Ze=33189:I.type===Tr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Qn&&Ze===6402&&I.type!==AS&&I.type!==Ka&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=Ka,Le=a.convert(I.type)),I.format===ro&&Ze===6402&&(Ze=34041,I.type!==Yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Yn,Le=a.convert(I.type))),ti&&(zt?i.texStorage2D(3553,1,Ze,ue.width,ue.height):i.texImage2D(3553,0,Ze,ue.width,ue.height,0,ze,Le,null));else if(I.isDataTexture)if(mt.length>0&&Oe){zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],zt?i.texSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Le,Ve.data):i.texImage2D(3553,ne,Ze,Ve.width,Ve.height,0,ze,Le,Ve.data);I.generateMipmaps=!1}else zt?(ti&&i.texStorage2D(3553,Y,Ze,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ue.width,ue.height,ze,Le,ue.data)):i.texImage2D(3553,0,Ze,ue.width,ue.height,0,ze,Le,ue.data);else if(I.isCompressedTexture)if(I.isCompressedArrayTexture){zt&&ti&&i.texStorage3D(35866,Y,Ze,mt[0].width,mt[0].height,ue.depth);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],I.format!==jr?ze!==null?zt?i.compressedTexSubImage3D(35866,ne,0,0,0,Ve.width,Ve.height,ue.depth,ze,Ve.data,0,0):i.compressedTexImage3D(35866,ne,Ze,Ve.width,Ve.height,ue.depth,0,Ve.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?i.texSubImage3D(35866,ne,0,0,0,Ve.width,Ve.height,ue.depth,ze,Le,Ve.data):i.texImage3D(35866,ne,Ze,Ve.width,Ve.height,ue.depth,0,ze,Le,Ve.data)}else{zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],I.format!==jr?ze!==null?zt?i.compressedTexSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Ve.data):i.compressedTexImage2D(3553,ne,Ze,Ve.width,Ve.height,0,Ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):zt?i.texSubImage2D(3553,ne,0,0,Ve.width,Ve.height,ze,Le,Ve.data):i.texImage2D(3553,ne,Ze,Ve.width,Ve.height,0,ze,Le,Ve.data)}else if(I.isDataArrayTexture)zt?(ti&&i.texStorage3D(35866,Y,Ze,ue.width,ue.height,ue.depth),i.texSubImage3D(35866,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):i.texImage3D(35866,0,Ze,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isData3DTexture)zt?(ti&&i.texStorage3D(32879,Y,Ze,ue.width,ue.height,ue.depth),i.texSubImage3D(32879,0,0,0,0,ue.width,ue.height,ue.depth,ze,Le,ue.data)):i.texImage3D(32879,0,Ze,ue.width,ue.height,ue.depth,0,ze,Le,ue.data);else if(I.isFramebufferTexture){if(ti)if(zt)i.texStorage2D(3553,Y,Ze,ue.width,ue.height);else{let ne=ue.width,ve=ue.height;for(let _e=0;_e<Y;_e++)i.texImage2D(3553,_e,Ze,ne,ve,0,ze,Le,null),ne>>=1,ve>>=1}}else if(mt.length>0&&Oe){zt&&ti&&i.texStorage2D(3553,Y,Ze,mt[0].width,mt[0].height);for(let ne=0,ve=mt.length;ne<ve;ne++)Ve=mt[ne],zt?i.texSubImage2D(3553,ne,0,0,ze,Le,Ve):i.texImage2D(3553,ne,Ze,ze,Le,Ve);I.generateMipmaps=!1}else zt?(ti&&i.texStorage2D(3553,Y,Ze,ue.width,ue.height),i.texSubImage2D(3553,0,0,0,ze,Le,ue)):i.texImage2D(3553,0,Ze,ze,Le,ue);A(I,Oe)&&S(ge),Be.__version=xe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function re(R,I,$){if(I.image.length!==6)return;let ge=ie(R,I),de=I.source;i.bindTexture(34067,R.__webglTexture,33984+$);let xe=r.get(de);if(de.version!==xe.__version||ge===!0){i.activeTexture(33984+$),e.pixelStorei(37440,I.flipY),e.pixelStorei(37441,I.premultiplyAlpha),e.pixelStorei(3317,I.unpackAlignment),e.pixelStorei(37443,0);let Be=I.isCompressedTexture||I.image[0].isCompressedTexture,Ce=I.image[0]&&I.image[0].isDataTexture,ue=[];for(let ne=0;ne<6;ne++)!Be&&!Ce?ue[ne]=x(I.image[ne],!1,!0,h):ue[ne]=Ce?I.image[ne].image:I.image[ne],ue[ne]=Je(I,ue[ne]);let Oe=ue[0],ze=b(Oe)||o,Le=a.convert(I.format,I.encoding),Ze=a.convert(I.type),Ve=_(I.internalFormat,Le,Ze,I.encoding),mt=o&&I.isVideoTexture!==!0,zt=xe.__version===void 0||ge===!0,ti=M(I,Oe,ze);U(34067,I,ze);let Y;if(Be){mt&&zt&&i.texStorage2D(34067,ti,Ve,Oe.width,Oe.height);for(let ne=0;ne<6;ne++){Y=ue[ne].mipmaps;for(let ve=0;ve<Y.length;ve++){let _e=Y[ve];I.format!==jr?Le!==null?mt?i.compressedTexSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Le,_e.data):i.compressedTexImage2D(34069+ne,ve,Ve,_e.width,_e.height,0,_e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):mt?i.texSubImage2D(34069+ne,ve,0,0,_e.width,_e.height,Le,Ze,_e.data):i.texImage2D(34069+ne,ve,Ve,_e.width,_e.height,0,Le,Ze,_e.data)}}}else{Y=I.mipmaps,mt&&zt&&(Y.length>0&&ti++,i.texStorage2D(34067,ti,Ve,ue[0].width,ue[0].height));for(let ne=0;ne<6;ne++)if(Ce){mt?i.texSubImage2D(34069+ne,0,0,0,ue[ne].width,ue[ne].height,Le,Ze,ue[ne].data):i.texImage2D(34069+ne,0,Ve,ue[ne].width,ue[ne].height,0,Le,Ze,ue[ne].data);for(let ve=0;ve<Y.length;ve++){let _e=Y[ve].image[ne].image;mt?i.texSubImage2D(34069+ne,ve+1,0,0,_e.width,_e.height,Le,Ze,_e.data):i.texImage2D(34069+ne,ve+1,Ve,_e.width,_e.height,0,Le,Ze,_e.data)}}else{mt?i.texSubImage2D(34069+ne,0,0,0,Le,Ze,ue[ne]):i.texImage2D(34069+ne,0,Ve,Le,Ze,ue[ne]);for(let ve=0;ve<Y.length;ve++){let _e=Y[ve];mt?i.texSubImage2D(34069+ne,ve+1,0,0,Le,Ze,_e.image[ne]):i.texImage2D(34069+ne,ve+1,Ve,Le,Ze,_e.image[ne])}}}A(I,ze)&&S(34067),xe.__version=de.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function Z(R,I,$,ge,de){let xe=a.convert($.format,$.encoding),Be=a.convert($.type),Ce=_($.internalFormat,xe,Be,$.encoding);r.get(I).__hasExternalTextures||(de===32879||de===35866?i.texImage3D(de,0,Ce,I.width,I.height,I.depth,0,xe,Be,null):i.texImage2D(de,0,Ce,I.width,I.height,0,xe,Be,null)),i.bindFramebuffer(36160,R),ye(I)?u.framebufferTexture2DMultisampleEXT(36160,ge,de,r.get($).__webglTexture,0,be(I)):(de===3553||de>=34069&&de<=34074)&&e.framebufferTexture2D(36160,ge,de,r.get($).__webglTexture,0),i.bindFramebuffer(36160,null)}function pe(R,I,$){if(e.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let ge=33189;if($||ye(I)){let de=I.depthTexture;de&&de.isDepthTexture&&(de.type===Tr?ge=36012:de.type===Ka&&(ge=33190));let xe=be(I);ye(I)?u.renderbufferStorageMultisampleEXT(36161,xe,ge,I.width,I.height):e.renderbufferStorageMultisample(36161,xe,ge,I.width,I.height)}else e.renderbufferStorage(36161,ge,I.width,I.height);e.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let ge=be(I);$&&ye(I)===!1?e.renderbufferStorageMultisample(36161,ge,35056,I.width,I.height):ye(I)?u.renderbufferStorageMultisampleEXT(36161,ge,35056,I.width,I.height):e.renderbufferStorage(36161,34041,I.width,I.height),e.framebufferRenderbuffer(36160,33306,36161,R)}else{let ge=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let de=0;de<ge.length;de++){let xe=ge[de],Be=a.convert(xe.format,xe.encoding),Ce=a.convert(xe.type),ue=_(xe.internalFormat,Be,Ce,xe.encoding),Oe=be(I);$&&ye(I)===!1?e.renderbufferStorageMultisample(36161,Oe,ue,I.width,I.height):ye(I)?u.renderbufferStorageMultisampleEXT(36161,Oe,ue,I.width,I.height):e.renderbufferStorage(36161,ue,I.width,I.height)}}e.bindRenderbuffer(36161,null)}function oe(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),H(I.depthTexture,0);let $=r.get(I.depthTexture).__webglTexture,ge=be(I);if(I.depthTexture.format===Qn)ye(I)?u.framebufferTexture2DMultisampleEXT(36160,36096,3553,$,0,ge):e.framebufferTexture2D(36160,36096,3553,$,0);else if(I.depthTexture.format===ro)ye(I)?u.framebufferTexture2DMultisampleEXT(36160,33306,3553,$,0,ge):e.framebufferTexture2D(36160,33306,3553,$,0);else throw new Error("Unknown depthTexture format")}function ae(R){let I=r.get(R),$=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if($)throw new Error("target.depthTexture not supported in Cube render targets");oe(I.__webglFramebuffer,R)}else if($){I.__webglDepthbuffer=[];for(let ge=0;ge<6;ge++)i.bindFramebuffer(36160,I.__webglFramebuffer[ge]),I.__webglDepthbuffer[ge]=e.createRenderbuffer(),pe(I.__webglDepthbuffer[ge],R,!1)}else i.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=e.createRenderbuffer(),pe(I.__webglDepthbuffer,R,!1);i.bindFramebuffer(36160,null)}function Me(R,I,$){let ge=r.get(R);I!==void 0&&Z(ge.__webglFramebuffer,R,R.texture,36064,3553),$!==void 0&&ae(R)}function Ae(R){let I=R.texture,$=r.get(R),ge=r.get(I);R.addEventListener("dispose",D),R.isWebGLMultipleRenderTargets!==!0&&(ge.__webglTexture===void 0&&(ge.__webglTexture=e.createTexture()),ge.__version=I.version,n.memory.textures++);let de=R.isWebGLCubeRenderTarget===!0,xe=R.isWebGLMultipleRenderTargets===!0,Be=b(R)||o;if(de){$.__webglFramebuffer=[];for(let Ce=0;Ce<6;Ce++)$.__webglFramebuffer[Ce]=e.createFramebuffer()}else{if($.__webglFramebuffer=e.createFramebuffer(),xe)if(s.drawBuffers){let Ce=R.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=r.get(Ce[ue]);ze.__webglTexture===void 0&&(ze.__webglTexture=e.createTexture(),n.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&R.samples>0&&ye(R)===!1){let Ce=xe?I:[I];$.__webglMultisampledFramebuffer=e.createFramebuffer(),$.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,$.__webglMultisampledFramebuffer);for(let ue=0;ue<Ce.length;ue++){let Oe=Ce[ue];$.__webglColorRenderbuffer[ue]=e.createRenderbuffer(),e.bindRenderbuffer(36161,$.__webglColorRenderbuffer[ue]);let ze=a.convert(Oe.format,Oe.encoding),Le=a.convert(Oe.type),Ze=_(Oe.internalFormat,ze,Le,Oe.encoding,R.isXRRenderTarget===!0),Ve=be(R);e.renderbufferStorageMultisample(36161,Ve,Ze,R.width,R.height),e.framebufferRenderbuffer(36160,36064+ue,36161,$.__webglColorRenderbuffer[ue])}e.bindRenderbuffer(36161,null),R.depthBuffer&&($.__webglDepthRenderbuffer=e.createRenderbuffer(),pe($.__webglDepthRenderbuffer,R,!0)),i.bindFramebuffer(36160,null)}}if(de){i.bindTexture(34067,ge.__webglTexture),U(34067,I,Be);for(let Ce=0;Ce<6;Ce++)Z($.__webglFramebuffer[Ce],R,I,36064,34069+Ce);A(I,Be)&&S(34067),i.unbindTexture()}else if(xe){let Ce=R.texture;for(let ue=0,Oe=Ce.length;ue<Oe;ue++){let ze=Ce[ue],Le=r.get(ze);i.bindTexture(3553,Le.__webglTexture),U(3553,ze,Be),Z($.__webglFramebuffer,R,ze,36064+ue,3553),A(ze,Be)&&S(3553)}i.unbindTexture()}else{let Ce=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?Ce=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(Ce,ge.__webglTexture),U(Ce,I,Be),Z($.__webglFramebuffer,R,I,36064,Ce),A(I,Be)&&S(Ce),i.unbindTexture()}R.depthBuffer&&ae(R)}function Ee(R){let I=b(R)||o,$=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let ge=0,de=$.length;ge<de;ge++){let xe=$[ge];if(A(xe,I)){let Be=R.isWebGLCubeRenderTarget?34067:3553,Ce=r.get(xe).__webglTexture;i.bindTexture(Be,Ce),S(Be),i.unbindTexture()}}}function Ie(R){if(o&&R.samples>0&&ye(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],$=R.width,ge=R.height,de=16384,xe=[],Be=R.stencilBuffer?33306:36096,Ce=r.get(R),ue=R.isWebGLMultipleRenderTargets===!0;if(ue)for(let Oe=0;Oe<I.length;Oe++)i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,null),i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,null,0);i.bindFramebuffer(36008,Ce.__webglMultisampledFramebuffer),i.bindFramebuffer(36009,Ce.__webglFramebuffer);for(let Oe=0;Oe<I.length;Oe++){xe.push(36064+Oe),R.depthBuffer&&xe.push(Be);let ze=Ce.__ignoreDepthValues!==void 0?Ce.__ignoreDepthValues:!1;if(ze===!1&&(R.depthBuffer&&(de|=256),R.stencilBuffer&&(de|=1024)),ue&&e.framebufferRenderbuffer(36008,36064,36161,Ce.__webglColorRenderbuffer[Oe]),ze===!0&&(e.invalidateFramebuffer(36008,[Be]),e.invalidateFramebuffer(36009,[Be])),ue){let Le=r.get(I[Oe]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,Le,0)}e.blitFramebuffer(0,0,$,ge,0,0,$,ge,de,9728),p&&e.invalidateFramebuffer(36008,xe)}if(i.bindFramebuffer(36008,null),i.bindFramebuffer(36009,null),ue)for(let Oe=0;Oe<I.length;Oe++){i.bindFramebuffer(36160,Ce.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+Oe,36161,Ce.__webglColorRenderbuffer[Oe]);let ze=r.get(I[Oe]).__webglTexture;i.bindFramebuffer(36160,Ce.__webglFramebuffer),e.framebufferTexture2D(36009,36064+Oe,3553,ze,0)}i.bindFramebuffer(36009,Ce.__webglMultisampledFramebuffer)}}function be(R){return Math.min(c,R.samples)}function ye(R){let I=r.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ne(R){let I=n.render.frame;f.get(R)!==I&&(f.set(R,I),R.update())}function Je(R,I){let $=R.encoding,ge=R.format,de=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===ng||$!==Gs&&($===tt?o===!1?t.has("EXT_sRGB")===!0&&ge===jr?(R.format=ng,R.minFilter=ot,R.generateMipmaps=!1):I=OS.sRGBToLinear(I):(ge!==jr||de!==ji)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",$)),I}this.allocateTextureUnit=z,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=j,this.setTexture3D=N,this.setTextureCube=q,this.rebindTextures=Me,this.setupRenderTarget=Ae,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=Ie,this.setupDepthRenderbuffer=ae,this.setupFrameBufferTexture=Z,this.useMultisampledRTT=ye}function GO(e,t,i){let r=i.isWebGL2;function s(a,n=null){let o;if(a===ji)return 5121;if(a===MT)return 32819;if(a===ET)return 32820;if(a===_T)return 5120;if(a===ST)return 5122;if(a===AS)return 5123;if(a===AT)return 5124;if(a===Ka)return 5125;if(a===Tr)return 5126;if(a===Tl)return r?5131:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(a===CT)return 6406;if(a===jr)return 6408;if(a===TT)return 6409;if(a===PT)return 6410;if(a===Qn)return 6402;if(a===ro)return 34041;if(a===ng)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(a===DT)return 6403;if(a===IT)return 36244;if(a===MS)return 33319;if(a===OT)return 33320;if(a===LT)return 36249;if(a===sf||a===af||a===nf||a===of)if(n===tt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(a===sf)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===af)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===nf)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===of)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(a===sf)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===af)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===nf)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===of)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Zy||a===Ky||a===Jy||a===$y)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(a===Zy)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Ky)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Jy)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===$y)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===RT)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===e1||a===t1)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(a===e1)return n===tt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(a===t1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===i1||a===r1||a===s1||a===a1||a===n1||a===o1||a===l1||a===h1||a===c1||a===d1||a===u1||a===p1||a===f1||a===m1)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(a===i1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===r1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===s1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===a1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===n1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===o1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===l1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===h1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===c1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===d1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===u1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===p1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===f1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===m1)return n===tt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===lf)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(a===lf)return n===tt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(a===BT||a===g1||a===v1||a===y1)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(a===lf)return o.COMPRESSED_RED_RGTC1_EXT;if(a===g1)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===v1)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===y1)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Yn?r?34042:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):e[a]!==void 0?e[a]:null}return{convert:s}}var HO=class extends zi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},al=class extends Tt{constructor(){super(),this.isGroup=!0,this.type="Group"}},WO={type:"move"},Rf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new al,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 al,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 al,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,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let f of e.hand.values()){let m=t.getJointPose(f,i),g=this._getHandJoint(l,f);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],c=h.position.distanceTo(d.position),u=.02,p=.005;l.inputState.pinching&&c>u+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&c<=u-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));n!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(n.matrix.fromArray(r.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),r.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(r.linearVelocity)):n.hasLinearVelocity=!1,r.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(r.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(WO)))}return n!==null&&(n.visible=r!==null),o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let i=new al;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Dl=class extends fi{constructor(e,t,i,r,s,a,n,o,l,h){if(h=h!==void 0?h:Qn,h!==Qn&&h!==ro)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&h===Qn&&(i=Ka),i===void 0&&h===ro&&(i=Yn),super(null,r,s,a,n,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=n!==void 0?n:Rt,this.minFilter=o!==void 0?o:Rt,this.flipY=!1,this.generateMipmaps=!1}},qO=class extends Ii{constructor(e,t){super();let i=this,r=null,s=1,a=null,n="local-floor",o=1,l=null,h=null,d=null,c=null,u=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Set,b=new Map,w=new zi;w.layers.enable(1),w.viewport=new rt;let A=new zi;A.layers.enable(2),A.viewport=new rt;let S=[w,A],_=new HO;_.layers.enable(1),_.layers.enable(2);let M=null,C=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getTargetRaySpace()},this.getControllerGrip=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getGripSpace()},this.getHand=function(j){let N=v[j];return N===void 0&&(N=new Rf,v[j]=N),N.getHandSpace()};function T(j){let N=y.indexOf(j.inputSource);if(N===-1)return;let q=v[N];q!==void 0&&q.dispatchEvent({type:j.type,data:j.inputSource})}function D(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",P);for(let j=0;j<v.length;j++){let N=y[j];N!==null&&(y[j]=null,v[j].disconnect(N))}M=null,C=null,e.setRenderTarget(m),u=null,c=null,d=null,r=null,g=null,H.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){s=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){n=j,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},this.getBaseLayer=function(){return c!==null?c:u},this.getBinding=function(){return d},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(j){if(r=j,r!==null){if(m=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",D),r.addEventListener("inputsourceschange",P),f.xrCompatible!==!0&&await t.makeXRCompatible(),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let N={antialias:r.renderState.layers===void 0?f.antialias:!0,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};u=new XRWebGLLayer(r,t,N),r.updateRenderState({baseLayer:u}),g=new Ct(u.framebufferWidth,u.framebufferHeight,{format:jr,type:ji,encoding:e.outputEncoding,stencilBuffer:f.stencil})}else{let N=null,q=null,V=null;f.depth&&(V=f.stencil?35056:33190,N=f.stencil?ro:Qn,q=f.stencil?Yn:Ka);let W={colorFormat:32856,depthFormat:V,scaleFactor:s};d=new XRWebGLBinding(r,t),c=d.createProjectionLayer(W),r.updateRenderState({layers:[c]}),g=new Ct(c.textureWidth,c.textureHeight,{format:jr,type:ji,depthTexture:new Dl(c.textureWidth,c.textureHeight,q,void 0,void 0,void 0,void 0,void 0,void 0,N),stencilBuffer:f.stencil,encoding:e.outputEncoding,samples:f.antialias?4:0});let U=e.properties.get(g);U.__ignoreDepthValues=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(n),H.setContext(r),H.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function P(j){for(let N=0;N<j.removed.length;N++){let q=j.removed[N],V=y.indexOf(q);V>=0&&(y[V]=null,v[V].disconnect(q))}for(let N=0;N<j.added.length;N++){let q=j.added[N],V=y.indexOf(q);if(V===-1){for(let U=0;U<v.length;U++)if(U>=y.length){y.push(q),V=U;break}else if(y[U]===null){y[U]=q,V=U;break}if(V===-1)break}let W=v[V];W&&W.connect(q)}}let O=new E,B=new E;function G(j,N,q){O.setFromMatrixPosition(N.matrixWorld),B.setFromMatrixPosition(q.matrixWorld);let V=O.distanceTo(B),W=N.projectionMatrix.elements,U=q.projectionMatrix.elements,ie=W[14]/(W[10]-1),Q=W[14]/(W[10]+1),re=(W[9]+1)/W[5],Z=(W[9]-1)/W[5],pe=(W[8]-1)/W[0],oe=(U[8]+1)/U[0],ae=ie*pe,Me=ie*oe,Ae=V/(-pe+oe),Ee=Ae*-pe;N.matrixWorld.decompose(j.position,j.quaternion,j.scale),j.translateX(Ee),j.translateZ(Ae),j.matrixWorld.compose(j.position,j.quaternion,j.scale),j.matrixWorldInverse.copy(j.matrixWorld).invert();let Ie=ie+Ae,be=Q+Ae,ye=ae-Ee,Ne=Me+(V-Ee),Je=re*Q/be*Ie,R=Z*Q/be*Ie;j.projectionMatrix.makePerspective(ye,Ne,Je,R,Ie,be)}function F(j,N){N===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(N.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(r===null)return;_.near=A.near=w.near=j.near,_.far=A.far=w.far=j.far,(M!==_.near||C!==_.far)&&(r.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,C=_.far);let N=j.parent,q=_.cameras;F(_,N);for(let W=0;W<q.length;W++)F(q[W],N);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),j.matrix.copy(_.matrix),j.matrix.decompose(j.position,j.quaternion,j.scale);let V=j.children;for(let W=0,U=V.length;W<U;W++)V[W].updateMatrixWorld(!0);q.length===2?G(_,w,A):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(!(c===null&&u===null))return o},this.setFoveation=function(j){o=j,c!==null&&(c.fixedFoveation=j),u!==null&&u.fixedFoveation!==void 0&&(u.fixedFoveation=j)},this.getPlanes=function(){return x};let z=null;function X(j,N){if(h=N.getViewerPose(l||a),p=N,h!==null){let q=h.views;u!==null&&(e.setRenderTargetFramebuffer(g,u.framebuffer),e.setRenderTarget(g));let V=!1;q.length!==_.cameras.length&&(_.cameras.length=0,V=!0);for(let W=0;W<q.length;W++){let U=q[W],ie=null;if(u!==null)ie=u.getViewport(U);else{let re=d.getViewSubImage(c,U);ie=re.viewport,W===0&&(e.setRenderTargetTextures(g,re.colorTexture,c.ignoreDepthValues?void 0:re.depthStencilTexture),e.setRenderTarget(g))}let Q=S[W];Q===void 0&&(Q=new zi,Q.layers.enable(W),Q.viewport=new rt,S[W]=Q),Q.matrix.fromArray(U.transform.matrix),Q.projectionMatrix.fromArray(U.projectionMatrix),Q.viewport.set(ie.x,ie.y,ie.width,ie.height),W===0&&_.matrix.copy(Q.matrix),V===!0&&_.cameras.push(Q)}}for(let q=0;q<v.length;q++){let V=y[q],W=v[q];V!==null&&W!==void 0&&W.update(V,N,l||a)}if(z&&z(j,N),N.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:N.detectedPlanes});let q=null;for(let V of x)N.detectedPlanes.has(V)||(q===null&&(q=[]),q.push(V));if(q!==null)for(let V of q)x.delete(V),b.delete(V),i.dispatchEvent({type:"planeremoved",data:V});for(let V of N.detectedPlanes)if(!x.has(V))x.add(V),b.set(V,N.lastChangedTime),i.dispatchEvent({type:"planeadded",data:V});else{let W=b.get(V);V.lastChangedTime>W&&(b.set(V,V.lastChangedTime),i.dispatchEvent({type:"planechanged",data:V}))}}p=null}let H=new NS;H.setAnimationLoop(X),this.setAnimationLoop=function(j){z=j},this.dispose=function(){}}};function XO(e,t){function i(m,g){g.color.getRGB(m.fogColor.value,zS(e)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function r(m,g,v,y,x){g.isMeshBasicMaterial||g.isMeshLambertMaterial?s(m,g):g.isMeshToonMaterial?(s(m,g),d(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g)):g.isMeshStandardMaterial?(s(m,g),c(m,g),g.isMeshPhysicalMaterial&&u(m,g,x)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),f(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&n(m,g)):g.isPointsMaterial?o(m,g,v,y):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.bumpMap&&(m.bumpMap.value=g.bumpMap,m.bumpScale.value=g.bumpScale,g.side===Si&&(m.bumpScale.value*=-1)),g.displacementMap&&(m.displacementMap.value=g.displacementMap,m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap),g.normalMap&&(m.normalMap.value=g.normalMap,m.normalScale.value.copy(g.normalScale),g.side===Si&&m.normalScale.value.negate()),g.specularMap&&(m.specularMap.value=g.specularMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v=t.get(g).envMap;if(v&&(m.envMap.value=v,m.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap){m.lightMap.value=g.lightMap;let b=e.physicallyCorrectLights!==!0?Math.PI:1;m.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let x;g.aoMap?x=g.aoMap:g.lightMap&&(x=g.lightMap),x!==void 0&&(x.isWebGLRenderTarget&&(x=x.texture),x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uv2Transform.value.copy(x.matrix))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity}function n(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function o(m,g,v,y){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*v,m.scale.value=y*.5,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let x;g.map?x=g.map:g.alphaMap&&(x=g.alphaMap),x!==void 0&&(x.matrixAutoUpdate===!0&&x.updateMatrix(),m.uvTransform.value.copy(x.matrix))}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map),g.alphaMap&&(m.alphaMap.value=g.alphaMap),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),m.uvTransform.value.copy(v.matrix))}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function c(m,g){m.roughness.value=g.roughness,m.metalness.value=g.metalness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap),t.get(g).envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function u(m,g,v){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),m.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===Si&&m.clearcoatNormalScale.value.negate())),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap)}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function f(m,g){m.referencePosition.value.copy(g.referencePosition),m.nearDistance.value=g.nearDistance,m.farDistance.value=g.farDistance}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function YO(e,t,i,r){let s={},a={},n=[],o=i.isWebGL2?e.getParameter(35375):0;function l(y,x){let b=x.program;r.uniformBlockBinding(y,b)}function h(y,x){let b=s[y.id];b===void 0&&(f(y),b=d(y),s[y.id]=b,y.addEventListener("dispose",g));let w=x.program;r.updateUBOMapping(y,w);let A=t.render.frame;a[y.id]!==A&&(u(y),a[y.id]=A)}function d(y){let x=c();y.__bindingPointIndex=x;let b=e.createBuffer(),w=y.__size,A=y.usage;return e.bindBuffer(35345,b),e.bufferData(35345,w,A),e.bindBuffer(35345,null),e.bindBufferBase(35345,x,b),b}function c(){for(let y=0;y<o;y++)if(n.indexOf(y)===-1)return n.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(y){let x=s[y.id],b=y.uniforms,w=y.__cache;e.bindBuffer(35345,x);for(let A=0,S=b.length;A<S;A++){let _=b[A];if(p(_,A,w)===!0){let M=_.__offset,C=Array.isArray(_.value)?_.value:[_.value],T=0;for(let D=0;D<C.length;D++){let P=C[D],O=m(P);typeof P=="number"?(_.__data[0]=P,e.bufferSubData(35345,M+T,_.__data)):P.isMatrix3?(_.__data[0]=P.elements[0],_.__data[1]=P.elements[1],_.__data[2]=P.elements[2],_.__data[3]=P.elements[0],_.__data[4]=P.elements[3],_.__data[5]=P.elements[4],_.__data[6]=P.elements[5],_.__data[7]=P.elements[0],_.__data[8]=P.elements[6],_.__data[9]=P.elements[7],_.__data[10]=P.elements[8],_.__data[11]=P.elements[0]):(P.toArray(_.__data,T),T+=O.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,M,_.__data)}}e.bindBuffer(35345,null)}function p(y,x,b){let w=y.value;if(b[x]===void 0){if(typeof w=="number")b[x]=w;else{let A=Array.isArray(w)?w:[w],S=[];for(let _=0;_<A.length;_++)S.push(A[_].clone());b[x]=S}return!0}else if(typeof w=="number"){if(b[x]!==w)return b[x]=w,!0}else{let A=Array.isArray(b[x])?b[x]:[b[x]],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 x=y.uniforms,b=0,w=16,A=0;for(let S=0,_=x.length;S<_;S++){let M=x[S],C={boundary:0,storage:0},T=Array.isArray(M.value)?M.value:[M.value];for(let D=0,P=T.length;D<P;D++){let O=T[D],B=m(O);C.boundary+=B.boundary,C.storage+=B.storage}if(M.__data=new Float32Array(C.storage/Float32Array.BYTES_PER_ELEMENT),M.__offset=b,S>0){A=b%w;let D=w-A;A!==0&&D-C.boundary<0&&(b+=w-A,M.__offset=b)}b+=C.storage}return A=b%w,A>0&&(b+=w-A),y.__size=b,y.__cache={},this}function m(y){let x={boundary:0,storage:0};return typeof y=="number"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function g(y){let x=y.target;x.removeEventListener("dispose",g);let b=n.indexOf(x.__bindingPointIndex);n.splice(b,1),e.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function v(){for(let y in s)e.deleteBuffer(s[y]);n=[],s={},a={}}return{bind:l,update:h,dispose:v}}function QO(){let e=Tu("canvas");return e.style.display="block",e}function GS(e={}){this.isWebGLRenderer=!0;let t=e.canvas!==void 0?e.canvas:QO(),i=e.context!==void 0?e.context:null,r=e.depth!==void 0?e.depth:!0,s=e.stencil!==void 0?e.stencil:!0,a=e.antialias!==void 0?e.antialias:!1,n=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,d;i!==null?d=i.getContextAttributes().alpha:d=e.alpha!==void 0?e.alpha:!1;let c=null,u=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=Gs,this.physicallyCorrectLights=!1,this.toneMapping=_a,this.toneMappingExposure=1;let m=this,g=!1,v=0,y=0,x=null,b=-1,w=null,A=new rt,S=new rt,_=null,M=t.width,C=t.height,T=1,D=null,P=null,O=new rt(0,0,M,C),B=new rt(0,0,M,C),G=!1,F=new Zv,z=!1,X=!1,H=null,j=new me,N=new k,q=new E,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return x===null?T:1}let U=i;function ie(L,ee){for(let le=0;le<L.length;le++){let J=L[le],he=t.getContext(J,ee);if(he!==null)return he}return null}try{let L={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:n,preserveDrawingBuffer:o,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Hl}`),t.addEventListener("webglcontextlost",Ze,!1),t.addEventListener("webglcontextrestored",Ve,!1),t.addEventListener("webglcontextcreationerror",mt,!1),U===null){let ee=["webgl2","webgl","experimental-webgl"];if(m.isWebGL1Renderer===!0&&ee.shift(),U=ie(ee,L),U===null)throw ie(ee)?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(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Q,re,Z,pe,oe,ae,Me,Ae,Ee,Ie,be,ye,Ne,Je,R,I,$,ge,de,xe,Be,Ce,ue,Oe;function ze(){Q=new lI(U),re=new iI(U,Q,e),Q.init(re),Ce=new GO(U,Q,re),Z=new VO(U,Q,re),pe=new dI,oe=new TO,ae=new jO(U,Q,Z,oe,re,Ce,pe),Me=new sI(m),Ae=new oI(m),Ee=new b3(U,re),ue=new eI(U,Q,Ee,re),Ie=new hI(U,Ee,pe,ue),be=new mI(U,Ie,Ee,pe),de=new fI(U,re,ae),I=new rI(oe),ye=new CO(m,Me,Ae,Q,re,ue,I),Ne=new XO(m,oe),Je=new DO,R=new zO(Q,re),ge=new $D(m,Me,Ae,Z,be,d,n),$=new FO(m,be,re),Oe=new YO(U,pe,re,Z),xe=new tI(U,Q,pe,re),Be=new cI(U,Q,pe,re),pe.programs=ye.programs,m.capabilities=re,m.extensions=Q,m.properties=oe,m.renderLists=Je,m.shadowMap=$,m.state=Z,m.info=pe}ze();let Le=new qO(m,U);this.xr=Le,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let L=Q.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=Q.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(L){L!==void 0&&(T=L,this.setSize(M,C,!1))},this.getSize=function(L){return L.set(M,C)},this.setSize=function(L,ee,le){if(Le.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}M=L,C=ee,t.width=Math.floor(L*T),t.height=Math.floor(ee*T),le!==!1&&(t.style.width=L+"px",t.style.height=ee+"px"),this.setViewport(0,0,L,ee)},this.getDrawingBufferSize=function(L){return L.set(M*T,C*T).floor()},this.setDrawingBufferSize=function(L,ee,le){M=L,C=ee,T=le,t.width=Math.floor(L*le),t.height=Math.floor(ee*le),this.setViewport(0,0,L,ee)},this.getCurrentViewport=function(L){return L.copy(A)},this.getViewport=function(L){return L.copy(O)},this.setViewport=function(L,ee,le,J){L.isVector4?O.set(L.x,L.y,L.z,L.w):O.set(L,ee,le,J),Z.viewport(A.copy(O).multiplyScalar(T).floor())},this.getScissor=function(L){return L.copy(B)},this.setScissor=function(L,ee,le,J){L.isVector4?B.set(L.x,L.y,L.z,L.w):B.set(L,ee,le,J),Z.scissor(S.copy(B).multiplyScalar(T).floor())},this.getScissorTest=function(){return G},this.setScissorTest=function(L){Z.setScissorTest(G=L)},this.setOpaqueSort=function(L){D=L},this.setTransparentSort=function(L){P=L},this.getClearColor=function(L){return L.copy(ge.getClearColor())},this.setClearColor=function(){ge.setClearColor.apply(ge,arguments)},this.getClearAlpha=function(){return ge.getClearAlpha()},this.setClearAlpha=function(){ge.setClearAlpha.apply(ge,arguments)},this.clear=function(L=!0,ee=!0,le=!0){let J=0;L&&(J|=16384),ee&&(J|=256),le&&(J|=1024),U.clear(J)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Ze,!1),t.removeEventListener("webglcontextrestored",Ve,!1),t.removeEventListener("webglcontextcreationerror",mt,!1),Je.dispose(),R.dispose(),oe.dispose(),Me.dispose(),Ae.dispose(),be.dispose(),ue.dispose(),Oe.dispose(),ye.dispose(),Le.dispose(),Le.removeEventListener("sessionstart",_e),Le.removeEventListener("sessionend",qe),H&&(H.dispose(),H=null),xt.stop()};function Ze(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function Ve(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=pe.autoReset,ee=$.enabled,le=$.autoUpdate,J=$.needsUpdate,he=$.type;ze(),pe.autoReset=L,$.enabled=ee,$.autoUpdate=le,$.needsUpdate=J,$.type=he}function mt(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function zt(L){let ee=L.target;ee.removeEventListener("dispose",zt),ti(ee)}function ti(L){Y(L),oe.remove(L)}function Y(L){let ee=oe.get(L).programs;ee!==void 0&&(ee.forEach(function(le){ye.releaseProgram(le)}),L.isShaderMaterial&&ye.releaseShaderCache(L))}this.renderBufferDirect=function(L,ee,le,J,he,ke){ee===null&&(ee=V);let at=he.isMesh&&he.matrixWorld.determinant()<0,ht=_C(L,ee,le,J,he);Z.setMaterial(J,at);let dt=le.index,Ot=1;J.wireframe===!0&&(dt=Ie.getWireframeAttribute(le),Ot=2);let bt=le.drawRange,gt=le.attributes.position,Li=bt.start*Ot,br=(bt.start+bt.count)*Ot;ke!==null&&(Li=Math.max(Li,ke.start*Ot),br=Math.min(br,(ke.start+ke.count)*Ot)),dt!==null?(Li=Math.max(Li,0),br=Math.min(br,dt.count)):gt!=null&&(Li=Math.max(Li,0),br=Math.min(br,gt.count));let $s=br-Li;if($s<0||$s===1/0)return;ue.setup(he,J,ht,le,dt);let Sn,ii=xe;if(dt!==null&&(Sn=Ee.get(dt),ii=Be,ii.setIndex(Sn)),he.isMesh)J.wireframe===!0?(Z.setLineWidth(J.wireframeLinewidth*W()),ii.setMode(1)):ii.setMode(4);else if(he.isLine){let vt=J.linewidth;vt===void 0&&(vt=1),Z.setLineWidth(vt*W()),he.isLineSegments?ii.setMode(1):he.isLineLoop?ii.setMode(2):ii.setMode(3)}else he.isPoints?ii.setMode(0):he.isSprite&&ii.setMode(4);if(he.isInstancedMesh)ii.renderInstances(Li,$s,he.count);else if(le.isInstancedBufferGeometry){let vt=le._maxInstanceCount!==void 0?le._maxInstanceCount:1/0,Kp=Math.min(le.instanceCount,vt);ii.renderInstances(Li,$s,Kp)}else ii.render(Li,$s)},this.compile=function(L,ee){function le(J,he,ke){J.transparent===!0&&J.side===Cr&&J.forceSinglePass===!1?(J.side=Si,J.needsUpdate=!0,Ir(J,he,ke),J.side=fs,J.needsUpdate=!0,Ir(J,he,ke),J.side=Cr):Ir(J,he,ke)}u=R.get(L),u.init(),f.push(u),L.traverseVisible(function(J){J.isLight&&J.layers.test(ee.layers)&&(u.pushLight(J),J.castShadow&&u.pushShadow(J))}),u.setupLights(m.physicallyCorrectLights),L.traverse(function(J){let he=J.material;if(he)if(Array.isArray(he))for(let ke=0;ke<he.length;ke++){let at=he[ke];le(at,L,J)}else le(he,L,J)}),f.pop(),u=null};let ne=null;function ve(L){ne&&ne(L)}function _e(){xt.stop()}function qe(){xt.start()}let xt=new NS;xt.setAnimationLoop(ve),typeof self<"u"&&xt.setContext(self),this.setAnimationLoop=function(L){ne=L,Le.setAnimationLoop(L),L===null?xt.stop():xt.start()},Le.addEventListener("sessionstart",_e),Le.addEventListener("sessionend",qe),this.render=function(L,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),Le.enabled===!0&&Le.isPresenting===!0&&(Le.cameraAutoUpdate===!0&&Le.updateCamera(ee),ee=Le.getCamera()),L.isScene===!0&&L.onBeforeRender(m,L,ee,x),u=R.get(L,f.length),u.init(),f.push(u),j.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),F.setFromProjectionMatrix(j),X=this.localClippingEnabled,z=I.init(this.clippingPlanes,X),c=Je.get(L,p.length),c.init(),p.push(c),Vt(L,ee,0,m.sortObjects),c.finish(),m.sortObjects===!0&&c.sort(D,P),z===!0&&I.beginShadows();let le=u.state.shadowsArray;if($.render(le,L,ee),z===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),ge.render(c,L),u.setupLights(m.physicallyCorrectLights),ee.isArrayCamera){let J=ee.cameras;for(let he=0,ke=J.length;he<ke;he++){let at=J[he];Oi(c,L,at,at.viewport)}}else Oi(c,L,ee);x!==null&&(ae.updateMultisampleRenderTarget(x),ae.updateRenderTargetMipmap(x)),L.isScene===!0&&L.onAfterRender(m,L,ee),ue.resetDefaultState(),b=-1,w=null,f.pop(),f.length>0?u=f[f.length-1]:u=null,p.pop(),p.length>0?c=p[p.length-1]:c=null};function Vt(L,ee,le,J){if(L.visible===!1)return;if(L.layers.test(ee.layers)){if(L.isGroup)le=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(ee);else if(L.isLight)u.pushLight(L),L.castShadow&&u.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||F.intersectsSprite(L)){J&&q.setFromMatrixPosition(L.matrixWorld).applyMatrix4(j);let ke=be.update(L),at=L.material;at.visible&&c.push(L,ke,at,le,q.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==pe.render.frame&&(L.skeleton.update(),L.skeleton.frame=pe.render.frame),!L.frustumCulled||F.intersectsObject(L))){J&&q.setFromMatrixPosition(L.matrixWorld).applyMatrix4(j);let ke=be.update(L),at=L.material;if(Array.isArray(at)){let ht=ke.groups;for(let dt=0,Ot=ht.length;dt<Ot;dt++){let bt=ht[dt],gt=at[bt.materialIndex];gt&&gt.visible&&c.push(L,ke,gt,le,q.z,bt)}}else at.visible&&c.push(L,ke,at,le,q.z,null)}}let he=L.children;for(let ke=0,at=he.length;ke<at;ke++)Vt(he[ke],ee,le,J)}function Oi(L,ee,le,J){let he=L.opaque,ke=L.transmissive,at=L.transparent;u.setupLightsView(le),z===!0&&I.setGlobalState(m.clippingPlanes,le),ke.length>0&&_n(he,ee,le),J&&Z.viewport(A.copy(J)),he.length>0&&Ft(he,ee,le),ke.length>0&&Ft(ke,ee,le),at.length>0&&Ft(at,ee,le),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function _n(L,ee,le){let J=re.isWebGL2;H===null&&(H=new Ct(1,1,{generateMipmaps:!0,type:Q.has("EXT_color_buffer_half_float")?Tl:ji,minFilter:Cl,samples:J&&a===!0?4:0})),m.getDrawingBufferSize(N),J?H.setSize(N.x,N.y):H.setSize(Cu(N.x),Cu(N.y));let he=m.getRenderTarget();m.setRenderTarget(H),m.clear();let ke=m.toneMapping;m.toneMapping=_a,Ft(L,ee,le),m.toneMapping=ke,ae.updateMultisampleRenderTarget(H),ae.updateRenderTargetMipmap(H),m.setRenderTarget(he)}function Ft(L,ee,le){let J=ee.isScene===!0?ee.overrideMaterial:null;for(let he=0,ke=L.length;he<ke;he++){let at=L[he],ht=at.object,dt=at.geometry,Ot=J===null?at.material:J,bt=at.group;ht.layers.test(le.layers)&&Js(ht,ee,le,dt,Ot,bt)}}function Js(L,ee,le,J,he,ke){L.onBeforeRender(m,ee,le,J,he,ke),L.modelViewMatrix.multiplyMatrices(le.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),he.onBeforeRender(m,ee,le,J,L,ke),he.transparent===!0&&he.side===Cr&&he.forceSinglePass===!1?(he.side=Si,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,L,ke),he.side=fs,he.needsUpdate=!0,m.renderBufferDirect(le,ee,J,he,L,ke),he.side=Cr):m.renderBufferDirect(le,ee,J,he,L,ke),L.onAfterRender(m,ee,le,J,he,ke)}function Ir(L,ee,le){ee.isScene!==!0&&(ee=V);let J=oe.get(L),he=u.state.lights,ke=u.state.shadowsArray,at=he.state.version,ht=ye.getParameters(L,he.state,ke,ee,le),dt=ye.getProgramCacheKey(ht),Ot=J.programs;J.environment=L.isMeshStandardMaterial?ee.environment:null,J.fog=ee.fog,J.envMap=(L.isMeshStandardMaterial?Ae:Me).get(L.envMap||J.environment),Ot===void 0&&(L.addEventListener("dispose",zt),Ot=new Map,J.programs=Ot);let bt=Ot.get(dt);if(bt!==void 0){if(J.currentProgram===bt&&J.lightsStateVersion===at)return ky(L,ht),bt}else ht.uniforms=ye.getUniforms(L),L.onBuild(le,ht,m),L.onBeforeCompile(ht,m),bt=ye.acquireProgram(ht,dt),Ot.set(dt,bt),J.uniforms=ht.uniforms;let gt=J.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(gt.clippingPlanes=I.uniform),ky(L,ht),J.needsLights=AC(L),J.lightsStateVersion=at,J.needsLights&&(gt.ambientLightColor.value=he.state.ambient,gt.lightProbe.value=he.state.probe,gt.directionalLights.value=he.state.directional,gt.directionalLightShadows.value=he.state.directionalShadow,gt.spotLights.value=he.state.spot,gt.spotLightShadows.value=he.state.spotShadow,gt.rectAreaLights.value=he.state.rectArea,gt.ltc_1.value=he.state.rectAreaLTC1,gt.ltc_2.value=he.state.rectAreaLTC2,gt.pointLights.value=he.state.point,gt.pointLightShadows.value=he.state.pointShadow,gt.hemisphereLights.value=he.state.hemi,gt.directionalShadowMap.value=he.state.directionalShadowMap,gt.directionalShadowMatrix.value=he.state.directionalShadowMatrix,gt.spotShadowMap.value=he.state.spotShadowMap,gt.spotLightMatrix.value=he.state.spotLightMatrix,gt.spotLightMap.value=he.state.spotLightMap,gt.pointShadowMap.value=he.state.pointShadowMap,gt.pointShadowMatrix.value=he.state.pointShadowMatrix);let Li=bt.getUniforms(),br=uu.seqWithValue(Li.seq,gt);return J.currentProgram=bt,J.uniformsList=br,bt}function ky(L,ee){let le=oe.get(L);le.outputEncoding=ee.outputEncoding,le.instancing=ee.instancing,le.skinning=ee.skinning,le.morphTargets=ee.morphTargets,le.morphNormals=ee.morphNormals,le.morphColors=ee.morphColors,le.morphTargetsCount=ee.morphTargetsCount,le.numClippingPlanes=ee.numClippingPlanes,le.numIntersection=ee.numClipIntersection,le.vertexAlphas=ee.vertexAlphas,le.vertexTangents=ee.vertexTangents,le.toneMapping=ee.toneMapping}function _C(L,ee,le,J,he){ee.isScene!==!0&&(ee=V),ae.resetTextureUnits();let ke=ee.fog,at=J.isMeshStandardMaterial?ee.environment:null,ht=x===null?m.outputEncoding:x.isXRRenderTarget===!0?x.texture.encoding:Gs,dt=(J.isMeshStandardMaterial?Ae:Me).get(J.envMap||at),Ot=J.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,bt=!!J.normalMap&&!!le.attributes.tangent,gt=!!le.morphAttributes.position,Li=!!le.morphAttributes.normal,br=!!le.morphAttributes.color,$s=J.toneMapped?m.toneMapping:_a,Sn=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,ii=Sn!==void 0?Sn.length:0,vt=oe.get(J),Kp=u.state.lights;if(z===!0&&(X===!0||L!==w)){let wr=L===w&&J.id===b;I.setState(J,L,wr)}let Jp=!1;J.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==Kp.state.version||vt.outputEncoding!==ht||he.isInstancedMesh&&vt.instancing===!1||!he.isInstancedMesh&&vt.instancing===!0||he.isSkinnedMesh&&vt.skinning===!1||!he.isSkinnedMesh&&vt.skinning===!0||vt.envMap!==dt||J.fog===!0&&vt.fog!==ke||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==I.numPlanes||vt.numIntersection!==I.numIntersection)||vt.vertexAlphas!==Ot||vt.vertexTangents!==bt||vt.morphTargets!==gt||vt.morphNormals!==Li||vt.morphColors!==br||vt.toneMapping!==$s||re.isWebGL2===!0&&vt.morphTargetsCount!==ii)&&(Jp=!0):(Jp=!0,vt.__version=J.version);let An=vt.currentProgram;Jp===!0&&(An=Ir(J,ee,he));let Uy=!1,uh=!1,$p=!1,Ti=An.getUniforms(),Mn=vt.uniforms;if(Z.useProgram(An.program)&&(Uy=!0,uh=!0,$p=!0),J.id!==b&&(b=J.id,uh=!0),Uy||w!==L){if(Ti.setValue(U,"projectionMatrix",L.projectionMatrix),re.logarithmicDepthBuffer&&Ti.setValue(U,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),w!==L&&(w=L,uh=!0,$p=!0),J.isShaderMaterial||J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshStandardMaterial||J.envMap){let wr=Ti.map.cameraPosition;wr!==void 0&&wr.setValue(U,q.setFromMatrixPosition(L.matrixWorld))}(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial)&&Ti.setValue(U,"isOrthographic",L.isOrthographicCamera===!0),(J.isMeshPhongMaterial||J.isMeshToonMaterial||J.isMeshLambertMaterial||J.isMeshBasicMaterial||J.isMeshStandardMaterial||J.isShaderMaterial||J.isShadowMaterial||he.isSkinnedMesh)&&Ti.setValue(U,"viewMatrix",L.matrixWorldInverse)}if(he.isSkinnedMesh){Ti.setOptional(U,he,"bindMatrix"),Ti.setOptional(U,he,"bindMatrixInverse");let wr=he.skeleton;wr&&(re.floatVertexTextures?(wr.boneTexture===null&&wr.computeBoneTexture(),Ti.setValue(U,"boneTexture",wr.boneTexture,ae),Ti.setValue(U,"boneTextureSize",wr.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 ef=le.morphAttributes;if((ef.position!==void 0||ef.normal!==void 0||ef.color!==void 0&&re.isWebGL2===!0)&&de.update(he,le,J,An),(uh||vt.receiveShadow!==he.receiveShadow)&&(vt.receiveShadow=he.receiveShadow,Ti.setValue(U,"receiveShadow",he.receiveShadow)),J.isMeshGouraudMaterial&&J.envMap!==null&&(Mn.envMap.value=dt,Mn.flipEnvMap.value=dt.isCubeTexture&&dt.isRenderTargetTexture===!1?-1:1),uh&&(Ti.setValue(U,"toneMappingExposure",m.toneMappingExposure),vt.needsLights&&SC(Mn,$p),ke&&J.fog===!0&&Ne.refreshFogUniforms(Mn,ke),Ne.refreshMaterialUniforms(Mn,J,T,C,H),uu.upload(U,vt.uniformsList,Mn,ae)),J.isShaderMaterial&&J.uniformsNeedUpdate===!0&&(uu.upload(U,vt.uniformsList,Mn,ae),J.uniformsNeedUpdate=!1),J.isSpriteMaterial&&Ti.setValue(U,"center",he.center),Ti.setValue(U,"modelViewMatrix",he.modelViewMatrix),Ti.setValue(U,"normalMatrix",he.normalMatrix),Ti.setValue(U,"modelMatrix",he.matrixWorld),he.previousModelViewMatrix&&Ti.setValue(U,"previousModelViewMatrix",he.previousModelViewMatrix),L.previousProjectionMatrix&&Ti.setValue(U,"previousProjectionMatrix",L.previousProjectionMatrix),J.isShaderMaterial||J.isRawShaderMaterial){let wr=J.uniformsGroups;for(let tf=0,MC=wr.length;tf<MC;tf++)if(re.isWebGL2){let Fy=wr[tf];Oe.update(Fy,An),Oe.bind(Fy,An)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return An}function SC(L,ee){L.ambientLightColor.needsUpdate=ee,L.lightProbe.needsUpdate=ee,L.directionalLights.needsUpdate=ee,L.directionalLightShadows.needsUpdate=ee,L.pointLights.needsUpdate=ee,L.pointLightShadows.needsUpdate=ee,L.spotLights.needsUpdate=ee,L.spotLightShadows.needsUpdate=ee,L.rectAreaLights.needsUpdate=ee,L.hemisphereLights.needsUpdate=ee}function AC(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(L,ee,le){oe.get(L.texture).__webglTexture=ee,oe.get(L.depthTexture).__webglTexture=le;let J=oe.get(L);J.__hasExternalTextures=!0,J.__hasExternalTextures&&(J.__autoAllocateDepthBuffer=le===void 0,J.__autoAllocateDepthBuffer||Q.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),J.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,ee){let le=oe.get(L);le.__webglFramebuffer=ee,le.__useDefaultFramebuffer=ee===void 0},this.setRenderTarget=function(L,ee=0,le=0){x=L,v=ee,y=le;let J=!0,he=null,ke=!1,at=!1;if(L){let ht=oe.get(L);ht.__useDefaultFramebuffer!==void 0?(Z.bindFramebuffer(36160,null),J=!1):ht.__webglFramebuffer===void 0?ae.setupRenderTarget(L):ht.__hasExternalTextures&&ae.rebindTextures(L,oe.get(L.texture).__webglTexture,oe.get(L.depthTexture).__webglTexture);let dt=L.texture;(dt.isData3DTexture||dt.isDataArrayTexture||dt.isCompressedArrayTexture)&&(at=!0);let Ot=oe.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(he=Ot[ee],ke=!0):re.isWebGL2&&L.samples>0&&ae.useMultisampledRTT(L)===!1?he=oe.get(L).__webglMultisampledFramebuffer:he=Ot,A.copy(L.viewport),S.copy(L.scissor),_=L.scissorTest}else A.copy(O).multiplyScalar(T).floor(),S.copy(B).multiplyScalar(T).floor(),_=G;if(Z.bindFramebuffer(36160,he)&&re.drawBuffers&&J&&Z.drawBuffers(L,he),Z.viewport(A),Z.scissor(S),Z.setScissorTest(_),ke){let ht=oe.get(L.texture);U.framebufferTexture2D(36160,36064,34069+ee,ht.__webglTexture,le)}else if(at){let ht=oe.get(L.texture),dt=ee||0;U.framebufferTextureLayer(36160,36064,ht.__webglTexture,le||0,dt)}b=-1},this.readRenderTargetPixels=function(L,ee,le,J,he,ke,at){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=oe.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&at!==void 0&&(ht=ht[at]),ht){Z.bindFramebuffer(36160,ht);try{let dt=L.texture,Ot=dt.format,bt=dt.type;if(Ot!==jr&&Ce.convert(Ot)!==U.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let gt=bt===Tl&&(Q.has("EXT_color_buffer_half_float")||re.isWebGL2&&Q.has("EXT_color_buffer_float"));if(bt!==ji&&Ce.convert(bt)!==U.getParameter(35738)&&!(bt===Tr&&(re.isWebGL2||Q.has("OES_texture_float")||Q.has("WEBGL_color_buffer_float")))&&!gt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=L.width-J&&le>=0&&le<=L.height-he&&U.readPixels(ee,le,J,he,Ce.convert(Ot),Ce.convert(bt),ke)}finally{let dt=x!==null?oe.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,dt)}}},this.copyFramebufferToTexture=function(L,ee,le=0){let J=Math.pow(2,-le),he=Math.floor(ee.image.width*J),ke=Math.floor(ee.image.height*J);ae.setTexture2D(ee,0),U.copyTexSubImage2D(3553,le,0,0,L.x,L.y,he,ke),Z.unbindTexture()},this.copyTextureToTexture=function(L,ee,le,J=0){let he=ee.image.width,ke=ee.image.height,at=Ce.convert(le.format),ht=Ce.convert(le.type);ae.setTexture2D(le,0),U.pixelStorei(37440,le.flipY),U.pixelStorei(37441,le.premultiplyAlpha),U.pixelStorei(3317,le.unpackAlignment),ee.isDataTexture?U.texSubImage2D(3553,J,L.x,L.y,he,ke,at,ht,ee.image.data):ee.isCompressedTexture?U.compressedTexSubImage2D(3553,J,L.x,L.y,ee.mipmaps[0].width,ee.mipmaps[0].height,at,ee.mipmaps[0].data):U.texSubImage2D(3553,J,L.x,L.y,at,ht,ee.image),J===0&&le.generateMipmaps&&U.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(L,ee,le,J,he=0){if(m.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let ke=L.max.x-L.min.x+1,at=L.max.y-L.min.y+1,ht=L.max.z-L.min.z+1,dt=Ce.convert(J.format),Ot=Ce.convert(J.type),bt;if(J.isData3DTexture)ae.setTexture3D(J,0),bt=32879;else if(J.isDataArrayTexture)ae.setTexture2DArray(J,0),bt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}U.pixelStorei(37440,J.flipY),U.pixelStorei(37441,J.premultiplyAlpha),U.pixelStorei(3317,J.unpackAlignment);let gt=U.getParameter(3314),Li=U.getParameter(32878),br=U.getParameter(3316),$s=U.getParameter(3315),Sn=U.getParameter(32877),ii=le.isCompressedTexture?le.mipmaps[0]:le.image;U.pixelStorei(3314,ii.width),U.pixelStorei(32878,ii.height),U.pixelStorei(3316,L.min.x),U.pixelStorei(3315,L.min.y),U.pixelStorei(32877,L.min.z),le.isDataTexture||le.isData3DTexture?U.texSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,Ot,ii.data):le.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),U.compressedTexSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,ii.data)):U.texSubImage3D(bt,he,ee.x,ee.y,ee.z,ke,at,ht,dt,Ot,ii),U.pixelStorei(3314,gt),U.pixelStorei(32878,Li),U.pixelStorei(3316,br),U.pixelStorei(3315,$s),U.pixelStorei(32877,Sn),he===0&&J.generateMipmaps&&U.generateMipmap(bt),Z.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?ae.setTextureCube(L,0):L.isData3DTexture?ae.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?ae.setTexture2DArray(L,0):ae.setTexture2D(L,0),Z.unbindTexture()},this.resetState=function(){v=0,y=0,x=null,Z.reset(),ue.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var ZO=class extends GS{};ZO.prototype.isWebGL1Renderer=!0;var HS=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new He(e),this.near=t,this.far=i}clone(){return new HS(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},nn=class extends Tt{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}},KO=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ag,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Hr()}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=Hr()),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=Hr()),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}}},Hi=new E,hg=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++)Hi.fromBufferAttribute(this,t),Hi.applyMatrix4(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Hi.fromBufferAttribute(this,t),Hi.applyNormalMatrix(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Hi.fromBufferAttribute(this,t),Hi.transformDirection(e),this.setXYZ(t,Hi.x,Hi.y,Hi.z);return this}setX(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Lt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Lt(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=wa(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=wa(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=wa(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=wa(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Lt(t,this.array),i=Lt(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=Lt(t,this.array),i=Lt(i,this.array),r=Lt(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=Lt(t,this.array),i=Lt(i,this.array),r=Lt(r,this.array),s=Lt(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 Ke(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 hg(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}}},WS=class extends Tt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Pu=class extends fi{constructor(e=null,t=1,i=1,r,s,a,n,o,l=Rt,h=Rt,d,c){super(null,a,n,o,l,h,r,s,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},$1=new me,JO=new me,$v=class{constructor(e=[],t=[]){this.uuid=Hr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new me)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let i=new me;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){let e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,a=e.length;s<a;s++){let n=e[s]?e[s].matrixWorld:JO;$1.multiplyMatrices(n,t[s]),$1.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new $v(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=PS(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new Pu(t,e,e,jr,Tr);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){let s=e.bones[i],a=t[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new WS),this.bones.push(a),this.boneInverses.push(new me().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){let e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let a=t[r];e.bones.push(a.uuid);let n=i[r];e.boneInverses.push(n.toArray())}return e}},$O=class extends Ke{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}},vn=class extends Oc{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new He(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}},ex=new E,tx=new E,ix=new me,Bf=new Wl,fd=new vr,Du=class extends Tt{constructor(e=new Ue,t=new vn){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++)ex.fromBufferAttribute(t,r-1),tx.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=ex.distanceTo(tx);e.setAttribute("lineDistance",new Te(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,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),fd.copy(i.boundingSphere),fd.applyMatrix4(r),fd.radius+=s,e.ray.intersectsSphere(fd)===!1)return;ix.copy(r).invert(),Bf.copy(e.ray).applyMatrix4(ix);let n=s/((this.scale.x+this.scale.y+this.scale.z)/3),o=n*n,l=new E,h=new E,d=new E,c=new E,u=this.isLineSegments?2:1,p=i.index,f=i.attributes.position;if(p!==null){let m=Math.max(0,a.start),g=Math.min(p.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=u){let x=p.getX(v),b=p.getX(v+1);if(l.fromBufferAttribute(f,x),h.fromBufferAttribute(f,b),Bf.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let w=e.ray.origin.distanceTo(c);w<e.near||w>e.far||t.push({distance:w,point:d.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else{let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let v=m,y=g-1;v<y;v+=u){if(l.fromBufferAttribute(f,v),h.fromBufferAttribute(f,v+1),Bf.distanceSqToSegment(l,h,c,d)>o)continue;c.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(c);x<e.near||x>e.far||t.push({distance:x,point:d.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 a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}},rx=new E,sx=new E,Rc=class extends Du{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)rx.fromBufferAttribute(t,r),sx.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+rx.distanceTo(sx);e.setAttribute("lineDistance",new Te(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},eL=class extends fi{constructor(e,t,i,r,s,a,n,o,l){super(e,t,i,r,s,a,n,o,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:ot,this.magFilter=s!==void 0?s:ot,this.generateMipmaps=!1;let h=this;function d(){h.needsUpdate=!0,e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(d)}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)}},Qs=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 a=1;a<=e;a++)i=this.getPoint(a/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,a;t?a=t:a=e*i[s-1];let n=0,o=s-1,l;for(;n<=o;)if(r=Math.floor(n+(o-n)/2),l=i[r]-a,l<0)n=r+1;else if(l>0)o=r-1;else{o=r;break}if(r=o,i[r]===a)return r/(s-1);let h=i[r],d=i[r+1]-h,c=(a-h)/d;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),a=this.getPoint(r),n=t||(s.isVector2?new k:new E);return n.copy(a).sub(s).normalize(),n}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new E,r=[],s=[],a=[],n=new E,o=new me;for(let u=0;u<=e;u++){let p=u/e;r[u]=this.getTangentAt(p,new E)}s[0]=new E,a[0]=new E;let l=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),c=Math.abs(r[0].z);h<=l&&(l=h,i.set(1,0,0)),d<=l&&(l=d,i.set(0,1,0)),c<=l&&i.set(0,0,1),n.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],n),a[0].crossVectors(r[0],s[0]);for(let u=1;u<=e;u++){if(s[u]=s[u-1].clone(),a[u]=a[u-1].clone(),n.crossVectors(r[u-1],r[u]),n.length()>Number.EPSILON){n.normalize();let p=Math.acos(pi(r[u-1].dot(r[u]),-1,1));s[u].applyMatrix4(o.makeRotationAxis(n,p))}a[u].crossVectors(r[u],s[u])}if(t===!0){let u=Math.acos(pi(s[0].dot(s[e]),-1,1));u/=e,r[0].dot(n.crossVectors(s[0],s[e]))>0&&(u=-u);for(let p=1;p<=e;p++)s[p].applyMatrix4(o.makeRotationAxis(r[p],u*p)),a[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:a}}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}},wp=class extends Qs{constructor(e=0,t=0,i=1,r=1,s=0,a=Math.PI*2,n=!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=a,this.aClockwise=n,this.aRotation=o}getPoint(e,t){let i=t||new k,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);let n=this.aStartAngle+e*s,o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);if(this.aRotation!==0){let h=Math.cos(this.aRotation),d=Math.sin(this.aRotation),c=o-this.aX,u=l-this.aY;o=c*h-u*d+this.aX,l=c*d+u*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}},tL=class extends wp{constructor(e,t,i,r,s,a){super(e,t,i,i,r,s,a),this.isArcCurve=!0,this.type="ArcCurve"}};function e0(){let e=0,t=0,i=0,r=0;function s(a,n,o,l){e=a,t=o,i=-3*a+3*n-2*o-l,r=2*a-2*n+o+l}return{initCatmullRom:function(a,n,o,l,h){s(n,o,h*(o-a),h*(l-n))},initNonuniformCatmullRom:function(a,n,o,l,h,d,c){let u=(n-a)/h-(o-a)/(h+d)+(o-n)/d,p=(o-n)/d-(l-n)/(d+c)+(l-o)/c;u*=d,p*=d,s(n,o,u,p)},calc:function(a){let n=a*a,o=n*a;return e+t*a+i*n+r*o}}}var md=new E,zf=new e0,Nf=new e0,kf=new e0,iL=class extends Qs{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,a=(s-(this.closed?0:1))*e,n=Math.floor(a),o=a-n;this.closed?n+=n>0?0:(Math.floor(Math.abs(n)/s)+1)*s:o===0&&n===s-1&&(n=s-2,o=1);let l,h;this.closed||n>0?l=r[(n-1)%s]:(md.subVectors(r[0],r[1]).add(r[0]),l=md);let d=r[n%s],c=r[(n+1)%s];if(this.closed||n+2<s?h=r[(n+2)%s]:(md.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=md),this.curveType==="centripetal"||this.curveType==="chordal"){let u=this.curveType==="chordal"?.5:.25,p=Math.pow(l.distanceToSquared(d),u),f=Math.pow(d.distanceToSquared(c),u),m=Math.pow(c.distanceToSquared(h),u);f<1e-4&&(f=1),p<1e-4&&(p=f),m<1e-4&&(m=f),zf.initNonuniformCatmullRom(l.x,d.x,c.x,h.x,p,f,m),Nf.initNonuniformCatmullRom(l.y,d.y,c.y,h.y,p,f,m),kf.initNonuniformCatmullRom(l.z,d.z,c.z,h.z,p,f,m)}else this.curveType==="catmullrom"&&(zf.initCatmullRom(l.x,d.x,c.x,h.x,this.tension),Nf.initCatmullRom(l.y,d.y,c.y,h.y,this.tension),kf.initCatmullRom(l.z,d.z,c.z,h.z,this.tension));return i.set(zf.calc(o),Nf.calc(o),kf.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 ax(e,t,i,r,s){let a=(r-t)*.5,n=(s-i)*.5,o=e*e,l=e*o;return(2*i-2*r+a+n)*l+(-3*i+3*r-2*a-n)*o+a*e+i}function rL(e,t){let i=1-e;return i*i*t}function sL(e,t){return 2*(1-e)*e*t}function aL(e,t){return e*e*t}function tc(e,t,i,r){return rL(e,t)+sL(e,i)+aL(e,r)}function nL(e,t){let i=1-e;return i*i*i*t}function oL(e,t){let i=1-e;return 3*i*i*e*t}function lL(e,t){return 3*(1-e)*e*e*t}function hL(e,t){return e*e*e*t}function ic(e,t,i,r,s){return nL(e,t)+oL(e,i)+lL(e,r)+hL(e,s)}var ls=class extends Qs{constructor(e=new k,t=new k,i=new k,r=new k){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,a=this.v2,n=this.v3;return i.set(ic(e,r.x,s.x,a.x,n.x),ic(e,r.y,s.y,a.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.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}},pu=class extends Qs{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,a=this.v2,n=this.v3;return i.set(ic(e,r.x,s.x,a.x,n.x),ic(e,r.y,s.y,a.y,n.y),ic(e,r.z,s.z,a.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.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}},ps=class extends Qs{constructor(e=new k,t=new k){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new k){let i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let i=t||new k;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},qS=class extends Qs{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}},un=class extends Qs{constructor(e=new k,t=new k,i=new k){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new k){let i=t,r=this.v0,s=this.v1,a=this.v2;return i.set(tc(e,r.x,s.x,a.x),tc(e,r.y,s.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}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}},cL=class extends Qs{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,a=this.v2;return i.set(tc(e,r.x,s.x,a.x),tc(e,r.y,s.y,a.y),tc(e,r.z,s.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}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}},t0=class extends Qs{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new k){let i=t,r=this.points,s=(r.length-1)*e,a=Math.floor(s),n=s-a,o=r[a===0?a:a-1],l=r[a],h=r[a>r.length-2?r.length-1:a+1],d=r[a>r.length-3?r.length-1:a+2];return i.set(ax(n,o.x,l.x,h.x,d.x),ax(n,o.y,l.y,h.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let r=e.points[t];this.points.push(new k().fromArray(r))}return this}},dL=Object.freeze({__proto__:null,ArcCurve:tL,CatmullRomCurve3:iL,CubicBezierCurve:ls,CubicBezierCurve3:pu,EllipseCurve:wp,LineCurve:ps,LineCurve3:qS,QuadraticBezierCurve:un,QuadraticBezierCurve3:cL,SplineCurve:t0}),XS=class extends Qs{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 ps(t,e))}getPoint(e,t){let i=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=i){let a=r[s]-i,n=this.curves[s],o=n.getLength(),l=o===0?0:1-a/o;return n.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 a=s[r],n=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,o=a.getPoints(n);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 dL[r.type]().fromJSON(r))}return this}},Iu=class extends XS{constructor(e){super(),this.type="Path",this.currentPoint=new k,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let i=new ps(this.currentPoint.clone(),new k(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){let s=new un(this.currentPoint.clone(),new k(e,t),new k(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,a){let n=new ls(this.currentPoint.clone(),new k(e,t),new k(i,r),new k(s,a));return this.curves.push(n),this.currentPoint.set(s,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new t0(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,a){let n=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+n,t+o,i,r,s,a),this}absarc(e,t,i,r,s,a){return this.absellipse(e,t,i,i,r,s,a),this}ellipse(e,t,i,r,s,a,n,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,s,a,n,o),this}absellipse(e,t,i,r,s,a,n,o){let l=new wp(e,t,i,r,s,a,n,o);if(this.curves.length>0){let d=l.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.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}},YS=class extends Ue{constructor(e=[new k(0,-.5),new k(.5,0),new k(0,.5)],t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=pi(r,0,Math.PI*2);let s=[],a=[],n=[],o=[],l=[],h=1/t,d=new E,c=new k,u=new E,p=new E,f=new E,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,f.copy(u),u.normalize(),o.push(u.x,u.y,u.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,u.x=g*1,u.y=-m,u.z=g*0,p.copy(u),u.x+=f.x,u.y+=f.y,u.z+=f.z,u.normalize(),o.push(u.x,u.y,u.z),f.copy(p)}for(let v=0;v<=t;v++){let y=i+v*h*r,x=Math.sin(y),b=Math.cos(y);for(let w=0;w<=e.length-1;w++){d.x=e[w].x*x,d.y=e[w].y,d.z=e[w].x*b,a.push(d.x,d.y,d.z),c.x=v/t,c.y=w/(e.length-1),n.push(c.x,c.y);let A=o[3*w+0]*x,S=o[3*w+1],_=o[3*w+0]*b;l.push(A,S,_)}}for(let v=0;v<t;v++)for(let y=0;y<e.length-1;y++){let x=y+v*e.length,b=x,w=x+e.length,A=x+e.length+1,S=x+1;s.push(b,w,S),s.push(A,S,w)}this.setIndex(s),this.setAttribute("position",new Te(a,3)),this.setAttribute("uv",new Te(n,2)),this.setAttribute("normal",new Te(l,3))}static fromJSON(e){return new YS(e.points,e.segments,e.phiStart,e.phiLength)}},i0=class extends Ue{constructor(e=1,t=1,i=1,r=32,s=1,a=!1,n=0,o=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};let l=this;r=Math.floor(r),s=Math.floor(s);let h=[],d=[],c=[],u=[],p=0,f=[],m=i/2,g=0;v(),a===!1&&(e>0&&y(!0),t>0&&y(!1)),this.setIndex(h),this.setAttribute("position",new Te(d,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function v(){let x=new E,b=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 D=T/r,P=D*o+n,O=Math.sin(P),B=Math.cos(P);b.x=C*O,b.y=-M*i+m,b.z=C*B,d.push(b.x,b.y,b.z),x.set(O,A,B).normalize(),c.push(x.x,x.y,x.z),u.push(D,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],D=f[_][S+1];h.push(M,C,D),h.push(C,T,D),w+=6}l.addGroup(g,w,0),g+=w}function y(x){let b=p,w=new k,A=new E,S=0,_=x===!0?e:t,M=x===!0?1:-1;for(let T=1;T<=r;T++)d.push(0,m*M,0),c.push(0,M,0),u.push(.5,.5),p++;let C=p;for(let T=0;T<=r;T++){let D=T/r*o+n,P=Math.cos(D),O=Math.sin(D);A.x=_*O,A.y=m*M,A.z=_*P,d.push(A.x,A.y,A.z),c.push(0,M,0),w.x=P*.5+.5,w.y=O*.5*M+.5,u.push(w.x,w.y),p++}for(let T=0;T<r;T++){let D=b+T,P=C+T;x===!0?h.push(P,P+1,D):h.push(P+1,P,D),S+=3}l.addGroup(g,S,x===!0?1:2),g+=S}}static fromJSON(e){return new i0(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},QS=class extends i0{constructor(e=1,t=1,i=32,r=1,s=!1,a=0,n=Math.PI*2){super(0,e,t,i,r,s,a,n),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:a,thetaLength:n}}static fromJSON(e){return new QS(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},r0=class extends Ue{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};let s=[],a=[];n(r),l(i),h(),this.setAttribute("position",new Te(s,3)),this.setAttribute("normal",new Te(s.slice(),3)),this.setAttribute("uv",new Te(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function n(v){let y=new E,x=new E,b=new E;for(let w=0;w<t.length;w+=3)u(t[w+0],y),u(t[w+1],x),u(t[w+2],b),o(y,x,b,v)}function o(v,y,x,b){let w=b+1,A=[];for(let S=0;S<=w;S++){A[S]=[];let _=v.clone().lerp(x,S/w),M=y.clone().lerp(x,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 x=0;x<s.length;x+=3)y.x=s[x+0],y.y=s[x+1],y.z=s[x+2],y.normalize().multiplyScalar(v),s[x+0]=y.x,s[x+1]=y.y,s[x+2]=y.z}function h(){let v=new E;for(let y=0;y<s.length;y+=3){v.x=s[y+0],v.y=s[y+1],v.z=s[y+2];let x=m(v)/2/Math.PI+.5,b=g(v)/Math.PI+.5;a.push(x,1-b)}p(),d()}function d(){for(let v=0;v<a.length;v+=6){let y=a[v+0],x=a[v+2],b=a[v+4],w=Math.max(y,x,b),A=Math.min(y,x,b);w>.9&&A<.1&&(y<.2&&(a[v+0]+=1),x<.2&&(a[v+2]+=1),b<.2&&(a[v+4]+=1))}}function c(v){s.push(v.x,v.y,v.z)}function u(v,y){let x=v*3;y.x=e[x+0],y.y=e[x+1],y.z=e[x+2]}function p(){let v=new E,y=new E,x=new E,b=new E,w=new k,A=new k,S=new k;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]),x.set(s[_+6],s[_+7],s[_+8]),w.set(a[M+0],a[M+1]),A.set(a[M+2],a[M+3]),S.set(a[M+4],a[M+5]),b.copy(v).add(y).add(x).divideScalar(3);let C=m(b);f(w,M+0,v,C),f(A,M+2,y,C),f(S,M+4,x,C)}}function f(v,y,x,b){b<0&&v.x===1&&(a[y]=v.x-1),x.x===0&&x.z===0&&(a[y]=b/2/Math.PI+.5)}function m(v){return Math.atan2(v.z,-v.x)}function g(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}static fromJSON(e){return new r0(e.vertices,e.indices,e.radius,e.details)}},ZS=class extends r0{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],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];super(s,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ZS(e.radius,e.detail)}},Ou=class extends Iu{constructor(e){super(e),this.uuid=Hr(),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 Iu().fromJSON(r))}return this}},uL={triangulate:function(e,t,i=2){let r=t&&t.length,s=r?t[0]*i:e.length,a=KS(e,0,s,i,!0),n=[];if(!a||a.next===a.prev)return n;let o,l,h,d,c,u,p;if(r&&(a=vL(e,t,a,i)),e.length>80*i){o=h=e[0],l=d=e[1];for(let f=i;f<s;f+=i)c=e[f],u=e[f+1],c<o&&(o=c),u<l&&(l=u),c>h&&(h=c),u>d&&(d=u);p=Math.max(h-o,d-l),p=p!==0?32767/p:0}return pc(a,n,i,o,l,p,0),n}};function KS(e,t,i,r,s){let a,n;if(s===TL(e,t,i,r)>0)for(a=t;a<i;a+=r)n=nx(a,e[a],e[a+1],n);else for(a=i-r;a>=t;a-=r)n=nx(a,e[a],e[a+1],n);return n&&_p(n,n.next)&&(mc(n),n=n.next),n}function so(e,t){if(!e)return e;t||(t=e);let i=e,r;do if(r=!1,!i.steiner&&(_p(i,i.next)||jt(i.prev,i,i.next)===0)){if(mc(i),i=t=i.prev,i===i.next)break;r=!0}else i=i.next;while(r||i!==t);return t}function pc(e,t,i,r,s,a,n){if(!e)return;!n&&a&&_L(e,r,s,a);let o=e,l,h;for(;e.prev!==e.next;){if(l=e.prev,h=e.next,a?fL(e,r,s,a):pL(e)){t.push(l.i/i|0),t.push(e.i/i|0),t.push(h.i/i|0),mc(e),e=h.next,o=h.next;continue}if(e=h,e===o){n?n===1?(e=mL(so(e),t,i),pc(e,t,i,r,s,a,2)):n===2&&gL(e,t,i,r,s,a):pc(so(e),t,i,r,s,a,1);break}}}function pL(e){let t=e.prev,i=e,r=e.next;if(jt(t,i,r)>=0)return!1;let s=t.x,a=i.x,n=r.x,o=t.y,l=i.y,h=r.y,d=s<a?s<n?s:n:a<n?a:n,c=o<l?o<h?o:h:l<h?l:h,u=s>a?s>n?s:n:a>n?a:n,p=o>l?o>h?o:h:l>h?l:h,f=r.next;for(;f!==t;){if(f.x>=d&&f.x<=u&&f.y>=c&&f.y<=p&&nl(s,o,a,l,n,h,f.x,f.y)&&jt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function fL(e,t,i,r){let s=e.prev,a=e,n=e.next;if(jt(s,a,n)>=0)return!1;let o=s.x,l=a.x,h=n.x,d=s.y,c=a.y,u=n.y,p=o<l?o<h?o:h:l<h?l:h,f=d<c?d<u?d:u:c<u?c:u,m=o>l?o>h?o:h:l>h?l:h,g=d>c?d>u?d:u:c>u?c:u,v=cg(p,f,t,i,r),y=cg(m,g,t,i,r),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&nl(o,d,l,c,h,u,x.x,x.y)&&jt(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&nl(o,d,l,c,h,u,b.x,b.y)&&jt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==n&&nl(o,d,l,c,h,u,x.x,x.y)&&jt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==s&&b!==n&&nl(o,d,l,c,h,u,b.x,b.y)&&jt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function mL(e,t,i){let r=e;do{let s=r.prev,a=r.next.next;!_p(s,a)&&JS(s,r,r.next,a)&&fc(s,a)&&fc(a,s)&&(t.push(s.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),mc(r),mc(r.next),r=e=a),r=r.next}while(r!==e);return so(r)}function gL(e,t,i,r,s,a){let n=e;do{let o=n.next.next;for(;o!==n.prev;){if(n.i!==o.i&&ML(n,o)){let l=$S(n,o);n=so(n,n.next),l=so(l,l.next),pc(n,t,i,r,s,a,0),pc(l,t,i,r,s,a,0);return}o=o.next}n=n.next}while(n!==e)}function vL(e,t,i,r){let s=[],a,n,o,l,h;for(a=0,n=t.length;a<n;a++)o=t[a]*r,l=a<n-1?t[a+1]*r:e.length,h=KS(e,o,l,r,!1),h===h.next&&(h.steiner=!0),s.push(AL(h));for(s.sort(yL),a=0;a<s.length;a++)i=xL(s[a],i);return i}function yL(e,t){return e.x-t.x}function xL(e,t){let i=bL(e,t);if(!i)return t;let r=$S(i,e);return so(r,r.next),so(i,i.next)}function bL(e,t){let i=t,r=-1/0,s,a=e.x,n=e.y;do{if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){let u=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=a&&u>r&&(r=u,s=i.x<i.next.x?i:i.next,u===a))return s}i=i.next}while(i!==t);if(!s)return null;let o=s,l=s.x,h=s.y,d=1/0,c;i=s;do a>=i.x&&i.x>=l&&a!==i.x&&nl(n<h?a:r,n,l,h,n<h?r:a,n,i.x,i.y)&&(c=Math.abs(n-i.y)/(a-i.x),fc(i,e)&&(c<d||c===d&&(i.x>s.x||i.x===s.x&&wL(s,i)))&&(s=i,d=c)),i=i.next;while(i!==o);return s}function wL(e,t){return jt(e.prev,e,t.prev)<0&&jt(t.next,e,e.next)<0}function _L(e,t,i,r){let s=e;do s.z===0&&(s.z=cg(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,SL(s)}function SL(e){let t,i,r,s,a,n,o,l,h=1;do{for(i=e,e=null,a=null,n=0;i;){for(n++,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--),a?a.nextZ=s:e=s,s.prevZ=a,a=s;i=r}a.nextZ=null,h*=2}while(n>1);return e}function cg(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 AL(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 nl(e,t,i,r,s,a,n,o){return(s-n)*(t-o)>=(e-n)*(a-o)&&(e-n)*(r-o)>=(i-n)*(t-o)&&(i-n)*(a-o)>=(s-n)*(r-o)}function ML(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!EL(e,t)&&(fc(e,t)&&fc(t,e)&&CL(e,t)&&(jt(e.prev,e,t.prev)||jt(e,t.prev,t))||_p(e,t)&&jt(e.prev,e,e.next)>0&&jt(t.prev,t,t.next)>0)}function jt(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function _p(e,t){return e.x===t.x&&e.y===t.y}function JS(e,t,i,r){let s=vd(jt(e,t,i)),a=vd(jt(e,t,r)),n=vd(jt(i,r,e)),o=vd(jt(i,r,t));return!!(s!==a&&n!==o||s===0&&gd(e,i,t)||a===0&&gd(e,r,t)||n===0&&gd(i,e,r)||o===0&&gd(i,t,r))}function gd(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 vd(e){return e>0?1:e<0?-1:0}function EL(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&&JS(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function fc(e,t){return jt(e.prev,e,e.next)<0?jt(e,t,e.next)>=0&&jt(e,e.prev,t)>=0:jt(e,t,e.prev)<0||jt(e,e.next,t)<0}function CL(e,t){let i=e,r=!1,s=(e.x+t.x)/2,a=(e.y+t.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function $S(e,t){let i=new dg(e.i,e.x,e.y),r=new dg(t.i,t.x,t.y),s=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=s,s.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function nx(e,t,i,r){let s=new dg(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 mc(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 dg(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 TL(e,t,i,r){let s=0;for(let a=t,n=i-r;a<i;a+=r)s+=(e[n]-e[a])*(e[a+1]+e[n+1]),n=a;return s}var eA=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 eA.area(e)<0}static triangulateShape(e,t){let i=[],r=[],s=[];ox(e),lx(i,e);let a=e.length;t.forEach(ox);for(let o=0;o<t.length;o++)r.push(a),a+=t[o].length,lx(i,t[o]);let n=uL.triangulate(i,r);for(let o=0;o<n.length;o+=3)s.push(n.slice(o,o+3));return s}};function ox(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function lx(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var tA=class extends r0{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 tA(e.radius,e.detail)}},s0=class extends Ue{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+n,Math.PI),l=0,h=[],d=new E,c=new E,u=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let v=[],y=g/i,x=0;g==0&&a==0?x=.5/t:g==i&&o==Math.PI&&(x=-.5/t);for(let b=0;b<=t;b++){let w=b/t;d.x=-e*Math.cos(r+w*s)*Math.sin(a+y*n),d.y=e*Math.cos(a+y*n),d.z=e*Math.sin(r+w*s)*Math.sin(a+y*n),p.push(d.x,d.y,d.z),c.copy(d).normalize(),f.push(c.x,c.y,c.z),m.push(w+x,1-y),v.push(l++)}h.push(v)}for(let g=0;g<i;g++)for(let v=0;v<t;v++){let y=h[g][v+1],x=h[g][v],b=h[g+1][v],w=h[g+1][v+1];(g!==0||a>0)&&u.push(y,x,w),(g!==i-1||o<Math.PI)&&u.push(x,b,w)}this.setIndex(u),this.setAttribute("position",new Te(p,3)),this.setAttribute("normal",new Te(f,3)),this.setAttribute("uv",new Te(m,2))}static fromJSON(e){return new s0(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},iA=class extends Ue{constructor(e=1,t=.4,i=64,r=8,s=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:a},i=Math.floor(i),r=Math.floor(r);let n=[],o=[],l=[],h=[],d=new E,c=new E,u=new E,p=new E,f=new E,m=new E,g=new E;for(let y=0;y<=i;++y){let x=y/i*s*Math.PI*2;v(x,s,a,e,u),v(x+.01,s,a,e,p),m.subVectors(p,u),g.addVectors(p,u),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let b=0;b<=r;++b){let w=b/r*Math.PI*2,A=-t*Math.cos(w),S=t*Math.sin(w);d.x=u.x+(A*g.x+S*f.x),d.y=u.y+(A*g.y+S*f.y),d.z=u.z+(A*g.z+S*f.z),o.push(d.x,d.y,d.z),c.subVectors(d,u).normalize(),l.push(c.x,c.y,c.z),h.push(y/i),h.push(b/r)}}for(let y=1;y<=i;y++)for(let x=1;x<=r;x++){let b=(r+1)*(y-1)+(x-1),w=(r+1)*y+(x-1),A=(r+1)*y+x,S=(r+1)*(y-1)+x;n.push(b,w,S),n.push(w,A,S)}this.setIndex(n),this.setAttribute("position",new Te(o,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(h,2));function v(y,x,b,w,A){let S=Math.cos(y),_=Math.sin(y),M=b/x*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 iA(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};function za(e,t,i){return rA(e)?new e.constructor(e.subarray(t,i!==void 0?i:e.length)):e.slice(t,i)}function yd(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 rA(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function PL(e){function t(s,a){return e[s]-e[a]}let i=e.length,r=new Array(i);for(let s=0;s!==i;++s)r[s]=s;return r.sort(t),r}function hx(e,t,i){let r=e.length,s=new e.constructor(r);for(let a=0,n=0;n!==r;++a){let o=i[a]*t;for(let l=0;l!==t;++l)s[n++]=e[o+l]}return s}function sA(e,t,i,r){let s=1,a=e[0];for(;a!==void 0&&a[r]===void 0;)a=e[s++];if(a===void 0)return;let n=a[r];if(n!==void 0)if(Array.isArray(n))do n=a[r],n!==void 0&&(t.push(a.time),i.push.apply(i,n)),a=e[s++];while(a!==void 0);else if(n.toArray!==void 0)do n=a[r],n!==void 0&&(t.push(a.time),n.toArray(i,i.length)),a=e[s++];while(a!==void 0);else do n=a[r],n!==void 0&&(t.push(a.time),i.push(n)),a=e[s++];while(a!==void 0)}var Sp=class{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let a;i:{r:if(!(e<r)){for(let n=i+2;;){if(r===void 0){if(e<s)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===n)break;if(s=r,r=t[++i],e<r)break t}a=t.length;break i}if(!(e>=s)){let n=t[1];e<n&&(i=2,s=n);for(let o=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=s,s=t[--i-1],e>=s)break t}a=i,i=0;break i}break e}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+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 a=0;a!==r;++a)t[a]=i[s+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},DL=class extends Sp{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:il,endingEnd:il}}intervalChanged_(e,t,i){let r=this.parameterPositions,s=e-2,a=e+1,n=r[s],o=r[a];if(n===void 0)switch(this.getSettings_().endingStart){case rl:s=e,n=2*t-i;break;case Mu:s=r.length-2,n=t+r[s]-r[s+1];break;default:s=e,n=i}if(o===void 0)switch(this.getSettings_().endingEnd){case rl:a=e,o=2*i-t;break;case Mu:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}let l=(i-t)*.5,h=this.valueSize;this._weightPrev=l/(t-n),this._weightNext=l/(o-i),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=this._offsetPrev,d=this._offsetNext,c=this._weightPrev,u=this._weightNext,p=(i-t)/(r-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-u)*m+(1.5+u)*f+.5*p,x=u*m-u*f;for(let b=0;b!==n;++b)s[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[d+b];return s}},aA=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=e*n,l=o-n,h=(i-t)/(r-t),d=1-h;for(let c=0;c!==n;++c)s[c]=a[l+c]*d+a[o+c]*h;return s}},IL=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}},Zs=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=yd(t,this.TimeBufferType),this.values=yd(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:yd(e.times,Array),values:yd(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new IL(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new aA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new DL(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Su:t=this.InterpolantFactoryMethodDiscrete;break;case Au:t=this.InterpolantFactoryMethodLinear;break;case hf: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 Su;case this.InterpolantFactoryMethodLinear:return Au;case this.InterpolantFactoryMethodSmooth:return hf}}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,a=r-1;for(;s!==r&&i[s]<e;)++s;for(;a!==-1&&i[a]>t;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);let n=this.getValueSize();this.times=za(i,s,a),this.values=za(this.values,s*n,a*n)}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 a=null;for(let n=0;n!==s;n++){let o=i[n];if(typeof o=="number"&&isNaN(o)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,n,o),e=!1;break}if(a!==null&&a>o){console.error("THREE.KeyframeTrack: Out of order keys.",this,n,o,a),e=!1;break}a=o}if(r!==void 0&&rA(r))for(let n=0,o=r.length;n!==o;++n){let l=r[n];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,n,l),e=!1;break}}return e}optimize(){let e=za(this.times),t=za(this.values),i=this.getValueSize(),r=this.getInterpolation()===hf,s=e.length-1,a=1;for(let n=1;n<s;++n){let o=!1,l=e[n],h=e[n+1];if(l!==h&&(n!==1||l!==e[0]))if(r)o=!0;else{let d=n*i,c=d-i,u=d+i;for(let p=0;p!==i;++p){let f=t[d+p];if(f!==t[c+p]||f!==t[u+p]){o=!0;break}}}if(o){if(n!==a){e[a]=e[n];let d=n*i,c=a*i;for(let u=0;u!==i;++u)t[c+u]=t[d+u]}++a}}if(s>0){e[a]=e[s];for(let n=s*i,o=a*i,l=0;l!==i;++l)t[o+l]=t[n+l];++a}return a!==e.length?(this.times=za(e,0,a),this.values=za(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=za(this.times,0),t=za(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};Zs.prototype.TimeBufferType=Float32Array;Zs.prototype.ValueBufferType=Float32Array;Zs.prototype.DefaultInterpolation=Au;var Ql=class extends Zs{};Ql.prototype.ValueTypeName="bool";Ql.prototype.ValueBufferType=Array;Ql.prototype.DefaultInterpolation=Su;Ql.prototype.InterpolantFactoryMethodLinear=void 0;Ql.prototype.InterpolantFactoryMethodSmooth=void 0;var nA=class extends Zs{};nA.prototype.ValueTypeName="color";var Lu=class extends Zs{};Lu.prototype.ValueTypeName="number";var OL=class extends Sp{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){let s=this.resultBuffer,a=this.sampleValues,n=this.valueSize,o=(i-t)/(r-t),l=e*n;for(let h=l+n;l!==h;l+=4)it.slerpFlat(s,0,a,l-n,a,l,o);return s}},Bc=class extends Zs{InterpolantFactoryMethodLinear(e){return new OL(this.times,this.values,this.getValueSize(),e)}};Bc.prototype.ValueTypeName="quaternion";Bc.prototype.DefaultInterpolation=Au;Bc.prototype.InterpolantFactoryMethodSmooth=void 0;var Zl=class extends Zs{};Zl.prototype.ValueTypeName="string";Zl.prototype.ValueBufferType=Array;Zl.prototype.DefaultInterpolation=Su;Zl.prototype.InterpolantFactoryMethodLinear=void 0;Zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Ru=class extends Zs{};Ru.prototype.ValueTypeName="vector";var ug=class{constructor(e,t=-1,i,r=qv){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Hr(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,r=1/(e.fps||1);for(let a=0,n=i.length;a!==n;++a)t.push(RL(i[a]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,a=i.length;s!==a;++s)t.push(Zs.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){let s=t.length,a=[];for(let n=0;n<s;n++){let o=[],l=[];o.push((n+s-1)%s,n,(n+1)%s),l.push(0,1,0);let h=PL(o);o=hx(o,1,h),l=hx(l,1,h),!r&&o[0]===0&&(o.push(s),l.push(l[0])),a.push(new Lu(".morphTargetInfluences["+t[n].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let r={},s=/^([\w-]*?)([\d]+)$/;for(let n=0,o=e.length;n<o;n++){let l=e[n],h=l.name.match(s);if(h&&h.length>1){let d=h[1],c=r[d];c||(r[d]=c=[]),c.push(l)}}let a=[];for(let n in r)a.push(this.CreateFromMorphTargetSequence(n,r[n],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(h,d,c,u,p){if(c.length!==0){let f=[],m=[];sA(c,f,m,u),f.length!==0&&p.push(new h(d,f,m))}},r=[],s=e.name||"default",a=e.fps||30,n=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let c={},u;for(u=0;u<d.length;u++)if(d[u].morphTargets)for(let p=0;p<d[u].morphTargets.length;p++)c[d[u].morphTargets[p]]=-1;for(let p in c){let f=[],m=[];for(let g=0;g!==d[u].morphTargets.length;++g){let v=d[u];f.push(v.time),m.push(v.morphTarget===p?1:0)}r.push(new Lu(".morphTargetInfluence["+p+"]",f,m))}o=c.length*a}else{let c=".bones["+t[h].name+"]";i(Ru,c+".position",d,"pos",r),i(Bc,c+".quaternion",d,"rot",r),i(Ru,c+".scale",d,"scl",r)}}return r.length===0?null:new this(s,o,r,n)}resetDuration(){let e=this.tracks,t=0;for(let i=0,r=e.length;i!==r;++i){let s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function LL(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Lu;case"vector":case"vector2":case"vector3":case"vector4":return Ru;case"color":return nA;case"quaternion":return Bc;case"bool":case"boolean":return Ql;case"string":return Zl}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function RL(e){if(e.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=LL(e.type);if(e.times===void 0){let i=[],r=[];sA(e.keys,i,r,"value"),e.times=i,e.values=r}return t.parse!==void 0?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var cx={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={}}},oA=class{constructor(e,t,i){let r=this,s=!1,a=0,n=0,o,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(h){n++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,n),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,n),a===n&&(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,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,c=l.length;d<c;d+=2){let u=l[d],p=l[d+1];if(u.global&&(u.lastIndex=0),u.test(h))return p}return null}}},BL=new oA,a0=class{constructor(e){this.manager=e!==void 0?e:BL,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}},aa={},zL=class extends Error{constructor(e,t){super(e),this.response=t}},pg=class extends a0{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=cx.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(aa[e]!==void 0){aa[e].push({onLoad:t,onProgress:i,onError:r});return}aa[e]=[],aa[e].push({onLoad:t,onProgress:i,onError:r});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),n=this.mimeType,o=this.responseType;fetch(a).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=aa[e],d=l.body.getReader(),c=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),u=c?parseInt(c):0,p=u!==0,f=0,m=new ReadableStream({start(g){v();function v(){d.read().then(({done:y,value:x})=>{if(y)g.close();else{f+=x.byteLength;let b=new ProgressEvent("progress",{lengthComputable:p,loaded:f,total:u});for(let w=0,A=h.length;w<A;w++){let S=h[w];S.onProgress&&S.onProgress(b)}g.enqueue(x),v()}})}}});return new Response(m)}else throw new zL(`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,n));case"json":return l.json();default:if(n===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(n),d=h&&h[1]?h[1].toLowerCase():void 0,c=new TextDecoder(d);return l.arrayBuffer().then(u=>c.decode(u))}}}).then(l=>{cx.add(e,l);let h=aa[e];delete aa[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onLoad&&u.onLoad(l)}}).catch(l=>{let h=aa[e];if(h===void 0)throw this.manager.itemError(e),l;delete aa[e];for(let d=0,c=h.length;d<c;d++){let u=h[d];u.onError&&u.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}},zc=class extends Tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new He(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}},NL=class extends zc{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new He(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Uf=new me,dx=new E,ux=new E,n0=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new k(512,512),this.map=null,this.mapPass=null,this.matrix=new me,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Zv,this._frameExtents=new k(1,1),this._viewportCount=1,this._viewports=[new rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;dx.setFromMatrixPosition(e.matrixWorld),t.position.copy(dx),ux.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ux),t.updateMatrixWorld(),Uf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Uf),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Uf)}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}},kL=class extends n0{constructor(){super(new zi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=uc*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}},UL=class extends zc{constructor(e,t,i=0,r=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new kL}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}},px=new me,_h=new E,Ff=new E,FL=class extends n0{constructor(){super(new zi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new k(4,2),this._viewportCount=6,this._viewports=[new rt(2,1,1,1),new rt(0,1,1,1),new rt(3,1,1,1),new rt(1,1,1,1),new rt(3,0,1,1),new rt(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()),_h.setFromMatrixPosition(e.matrixWorld),i.position.copy(_h),Ff.copy(i.position),Ff.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Ff),i.updateMatrixWorld(),r.makeTranslation(-_h.x,-_h.y,-_h.z),px.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(px)}},VL=class extends zc{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 FL}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},jL=class extends n0{constructor(){super(new Kv(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},GL=class extends zc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Tt.DEFAULT_UP),this.updateMatrix(),this.target=new Tt,this.shadow=new jL}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},HL=class extends Ue{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}},lA=class extends a0{constructor(e){super(e)}load(e,t,i,r){let s=this,a=new pg(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(n){try{t(s.parse(JSON.parse(n)))}catch(o){r?r(o):console.error(o),s.manager.itemError(e)}},i,r)}parse(e){let t={},i={};function r(c,u){if(t[u]!==void 0)return t[u];let p=c.interleavedBuffers[u],f=s(c,p.buffer),m=Qc(p.type,f),g=new KO(m,p.stride);return g.uuid=p.uuid,t[u]=g,g}function s(c,u){if(i[u]!==void 0)return i[u];let p=c.arrayBuffers[u],f=new Uint32Array(p).buffer;return i[u]=f,f}let a=e.isInstancedBufferGeometry?new HL:new Ue,n=e.data.index;if(n!==void 0){let c=Qc(n.type,n.array);a.setIndex(new Ke(c,1))}let o=e.data.attributes;for(let c in o){let u=o[c],p;if(u.isInterleavedBufferAttribute){let f=r(e.data,u.data);p=new hg(f,u.itemSize,u.offset,u.normalized)}else{let f=Qc(u.type,u.array),m=u.isInstancedBufferAttribute?$O:Ke;p=new m(f,u.itemSize,u.normalized)}u.name!==void 0&&(p.name=u.name),u.usage!==void 0&&p.setUsage(u.usage),u.updateRange!==void 0&&(p.updateRange.offset=u.updateRange.offset,p.updateRange.count=u.updateRange.count),a.setAttribute(c,p)}let l=e.data.morphAttributes;if(l)for(let c in l){let u=l[c],p=[];for(let f=0,m=u.length;f<m;f++){let g=u[f],v;if(g.isInterleavedBufferAttribute){let y=r(e.data,g.data);v=new hg(y,g.itemSize,g.offset,g.normalized)}else{let y=Qc(g.type,g.array);v=new Ke(y,g.itemSize,g.normalized)}g.name!==void 0&&(v.name=g.name),p.push(v)}a.morphAttributes[c]=p}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let c=0,u=h.length;c!==u;++c){let p=h[c];a.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let c=new E;d.center!==void 0&&c.fromArray(d.center),a.boundingSphere=new vr(c,d.radius)}return e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}},WL=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=fx(),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=fx();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function fx(){return(typeof performance>"u"?Date:performance).now()}var qL=class{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,a;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let i=this.buffer,r=this.valueSize,s=e*r+r,a=this.cumulativeWeight;if(a===0){for(let n=0;n!==r;++n)i[s+n]=i[n];a=t}else{a+=t;let n=t/a;this._mixBufferRegion(i,s,0,n,r)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,a=this.cumulativeWeightAdditive,n=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let o=t*this._origIndex;this._mixBufferRegion(i,r,o,1-s,t)}a>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){n.setValue(i,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,a=r;s!==a;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let a=0;a!==s;++a)e[t+a]=e[i+a]}_slerp(e,t,i,r){it.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){let a=this._workIndex*s;it.multiplyQuaternionsFlat(e,a,e,t,e,i),it.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,i,r,s){let a=1-r;for(let n=0;n!==s;++n){let o=t+n;e[o]=e[o]*a+e[i+n]*r}}_lerpAdditive(e,t,i,r,s){for(let a=0;a!==s;++a){let n=t+a;e[n]=e[n]+e[i+a]*r}}},o0="\\[\\]\\.:\\/",XL=new RegExp("["+o0+"]","g"),l0="[^"+o0+"]",YL="[^"+o0.replace("\\.","")+"]",QL=/((?:WC+[\/:])*)/.source.replace("WC",l0),ZL=/(WCOD+)?/.source.replace("WCOD",YL),KL=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",l0),JL=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",l0),$L=new RegExp("^"+QL+ZL+KL+JL+"$"),e4=["material","materials","bones","map"],t4=class{constructor(e,t,i){let r=i||Dt.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()}},Dt=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Dt.parseTrackName(t),this.node=Dt.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 Dt.Composite(e,t,i):new Dt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(XL,"")}static parseTrackName(e){let t=$L.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);e4.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 a=0;a<s.length;a++){let n=s[a];if(n.name===t||n.uuid===t)return n;let o=i(n.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=Dt.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 a=e[r];if(a===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 n=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?n=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(n=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=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(o=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(o=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[o],this.setValue=this.SetterByBindingTypeAndVersioning[o][n]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Dt.Composite=t4;Dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Dt.prototype.GetterByBindingType=[Dt.prototype._getValue_direct,Dt.prototype._getValue_array,Dt.prototype._getValue_arrayElement,Dt.prototype._getValue_toArray];Dt.prototype.SetterByBindingTypeAndVersioning=[[Dt.prototype._setValue_direct,Dt.prototype._setValue_direct_setNeedsUpdate,Dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_array,Dt.prototype._setValue_array_setNeedsUpdate,Dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_arrayElement,Dt.prototype._setValue_arrayElement_setNeedsUpdate,Dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Dt.prototype._setValue_fromArray,Dt.prototype._setValue_fromArray_setNeedsUpdate,Dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var i4=class{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;let s=t.tracks,a=s.length,n=new Array(a),o={endingStart:il,endingEnd:il};for(let l=0;l!==a;++l){let h=s[l].createInterpolant(null);n[l]=h,h.settings=o}this._interpolantSettings=o,this._interpolants=n,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=CS,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){let r=this._clip.duration,s=e._clip.duration,a=s/r,n=r/s;e.warp(1,a,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){let r=this._mixer,s=r.time,a=this.timeScale,n=this._timeScaleInterpolant;n===null&&(n=r._lendControlInterpolant(),this._timeScaleInterpolant=n);let o=n.parameterPositions,l=n.sampleValues;return o[0]=s,o[1]=s+i,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let o=(e-s)*i;o<0||i===0?t=0:(this._startTime=null,t=i*o)}t*=this._updateTimeScale(e);let a=this._updateTime(t),n=this._updateWeight(e);if(n>0){let o=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case zT:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(a),l[h].accumulateAdditive(n);break;case qv:default:for(let h=0,d=o.length;h!==d;++h)o[h].evaluate(a),l[h].accumulate(r,n)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;if(i!==null){let r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,r=this.time+e,s=this._loopCount,a=i===Wv;if(e===0)return s===-1?r:a&&(s&1)===1?t-r:r;if(i===ES){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){let n=Math.floor(r/t);r-=t*n,s+=Math.abs(n);let o=this.repetitions-s;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(o===1){let l=e<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=r;if(a&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){let r=this._interpolantSettings;i?(r.endingStart=rl,r.endingEnd=rl):(e?r.endingStart=this.zeroSlopeAtStart?rl:il:r.endingStart=Mu,t?r.endingEnd=this.zeroSlopeAtEnd?rl:il:r.endingEnd=Mu)}_scheduleFading(e,t,i){let r=this._mixer,s=r.time,a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);let n=a.parameterPositions,o=a.sampleValues;return n[0]=s,o[0]=t,n[1]=s+e,o[1]=i,this}},r4=new Float32Array(1),s4=class extends Ii{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,a=e._propertyBindings,n=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];h===void 0&&(h={},l[o]=h);for(let d=0;d!==s;++d){let c=r[d],u=c.name,p=h[u];if(p!==void 0)++p.referenceCount,a[d]=p;else{if(p=a[d],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,o,u));continue}let f=t&&t._propertyBindings[d].binding.parsedPath;p=new qL(Dt.create(i,u,f),c.ValueTypeName,c.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,o,u),a[d]=p}n[d].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){let r=this._actions,s=this._actionsByClip,a=s[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=a;else{let n=a.knownActions;e._byClipCacheIndex=n.length,n.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,a=this._actionsByClip,n=a[s],o=n.knownActions,l=o[o.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,o[h]=l,o.pop(),e._byClipCacheIndex=null;let d=n.actionByRoot,c=(e._localRoot||this._root).uuid;delete d[c],o.length===0&&delete a[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){let s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){let r=this._bindingsByRootAndName,s=this._bindings,a=r[t];a===void 0&&(a={},r[t]=a),a[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,a=this._bindingsByRootAndName,n=a[r],o=t[t.length-1],l=e._cacheIndex;o._cacheIndex=l,t[l]=o,t.pop(),delete n[s],Object.keys(n).length===0&&delete a[r]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return i===void 0&&(i=new aA(new Float32Array(2),new Float32Array(2),1,r4),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){let r=t||this._root,s=r.uuid,a=typeof e=="string"?ug.findByName(r,e):e,n=a!==null?a.uuid:e,o=this._actionsByClip[n],l=null;if(i===void 0&&(a!==null?i=a.blendMode:i=qv),o!==void 0){let d=o.actionByRoot[s];if(d!==void 0&&d.blendMode===i)return d;l=o.knownActions[0],a===null&&(a=l._clip)}if(a===null)return null;let h=new i4(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,n,s),h}existingAction(e,t){let i=t||this._root,r=i.uuid,s=typeof e=="string"?ug.findByName(i,e):e,a=s?s.uuid:e,n=this._actionsByClip[a];return n!==void 0&&n.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;let t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(r,e,s,a);let n=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)n[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){let a=s.knownActions;for(let n=0,o=a.length;n!==o;++n){let l=a[n];this._deactivateAction(l);let h=l._cacheIndex,d=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,d._cacheIndex=h,t[h]=d,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let a in i){let n=i[a].actionByRoot,o=n[t];o!==void 0&&(this._deactivateAction(o),this._removeInactiveAction(o))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let a in s){let n=s[a];n.restoreOriginalState(),this._removeInactiveBinding(n)}}uncacheAction(e,t){let i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}},fe=class{constructor(e){this.value=e}clone(){return new fe(this.value.clone===void 0?this.value:this.value.clone())}},hA=class{constructor(e,t,i=0,r=1/0){this.ray=new Wl(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Yv,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 fg(e,this,i,t),i.sort(mx),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)fg(e[r],this,i,t);return i.sort(mx),i}};function mx(e,t){return e.distance-t.distance}function fg(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),r===!0){let s=e.children;for(let a=0,n=s.length;a<n;a++)fg(s[a],t,i,!0)}}var gx=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(pi(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},vx=new k,cA=class{constructor(e=new k(1/0,1/0),t=new k(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=vx.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 vx.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)}},yx=new E,xd=new E,Wr=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){yx.subVectors(e,this.start),xd.subVectors(this.end,this.start);let i=xd.dot(xd),r=xd.dot(yx)/i;return t&&(r=pi(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)}},xx=new E,a4=class extends Tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Ue,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 a=0,n=1,o=32;a<o;a++,n++){let l=a/o*Math.PI*2,h=n/o*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}i.setAttribute("position",new Te(r,3));let s=new vn({fog:!1,toneMapped:!1});this.cone=new Rc(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),xx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(xx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},n4=class extends ur{constructor(e,t,i){let r=new s0(t,4,2),s=new Lc({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)}},bx=new E,bd=new E,wx=new E,o4=class extends Tt{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 Ue;r.setAttribute("position",new Te([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new vn({fog:!1,toneMapped:!1});this.lightPlane=new Du(r,s),this.add(this.lightPlane),r=new Ue,r.setAttribute("position",new Te([0,0,0,0,0,1],3)),this.targetLine=new Du(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),bx.setFromMatrixPosition(this.light.matrixWorld),bd.setFromMatrixPosition(this.light.target.matrixWorld),wx.subVectors(bd,bx),this.lightPlane.lookAt(bd),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(bd),this.targetLine.scale.z=wx.length()}},wd=new E,Gt=new Xl,Bu=class extends Rc{constructor(e){let t=new Ue,i=new vn({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],a={};n("n1","n2"),n("n2","n4"),n("n4","n3"),n("n3","n1"),n("f1","f2"),n("f2","f4"),n("f4","f3"),n("f3","f1"),n("n1","f1"),n("n2","f2"),n("n3","f3"),n("n4","f4"),n("p","n1"),n("p","n2"),n("p","n3"),n("p","n4"),n("u1","u2"),n("u2","u3"),n("u3","u1"),n("c","t"),n("p","c"),n("cn1","cn2"),n("cn3","cn4"),n("cf1","cf2"),n("cf3","cf4");function n(p,f){o(p),o(f)}function o(p){r.push(0,0,0),s.push(0,0,0),a[p]===void 0&&(a[p]=[]),a[p].push(r.length/3-1)}t.setAttribute("position",new Te(r,3)),t.setAttribute("color",new Te(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=a,this.update();let l=new He(16755200),h=new He(16711680),d=new He(43775),c=new He(16777215),u=new He(3355443);this.setColors(l,h,d,c,u)}setColors(e,t,i,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,i=1,r=1;Gt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Yt("c",t,e,Gt,0,0,-1),Yt("t",t,e,Gt,0,0,1),Yt("n1",t,e,Gt,-i,-r,-1),Yt("n2",t,e,Gt,i,-r,-1),Yt("n3",t,e,Gt,-i,r,-1),Yt("n4",t,e,Gt,i,r,-1),Yt("f1",t,e,Gt,-i,-r,1),Yt("f2",t,e,Gt,i,-r,1),Yt("f3",t,e,Gt,-i,r,1),Yt("f4",t,e,Gt,i,r,1),Yt("u1",t,e,Gt,i*.7,r*1.1,-1),Yt("u2",t,e,Gt,-i*.7,r*1.1,-1),Yt("u3",t,e,Gt,0,r*2,-1),Yt("cf1",t,e,Gt,-i,0,1),Yt("cf2",t,e,Gt,i,0,1),Yt("cf3",t,e,Gt,0,-r,1),Yt("cf4",t,e,Gt,0,r,1),Yt("cn1",t,e,Gt,-i,0,-1),Yt("cn2",t,e,Gt,i,0,-1),Yt("cn3",t,e,Gt,0,-r,-1),Yt("cn4",t,e,Gt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Yt(e,t,i,r,s,a,n){wd.set(s,a,n).unproject(r);let o=t[e];if(o!==void 0){let l=i.getAttribute("position");for(let h=0,d=o.length;h<d;h++)l.setXYZ(o[h],wd.x,wd.y,wd.z)}}var zu=class extends Rc{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 Ue;s.setIndex(new Ke(i,1)),s.setAttribute("position",new Te(r,3)),super(s,new vn({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()}},l4=class extends Rc{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 Ue;r.setAttribute("position",new Te(t,3)),r.setAttribute("color",new Te(i,3));let s=new vn({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){let r=new He,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:Hl}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Hl);var Sh=".",h0=Symbol("target"),dA=Symbol("unsubscribe");function mg(e){return e instanceof Date||e instanceof Set||e instanceof Map||e instanceof WeakSet||e instanceof WeakMap||ArrayBuffer.isView(e)}function h4(e){return(typeof e=="object"?e===null:typeof e!="function")||e instanceof RegExp}var zs=Array.isArray;function c0(e){return typeof e=="symbol"}var c4={after:(e,t)=>zs(e)?e.slice(t.length):t===""?e:e.slice(t.length+1),concat:(e,t)=>zs(e)?(e=[...e],t&&e.push(t),e):t&&t.toString!==void 0?(e!==""&&(e+=Sh),c0(t)?e+t.toString():e+t):e,initial:e=>{if(zs(e))return e.slice(0,-1);if(e==="")return e;let t=e.lastIndexOf(Sh);return t===-1?"":e.slice(0,t)},last:e=>{if(zs(e))return e[e.length-1]||"";if(e==="")return e;let t=e.lastIndexOf(Sh);return t===-1?e:e.slice(t+1)},walk:(e,t)=>{if(zs(e))for(let i of e)t(i);else if(e!==""){let i=0,r=e.indexOf(Sh);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(Sh,i)}},get(e,t){return this.walk(t,i=>{e&&(e=e[i])}),e}},Ur=c4;function d4(e){return typeof e=="object"&&typeof e.next=="function"}function u4(e,t,i,r,s){let a=e.next;if(t.name==="entries")e.next=function(){let n=a.call(this);return n.done===!1&&(n.value[0]=s(n.value[0],t,n.value[0],r),n.value[1]=s(n.value[1],t,n.value[0],r)),n};else if(t.name==="values"){let n=i[h0].keys();e.next=function(){let o=a.call(this);return o.done===!1&&(o.value=s(o.value,t,n.next().value,r)),o}}else e.next=function(){let n=a.call(this);return n.done===!1&&(n.value=s(n.value,t,n.value,r)),n};return e}function _x(e,t,i){return e.isUnsubscribed||t.ignoreSymbols&&c0(i)||t.ignoreUnderscores&&i.charAt(0)==="_"||"ignoreKeys"in t&&t.ignoreKeys.includes(i)}var p4=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],a=s||e;this._pathCache.set(a,t);let n=this._proxyCache.get(a);return n===void 0&&(n=s===void 0?new Proxy(e,i):e,this._proxyCache.set(a,n)),n}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,Ur.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 a=this._getOwnPropertyDescriptor(e,t);return a!==void 0&&"set"in a?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 gg(e){return toString.call(e)==="[object Object]"}function _d(){return!0}function Oo(e,t){return e.length!==t.length||e.some((i,r)=>t[r]!==i)}var uA=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]),f4=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),pA={push:_d,pop:_d,shift:_d,unshift:_d,copyWithin:Oo,reverse:Oo,sort:Oo,splice:Oo,flat:Oo,fill:Oo},m4=new Set([...uA,...f4,...Object.keys(pA)]);function Sd(e,t){if(e.size!==t.size)return!0;for(let i of e)if(!t.has(i))return!0;return!1}var fA=["keys","values","entries"],mA=new Set(["has","toString"]),gA={add:Sd,clear:Sd,delete:Sd,forEach:Sd},g4=new Set([...mA,...Object.keys(gA),...fA]);function Ad(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 v4=new Set([...mA,"get"]),vA={set:Ad,clear:Ad,delete:Ad,forEach:Ad},y4=new Set([...v4,...Object.keys(vA),...fA]),pn=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 uA.has(e)}_shallowClone(e){let t=e;if(gg(e))t={...e};else if(zs(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?(zs(r)?this._onIsChanged=pA[t]:r instanceof Set?this._onIsChanged=gA[t]:r instanceof Map&&(this._onIsChanged=vA[t]),r):i}update(e,t,i){let r=Ur.after(e,this._path);if(t!=="length"){let s=this.clone;Ur.walk(r,a=>{s&&s[a]&&(this._clonedCache.has(s[a])||(s[a]=this._shallowClone(s[a])),s=s[a])}),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],Ur.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}},Sx=class extends pn{static isHandledMethod(e){return m4.has(e)}},x4=class extends pn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}},Ax=class extends pn{static isHandledMethod(e){return g4.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)}},Mx=class extends pn{static isHandledMethod(e){return y4.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)}},b4=class extends pn{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)}},w4=class extends pn{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)}},Ko=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gg(e)||zs(e)||mg(e)}static isHandledMethod(e,t){return gg(e)?pn.isHandledMethod(t):zs(e)?Sx.isHandledMethod(t):e instanceof Set?Ax.isHandledMethod(t):e instanceof Map?Mx.isHandledMethod(t):mg(e)}get isCloning(){return this._stack.length>0}start(e,t,i){let r=pn;zs(e)?r=Sx:e instanceof Date?r=x4:e instanceof Set?r=Ax:e instanceof Map?r=Mx:e instanceof WeakSet?r=b4:e instanceof WeakMap&&(r=w4),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=Ko.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}},_4={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},d0=(e,t,i={})=>{i={..._4,...i};let r=Symbol("ProxyTarget"),{equals:s,isShallow:a,ignoreDetached:n,details:o}=i,l=new p4(s),h=typeof i.onValidate=="function",d=new Ko(h),c=(y,x,b,w,A)=>!h||d.isCloning||i.onValidate(Ur.concat(l.getPath(y),x),b,w,A)===!0,u=(y,x,b,w)=>{!_x(l,i,x)&&!(n&&l.isDetached(y,e))&&p(l.getPath(y),x,b,w)},p=(y,x,b,w,A)=>{d.isCloning?d.update(y,x,w):t(Ur.concat(y,x),b,w,A)},f=y=>y&&(y[r]||y),m=(y,x,b,w)=>h4(y)||b==="constructor"||a&&!Ko.isHandledMethod(x,b)||_x(l,i,b)||l.isGetInvariant(x,b)||n&&l.isDetached(x,e)?y:(w===void 0&&(w=l.getPath(x)),l.getProxy(y,Ur.concat(w,b),g,r)),g={get(y,x,b){if(c0(x)){if(x===r||x===h0)return y;if(x===dA&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let w=mg(y)?Reflect.get(y,x):Reflect.get(y,x,b);return m(w,y,x)},set(y,x,b,w){b=f(b);let A=y[r]||y,S=A[x];if(s(S,b)&&x in y)return!0;let _=c(y,x,b,S);return _&&l.setProperty(A,x,b,w,S)?(u(y,x,y[x],S),!0):!_},defineProperty(y,x,b){if(!l.isSameDescriptor(b,y,x)){let w=y[x];c(y,x,b.value,w)&&l.defineProperty(y,x,b,w)&&u(y,x,b.value,w)}return!0},deleteProperty(y,x){if(!Reflect.has(y,x))return!0;let b=Reflect.get(y,x),w=c(y,x,void 0,b);return w&&l.deleteProperty(y,x,b)?(u(y,x,void 0,b),!0):!w},apply(y,x,b){let w=x[r]||x;if(l.isUnsubscribed)return Reflect.apply(y,w,b);if((o===!1||o!==!0&&!o.includes(y.name))&&Ko.isHandledType(w)){let A=Ur.initial(l.getPath(y)),S=Ko.isHandledMethod(w,y.name);d.start(w,A,b);let _=Reflect.apply(y,d.preferredThisArg(y,x,w),S?b.map(T=>f(T)):b),M=d.isChanged(w,s),C=d.stop();if(Ko.isHandledType(_)&&S&&(x instanceof Map&&y.name==="get"&&(A=Ur.concat(A,b[0])),_=l.getProxy(_,A,g)),M){let T={name:y.name,args:b,result:_},D=d.isCloning?Ur.initial(A):A,P=d.isCloning?Ur.last(A):"";c(Ur.get(e,D),P,w,C,T)?p(D,P,w,C,T):d.undo(w)}return(x instanceof Map||x instanceof Set)&&d4(_)?u4(_,y,x,A,m):_}return Reflect.apply(y,x,b)}},v=l.getProxy(e,i.pathAsArray?[]:"",g);return t=t.bind(v),h&&(i.onValidate=i.onValidate.bind(v)),v};d0.target=e=>e&&e[h0]||e;d0.unsubscribe=e=>e[dA]||e;var Ex=d0,S4=typeof global=="object"&&global&&global.Object===Object&&global,yA=S4,A4=typeof self=="object"&&self&&self.Object===Object&&self,M4=yA||A4||Function("return this")(),gs=M4,E4=gs.Symbol,Xr=E4,xA=Object.prototype,C4=xA.hasOwnProperty,T4=xA.toString,Ah=Xr?Xr.toStringTag:void 0;function P4(e){var t=C4.call(e,Ah),i=e[Ah];try{e[Ah]=void 0;var r=!0}catch{}var s=T4.call(e);return r&&(t?e[Ah]=i:delete e[Ah]),s}var D4=P4,I4=Object.prototype,O4=I4.toString;function L4(e){return O4.call(e)}var R4=L4,B4="[object Null]",z4="[object Undefined]",Cx=Xr?Xr.toStringTag:void 0;function N4(e){return e==null?e===void 0?z4:B4:Cx&&Cx in Object(e)?D4(e):R4(e)}var lo=N4;function k4(e){return e!=null&&typeof e=="object"}var Ea=k4,U4="[object Symbol]";function F4(e){return typeof e=="symbol"||Ea(e)&&lo(e)==U4}var Ap=F4;function V4(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 bA=V4,j4=Array.isArray,Ws=j4,G4=1/0,Tx=Xr?Xr.prototype:void 0,Px=Tx?Tx.toString:void 0;function wA(e){if(typeof e=="string")return e;if(Ws(e))return bA(e,wA)+"";if(Ap(e))return Px?Px.call(e):"";var t=e+"";return t=="0"&&1/e==-G4?"-0":t}var H4=wA,W4=/\s/;function q4(e){for(var t=e.length;t--&&W4.test(e.charAt(t)););return t}var X4=q4,Y4=/^\s+/;function Q4(e){return e&&e.slice(0,X4(e)+1).replace(Y4,"")}var Z4=Q4;function K4(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var ms=K4,Dx=0/0,J4=/^[-+]0x[0-9a-f]+$/i,$4=/^0b[01]+$/i,eR=/^0o[0-7]+$/i,tR=parseInt;function iR(e){if(typeof e=="number")return e;if(Ap(e))return Dx;if(ms(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ms(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Z4(e);var i=$4.test(e);return i||eR.test(e)?tR(e.slice(2),i?2:8):J4.test(e)?Dx:+e}var Ix=iR;function rR(e){return e}var sR=rR,aR="[object AsyncFunction]",nR="[object Function]",oR="[object GeneratorFunction]",lR="[object Proxy]";function hR(e){if(!ms(e))return!1;var t=lo(e);return t==nR||t==oR||t==aR||t==lR}var _A=hR,cR=gs["__core-js_shared__"],Vf=cR,Ox=function(){var e=/[^.]+$/.exec(Vf&&Vf.keys&&Vf.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function dR(e){return!!Ox&&Ox in e}var uR=dR,pR=Function.prototype,fR=pR.toString;function mR(e){if(e!=null){try{return fR.call(e)}catch{}try{return e+""}catch{}}return""}var ho=mR,gR=/[\\^$.*+?()[\]{}|]/g,vR=/^\[object .+?Constructor\]$/,yR=Function.prototype,xR=Object.prototype,bR=yR.toString,wR=xR.hasOwnProperty,_R=RegExp("^"+bR.call(wR).replace(gR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function SR(e){if(!ms(e)||uR(e))return!1;var t=_A(e)?_R:vR;return t.test(ho(e))}var AR=SR;function MR(e,t){return e?.[t]}var ER=MR;function CR(e,t){var i=ER(e,t);return AR(i)?i:void 0}var co=CR,TR=co(gs,"WeakMap"),vg=TR,Lx=Object.create,PR=function(){function e(){}return function(t){if(!ms(t))return{};if(Lx)return Lx(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),DR=PR;function IR(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 OR=IR;function LR(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t}var RR=LR,BR=800,zR=16,NR=Date.now;function kR(e){var t=0,i=0;return function(){var r=NR(),s=zR-(r-i);if(i=r,s>0){if(++t>=BR)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var UR=kR;function FR(e){return function(){return e}}var VR=FR,jR=function(){try{var e=co(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Nu=jR,GR=Nu?function(e,t){return Nu(e,"toString",{configurable:!0,enumerable:!1,value:VR(t),writable:!0})}:sR,HR=GR,WR=UR(HR),qR=WR;function XR(e,t){for(var i=-1,r=e==null?0:e.length;++i<r&&t(e[i],i,e)!==!1;);return e}var YR=XR,QR=9007199254740991,ZR=/^(?:0|[1-9]\d*)$/;function KR(e,t){var i=typeof e;return t=t??QR,!!t&&(i=="number"||i!="symbol"&&ZR.test(e))&&e>-1&&e%1==0&&e<t}var u0=KR;function JR(e,t,i){t=="__proto__"&&Nu?Nu(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}var SA=JR;function $R(e,t){return e===t||e!==e&&t!==t}var p0=$R,eB=Object.prototype,tB=eB.hasOwnProperty;function iB(e,t,i){var r=e[t];(!(tB.call(e,t)&&p0(r,i))||i===void 0&&!(t in e))&&SA(e,t,i)}var f0=iB;function rB(e,t,i,r){var s=!i;i||(i={});for(var a=-1,n=t.length;++a<n;){var o=t[a],l=r?r(i[o],e[o],o,i,e):void 0;l===void 0&&(l=e[o]),s?SA(i,o,l):f0(i,o,l)}return i}var Nc=rB,Rx=Math.max;function sB(e,t,i){return t=Rx(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,a=Rx(r.length-t,0),n=Array(a);++s<a;)n[s]=r[t+s];s=-1;for(var o=Array(t+1);++s<t;)o[s]=r[s];return o[t]=i(n),OR(e,this,o)}}var aB=sB,nB=9007199254740991;function oB(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=nB}var m0=oB;function lB(e){return e!=null&&m0(e.length)&&!_A(e)}var AA=lB,hB=Object.prototype;function cB(e){var t=e&&e.constructor,i=typeof t=="function"&&t.prototype||hB;return e===i}var g0=cB;function dB(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}var uB=dB,pB="[object Arguments]";function fB(e){return Ea(e)&&lo(e)==pB}var Bx=fB,MA=Object.prototype,mB=MA.hasOwnProperty,gB=MA.propertyIsEnumerable,vB=Bx(function(){return arguments}())?Bx:function(e){return Ea(e)&&mB.call(e,"callee")&&!gB.call(e,"callee")},v0=vB;function yB(){return!1}var xB=yB,EA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zx=EA&&typeof module=="object"&&module&&!module.nodeType&&module,bB=zx&&zx.exports===EA,Nx=bB?gs.Buffer:void 0,wB=Nx?Nx.isBuffer:void 0,_B=wB||xB,ku=_B,SB="[object Arguments]",AB="[object Array]",MB="[object Boolean]",EB="[object Date]",CB="[object Error]",TB="[object Function]",PB="[object Map]",DB="[object Number]",IB="[object Object]",OB="[object RegExp]",LB="[object Set]",RB="[object String]",BB="[object WeakMap]",zB="[object ArrayBuffer]",NB="[object DataView]",kB="[object Float32Array]",UB="[object Float64Array]",FB="[object Int8Array]",VB="[object Int16Array]",jB="[object Int32Array]",GB="[object Uint8Array]",HB="[object Uint8ClampedArray]",WB="[object Uint16Array]",qB="[object Uint32Array]",Ut={};Ut[kB]=Ut[UB]=Ut[FB]=Ut[VB]=Ut[jB]=Ut[GB]=Ut[HB]=Ut[WB]=Ut[qB]=!0;Ut[SB]=Ut[AB]=Ut[zB]=Ut[MB]=Ut[NB]=Ut[EB]=Ut[CB]=Ut[TB]=Ut[PB]=Ut[DB]=Ut[IB]=Ut[OB]=Ut[LB]=Ut[RB]=Ut[BB]=!1;function XB(e){return Ea(e)&&m0(e.length)&&!!Ut[lo(e)]}var YB=XB;function QB(e){return function(t){return e(t)}}var y0=QB,CA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rc=CA&&typeof module=="object"&&module&&!module.nodeType&&module,ZB=rc&&rc.exports===CA,jf=ZB&&yA.process,KB=function(){try{var e=rc&&rc.require&&rc.require("util").types;return e||jf&&jf.binding&&jf.binding("util")}catch{}}(),Il=KB,kx=Il&&Il.isTypedArray,JB=kx?y0(kx):YB,TA=JB,$B=Object.prototype,ez=$B.hasOwnProperty;function tz(e,t){var i=Ws(e),r=!i&&v0(e),s=!i&&!r&&ku(e),a=!i&&!r&&!s&&TA(e),n=i||r||s||a,o=n?uB(e.length,String):[],l=o.length;for(var h in e)(t||ez.call(e,h))&&!(n&&(h=="length"||s&&(h=="offset"||h=="parent")||a&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||u0(h,l)))&&o.push(h);return o}var PA=tz;function iz(e,t){return function(i){return e(t(i))}}var DA=iz,rz=DA(Object.keys,Object),sz=rz,az=Object.prototype,nz=az.hasOwnProperty;function oz(e){if(!g0(e))return sz(e);var t=[];for(var i in Object(e))nz.call(e,i)&&i!="constructor"&&t.push(i);return t}var lz=oz;function hz(e){return AA(e)?PA(e):lz(e)}var x0=hz;function cz(e){var t=[];if(e!=null)for(var i in Object(e))t.push(i);return t}var dz=cz,uz=Object.prototype,pz=uz.hasOwnProperty;function fz(e){if(!ms(e))return dz(e);var t=g0(e),i=[];for(var r in e)r=="constructor"&&(t||!pz.call(e,r))||i.push(r);return i}var mz=fz;function gz(e){return AA(e)?PA(e,!0):mz(e)}var b0=gz,vz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,yz=/^\w*$/;function xz(e,t){if(Ws(e))return!1;var i=typeof e;return i=="number"||i=="symbol"||i=="boolean"||e==null||Ap(e)?!0:yz.test(e)||!vz.test(e)||t!=null&&e in Object(t)}var bz=xz,wz=co(Object,"create"),gc=wz;function _z(){this.__data__=gc?gc(null):{},this.size=0}var Sz=_z;function Az(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Mz=Az,Ez="__lodash_hash_undefined__",Cz=Object.prototype,Tz=Cz.hasOwnProperty;function Pz(e){var t=this.__data__;if(gc){var i=t[e];return i===Ez?void 0:i}return Tz.call(t,e)?t[e]:void 0}var Dz=Pz,Iz=Object.prototype,Oz=Iz.hasOwnProperty;function Lz(e){var t=this.__data__;return gc?t[e]!==void 0:Oz.call(t,e)}var Rz=Lz,Bz="__lodash_hash_undefined__";function zz(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=gc&&t===void 0?Bz:t,this}var Nz=zz;function Kl(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])}}Kl.prototype.clear=Sz;Kl.prototype.delete=Mz;Kl.prototype.get=Dz;Kl.prototype.has=Rz;Kl.prototype.set=Nz;var Ux=Kl;function kz(){this.__data__=[],this.size=0}var Uz=kz;function Fz(e,t){for(var i=e.length;i--;)if(p0(e[i][0],t))return i;return-1}var Mp=Fz,Vz=Array.prototype,jz=Vz.splice;function Gz(e){var t=this.__data__,i=Mp(t,e);if(i<0)return!1;var r=t.length-1;return i==r?t.pop():jz.call(t,i,1),--this.size,!0}var Hz=Gz;function Wz(e){var t=this.__data__,i=Mp(t,e);return i<0?void 0:t[i][1]}var qz=Wz;function Xz(e){return Mp(this.__data__,e)>-1}var Yz=Xz;function Qz(e,t){var i=this.__data__,r=Mp(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this}var Zz=Qz;function Jl(e){var t=-1,i=e==null?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}Jl.prototype.clear=Uz;Jl.prototype.delete=Hz;Jl.prototype.get=qz;Jl.prototype.has=Yz;Jl.prototype.set=Zz;var Ep=Jl,Kz=co(gs,"Map"),vc=Kz;function Jz(){this.size=0,this.__data__={hash:new Ux,map:new(vc||Ep),string:new Ux}}var $z=Jz;function e5(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var t5=e5;function i5(e,t){var i=e.__data__;return t5(t)?i[typeof t=="string"?"string":"hash"]:i.map}var Cp=i5;function r5(e){var t=Cp(this,e).delete(e);return this.size-=t?1:0,t}var s5=r5;function a5(e){return Cp(this,e).get(e)}var n5=a5;function o5(e){return Cp(this,e).has(e)}var l5=o5;function h5(e,t){var i=Cp(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this}var c5=h5;function $l(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])}}$l.prototype.clear=$z;$l.prototype.delete=s5;$l.prototype.get=n5;$l.prototype.has=l5;$l.prototype.set=c5;var Tp=$l,d5="Expected a function";function w0(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(d5);var i=function(){var r=arguments,s=t?t.apply(this,r):r[0],a=i.cache;if(a.has(s))return a.get(s);var n=e.apply(this,r);return i.cache=a.set(s,n)||a,n};return i.cache=new(w0.Cache||Tp),i}w0.Cache=Tp;var u5=w0,p5=500;function f5(e){var t=u5(e,function(r){return i.size===p5&&i.clear(),r}),i=t.cache;return t}var m5=f5,g5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,v5=/\\(\\)?/g,y5=m5(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(g5,function(i,r,s,a){t.push(s?a.replace(v5,"$1"):r||i)}),t}),x5=y5;function b5(e){return e==null?"":H4(e)}var w5=b5;function _5(e,t){return Ws(e)?e:bz(e,t)?[e]:x5(w5(e))}var eh=_5,S5=1/0;function A5(e){if(typeof e=="string"||Ap(e))return e;var t=e+"";return t=="0"&&1/e==-S5?"-0":t}var Pp=A5;function M5(e,t){t=eh(t,e);for(var i=0,r=t.length;e!=null&&i<r;)e=e[Pp(t[i++])];return i&&i==r?e:void 0}var IA=M5;function E5(e,t){for(var i=-1,r=t.length,s=e.length;++i<r;)e[s+i]=t[i];return e}var _0=E5,Fx=Xr?Xr.isConcatSpreadable:void 0;function C5(e){return Ws(e)||v0(e)||!!(Fx&&e&&e[Fx])}var T5=C5;function OA(e,t,i,r,s){var a=-1,n=e.length;for(i||(i=T5),s||(s=[]);++a<n;){var o=e[a];t>0&&i(o)?t>1?OA(o,t-1,i,r,s):_0(s,o):r||(s[s.length]=o)}return s}var P5=OA;function D5(e){var t=e==null?0:e.length;return t?P5(e,1):[]}var I5=D5;function O5(e){return qR(aB(e,void 0,I5),e+"")}var LA=O5,L5=DA(Object.getPrototypeOf,Object),S0=L5,R5="[object Object]",B5=Function.prototype,z5=Object.prototype,RA=B5.toString,N5=z5.hasOwnProperty,k5=RA.call(Object);function U5(e){if(!Ea(e)||lo(e)!=R5)return!1;var t=S0(e);if(t===null)return!0;var i=N5.call(t,"constructor")&&t.constructor;return typeof i=="function"&&i instanceof i&&RA.call(i)==k5}var F5=U5;function V5(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 a=Array(s);++r<s;)a[r]=e[r+t];return a}var j5=V5;function G5(){this.__data__=new Ep,this.size=0}var H5=G5;function W5(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i}var q5=W5;function X5(e){return this.__data__.get(e)}var Y5=X5;function Q5(e){return this.__data__.has(e)}var Z5=Q5,K5=200;function J5(e,t){var i=this.__data__;if(i instanceof Ep){var r=i.__data__;if(!vc||r.length<K5-1)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Tp(r)}return i.set(e,t),this.size=i.size,this}var $5=J5;function th(e){var t=this.__data__=new Ep(e);this.size=t.size}th.prototype.clear=H5;th.prototype.delete=q5;th.prototype.get=Y5;th.prototype.has=Z5;th.prototype.set=$5;var fu=th;function eN(e,t){return e&&Nc(t,x0(t),e)}var tN=eN;function iN(e,t){return e&&Nc(t,b0(t),e)}var rN=iN,BA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vx=BA&&typeof module=="object"&&module&&!module.nodeType&&module,sN=Vx&&Vx.exports===BA,jx=sN?gs.Buffer:void 0,Gx=jx?jx.allocUnsafe:void 0;function aN(e,t){if(t)return e.slice();var i=e.length,r=Gx?Gx(i):new e.constructor(i);return e.copy(r),r}var nN=aN;function oN(e,t){for(var i=-1,r=e==null?0:e.length,s=0,a=[];++i<r;){var n=e[i];t(n,i,e)&&(a[s++]=n)}return a}var lN=oN;function hN(){return[]}var zA=hN,cN=Object.prototype,dN=cN.propertyIsEnumerable,Hx=Object.getOwnPropertySymbols,uN=Hx?function(e){return e==null?[]:(e=Object(e),lN(Hx(e),function(t){return dN.call(e,t)}))}:zA,A0=uN;function pN(e,t){return Nc(e,A0(e),t)}var fN=pN,mN=Object.getOwnPropertySymbols,gN=mN?function(e){for(var t=[];e;)_0(t,A0(e)),e=S0(e);return t}:zA,NA=gN;function vN(e,t){return Nc(e,NA(e),t)}var yN=vN;function xN(e,t,i){var r=t(e);return Ws(e)?r:_0(r,i(e))}var kA=xN;function bN(e){return kA(e,x0,A0)}var yg=bN;function wN(e){return kA(e,b0,NA)}var UA=wN,_N=co(gs,"DataView"),xg=_N,SN=co(gs,"Promise"),bg=SN,AN=co(gs,"Set"),wg=AN,Wx="[object Map]",MN="[object Object]",qx="[object Promise]",Xx="[object Set]",Yx="[object WeakMap]",Qx="[object DataView]",EN=ho(xg),CN=ho(vc),TN=ho(bg),PN=ho(wg),DN=ho(vg),Bn=lo;(xg&&Bn(new xg(new ArrayBuffer(1)))!=Qx||vc&&Bn(new vc)!=Wx||bg&&Bn(bg.resolve())!=qx||wg&&Bn(new wg)!=Xx||vg&&Bn(new vg)!=Yx)&&(Bn=function(e){var t=lo(e),i=t==MN?e.constructor:void 0,r=i?ho(i):"";if(r)switch(r){case EN:return Qx;case CN:return Wx;case TN:return qx;case PN:return Xx;case DN:return Yx}return t});var yc=Bn,IN=Object.prototype,ON=IN.hasOwnProperty;function LN(e){var t=e.length,i=new e.constructor(t);return t&&typeof e[0]=="string"&&ON.call(e,"index")&&(i.index=e.index,i.input=e.input),i}var RN=LN,BN=gs.Uint8Array,Uu=BN;function zN(e){var t=new e.constructor(e.byteLength);return new Uu(t).set(new Uu(e)),t}var M0=zN;function NN(e,t){var i=t?M0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}var kN=NN,UN=/\w*$/;function FN(e){var t=new e.constructor(e.source,UN.exec(e));return t.lastIndex=e.lastIndex,t}var VN=FN,Zx=Xr?Xr.prototype:void 0,Kx=Zx?Zx.valueOf:void 0;function jN(e){return Kx?Object(Kx.call(e)):{}}var GN=jN;function HN(e,t){var i=t?M0(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}var WN=HN,qN="[object Boolean]",XN="[object Date]",YN="[object Map]",QN="[object Number]",ZN="[object RegExp]",KN="[object Set]",JN="[object String]",$N="[object Symbol]",ek="[object ArrayBuffer]",tk="[object DataView]",ik="[object Float32Array]",rk="[object Float64Array]",sk="[object Int8Array]",ak="[object Int16Array]",nk="[object Int32Array]",ok="[object Uint8Array]",lk="[object Uint8ClampedArray]",hk="[object Uint16Array]",ck="[object Uint32Array]";function dk(e,t,i){var r=e.constructor;switch(t){case ek:return M0(e);case qN:case XN:return new r(+e);case tk:return kN(e,i);case ik:case rk:case sk:case ak:case nk:case ok:case lk:case hk:case ck:return WN(e,i);case YN:return new r;case QN:case JN:return new r(e);case ZN:return VN(e);case KN:return new r;case $N:return GN(e)}}var uk=dk;function pk(e){return typeof e.constructor=="function"&&!g0(e)?DR(S0(e)):{}}var fk=pk,mk="[object Map]";function gk(e){return Ea(e)&&yc(e)==mk}var vk=gk,Jx=Il&&Il.isMap,yk=Jx?y0(Jx):vk,xk=yk,bk="[object Set]";function wk(e){return Ea(e)&&yc(e)==bk}var _k=wk,$x=Il&&Il.isSet,Sk=$x?y0($x):_k,Ak=Sk,Mk=1,Ek=2,Ck=4,FA="[object Arguments]",Tk="[object Array]",Pk="[object Boolean]",Dk="[object Date]",Ik="[object Error]",VA="[object Function]",Ok="[object GeneratorFunction]",Lk="[object Map]",Rk="[object Number]",jA="[object Object]",Bk="[object RegExp]",zk="[object Set]",Nk="[object String]",kk="[object Symbol]",Uk="[object WeakMap]",Fk="[object ArrayBuffer]",Vk="[object DataView]",jk="[object Float32Array]",Gk="[object Float64Array]",Hk="[object Int8Array]",Wk="[object Int16Array]",qk="[object Int32Array]",Xk="[object Uint8Array]",Yk="[object Uint8ClampedArray]",Qk="[object Uint16Array]",Zk="[object Uint32Array]",Nt={};Nt[FA]=Nt[Tk]=Nt[Fk]=Nt[Vk]=Nt[Pk]=Nt[Dk]=Nt[jk]=Nt[Gk]=Nt[Hk]=Nt[Wk]=Nt[qk]=Nt[Lk]=Nt[Rk]=Nt[jA]=Nt[Bk]=Nt[zk]=Nt[Nk]=Nt[kk]=Nt[Xk]=Nt[Yk]=Nt[Qk]=Nt[Zk]=!0;Nt[Ik]=Nt[VA]=Nt[Uk]=!1;function mu(e,t,i,r,s,a){var n,o=t&Mk,l=t&Ek,h=t&Ck;if(i&&(n=s?i(e,r,s,a):i(e)),n!==void 0)return n;if(!ms(e))return e;var d=Ws(e);if(d){if(n=RN(e),!o)return RR(e,n)}else{var c=yc(e),u=c==VA||c==Ok;if(ku(e))return nN(e,o);if(c==jA||c==FA||u&&!s){if(n=l||u?{}:fk(e),!o)return l?yN(e,rN(n,e)):fN(e,tN(n,e))}else{if(!Nt[c])return s?e:{};n=uk(e,c,o)}}a||(a=new fu);var p=a.get(e);if(p)return p;a.set(e,n),Ak(e)?e.forEach(function(g){n.add(mu(g,t,i,g,e,a))}):xk(e)&&e.forEach(function(g,v){n.set(v,mu(g,t,i,v,e,a))});var f=h?l?UA:yg:l?b0:x0,m=d?void 0:f(e);return YR(m||e,function(g,v){m&&(v=g,g=e[v]),f0(n,v,mu(g,t,i,v,e,a))}),n}var GA=mu,Kk=1,Jk=4;function $k(e){return GA(e,Kk|Jk)}var Dp=$k,eU="__lodash_hash_undefined__";function tU(e){return this.__data__.set(e,eU),this}var iU=tU;function rU(e){return this.__data__.has(e)}var sU=rU;function Fu(e){var t=-1,i=e==null?0:e.length;for(this.__data__=new Tp;++t<i;)this.add(e[t])}Fu.prototype.add=Fu.prototype.push=iU;Fu.prototype.has=sU;var aU=Fu;function nU(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 oU=nU;function lU(e,t){return e.has(t)}var hU=lU,cU=1,dU=2;function uU(e,t,i,r,s,a){var n=i&cU,o=e.length,l=t.length;if(o!=l&&!(n&&l>o))return!1;var h=a.get(e),d=a.get(t);if(h&&d)return h==t&&d==e;var c=-1,u=!0,p=i&dU?new aU:void 0;for(a.set(e,t),a.set(t,e);++c<o;){var f=e[c],m=t[c];if(r)var g=n?r(m,f,c,t,e,a):r(f,m,c,e,t,a);if(g!==void 0){if(g)continue;u=!1;break}if(p){if(!oU(t,function(v,y){if(!hU(p,y)&&(f===v||s(f,v,i,r,a)))return p.push(y)})){u=!1;break}}else if(!(f===m||s(f,m,i,r,a))){u=!1;break}}return a.delete(e),a.delete(t),u}var HA=uU;function pU(e){var t=-1,i=Array(e.size);return e.forEach(function(r,s){i[++t]=[s,r]}),i}var fU=pU;function mU(e){var t=-1,i=Array(e.size);return e.forEach(function(r){i[++t]=r}),i}var gU=mU,vU=1,yU=2,xU="[object Boolean]",bU="[object Date]",wU="[object Error]",_U="[object Map]",SU="[object Number]",AU="[object RegExp]",MU="[object Set]",EU="[object String]",CU="[object Symbol]",TU="[object ArrayBuffer]",PU="[object DataView]",eb=Xr?Xr.prototype:void 0,Gf=eb?eb.valueOf:void 0;function DU(e,t,i,r,s,a,n){switch(i){case PU:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case TU:return!(e.byteLength!=t.byteLength||!a(new Uu(e),new Uu(t)));case xU:case bU:case SU:return p0(+e,+t);case wU:return e.name==t.name&&e.message==t.message;case AU:case EU:return e==t+"";case _U:var o=fU;case MU:var l=r&vU;if(o||(o=gU),e.size!=t.size&&!l)return!1;var h=n.get(e);if(h)return h==t;r|=yU,n.set(e,t);var d=HA(o(e),o(t),r,s,a,n);return n.delete(e),d;case CU:if(Gf)return Gf.call(e)==Gf.call(t)}return!1}var IU=DU,OU=1,LU=Object.prototype,RU=LU.hasOwnProperty;function BU(e,t,i,r,s,a){var n=i&OU,o=yg(e),l=o.length,h=yg(t),d=h.length;if(l!=d&&!n)return!1;for(var c=l;c--;){var u=o[c];if(!(n?u in t:RU.call(t,u)))return!1}var p=a.get(e),f=a.get(t);if(p&&f)return p==t&&f==e;var m=!0;a.set(e,t),a.set(t,e);for(var g=n;++c<l;){u=o[c];var v=e[u],y=t[u];if(r)var x=n?r(y,v,u,t,e,a):r(v,y,u,e,t,a);if(!(x===void 0?v===y||s(v,y,i,r,a):x)){m=!1;break}g||(g=u=="constructor")}if(m&&!g){var b=e.constructor,w=t.constructor;b!=w&&"constructor"in e&&"constructor"in t&&!(typeof b=="function"&&b instanceof b&&typeof w=="function"&&w instanceof w)&&(m=!1)}return a.delete(e),a.delete(t),m}var zU=BU,NU=1,tb="[object Arguments]",ib="[object Array]",Md="[object Object]",kU=Object.prototype,rb=kU.hasOwnProperty;function UU(e,t,i,r,s,a){var n=Ws(e),o=Ws(t),l=n?ib:yc(e),h=o?ib:yc(t);l=l==tb?Md:l,h=h==tb?Md:h;var d=l==Md,c=h==Md,u=l==h;if(u&&ku(e)){if(!ku(t))return!1;n=!0,d=!1}if(u&&!d)return a||(a=new fu),n||TA(e)?HA(e,t,i,r,s,a):IU(e,t,l,i,r,s,a);if(!(i&NU)){var p=d&&rb.call(e,"__wrapped__"),f=c&&rb.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return a||(a=new fu),s(m,g,i,r,a)}}return u?(a||(a=new fu),zU(e,t,i,r,s,a)):!1}var FU=UU;function WA(e,t,i,r,s){return e===t?!0:e==null||t==null||!Ea(e)&&!Ea(t)?e!==e&&t!==t:FU(e,t,i,r,WA,s)}var VU=WA;function jU(e,t){return e!=null&&t in Object(e)}var GU=jU;function HU(e,t,i){t=eh(t,e);for(var r=-1,s=t.length,a=!1;++r<s;){var n=Pp(t[r]);if(!(a=e!=null&&i(e,n)))break;e=e[n]}return a||++r!=s?a:(s=e==null?0:e.length,!!s&&m0(s)&&u0(n,s)&&(Ws(e)||v0(e)))}var WU=HU;function qU(e,t){return e!=null&&WU(e,t,GU)}var XU=qU,YU=function(){return gs.Date.now()},Hf=YU,QU="Expected a function",ZU=Math.max,KU=Math.min;function JU(e,t,i){var r,s,a,n,o,l,h=0,d=!1,c=!1,u=!0;if(typeof e!="function")throw new TypeError(QU);t=Ix(t)||0,ms(i)&&(d=!!i.leading,c="maxWait"in i,a=c?ZU(Ix(i.maxWait)||0,t):a,u="trailing"in i?!!i.trailing:u);function p(A){var S=r,_=s;return r=s=void 0,h=A,n=e.apply(_,S),n}function f(A){return h=A,o=setTimeout(v,t),d?p(A):n}function m(A){var S=A-l,_=A-h,M=t-S;return c?KU(M,a-_):M}function g(A){var S=A-l,_=A-h;return l===void 0||S>=t||S<0||c&&_>=a}function v(){var A=Hf();if(g(A))return y(A);o=setTimeout(v,m(A))}function y(A){return o=void 0,u&&r?p(A):(r=s=void 0,n)}function x(){o!==void 0&&clearTimeout(o),h=0,r=l=s=o=void 0}function b(){return o===void 0?n:y(Hf())}function w(){var A=Hf(),S=g(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)),n}return w.cancel=x,w.flush=b,w}var E0=JU;function $U(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var eF=$U;function tF(e,t){return t.length<2?e:IA(e,j5(t,0,-1))}var iF=tF;function rF(e,t){return VU(e,t)}var qA=rF;function sF(e,t){return t=eh(t,e),e=iF(e,t),e==null||delete e[Pp(eF(t))]}var aF=sF;function nF(e){return F5(e)?void 0:e}var oF=nF,lF=1,hF=2,cF=4,dF=LA(function(e,t){var i={};if(e==null)return i;var r=!1;t=bA(t,function(a){return a=eh(a,e),r||(r=a.length>1),a}),Nc(e,UA(e),i),r&&(i=GA(i,lF|hF|cF,oF));for(var s=t.length;s--;)aF(i,t[s]);return i}),_g=dF;function uF(e,t,i,r){if(!ms(e))return e;t=eh(t,e);for(var s=-1,a=t.length,n=a-1,o=e;o!=null&&++s<a;){var l=Pp(t[s]),h=i;if(l==="__proto__"||l==="constructor"||l==="prototype")return e;if(s!=n){var d=o[l];h=r?r(d,l,o):void 0,h===void 0&&(h=ms(d)?d:u0(t[s+1])?[]:{})}f0(o,l,h),o=o[l]}return e}var pF=uF;function fF(e,t,i){for(var r=-1,s=t.length,a={};++r<s;){var n=t[r],o=IA(e,n);i(o,n)&&pF(a,eh(n,e),o)}return a}var mF=fF;function gF(e,t){return mF(e,t,function(i,r){return XU(e,r)})}var vF=gF,yF=LA(function(e,t){return e==null?{}:vF(e,t)}),Sa=yF,xF="Expected a function";function bF(e,t,i){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(xF);return ms(i)&&(r="leading"in i?!!i.leading:r,s="trailing"in i?!!i.trailing:s),E0(e,t,{leading:r,maxWait:t,trailing:s})}var wF=bF;function _F(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function Ca(e,t){return Object.setPrototypeOf(e,t),e}var SF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),AF=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),MF=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||Ip&&"ontouchend"in document,EF=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,CF=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,TF=()=>{if(typeof window>"u")return!1;let e=navigator.userAgent,t=navigator.vendor;return/Safari/i.test(e)&&/Apple Computer/.test(t)},PF=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},DF=()=>{if(typeof window>"u")return;let e=new URLSearchParams(window.location.search).get("desktop-app-version");return e?(window.localStorage.setItem("desktop-app-version",e),e):window.localStorage.getItem("desktop-app-version")??"0.0.6"},IF=SF(),yY=IF?DF():void 0,Ip=AF(),XA=MF(),OF=EF(),Pr=CF(),sb=TF(),ab=Number(PF());function YA(e){return Array.isArray(e)?e:[e]}function LF(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 Ed(e){return Ip?e.metaKey:e.ctrlKey}var Xe=[],Vu={},qh={},gu={};function QA(e){Xe.includes(e)||Xe.push(e)}function pl(e){delete Vu[e.pointerId];for(let t=0;t<Xe.length;t++)if(Xe[t].pointerId===e.pointerId){Xe.splice(t,1);break}}function RF(){Xe.splice(0,Xe.length)}function ju(e){if(e.pointerType!=="touch")return;let t=Vu[e.pointerId];t===void 0&&(t={x:0,y:0},Vu[e.pointerId]=t),t.x=e.pageX,t.y=e.pageY}function Wf(e){let t=e.pointerId===Xe[0].pointerId?Xe[1]:Xe[0];return Vu[t.pointerId]}function ZA(e){qh[e.key]=!0,gu[e.key]=gu[e.key]===void 0?1:gu[e.key]+1}function KA(e){if(Ip&&qh.Meta)for(let t in qh)qh[t]=!1;else qh[e.key]=!1;gu={}}function BF(e){e.addEventListener("pointerdown",QA,!0),e.addEventListener("pointerdown",ju,!0),e.addEventListener("pointermove",ju,!0),e.addEventListener("pointerup",pl,!0),e.addEventListener("pointercancel",pl,!0),e.addEventListener("pointerleave",pl,!0),window.addEventListener("keydown",ZA,!0),window.addEventListener("keyup",KA,!0)}function zF(e){e.removeEventListener("pointerdown",QA,!0),e.removeEventListener("pointerdown",ju,!0),e.removeEventListener("pointermove",ju,!0),e.removeEventListener("pointerup",pl,!0),e.removeEventListener("pointercancel",pl,!0),e.removeEventListener("pointerleave",pl,!0),window.removeEventListener("keydown",ZA,!0),window.removeEventListener("keyup",KA,!0)}var JA,NF=new Promise(e=>{JA=e}),Cd;function kF(){if(Cd)return Cd;async function e(){let t="https://unpkg.com/@splinetool/navmesh-wasm@0.9.497/build",i=import("./navmesh.js"),[r,s]=await Promise.all([i,fetch(`${t}/navmesh.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});JA(n)}return Cd=e(),Cd}var $A,UF=new Promise(e=>{$A=e}),Td;function FF(){if(Td)return Td;async function e(){let t=await import("./physics.js");await t.init(),$A(t)}return Td=e(),Td}var nt=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,nt.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:a}=e,n={...t,[s]:a};return Object.setPrototypeOf(n,nt.prototype),{data:n,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,nt.prototype),delete s[i],{data:s,actual:e,reverse:{type:1,id:i,data:r}}}}return null}};function C0(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"&&C0(r)}return Object.freeze(e)}function VF(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 e2=class extends Error{};function qf(e){let t={...e};return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}function Ja(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 a=e;e=t,t=a}let r=[],s=1/(i+1);for(let a=0;a<i;a++){let n=e+(t-e)*(a+.75+Math.random()*.5)*s;r.push(n)}return r}function T0(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 jF(){return typeof process<"u"}function t2(e,t){for(let i of e)t(i.id,i.data)!==!0&&t2(i.children,t)}function i2(e,t){if(t(e.id,e.data)!==!0)for(let i of e.children)i2(i,t)}var mr=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,mr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)C0(this[e]),e++}fillCaches0(e,t){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let i of e.children)this.fillCaches0(i,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,t){if(!this.has(e))return!0;for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}rootAcestor(e){for(;e;){let t=this.parent(e);if(t)e=t;else return e}return e}isDescendantOf(e,t){for(;e;){let i=this.parent(e);if(i===t)return!0;e=i}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let i=this.get(e);i&&i2(i,t)}}traverse(e){t2(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(n=>n.id===e);if(s<0)throw new Error("not expected");let a=r[s];return r=[...r],r[s]={...a,data:t},this.modifyArrayBy(i,r)}}modifyArrayBy(e,t){let i=e,r=t;for(;i!==null;){let a=r,n=i;if(i=this.parent(i),i===void 0)throw new Error;r=this.childrenArray(i);let o=r.findIndex(l=>l.id===n);if(o<0)throw new Error;r=[...r],r[o]={...r[o],children:a}}Object.setPrototypeOf(r,mr.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:a}=e;if(t!==null&&this.get(t)===void 0||this.checkDuplicatedIdRec(e))return null;{let n=t,o=this.childrenArray(n),l={fi:i,id:r,data:s,children:a};return o=[...o,l],o.sort((h,d)=>h.fi-d.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(n,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(n=>n.id===t);e.localIndex=s,r=[...r];let a=r.splice(s,1)[0];return{data:this.modifyArrayBy(i,r),actual:e,reverse:{type:7,...a,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 e2("cyclic tree");c=this.parent(c)}}let s=this.parent(r);if(s===void 0)return null;let a=s,n=this.childrenArray(s),o=n.findIndex(c=>c.id===r);n=[...n];let l=n.splice(o,1)[0],h=this.modifyArrayBy(s,n);s=t,n=h.childrenArray(s);let d=l.fi;return l={...l,fi:i},n=[...n,l],n.sort((c,u)=>c.fi-u.fi),e.localIndex=n.indexOf(l),h=h.modifyArrayBy(s,n),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,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)=>VF(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 Ja(0,i,i);{let s=r[0].fi;return Ja(s-i,s,i)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=r.find(n=>n.fi>s.fi);if(a===void 0){let n=r[r.length-1].fi;return Ja(n,n+i,i)}else return Ja(s.fi,a.fi,i)}}},Gu;(e=>{function t(i,r){if(r.type!==0)return null;if(Array.isArray(i)){let s=r.props,a={},n=[...i],o=!1;if(s)for(let l of Object.keys(s)){let h=parseInt(l);if(isNaN(h))throw new Error("wrong index");a[l]=n[h],n[h]=s[l],o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}else{let s=r.props,a={},n={...i},o=!1;if(s)for(let l of Object.keys(s)){a[l]=n[l];let h=s[l];h===void 0?delete n[l]:n[l]=h,o=!0}return o?{data:n,actual:r,reverse:{type:0,props:a}}:null}}e.runOp=t})(Gu||(Gu={}));var We=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,We.prototype)}deepFreeze(){let e=0;for(;e<this.length;)C0(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(a=>a.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,We.prototype);let t=e;return jF()||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,a={fi:t,id:i,data:r};return s=[...s,a],s.sort((n,o)=>n.fi-o.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:t}=e,i=this,r=i.findIndex(a=>a.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 a=r[s].fi,n={...r[s],fi:t};return r[s]=n,r.sort((o,l)=>o.fi-l.fi),e.localIndex=r.indexOf(n),{data:this.modifyArrayBy(r),actual:e,reverse:{type:6,fi:a,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 Ja(0,t,t);{let r=i[0].fi;return Ja(r-t,r,t)}}else{let r=this.get(e);if(r===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>r.fi);if(s===void 0){let a=i[i.length-1].fi;return Ja(a,a+t,t)}else return Ja(r.fi,s.fi,t)}}};function Ol(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&&!Ol(i))return null;r+=1}i=i?qf(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=qf(o),delete i[e.path[r-1]])}else{let o=t[r-1];if(o){let l=qf(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 a=Object.setPrototypeOf(i,mi.prototype),n={...e,props:s};return{data:a,actual:e,reverse:n}}},on;(e=>{function t(s,a){return xc(s,a)??s}e.apply=t;function i(s,a){return D0(s,a)}e.merge=i;function r(s,a){let n=0,o=a.path,l=s;for(;n<o.length&&l!==void 0;){if(l=Zi.zoomOnce(l,o[n]),l===void 0)return a;if(!Ol(l))return;n+=1}if(l===void 0)return a;if(Ol(l))if(a.type===0){let h={...a.props};for(let d of Object.keys(l))delete h[d];return{...a,props:h}}else if(a.type===1||a.type===4||a.type===7){let h=P0([a],l);return h?(console.log(h),h):a}else return a}e.filterOp=r})(on||(on={}));function P0(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=xc(s.data,t[a]);if(i=i||n!==void 0,n===void 0&&(n=s.data),s.children){let o=P0(s.children,t);return o!==void 0?i=!0:o=s.children,{...s,id:a,data:n,children:o}}else return{...s,id:a,data:n}});if(i)return r}function GF(e,t){if(t===void 0)return;let i=!1,r=e.map(s=>{let a=s.id,n=xc(s.data,t[a]);return i=i||n!==void 0,n===void 0&&(n=s.data),{...s,id:a,data:n}});if(i)return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}function xc(e,t){if(!Ol(t))return t;if(e instanceof mr){let i=P0(e,t);return i!==void 0&&Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i}else{if(e instanceof We)return GF(e,t);if(Array.isArray(e)){let i=!1,r=e.map((s,a)=>{let n=xc(s,t[a]);return i=i||n!==void 0,n===void 0&&(n=s),n});return i?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else{if(e instanceof mi)return D0(e,t);if(e&&typeof e=="object"){let i={},r=!1;for(let[s,a]of Object.entries(e)){let n=xc(a,t[s]);r=r||n!==void 0,n===void 0&&(n=a),i[s]=n}return r?(Object.setPrototypeOf(i,Object.getPrototypeOf(e)),i):void 0}}}}function D0(e,t){if(e===void 0)return t;if(t===void 0)return e;if(!Ol(t))return t;if(!Ol(e))return on.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 a=D0(e===void 0?void 0:e[s],t===void 0?void 0:t[s]);r[s]=a}return r}function HF(e,t){let i={cur:[],result:[],len:0};return e=bc(e,t,i)??e,[e,i.result]}function Hu(e,t){return e===null?null:(e.cur[e.len]=t,e.len+=1,e)}function Wu(e){e&&(e.len-=1)}function WF(e){if(e===null)return null;e.result.push(e.cur.slice(0,e.len))}function r2(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=bc(a.data,t,Hu(i,n));Wu(i),r=r||l!==void 0,l===void 0&&(l=a.data);let h=r2(a.children,t,i);return h!==void 0?r=!0:h=a.children,{...a,id:n,data:l,children:h}});if(r)return s}function qF(e,t,i){let r=!1,s=e.map(a=>{let n=a.id,o=t[n];if(o!==void 0&&typeof o=="string"&&(r=!0,n=o,i!==null))throw new Error("not supported");let l=bc(a.data,t,Hu(i,n));return Wu(i),r=r||l!==void 0,l===void 0&&(l=a.data),{...a,id:n,data:l}});if(r)return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}function bc(e,t,i){if(e instanceof mr){let r=r2(e,t,i);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r}else{if(e instanceof We)return qF(e,t,i);if(Array.isArray(e)){let r=!1,s=e.map((a,n)=>{let o=bc(a,t,Hu(i,n));return Wu(i),r=r||o!==void 0,o===void 0&&(o=a),o});return r?(Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s):void 0}else if(e&&typeof e=="object"&&!T0(e)){let r={},s=!1;for(let[a,n]of Object.entries(e))if(a!=="name"){let o=t[a];if(typeof o=="string"){if(i!==null)throw new Error("not supported");s=!0,a=o}let l=bc(n,t,Hu(i,a));Wu(i),s=s||l!==void 0,l===void 0&&(l=n),r[a]=l}else r[a]=n;return s?(Object.setPrototypeOf(r,Object.getPrototypeOf(e)),r):void 0}else if(typeof e=="string"){let r=t[e];return r!==void 0&&WF(i),r}else return}}var Sg;(e=>{function t(i,r){let s=Zi.zoom(r,i.path);if(typeof s=="object"){let a={};for(let n of Object.keys(i.props))a[n]=s[n];return{...i,props:a}}else return{...i,props:{}}}e.replaceProps=t})(Sg||(Sg={}));var ki;(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 d=h.path;for(var c=[];;){let u;if(l instanceof mi&&h.type===0&&(u=l.runOp({...h,path:d.slice(c.length)}),u===null&&(u=void 0)),u===void 0&&c.length===d.length&&(l instanceof mr||l instanceof We||l instanceof nt?u=l.runOp(h):u=Gu.runOp(l,h)),u!==void 0)if(u!==null){let m=u.data;for(let g=c.length-1;g>=0;g--){let v=d[g],y=c[g];if(y instanceof mr){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof We){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof nt){if(typeof v=="number")throw new Error("illegal arg");m=y.modifyById(v,m)}else if(y instanceof mi){let x={...y,[v]:m};m=Object.setPrototypeOf(x,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 x=m;m=[...y],m[v]=x}else m={...y,[v]:m};else return null}return{data:m,actual:{...u.actual,path:d},reverse:{...u.reverse,path:d}}}else return null;let p=d[c.length],f;if(l instanceof mr){if(typeof p=="number")throw new Error("");f=l.get(p)?.data}else if(l instanceof We){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 d=0;d<l.length&&d<h.length;d++)if(l[d]!==h[d])return!0;return!1}e.pathDisjoint=s;function a(l,h){if(l.length!==h.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==h[d])return!1;return!0}e.pathEq=a;function n(l,h){return s(l.path,h.path)}e.commutative=n;function o(l,h){return l.type===0&&h.type===0&&a(l.path,h.path)?Object.keys(l.props).every(d=>h.props[d]!==void 0):!1}e.subsumed=o})(ki||(ki={}));var Ag;(e=>{function t(){return[]}e.empty=t;function i(h,d){let c=[];for(let u of h){let[p,...f]=u.path;p===d&&c.push({...u,path:f})}return c}e.removePrefix=i;function r(h,d){return h.map(c=>({...c,path:[d,...c.path]}))}e.addPrefix=r;function s(h,d){return[...h,...d]}e.concat=s;function a(h,d){return[...h.filter(c=>!d.some(u=>ki.subsumed(c,u))),...d]}e.compress=a;function n(h,d){return h.every(c=>d.every(u=>ki.commutative(c,u)))}e.commutative=n;function o(h,d){for(let c of d){let u=l(h,c);u!==null&&(h=u.data)}return h}e.applyAll=o;function l(h,d){var c=h;let u=[],p=[];for(let f of d)try{if(f.type===3||f.type===5&&f.path[f.path.length-1]==="variables"){let m,g,v;if(f.type===3?(m=Zi.zoom(c,[...f.path,f.id]),v=ki.apply(c,{...f,type:2})):(m=Zi.zoom(c,[...f.path,f.id,"value"]),v=ki.apply(c,f)),v!==null){c=v.data;let[y,x]=HF(c,{[f.id]:m});c=y;for(let b=0;b<x.length;b++){let w=x[b],A=w.pop();if(typeof A=="number"){let S=[A];for(let M=b+1;M<x.length;M++){let C=x[M],T=C[C.length-1];if(typeof T=="number"&&Zi.equal(w,C.slice(0,C.length-1)))S.push(T),x.splice(M,1);else break}let _=Zi.zoom(c,w);g=_.map((M,C)=>S.includes(C)?f.id:M),m=_,A=w.pop()}else{if(A==="alphaOverride"||A==="alpha"){m/=100;let S=m,_=Zi.zoom(c,w.slice(0,w.length-2)),M=_.layers.map(C=>C.id===w[w.length-1]?{...C,data:{...C.data,[A]:S}}:C);Object.setPrototypeOf(M,Object.getPrototypeOf(_.layers)),_.layers=M}g=f.id}u.push({type:0,path:w,props:{[A]:m}}),p.push({type:0,path:w,props:{[A]:g}})}p.push(v.reverse),u.push(v.actual)}}else{let m=ki.apply(c,f);m!==null&&(u.push(m.actual),c=m.data,p.push(m.reverse))}}catch(m){if(m instanceof e2)return null;throw m}return{data:c,actual:u,reverse:p.reverse()}}e.apply=l})(Ag||(Ag={}));var s2=Symbol(),XF=Symbol(),Op=Symbol(),kc=class{reportOp(e,t,i=[]){let r=this;if(t===null)return;r._current=t.data;let s=i;for(;!(r instanceof n2);){let a=r._path,n=r._current;if(a!==""&&s.splice(0,0,a),r=r._parent,r===null)return;r.update(a,n)}r.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let i=t[Op];i&&i(),delete this._children[e]}}}},YF=class extends kc{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,Gu.runOp(this._current,e),e.path)}},QF=class extends kc{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,nt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},a2={get(e,t){if(t===Op)return()=>{e._parent=null};if(t===s2)return e._current;if(t===XF)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 a=i[t],n=Lp(e,t,a);return n!==a?(r===void 0&&(r={},e._children=r),r[t]=n,n):a},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]}}},ZF={...a2,set(e,t,i){let r={type:0,props:{[t]:oi(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}},KF={...a2,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}},I0=class extends kc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Op]=()=>{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,a=Lp(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}insertBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.add(e,r[s],a.id,a.data,a.children)}}moveAfter(e,t,i){let r=this._current.insertAfterHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}moveBefore(e,t,i){let r=this._current.insertBeforeHelper(e,t,i.length);for(let s=0;s<i.length;s++){let a=i[s];this.move(e,r[s],a)}}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)}},O0=class extends kc{constructor(e,t,i){super(),this._children={},this._parent=e,this._path=t,this._current=i,this[Op]=()=>{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,a=Lp(this,e,s);return a!==s?(i===void 0&&(i={},this._children=i),i[e]=a,a):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 Xf(e,t,i){if(e.length>0){let r=e[e.length-1];if(r.type===0&&t.type===0&&Zi.equal(r.path,i)){Object.assign(r.props,t.props);return}}e.push({...t,path:i})}var n2=class extends kc{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){Xf(this.ts,t,e),Xf(this.actual,i,e),Xf(this.reverse,r,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Lp(e,t,i){return i instanceof mr?new I0(e,t,i):i instanceof We?new O0(e,t,i):i instanceof nt?new Proxy(new QF(e,t,i),KF):i!==null&&typeof i=="object"?T0(i)?i:new Proxy(new YF(e,t,i),ZF):i}function o2(e){let t=new n2(e);return[Lp(t,"",e),t]}function wc(e,t){let[i,r]=o2(e);return t(i),r.result()}function oi(e){return e instanceof I0||e instanceof O0?e._current:e!==null&&typeof e=="object"?e[s2]:e}var Zi;(e=>{function t(a,n){if(n.length===a.length)for(var o=0;o<a.length;){if(a[o]!==n[o])return!1;o+=1}else return!1;return!0}e.equal=t;function i(a,n,o){let l=s(o,a);if(l!==void 0&&typeof l=="object"&&l!==null){let h={...n};return Object.keys(l).forEach(d=>{delete h[d]}),h}else return n}e.removeOverridden=i;function r(a,n){if((a instanceof mr||a instanceof I0)&&typeof n=="string"||(a instanceof We||a instanceof O0)&&typeof n=="string")return a.data(n);if(typeof n=="number"&&Array.isArray(a)||typeof n=="string"&&typeof a=="object"&&a!==null)return a[n]}e.zoomOnce=r;function s(a,n,o=0){for(;o<n.length&&a!==void 0;)a=r(a,n[o]),o+=1;return a}e.zoom=s})(Zi||(Zi={}));function JF(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 Gr(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 l2=class{},nb=class extends l2{constructor(e){super(),this.id=e}},ob=class extends l2{constructor(e){super(),this.data=e}},Mg;try{Mg=new TextDecoder}catch{}var De,ln,K=0,h2=[],Eg=h2,Cg=0,cr={},wt,$a,Fr=0,Ns=0,Mr,Aa,ir=[],St,lb={useRecords:!1,mapsAsObjects:!0},c2=class{},d2=new c2;d2.name="MessagePack 0xC1";var Ll=!1,qu=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(De)return v2(()=>(Pg(),this?this.unpack(e,t):qu.prototype.unpack.call(lb,e,t)));ln=t>-1?t:e.length,K=0,Cg=0,Ns=0,$a=null,Eg=h2,Mr=null,De=e;try{St=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(i){throw De=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 qu){if(cr=this,this.structures)return wt=this.structures,Pd();(!wt||wt.length>0)&&(wt=[])}else cr=lb,(!wt||wt.length>0)&&(wt=[]);return Pd()}unpackMultiple(e,t){let i,r=0;try{Ll=!0;let s=e.length,a=this?this.unpack(e,s):Bp.unpack(e,s);if(t){for(t(a);K<s;)if(r=K,t(Pd())===!1)return}else{for(i=[a];K<s;)r=K,i.push(Pd());return i}}catch(s){throw s.lastPosition=r,s.values=i,s}finally{Ll=!1,Pg()}}_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 Pd(){try{if(!cr.trusted&&!Ll){let t=wt.sharedLength||0;t<wt.length&&(wt.length=t)}let e=Wt();if(K==ln)wt.restoreStructures&&hb(),wt=null,De=null,Aa&&(Aa=null);else if(K>ln){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Ll)throw new Error("Data read, but end of buffer not reached");return e}catch(e){throw wt.restoreStructures&&hb(),Pg(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer"))&&(e.incomplete=!0),e}}function hb(){for(let e in wt.restoreStructures)wt[e]=wt.restoreStructures[e];wt.restoreStructures=null}function Wt(){let e=De[K++];if(e<160)if(e<128){if(e<64)return e;{let t=wt[e&63]||cr.getStructures&&u2()[e&63];return t?(t.read||(t.read=L0(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,cr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[f2()]=Wt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Wt(),Wt());return t}else{e-=144;let t=new Array(e);for(let i=0;i<e;i++)t[i]=Wt();return t}else if(e<192){let t=e-160;if(Ns>=K)return $a.slice(K-Fr,(K+=t)-Fr);if(Ns==0&&ln<140){let i=t<16?R0(t):p2(t);if(i!=null)return i}return Tg(t)}else{let t;switch(e){case 192:return null;case 193:return Mr?(t=Wt(),t>0?Mr[1].slice(Mr.position1,Mr.position1+=t):Mr[0].slice(Mr.position0,Mr.position0-=t)):d2;case 194:return!1;case 195:return!0;case 196:return Yf(De[K++]);case 197:return t=St.getUint16(K),K+=2,Yf(t);case 198:return t=St.getUint32(K),K+=4,Yf(t);case 199:return Pn(De[K++]);case 200:return t=St.getUint16(K),K+=2,Pn(t);case 201:return t=St.getUint32(K),K+=4,Pn(t);case 202:if(t=St.getFloat32(K),cr.useFloat32>2){let i=B0[(De[K]&127)<<1|De[K+1]>>7];return K+=4,(i*t+(t>0?.5:-.5)>>0)/i}return K+=4,t;case 203:return t=St.getFloat64(K),K+=8,t;case 204:return De[K++];case 205:return t=St.getUint16(K),K+=2,t;case 206:return t=St.getUint32(K),K+=4,t;case 207:return cr.int64AsNumber?(t=St.getUint32(K)*4294967296,t+=St.getUint32(K+4)):t=St.getBigUint64(K),K+=8,t;case 208:return St.getInt8(K++);case 209:return t=St.getInt16(K),K+=2,t;case 210:return t=St.getInt32(K),K+=4,t;case 211:return cr.int64AsNumber?(t=St.getInt32(K)*4294967296,t+=St.getUint32(K+4)):t=St.getBigInt64(K),K+=8,t;case 212:if(t=De[K++],t==114)return fb(De[K++]&63);{let i=ir[t];if(i)return i.read?(K++,i.read(Wt())):i.noBuffer?(K++,i()):i(De.subarray(K,++K));throw new Error("Unknown extension "+t)}case 213:return t=De[K],t==114?(K++,fb(De[K++]&63,De[K++])):Pn(2);case 214:return Pn(4);case 215:return Pn(8);case 216:return Pn(16);case 217:return t=De[K++],Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):e6(t);case 218:return t=St.getUint16(K),K+=2,Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):t6(t);case 219:return t=St.getUint32(K),K+=4,Ns>=K?$a.slice(K-Fr,(K+=t)-Fr):i6(t);case 220:return t=St.getUint16(K),K+=2,db(t);case 221:return t=St.getUint32(K),K+=4,db(t);case 222:return t=St.getUint16(K),K+=2,ub(t);case 223:return t=St.getUint32(K),K+=4,ub(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 $F=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function L0(e,t){function i(){if(i.count++>2){let s=e.read=new Function("r","return function(){return {"+e.map(a=>$F.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"}}")(Wt);return e.highByte===0&&(e.read=cb(t,e.read)),s()}let r={};for(let s=0,a=e.length;s<a;s++){let n=e[s];r[n]=Wt()}return r}return i.count=0,e.highByte===0?cb(t,i):i}var cb=(e,t)=>function(){let i=De[K++];if(i===0)return t();let r=e<32?-(e+(i<<5)):e+(i<<5),s=wt[r]||u2()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=L0(s,e)),s.read()};function u2(){let e=v2(()=>(De=null,cr.getStructures()));return wt=cr._mergeStructures(e,wt)}var Tg=Rp,e6=Rp,t6=Rp,i6=Rp;function Rp(e){let t;if(e<16&&(t=R0(e)))return t;if(e>64&&Mg)return Mg.decode(De.subarray(K,K+=e));let i=K+e,r=[];for(t="";K<i;){let s=De[K++];if((s&128)===0)r.push(s);else if((s&224)===192){let a=De[K++]&63;r.push((s&31)<<6|a)}else if((s&240)===224){let a=De[K++]&63,n=De[K++]&63;r.push((s&31)<<12|a<<6|n)}else if((s&248)===240){let a=De[K++]&63,n=De[K++]&63,o=De[K++]&63,l=(s&7)<<18|a<<12|n<<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+=wi.apply(String,r),r.length=0)}return r.length>0&&(t+=wi.apply(String,r)),t}function db(e){let t=new Array(e);for(let i=0;i<e;i++)t[i]=Wt();return t}function ub(e){if(cr.mapsAsObjects){let t={};for(let i=0;i<e;i++)t[f2()]=Wt();return t}else{let t=new Map;for(let i=0;i<e;i++)t.set(Wt(),Wt());return t}}var wi=String.fromCharCode;function p2(e){let t=K,i=new Array(e);for(let r=0;r<e;r++){let s=De[K++];if((s&128)>0){K=t;return}i[r]=s}return wi.apply(String,i)}function R0(e){if(e<4)if(e<2){if(e===0)return"";{let t=De[K++];if((t&128)>1){K-=1;return}return wi(t)}}else{let t=De[K++],i=De[K++];if((t&128)>0||(i&128)>0){K-=2;return}if(e<3)return wi(t,i);let r=De[K++];if((r&128)>0){K-=3;return}return wi(t,i,r)}else{let t=De[K++],i=De[K++],r=De[K++],s=De[K++];if((t&128)>0||(i&128)>0||(r&128)>0||(s&128)>0){K-=4;return}if(e<6){if(e===4)return wi(t,i,r,s);{let a=De[K++];if((a&128)>0){K-=5;return}return wi(t,i,r,s,a)}}else if(e<8){let a=De[K++],n=De[K++];if((a&128)>0||(n&128)>0){K-=6;return}if(e<7)return wi(t,i,r,s,a,n);let o=De[K++];if((o&128)>0){K-=7;return}return wi(t,i,r,s,a,n,o)}else{let a=De[K++],n=De[K++],o=De[K++],l=De[K++];if((a&128)>0||(n&128)>0||(o&128)>0||(l&128)>0){K-=8;return}if(e<10){if(e===8)return wi(t,i,r,s,a,n,o,l);{let h=De[K++];if((h&128)>0){K-=9;return}return wi(t,i,r,s,a,n,o,l,h)}}else if(e<12){let h=De[K++],d=De[K++];if((h&128)>0||(d&128)>0){K-=10;return}if(e<11)return wi(t,i,r,s,a,n,o,l,h,d);let c=De[K++];if((c&128)>0){K-=11;return}return wi(t,i,r,s,a,n,o,l,h,d,c)}else{let h=De[K++],d=De[K++],c=De[K++],u=De[K++];if((h&128)>0||(d&128)>0||(c&128)>0||(u&128)>0){K-=12;return}if(e<14){if(e===12)return wi(t,i,r,s,a,n,o,l,h,d,c,u);{let p=De[K++];if((p&128)>0){K-=13;return}return wi(t,i,r,s,a,n,o,l,h,d,c,u,p)}}else{let p=De[K++],f=De[K++];if((p&128)>0||(f&128)>0){K-=14;return}if(e<15)return wi(t,i,r,s,a,n,o,l,h,d,c,u,p,f);let m=De[K++];if((m&128)>0){K-=15;return}return wi(t,i,r,s,a,n,o,l,h,d,c,u,p,f,m)}}}}}function Yf(e){return cr.copyBuffers?Uint8Array.prototype.slice.call(De,K,K+=e):De.subarray(K,K+=e)}function Pn(e){let t=De[K++];if(ir[t])return ir[t](De.subarray(K,K+=e));throw new Error("Unknown extension type "+t)}var pb=new Array(4096);function f2(){let e=De[K++];if(e>=160&&e<192){if(e=e-160,Ns>=K)return $a.slice(K-Fr,(K+=e)-Fr);if(!(Ns==0&&ln<180))return Tg(e)}else return K--,Wt();let t=(e<<5^(e>1?St.getUint16(K):e>0?De[K]:0))&4095,i=pb[t],r=K,s=K+e-3,a,n=0;if(i&&i.bytes==e){for(;r<s;){if(a=St.getUint32(r),a!=i[n++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(a=De[r++],a!=i[n++]){r=1879048192;break}if(r===s)return K=r,i.string;s-=3,r=K}for(i=[],pb[t]=i,i.bytes=e;r<s;)a=St.getUint32(r),i.push(a),r+=4;for(s+=3;r<s;)a=De[r++],i.push(a);let o=e<16?R0(e):p2(e);return o!=null?i.string=o:i.string=Tg(e)}var fb=(e,t)=>{var i=Wt();let r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,i.highByte=t);let s=wt[e];return s&&s.isShared&&((wt.restoreStructures||(wt.restoreStructures=[]))[e]=s),wt[e]=i,i.read=L0(i,r),i.read()},m2=typeof self=="object"?self:global;ir[0]=()=>{};ir[0].noBuffer=!0;ir[101]=()=>{let e=Wt();return(m2[e[0]]||Error)(e[1])};ir[105]=e=>{let t=St.getUint32(K-4);Aa||(Aa=new Map);let i=De[K],r;i>=144&&i<160||i==220||i==221?r=[]:r={};let s={target:r};Aa.set(t,s);let a=Wt();return s.used?Object.assign(r,a):(s.target=a,a)};ir[112]=e=>{let t=St.getUint32(K-4),i=Aa.get(t);return i.used=!0,i.target};ir[115]=()=>new Set(Wt());var g2=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");ir[116]=e=>{let t=e[0],i=g2[t];if(!i)throw new Error("Could not find typed array for code "+t);return new m2[i](Uint8Array.prototype.slice.call(e,1).buffer)};ir[120]=()=>{let e=Wt();return new RegExp(e[0],e[1])};ir[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],i=K;K+=t-4,Mr=[Wt(),Wt()],Mr.position0=0,Mr.position1=0;let r=K;K=i;try{return Wt()}finally{K=r}};ir[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 v2(e){let t=ln,i=K,r=Cg,s=Fr,a=Ns,n=$a,o=Eg,l=Aa,h=Mr,d=new Uint8Array(De.slice(0,ln)),c=wt,u=wt.slice(0,wt.length),p=cr,f=Ll,m=e();return ln=t,K=i,Cg=r,Fr=s,Ns=a,$a=n,Eg=o,Aa=l,Mr=h,De=d,Ll=f,wt=c,wt.splice(0,wt.length,...u),cr=p,St=new DataView(De.buffer,De.byteOffset,De.byteLength),m}function Pg(){De=null,Aa=null,wt=null}function r6(e){e.unpack?ir[e.type]=e.unpack:ir[e.type]=e}var B0=new Array(147);for(let e=0;e<256;e++)B0[e]=+("1e"+Math.floor(45.15-e*.30103));var Bp=new qu({useRecords:!1}),xY=Bp.unpack,bY=Bp.unpackMultiple,wY=Bp.unpack,s6={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},a6=new Float32Array(1),_Y=new Uint8Array(a6.buffer,0,4),vu;try{vu=new TextEncoder}catch{}var Xu,z0,zp=typeof Buffer<"u",Qf=zp?Buffer.allocUnsafeSlow:Uint8Array,y2=zp?Buffer:Uint8Array,mb=zp?4294967296:2144337920,ce,Qt,te=0,bs,ws=null,n6=/[\u0080-\uFFFF]/,Mh=Symbol("record-id"),x2=class extends qu{constructor(e){super(e),this.offset=0;let t,i,r,s,a,n,o=0,l=y2.prototype.utf8Write?function(S,_,M){return ce.utf8Write(S,_,M)}:vu&&vu.encodeInto?function(S,_){return vu.encodeInto(S,ce.subarray(_)).written}:!1,h=this;e||(e={});let d=e&&e.sequential,c=e.structures||e.saveStructures,u=e.maxSharedStructures;if(u==null&&(u=c?32:0),u>8160)throw new Error("Maximum maxSharedStructure is 8160");let p=e.maxOwnStructures;p==null&&(p=c?32:64),d&&!e.saveStructures&&(this.structures=[]);let f=u>32||p+u>64,m=u+64,g=u+p+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],y=0,x=0;this.pack=this.encode=function(S,_){if(ce||(ce=new Qf(8192),Qt=new DataView(ce.buffer,0,8192),te=0),bs=ce.length-10,bs-te<2048?(ce=new Qf(ce.length),Qt=new DataView(ce.buffer,0,ce.length),bs=ce.length-10,te=0):te=te+7&2147483640,i=te,n=h.structuredClone?new Map:null,h.bundleStrings?(ws=["",""],ce[te++]=214,ce[te++]=98,ws.position=te-i,te+=4):ws=null,r=h.structures,r){r.uninitialized&&(r=h._mergeStructures(h.getStructures()));let M=r.sharedLength||0;if(M>u)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let C=0;C<M;C++){let T=r[C];if(!T)continue;let D,P=r.transitions;for(let O=0,B=T.length;O<B;O++){let G=T[O];D=P[G],D||(D=P[G]=Object.create(null)),P=D}P[Mh]=C+64}o=M}d||(r.nextId=M+64)}s&&(s=!1),a=r||[];try{if(b(S),ws){Qt.setUint32(ws.position+i,te-ws.position-i);let M=ws;ws=null,b(M[0]),b(M[1])}if(h.offset=te,n&&n.idsToInsert){te+=n.idsToInsert.length*6,te>bs&&A(te),h.offset=te;let M=l6(ce.subarray(i,te),n.idsToInsert);return n=null,M}return _&h6?(ce.start=i,ce.end=te,ce):ce.subarray(i,te)}finally{if(r){if(x<10&&x++,y>1e4)r.transitions=null,x=0,y=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let M=0,C=v.length;M<C;M++)v[M][Mh]=0;v=[]}if(s&&h.saveStructures){let M=r.sharedLength||u;r.length>M&&(r=r.slice(0,M));let C=ce.subarray(i,te);return h.saveStructures(r,o)===!1?(h._mergeStructures(h.getStructures()),h.pack(S)):(o=M,C)}}_&c6&&(te=i)}};let b=S=>{te>bs&&(ce=A(te));var _=typeof S,M;if(_==="string"){let C=S.length;if(ws&&C>=8&&C<4096){let P=n6.test(S);ws[P?0:1]+=S,ce[te++]=193,b(P?-C:C);return}let T;C<32?T=1:C<256?T=2:C<65536?T=3:T=5;let D=C*3;if(te+D>bs&&(ce=A(te+D)),C<64||!l){let P,O,B,G=te+T;for(P=0;P<C;P++)O=S.charCodeAt(P),O<128?ce[G++]=O:O<2048?(ce[G++]=O>>6|192,ce[G++]=O&63|128):(O&64512)===55296&&((B=S.charCodeAt(P+1))&64512)===56320?(O=65536+((O&1023)<<10)+(B&1023),P++,ce[G++]=O>>18|240,ce[G++]=O>>12&63|128,ce[G++]=O>>6&63|128,ce[G++]=O&63|128):(ce[G++]=O>>12|224,ce[G++]=O>>6&63|128,ce[G++]=O&63|128);M=G-te-T}else M=l(S,te+T,D);M<32?ce[te++]=160|M:M<256?(T<2&&ce.copyWithin(te+2,te+1,te+1+M),ce[te++]=217,ce[te++]=M):M<65536?(T<3&&ce.copyWithin(te+3,te+2,te+2+M),ce[te++]=218,ce[te++]=M>>8,ce[te++]=M&255):(T<5&&ce.copyWithin(te+5,te+3,te+3+M),ce[te++]=219,Qt.setUint32(te,M),te+=4),te+=M}else if(_==="number")if(S>>>0===S)S<64?ce[te++]=S:S<256?(ce[te++]=204,ce[te++]=S):S<65536?(ce[te++]=205,ce[te++]=S>>8,ce[te++]=S&255):(ce[te++]=206,Qt.setUint32(te,S),te+=4);else if(S>>0===S)S>=-32?ce[te++]=256+S:S>=-128?(ce[te++]=208,ce[te++]=S+256):S>=-32768?(ce[te++]=209,Qt.setInt16(te,S),te+=2):(ce[te++]=210,Qt.setInt32(te,S),te+=4);else{let C;if((C=this.useFloat32)>0&&S<4294967296&&S>=-2147483648){ce[te++]=202,Qt.setFloat32(te,S);let T;if(C<4||(T=S*B0[(ce[te]&127)<<1|ce[te+1]>>7])>>0===T){te+=4;return}else te--}ce[te++]=203,Qt.setFloat64(te,S),te+=8}else if(_==="object")if(!S)ce[te++]=192;else{if(n){let T=n.get(S);if(T){if(!T.id){let D=n.idsToInsert||(n.idsToInsert=[]);T.id=D.push(T)}ce[te++]=214,ce[te++]=112,Qt.setUint32(te,T.id),te+=4;return}else n.set(S,{offset:te-i})}let C=S.constructor;if(C===Object)w(S,!0);else if(C===Array){M=S.length,M<16?ce[te++]=144|M:M<65536?(ce[te++]=220,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=221,Qt.setUint32(te,M),te+=4);for(let T=0;T<M;T++)b(S[T])}else if(C===Map){M=S.size,M<16?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,Qt.setUint32(te,M),te+=4);for(let[T,D]of S)b(T),b(D)}else{for(let T=0,D=Xu.length;T<D;T++){let P=z0[T];if(S instanceof P){let O=Xu[T];if(O.write){O.type&&(ce[te++]=212,ce[te++]=O.type,ce[te++]=0),b(O.write.call(this,S));return}let B=ce,G=Qt,F=te;ce=null;let z;try{z=O.pack.call(this,S,X=>(ce=B,B=null,te+=X,te>bs&&A(te),{target:ce,targetView:Qt,position:te-X}),b)}finally{B&&(ce=B,Qt=G,te=F,bs=ce.length-10)}z&&(z.length+te>bs&&A(z.length+te),te=o6(z,ce,te,O.type));return}}w(S,!S.hasOwnProperty)}}else if(_==="boolean")ce[te++]=S?195:194;else if(_==="bigint"){if(S<BigInt(1)<<BigInt(63)&&S>=-(BigInt(1)<<BigInt(63)))ce[te++]=211,Qt.setBigInt64(te,S);else if(S<BigInt(1)<<BigInt(64)&&S>0)ce[te++]=207,Qt.setBigUint64(te,S);else if(this.largeBigIntToFloat)ce[te++]=203,Qt.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?ce[te++]=192:(ce[te++]=212,ce[te++]=0,ce[te++]=0);else if(_==="function")b(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?ce[te++]=128|M:M<65536?(ce[te++]=222,ce[te++]=M>>8,ce[te++]=M&255):(ce[te++]=223,Qt.setUint32(te,M),te+=4);let C;for(let T=0;T<M;T++)b(C=_[T]),b(S[C])}:(S,_)=>{ce[te++]=222;let M=te-i;te+=2;let C=0;for(let T in S)(_||S.hasOwnProperty(T))&&(b(T),b(S[T]),C++);ce[M+++i]=C>>8,ce[M+i]=C&255}:S=>{let _=Object.keys(S),M,C=a.transitions||(a.transitions=Object.create(null)),T=0;for(let P=0,O=_.length;P<O;P++){let B=_[P];M=C[B],M||(M=C[B]=Object.create(null),T++),C=M}let D=C[Mh];if(D)D>=96&&f?(ce[te++]=((D-=96)&31)+96,ce[te++]=D>>5):ce[te++]=D;else{D=a.nextId,D||(D=64),D<m&&this.shouldShareStructure&&!this.shouldShareStructure(_)?(D=a.nextOwnId,D<g||(D=m),a.nextOwnId=D+1):(D>=g&&(D=m),a.nextId=D+1);let P=_.highByte=D>=96&&f?D-96>>5:-1;C[Mh]=D,a[D-64]=_,D<m?(_.isShared=!0,a.sharedLength=D-63,s=!0,P>=0?(ce[te++]=(D&31)+96,ce[te++]=P):ce[te++]=D):(P>=0?(ce[te++]=213,ce[te++]=114,ce[te++]=(D&31)+96,ce[te++]=P):(ce[te++]=212,ce[te++]=114,ce[te++]=D),T&&(y+=x*T),v.length>=p&&(v.shift()[Mh]=0),v.push(C),b(_))}for(let P=0,O=_.length;P<O;P++)b(S[_[P]])},A=S=>{let _;if(S>16777216){if(S-i>mb)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(mb,Math.round(Math.max((S-i)*(S>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(S-i<<2,ce.length-1)>>12)+1<<12;let M=new Qf(_);return Qt=new DataView(M.buffer,0,_),ce.copy?ce.copy(M,0,i,S):M.set(ce.slice(i,S)),te-=i,i=0,bs=M.length-10,ce=M}}useBuffer(e){ce=e,Qt=new DataView(ce.buffer,ce.byteOffset,ce.byteLength),te=0}};z0=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,c2];Xu=[{pack(e,t,i){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:a,position:n}=t(6);s[n++]=214,s[n++]=255,a.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:s,targetView:a,position:n}=t(10);s[n++]=215,s[n++]=255,a.setUint32(n,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),a.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),i(this.onInvalidDate());let{target:s,targetView:a,position:n}=t(3);s[n++]=212,s[n++]=255,s[n++]=255}else{let{target:s,targetView:a,position:n}=t(15);s[n++]=199,s[n++]=12,s[n++]=255,a.setUint32(n,e.getMilliseconds()*1e6),a.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(e,t,i){let r=Array.from(e),{target:s,position:a}=t(this.structuredClone?3:0);this.structuredClone&&(s[a++]=212,s[a++]=115,s[a++]=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?gb(e,16,t):vb(zp?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let i=e.constructor;i!==y2&&this.structuredClone?gb(e,g2.indexOf(i.name),t):vb(e,t)}},{pack(e,t){let{target:i,position:r}=t(1);i[r]=193}}];function gb(e,t,i,r){let s=e.byteLength;if(s+1<256){var{target:a,position:n}=i(4+s);a[n++]=199,a[n++]=s+1}else if(s+1<65536){var{target:a,position:n}=i(5+s);a[n++]=200,a[n++]=s+1>>8,a[n++]=s+1&255}else{var{target:a,position:n,targetView:o}=i(7+s);a[n++]=201,o.setUint32(n,s+1),n+=4}a[n++]=116,a[n++]=t,a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n)}function vb(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:a}=t(i+5);r[s++]=198,a.setUint32(s,i),s+=4}r.set(e,s)}function o6(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 l6(e,t){let i,r=t.length*6,s=e.length-r;for(t.sort((a,n)=>a.offset>n.offset?1:-1);i=t.pop();){let a=i.offset,n=i.id;e.copyWithin(a+r,a,s),r-=6;let o=a+r;e[o++]=214,e[o++]=105,e[o++]=n>>24,e[o++]=n>>16&255,e[o++]=n>>8&255,e[o++]=n&255,s=a}return e}function ih(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)");z0.unshift(e.Class),Xu.unshift(e)}r6(e)}var b2=new x2({useRecords:!1}),SY=b2.pack,AY=b2.pack,{NEVER:MY,ALWAYS:EY,DECIMAL_ROUND:CY,DECIMAL_FIT:TY}=s6,h6=512,c6=1024,yb=new x2({structuredClone:!0});ih({Class:nt.prototype.constructor,type:1,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,nt.prototype),e}});ih({Class:We.prototype.constructor,type:2,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,We.prototype),e}});ih({Class:mr.prototype.constructor,type:3,write(e){return[...e]},read(e){return Object.setPrototypeOf(e,mr.prototype),e}});ih({Class:nb.prototype.constructor,type:4,write(e){return e.id},read(e){return new nb(e)}});ih({Class:ob.prototype.constructor,type:5,write(e){return e.data},read(e){return new ob(e)}});ih({Class:mi.prototype.constructor,type:6,write(e){return{...e}},read(e){return Object.setPrototypeOf(e,mi.prototype),e}});function d6(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 Dg(e){if(T0(e))return e;if(Array.isArray(e))return e.map(Dg);if(typeof e=="object"&&e!==null){let t={};for(let i of Object.keys(e).sort())t[i]=Dg(e[i]);return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),t}else return e}var Ig;(e=>{function t(s){return yb.pack(s)}e.serialize=t;function i(s){return yb.unpack(s)}e.deserialize=i;function r(s){return d6(t(Dg(s))).toString()}e.checksum=r})(Ig||(Ig={}));var xb;(e=>{function t(r){return r.type==="Conditional"?r.condition.type==="Distance"?"Distance":"StateChange":r.type}e.toEventUIType=t;function i(r){return r==="Distance"||r==="StateChange"?"Conditional":r}e.fromEventUIType=i})(xb||(xb={}));var Ar={LookAt:[],Follow:["Create"],DragDrop:["Transition","Animation","Audio","Create","SetVariable","DynamicVariablePlay","Conditional"],MouseHover:["Transition","Animation","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Scroll:["Transition","Animation","Create","SetVariable","DynamicVariablePlay","Conditional"],Start:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","SetVariable","DynamicVariablePlay","Conditional"],Conditional:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MouseUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],MousePress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyDown:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyUp:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],KeyPress:["Transition","Animation","Audio","Video","Link","Create","SwitchCamera","Reset","SetVariable","DynamicVariablePlay","Conditional"],GameControl:["Transition","Animation","Audio","Create","Conditional"],Collision:["Transition","Animation","Audio","Video","Create","Destroy","Reset","SetVariable","DynamicVariablePlay","Conditional"],Trigger:["Transition","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],Resize:["Transition","Animation","Audio","Video","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"],VariableChange:["Transition","Animation","Audio","Video","Link","Create","Destroy","SwitchCamera","SceneTransition","Reset","SetVariable","DynamicVariablePlay","Conditional"]},bb;(e=>{function t(r){return r.type==="MouseDown"||r.type==="MouseUp"||r.type==="MousePress"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="KeyPress"}e.is=t;function i(r){return r==="MouseDown"||r==="MouseUp"||r==="MousePress"?{type:r,mode:"Object",disabled:!1,runMode:"Once",actions:new We}:{type:r,disabled:!1,key:void 0,runMode:"Once",actions:new We}}e.defaultData=i})(bb||(bb={}));var Yu;(e=>{function t(i){return{type:"Property",value:[i??null,"position","x"]}}e.propertyDefaultData=t,e.valueDefaultData={type:"Literal",value:0}})(Yu||(Yu={}));var Og;(e=>{function t(s){return{type:"Comparison",operator:"==",lOperand:Yu.propertyDefaultData(s),rOperand:{...Yu.valueDefaultData}}}e.comparisonDefaultData=t;function i(s){return{type:"Distance",toObject:s??null,fromObject:s??null,distance:200}}e.distanceDefaultData=i;function r(s,a){return{type:"State",object:s??null,state:a??null}}e.stateDefaultData=r})(Og||(Og={}));var wb;(e=>{function t(r){return r.type==="Conditional"}e.is=t;function i(r){return{type:"Conditional",disabled:!1,inActions:new We,outActions:new We,condition:Og.distanceDefaultData(r)}}e.defaultData=i})(wb||(wb={}));var _b;(e=>e.defaultData={type:"DragDrop",cursor:"hand",disabled:!1,dampingFactor:1,objects:[],snapTo:"center",snapSurfaceMode:"bbox",snapSurfaceOffset:0,dropOn:"all",autoOrient:!0,dropDestinations:[],plane:"adaptive",planeMode:"locked",referenceFrame:"global",limits:[-1/0,1/0,-1/0,1/0,-1/0,1/0],drop:!1,resetOnSnapFail:!1,snapSpeed:20,resetSpeed:20,dragDropActions:{drag:new We,drop:new We}})(_b||(_b={}));var Lg;(e=>e.defaultData={type:"Follow",disabled:!1,maxDelta:0,dampingFactor:1,target:"cursor",plane:"custom",resetOnPointerLeave:!0,resetAfterDistanceLimit:!0,enabledTranslation:[!0,!0,!0],limitDistanceEnabled:!1,limitDistance:1e3,snapDelay:0,resetSpeed:5,actions:new We})(Lg||(Lg={}));var Rg;(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})(Rg||(Rg={}));var Sb;(e=>{function t(r){return r.type==="MouseHover"}e.is=t;function i(){return{type:"MouseHover",disabled:!1,actions:new We}}e.defaultData=i})(Sb||(Sb={}));var Ab;(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 We}}e.defaultData=i})(Ab||(Ab={}));var Mb;(e=>{function t(r){return r.type==="Start"}e.is=t;function i(){return{type:"Start",disabled:!1,actions:new We}}e.defaultData=i})(Mb||(Mb={}));var Eb;(e=>{function t(r){return r.type==="Collision"}e.is=t;function i(){return{type:"Collision",disabled:!1,runMode:"Once",target:"character",actions:new We}}e.defaultData=i})(Eb||(Eb={}));var Cb;(e=>{function t(r){return r.type==="Trigger"}e.is=t;function i(r,s){return{type:"Trigger",disabled:!1,runMode:"Once",target:"all",triggeringObjects:[],actions:new We,triggerZone:"box",position:s.toArray(),rotation:[0,0,0],size:r.toArray(),radius:r.length()/2,helperVisible:!0}}e.defaultData=i})(Cb||(Cb={}));var Bg;(e=>{e.defaultSizes={mobile:[480,480],tablet:[768,768],desktop:[1200,1200],custom:[769,1200]};function t(n){return n.type==="Resize"}e.is=t;function i(n){return typeof n=="string"?n:"custom"}e.sizeToDevice=i;function r(n){return typeof n=="string"?[...e.defaultSizes[n]]:[...n]}e.deviceToSize=r;function s(){let n={size:"mobile",operator:"<",actions:new We},o={size:"tablet",operator:"<",actions:new We},l={size:[...e.defaultSizes.custom],operator:"<>",actions:new We},h=new We;return h.push({id:Re.generateUUID(),fi:0,data:n},{id:Re.generateUUID(),fi:1,data:o},{id:Re.generateUUID(),fi:2,data:l}),{type:"Resize",disabled:!1,orientation:"horizontal",breakpoints:h}}e.defaultData=s;function a(){return{size:[...e.defaultSizes.custom],operator:"<>",actions:new We}}e.defaultBreakpointData=a})(Bg||(Bg={}));var zg;(e=>{e.propertyPaths={Position:["position"],"Position X":["position","x"],"Position Y":["position","y"],"Position Z":["position","z"],Rotation:["rotation"],"Rotation X":["rotation","x"],"Rotation Y":["rotation","y"],"Rotation Z":["rotation","z"],Scale:["scale"],"Scale X":["scale","x"],"Scale Y":["scale","y"],"Scale Z":["scale","z"],Width:["width"],Height:["height"],Depth:["depth"],"Mouse Position X":["mouse","x"],"Mouse Position Y":["mouse","y"],"Mouse Pressed":["mouse","pressed"],"Screen Width":["mouse","width"],"Screen Height":["mouse","height"],"Hit Position X":["raycast","x"],"Hit Position Y":["raycast","y"],"Hit Position Z":["raycast","z"],"Hit Object Position X":["raycast","objX"],"Hit Object Position Y":["raycast","objY"],"Hit Object Position Z":["raycast","objZ"]};function t(r){return r.type==="VariableChange"}e.is=t;function i(){return{disabled:!1,type:"VariableChange",actions:new We,variableId:"",objectId:null,property:"Position X"}}e.defaultData=i})(zg||(zg={}));var rh="personal camera",sc="a218fcc3-276b-49b9-b485-49037fd14f5f",u6=2960946,Yr=5526619,ol;(e=>{function t(r,s){return r[0]===s[0]&&r[1]===s[1]}e.isEqual=t;function i(r,s,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a]}e.lerp=i})(ol||(ol={}));var Kn;(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 a(l,h){return[l[0]*h[0],l[1]*h[1],l[2]*h[2]]}e.mul=a;function n(l,h){return Math.hypot(l[0]-h[0],l[1]-h[1],l[2]-h[2])}e.dist=n;function o(l,h,d){return[l[0]+(h[0]-l[0])*d,l[1]+(h[1]-l[1])*d,l[2]+(h[2]-l[2])*d]}e.lerp=o})(Kn||(Kn={}));var Qu;(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,a){return[r[0]+(s[0]-r[0])*a,r[1]+(s[1]-r[1])*a,r[2]+(s[2]-r[2])*a,r[3]+(s[3]-r[3])*a]}e.lerp=i})(Qu||(Qu={}));var Rl;(e=>{e.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let n=0;n<16;n++)if(s[n]!==a[n])return!1;return!0}e.isEqual=t;function i(s){return s??e.identity}e.simplify=i;function r(s,a){let n=a.slice(0);for(var o=0,l=a.length;o<l;o+=3){let h=s[3]*a[o]+s[7]*a[o+1]+s[11]*a[o+2]+s[15];n[o]=(s[0]*a[o]+s[4]*a[o+1]+s[8]*a[o+2]+s[12])/h,n[o+1]=(s[1]*a[o]+s[5]*a[o+1]+s[9]*a[o+2]+s[13])/h,n[o+2]=(s[2]*a[o]+s[6]*a[o+1]+s[10]*a[o+2]+s[14])/h}return n}e.applyMatrix4=r})(Rl||(Rl={}));var Yi;(e=>{function t(l){return typeof l=="object"&&typeof l.r=="number"&&typeof l.g=="number"&&typeof l.b=="number"}e.isRGB=t,e.white={r:1,g:1,b:1},e.red={r:1,g:0,b:0},e.black={r:0,g:0,b:0};function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:1}}e.toRgb255a1=i;function r(l){return{r:l.r,g:l.g,b:l.b}}e.clone=r;function s(l){return l=Math.floor(l),{r:(l>>16&255)/255,g:(l>>8&255)/255,b:(l&255)/255}}e.fromHex=s;function a(l){return Math.round(l.r*255)*65536+Math.round(l.g*255)*256+Math.round(l.b*255)}e.toHex=a;function n(l,h){return l.r===h.r&&l.g===h.g&&l.b===h.b}e.equals=n;function o(l,h,d){return{r:l.r+(h.r-l.r)*d,g:l.g+(h.g-l.g)*d,b:l.b+(h.b-l.b)*d}}e.lerp=o})(Yi||(Yi={}));var hs;(e=>{e.white={...Yi.white,a:1},e.transparent={...Yi.white,a:0};function t(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}e.from0to1=t;function i(n,o){return{...Yi.fromHex(n),a:o}}e.fromHexAndA=i;function r(n){return{r:Math.round(n.r*255),g:Math.round(n.g*255),b:Math.round(n.b*255),a:n.a}}e.toRgb255a1=r;function s(n,o){return Yi.equals(n,o)&&n.a===o.a}e.equals=s;function a(n,o,l){return{r:n.r+(o.r-n.r)*l,g:n.g+(o.g-n.g)*l,b:n.b+(o.b-n.b)*l,a:n.a+(o.a-n.a)*l}}e.lerp=a})(hs||(hs={}));var Ng;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Ng||(Ng={}));var Tb;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(Tb||(Tb={}));var Pb;(e=>e.defaultData={control1:[.5,0],control2:[.5,1]})(Pb||(Pb={}));var qa;(e=>(e.linear=[0,0,1,1],e.ease=[.25,.1,.25,1],e.easeIn=[.42,0,1,1],e.easeOut=[0,0,.58,1],e.easeInOut=[.42,0,.58,1]))(qa||(qa={}));function p6(e){return typeof e=="string"&&e.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!1}var ao;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(i){return e.all.includes(i)}e.is=t})(ao||(ao={}));var Bl;(e=>{e.DefaultUp=[0,1,0],e.DefaultTargetOffset=1e3,e.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:e.DefaultUp,isUpVectorFlipped:!1,targetOffset:e.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}e.getZoom=t})(Bl||(Bl={}));var en;(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(a=>a*(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 a={...r};if(w2.forEach(n=>{Object.assign(a,{[n]:s[n]??r[n]})}),a.radial={...r.radial},s.radial){let n=r.radial,o=s.radial;_2.forEach(l=>{Object.assign(a.radial,{[l]:o[l]??n[l]})})}if(a.linear={...r.linear},s.linear){let n=r.linear,o=s.linear;S2.forEach(l=>{Object.assign(a.linear,{[l]:o[l]??n[l]})})}if(a.grid={...r.grid},s.grid){let n=r.grid,o=s.grid;A2.forEach(l=>{Object.assign(a.grid,{[l]:o[l]??n[l]})})}if(a.toObject={...r.toObject},s.toObject){let n=r.toObject,o=s.toObject;M2.forEach(l=>{Object.assign(a.toObject,{[l]:o[l]??n[l]})})}if(a.randomnessObject={...r.randomnessObject},s.randomnessObject){let n=r.randomnessObject,o=s.randomnessObject;E2.forEach(l=>{Object.assign(a.randomnessObject,{[l]:o[l]??n[l]})})}return a}e.merge=i})(en||(en={}));var kg;(e=>{e.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function i(r,s){let a=[];r.count!==void 0&&a.push({type:0,path:s,props:{count:r.count}});for(let n of t){let o=r[n];o&&Object.keys(o).length>0&&a.push({type:0,path:[...s,n],props:o})}return a}e.toOps=i})(kg||(kg={}));var w2=["count"],_2=["radius","start","end","position","scale","rotation"],S2=["position","scale","rotation"],A2=["count","size"],M2=["count","position","scale","rotation"],E2=["strength","scale","rotation","position","movement","seed","freqScale"],Ug;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(i){return e.all.includes(i)}e.is=t})(Ug||(Ug={}));var Fg;(e=>{function t(r){return i(r)}e.defaultData=t;function i(r){if(r==="PointLight")return{type:r,color:hs.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:hs.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:hs.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Fg||(Fg={}));var zl;(e=>e.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(zl||(zl={}));var Vg;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(i,r){return i.castShadow===r.castShadow&&i.receiveShadow===r.receiveShadow}e.equals=t})(Vg||(Vg={}));var jg;(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})(jg||(jg={}));var Gg;(e=>e.defaultData={...jg.defaultData,...Vg.defaultData})(Gg||(Gg={}));var Db;(e=>{function t(i,r){let s=[];if("material"in i){let a=typeof i.material=="string"?r.materials[i.material]??r.lib.materials[i.material]?.asset:i.material;a&&s.push(a)}else if("materials"in i)for(let a of i.materials){let n=typeof a=="string"?r.materials[a]??r.lib.materials[a]?.asset:a;n&&s.push(n)}return s}e.getMaterialData=t})(Db||(Db={}));var Zu;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Zu||(Zu={}));var Ib;(e=>{function t(i){return i==="texture"||i==="video"||i==="color"||i==="depth"||i==="normal"||i==="gradient"||i==="noise"||i==="fresnel"||i==="rainbow"||i==="toon"||i==="outline"||i==="transmission"||i==="matcap"||i==="displace"||i==="pattern"||i==="light"}e.is=t})(Ib||(Ib={}));function f6(e){return e.type!=="displace"}var Ob;(e=>{function t(i){return i==="phong"||i==="toon"||i==="lambert"||i==="physical"}e.is=t})(Ob||(Ob={}));var C2=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],m6=["wrapping","image","video","name"],lr;(e=>{function t(a,n){let{texture:o,...l}=n;if(Object.assign(a,l),o){let h=a.texture;h&&Object.assign(h,o)}}e.patch=t;function i(a,n){return a==="light"&&n?r(n):s(a)}e.defaultData=i;function r(a){let n={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...n,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...n,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...n,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...n,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function s(a){let n={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...n,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0]},crop:!1};case"video":return{...n,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Zu.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...n,type:"color",color:Yi.fromHex(Yr)};case"depth":return{...n,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...n,type:"normal",cnormal:[1,1,1]};case"gradient":return{...n,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...n,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Yi.fromHex(6710886),a:1},colorB:{...Yi.fromHex(6710886),a:1},colorC:{...Yi.fromHex(16777215),a:1},colorD:{...Yi.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...n,type:"fresnel",color:hs.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...n,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...n,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:hs.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...n,type:"outline",outlineColor:hs.fromHexAndA(0,1),contourColor:hs.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{...n,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...n,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...n,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Yi.fromHex(0),a:1},colorB:{...Yi.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(lr||(lr={}));var Fi;(e=>{function t(h){return!h.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}e.isMergable=t;function i(h){let d="";return h.layers.forEach(c=>{Object.entries(c.data).forEach(([u,p])=>{d+=`${u}${p}`,Array.isArray(p)?p.forEach(f=>d+=`${f}`):typeof p=="object"?Object.values(p).forEach(f=>{typeof f=="number"?d+=`${f.toFixed(4)}`:d+=`${f}`}):d+=`${p}`})}),d}e.getHash=i;function r(){return{layers:new We}}e.defaultEmptyData=r;function s(h="layer1",d="layer2"){return n("phong",h,d)}e.defaultData=s;function a(h,d){return{...h,name:d}}e.withName=a;function n(h,d="layer1",c="layer2"){let u=new We;return u.push({fi:0,data:lr.defaultData("light",h),id:d}),u.push({fi:1,data:lr.defaultData("color"),id:c}),{layers:u}}e.defaultTwoLayerData=n;function o(h,d="phong",c="layer1",u="layer2"){let p=lr.defaultData("texture");Object.assign(p.texture,{image:h});let f=new We;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:lr.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerTextureData=o;function l(h,d="phong",c="layer1",u="layer2"){let p=lr.defaultData("video");Object.assign(p.texture,{video:h});let f=new We;return f.push({fi:0,data:p,id:c}),f.push({fi:1,data:lr.defaultData("light",d),id:u}),{layers:f}}e.defaultTwoLayerVideoTextureData=l})(Fi||(Fi={}));var Ku;(e=>{function t(){return{points:new We,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=t})(Ku||(Ku={}));var Ju;(e=>{function t(){return{points:new We,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}e.defaultData=t})(Ju||(Ju={}));var T2={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0},Hg;(e=>{function t(i,r){let s={...i};return D2.forEach(a=>{Object.assign(s,{[a]:r[a]??i[a]})}),s}e.merge=t})(Hg||(Hg={}));var P2={shape:T2,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},D2=["depth","offset","angle","twist","startScale","endScale"],$u;(e=>{function t(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"}e.is2DParametricMesh=t;function i(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=i})($u||($u={}));var Wg;(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,Hg.merge(s.extrusion,r.extrusion))),s}e.merge=t})(Wg||(Wg={}));var fl;(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:Ju.defaultData(),extrusion:P2};if(i==="VectorGeometry")return{width:1,height:1,type:i,subdivisions:12,shape:Ku.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:{textValue:""},textTransform:1,font:"Roboto_regular",extrudeBevelSize:0,extrudeBevelSegments:1};if(i==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}e.defaultData=t})(fl||(fl={}));var Lb=["width","height","depth"],qg;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Yi.white,near:.1,far:2e3})(qg||(qg={}));var ep;(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}}})(ep||(ep={}));var Xg;(e=>e.defaultData={softShadowQuality:"low"})(Xg||(Xg={}));var Yg;(e=>e.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Yg||(Yg={}));var Qg;(e=>e.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qg||(Qg={}));var Nl;(e=>e.defaultData={usePhysics:!1,gravity:-10})(Nl||(Nl={}));var Zg;(e=>e.defaultData={playCamera:rh,gameControlObject:null})(Zg||(Zg={}));var Kg;(e=>e.defaultData={backgroundColor:hs.fromHexAndA(u6,1),postprocessing:ep.defaultData,fog:qg.defaultData,globalPhysics:Nl.defaultData,ambient:Yg.defaultData,ao:Qg.defaultData,shadow:Xg.defaultData,publish:Zg.defaultData})(Kg||(Kg={}));var Rb;(e=>{function t(r){return r==="Component"||r==="Instance"}e.isComponentRelated=t;function i(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=i})(Rb||(Rb={}));var kl;(e=>{e.identity={...Ng.identity,hiddenMatrix:Rl.identity};function t(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}e.fromObject=t;function i(s,a){return{position:a?.position||s.position,rotation:a?.rotation||s.rotation,scale:a?.scale||s.scale,hiddenMatrix:a?.hiddenMatrix||s.hiddenMatrix}}e.merge=i;function r(s,a){return _F({position:Kn.isEqual(s.position,a.position)?void 0:a.position,rotation:Kn.isEqual(s.rotation,a.rotation)?void 0:a.rotation,scale:Kn.isEqual(s.scale,a.scale)?null:a.scale,hiddenMatrix:Rl.isEqual(s.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}e.diff=r})(kl||(kl={}));var tr;(e=>e.defaultData={states:new We,events:new We,visible:!0,raycastLock:!1,physics:zl.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...kl.identity,cloner:null})(tr||(tr={}));var Jg;(e=>e.defaultData={type:"Empty",...tr.defaultData})(Jg||(Jg={}));var Bb;(e=>e.defaultData={type:"Component",...tr.defaultData})(Bb||(Bb={}));var ml;(e=>e.defaultData={type:"Mesh",...tr.defaultData,...Gg.defaultData})(ml||(ml={}));var _c;(e=>e.defaultData={...tr.defaultData,...kl.identity,position:[0,0,Bl.DefaultTargetOffset],...Bl.defaultData})(_c||(_c={}));var $g;(e=>{function t(i){return{...tr.defaultData,...Fg.defaultData(i)}}e.defaultData=t,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})($g||($g={}));var tp;(e=>{function t(r,s,a=0){for(;a<s.length;){let n=r?r[s[a]]:void 0;if(s.length===a+1)return n;if(n)r=n.descendants,a+=1;else return}}e.resolveWithDes=t;function i(r,s,a=0){let n=t(r,s,a);if(n){let o=Object.keys(n);if(o.length===1&&o[0]==="descendants")return}return n}e.resolve=i})(tp||(tp={}));var tn;(e=>{e.rootOverrideProps=["physics","events"],e.compositeNonOptionalOverrideProps=["geometry"],e.compositeEntireOverrideOverrideProps=["material"];function t(r,s){return{...tr.defaultData,...s,component:r,overrides:new mi,physics:void 0,events:void 0,type:"Instance"}}e.ofComponent=t;function i(r){let s=kl.fromObject(r.data);return t(r.id,s)}e.fromComponentData=i})(tn||(tn={}));var Ul;(e=>e.defaultData={type:"Page",...tr.defaultData,physics:{...zl.defaultData,fusedBody:!1},...Kg.defaultData,camera:_c.defaultData})(Ul||(Ul={}));var ev;(e=>(e.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Rl.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:zl.defaultData,states:new We,events:new We,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Bl.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",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("RectangleGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultBooleanObject={name:"Boolean",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("BooleanGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")},e.defaultTextObject={name:"Text",...tr.defaultData,...ml.defaultData,geometry:fl.defaultData("TextGeometry"),material:Fi.defaultTwoLayerData("phong","layer1","layer2")}))(ev||(ev={}));var Gn;(e=>{function t(a,n){let o={name:n};return a.type==="Mesh"?(o.geometry={},"material"in a&&(o.material={layers:new mi}),"materials"in a&&(o.materials=a.materials.map(l=>({layers:new mi})))):ao.is(a.type)&&(o.perspective={},o.orthographic={}),o}e.newEmpty=t;function i(a,n){if(n===void 0)return a;let o={...a};return"material"in o&&"material"in n&&n.material&&(o.material=wc(o.material,l=>{if(typeof l!="string")for(let[h,d]of Object.entries(n.material.layers)){let c=l.layers.data(h);c&&lr.patch(c,d)}}).data),o.materials&&n.materials&&(o.materials=wc(o.materials,l=>{for(let h=0;h<o.materials.length;h++){let d=n.materials[h];if(typeof d!="string")for(let[c,u]of Object.entries(d.layers)){let p=l[h]?.layers?.data(c);p&&lr.patch(p,u)}}}).data),o}function r(a,n){let o,l=[],h={orthographic:0,perspective:0,geometry:0};function d(c,u){for(let[p,f]of Object.entries(u.layers)){let{texture:m,...g}=f;if(m!==void 0&&Object.keys(m).length>0){let v={path:[...c,"layers",p,"texture"],props:m,type:0};l.push(v)}if(Object.keys(g).length>0){let v={path:[...c,"layers",p],props:g,type:0};l.push(v)}}}for(let[c,u]of Object.entries(n))if(c!=="name")if(c==="cloner")l.push(...kg.toOps(u,["cloner"]));else if(c==="pathSnapping")l.push({path:[c],props:{slide:u.slide,offset:u.offset},type:0});else if(c==="material")d(["material"],u);else if(c==="materials")for(let[p,f]of Object.entries(u))d(["materials",p],f);else if(h[c]===0){if(c==="geometry"&&u.extrusion!==void 0){let p={path:[c,"extrusion"],props:u.extrusion,type:0};l.push(p),u={...u},delete u.extrusion}if(Object.keys(u).length>0){let p={path:[c],props:u,type:0};l.push(p)}}else o===void 0&&(o={path:[],props:{},type:0},l.push(o)),o.props[c]=u;return l}e.toOps=r;function s(a,n){if(n===void 0)return a;let o={...a};if(Object.assign(o,kl.merge(o,n)),Object.assign(o,{pathSnapping:Object.assign({},o.pathSnapping,{slide:n.pathSnapping?.slide??o.pathSnapping?.slide??0,offset:n.pathSnapping?.offset??o.pathSnapping?.offset??0})}),ao.is(a.type)){o.orthographic={...o.orthographic},o.perspective={...o.perspective};let l=n;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(a.type==="Mesh")"geometry"in n&&Object.assign(o,{geometry:Wg.merge(o.geometry,n.geometry)}),(n.material||n.materials)&&(o=i(o,n)),o.cloner&&"cloner"in n&&Object.assign(o,{cloner:en.merge(o.cloner,n.cloner)});else if(a.type==="Empty")o.cloner&&"cloner"in n&&Object.assign(o,{cloner:en.merge(o.cloner,n.cloner)});else if(Ug.is(a.type)){let l=n;l.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Yi.clone(l.color))}return o}e.patch=s})(Gn||(Gn={}));var ip;(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,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(ip||(ip={}));var Jn;(e=>e.defaultData={orbitControls:ip.defaultData,playPage:sc,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((t,i)=>{let r=0,s=0;return i<5?s=-30:i<10&&(s=30),i===0||i===10||i===5?r=30:(i===4||i===11||i===9)&&(r=-30),[120,[r,s],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Jn||(Jn={}));var tv;(e=>e.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(tv||(tv={}));var iv;(e=>e.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(iv||(iv={}));var gl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...tv.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:iv.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(gl||(gl={}));var Sc;(e=>{function t(r){return r.find(s=>s.data.type==="Page"&&s.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=t;function i(r,s,a){r.scene.objects.traverseFrom(s,(n,o)=>{if(o.type==="Instance"){let l=np.getComponentData(r,o.component)?.data;l&&a(n,o,l.events)}else a(n,o,o.events)})}e.traverseModuleInstances=i})(Sc||(Sc={}));var vl;(e=>{e.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(s={withLight:!0,withSquare:!0}){let a=[],n=ev.defaultMeshObject;s.withLight===!0&&a.push({fi:-1,data:$g.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),s.withSquare===!0&&a.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:n,children:[]});let o=new mr;return o.push({fi:1,id:sc,data:{...Ul.defaultData,name:"Scene 1"},children:a}),o}e.defaultData={objects:t(),publish:Jn.defaultData,styles:gl.defaultData()},e.emptyDataWithoutPage=function(){return{objects:new mr,publish:Jn.defaultData,styles:gl.defaultData()}},e.emptyDataWithPage=function(s){return{objects:t(s),publish:Jn.defaultData,styles:gl.defaultData()}};function i(s){return{...e.defaultData,objects:Ca(s,mr.prototype)}}e.withObjs=i;function r(s,a){return i([{id:s,data:a,children:[],fi:0}])}e.withObj=r})(vl||(vl={}));var ac;(e=>e.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ac||(ac={}));var rp;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(rp||(rp={}));var Dr;(e=>{function t(n){return n.textValue!==void 0}e.isTextValue=t;function i(n){return typeof n=="number"}e.isNumber=i;function r(n){return typeof n=="boolean"}e.isBoolean=r;function s(n){return t(n)?"string":r(n)?"boolean":"number"}e.typeOfVariable=s;function a(n){return e.isTextValue(n)?Array.isArray(n.textValue)?n.textValue.map(o=>o.toString().padStart(n.padding??2,"0")).join(n.deliminator??":")+(n.suffix!==void 0?" "+n.suffix:""):n.textValue.toString():e.isBoolean(n)?n?"True":"False":e.isNumber(n)?parseFloat(n.toFixed(3)).toString():n.toString()}e.getDisplayedValue=a})(Dr||(Dr={}));var rv;(e=>e.all=["images","videos","colors","audios","fonts","materials","variables"])(rv||(rv={}));var zb;(e=>e.all=[...rv.all,"components"])(zb||(zb={}));var Nb;(e=>{function t(){return{images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,materials:new nt,components:new nt,variables:new nt}}e.defaultData=t})(Nb||(Nb={}));var Fl;(e=>{function t(){return{images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,materials:new nt,components:new nt,variables:new nt}}e.defaultData=t})(Fl||(Fl={}));var ns;(e=>{function t(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ca(n,nt.prototype)}e.defaultColors=t;function i(n){let o={};return n?.withAITexture&&(o["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...rp.emptyImage,name:"AI generated image"}),Ca(o,nt.prototype)}e.defaultImages=i;function r(){return{catelogs:new nt,materials:new nt,images:new nt,videos:new nt,colors:new nt,audios:new nt,fonts:new nt,variables:new We,lib:Fl.defaultData()}}e.emptyData=r;function s(n){switch(n){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let o=[0,0,0];return{name:"Time",value:{textValue:o,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:o,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",n)}}e.defaultVariables=s;function a(n,o){if(o.format==="HH:mm:ss"){let l=Math.floor(n/3600),h=Math.floor((n-l*3600)/60),d=Math.round(n-l*3600-h*60);return{textValue:[l,h,d]}}else if(o.format==="mm:ss"){let l=Math.floor(n/60),h=Math.round(n-l*60);return{textValue:[l,h]}}else return o.format==="number"?n=Math.round(n):n=Math.round(n*1e3)/1e3,n}e.getFormattedTimerTime=a})(ns||(ns={}));var sp;(e=>e.list=["idle","move","jump","run"])(sp||(sp={}));var ap;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new We,move:new We,jump:new We,run:new We},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:hs.fromHexAndA(3728051,1)}}))(ap||(ap={}));function kb(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]],a=[0,1];for(let o=2;o<10;o++)s.push(s[1]),a.push(1);let n={...Sa(oi(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:s,steps:a,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,n)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let i={...oi(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,i)}})}function Xa(e,t){Object.values(e.shared.materials).forEach(i=>t(i))}function Ya(e,t){e.scene.objects.traverse((i,r)=>{"materials"in r?r.materials.forEach((s,a)=>{s===void 0&&(r.materials[a]=Fi.defaultData(),s=r.materials[a]),typeof s!="string"&&t(s)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Fi.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Fi.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(s=>{s.material&&typeof s.material!="string"&&t(s.material)})})}function g6(e){Object.assign(e.scene.publish,{orbitControls:{...ip.defaultData,...oi(e.scene.publish.orbitControls)}})}function v6(e){Object.assign(e.scene.publish.settings,{video:{...Jn.defaultData.settings.video,...oi(e.scene.publish.settings.video)}})}function y6(e){function t(i){if(i.layers){for(let r of Object.values(i.layers))if(r){for(let[s,a]of Object.entries(r))if((C2.includes(s)||typeof a=="boolean")&&delete r[s],s==="texture")for(let[n,o]of Object.entries(a))(m6.includes(n)||typeof o=="boolean")&&delete a[n]}}}e.scene.objects.traverse((i,r)=>{r.states.forEach(s=>{let a=s;a.material?t(a.material):a.materials&&a.materials.forEach(n=>{t(n)})})})}function x6(e){e.scene.publish.withBackground=!0}function b6(e){e.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function w6(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 _6(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 S6(e){e.scene.objects.traverse((t,i)=>{let r=e.scene.objects.unproxy().parent(t);if(r){let s=oi(e.scene.objects.data(r));s&&s.type==="Mesh"&&s.geometry.type==="BooleanGeometry"&&i.type==="Mesh"&&(i.visible=oi(i).booleanExclude!==!0)}})}function A6(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 M6(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(a=>{let n=a;if(n.material){let o=oi(n.material).layers;i(o),n.material.layers=o}if(n.materials)for(let o=0;o<n.materials.length;o++){let l=n.materials[o],h=oi(l).layers;i(h),l.layers=h}})})}function Ub(e){e.layers===void 0&&Object.assign(e,Fi.defaultTwoLayerData("lambert"))}function Zf(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={...oi(t),colors:i,steps:r};Object.assign(t,s)}})}function E6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&(i.geometry.type==="BooleanGeometry"||i.geometry.type==="SubdivGeometry")&&(i.geometry.phongAngle=35)})}function Fb(e){e.scene.objects.traverse((t,i)=>{"materials"in i?i.materials.forEach(r=>{typeof r!="string"&&Zf(r)}):"material"in i&&typeof i.material!="string"&&Zf(i.material)}),Object.values(e.shared.materials).forEach(t=>Zf(t))}function C6(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 T6(e){e.shared.audios=Ca({},nt.prototype)}function P6(e){e.shared.videos=Ca({},nt.prototype)}function D6(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 I6(e){Object.entries(oi(e.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.images[t]}),Object.entries(oi(e.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete e.shared.audios[t]})}function O6(e){e.scene.publish.settings.web.preload=!1}function Vb(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 jb(e){e.layers&&e.layers.forEach(t=>{f6(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function L6(e){e.shared.fonts=Ca({},nt.prototype)}function R6(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 B6(e){let t=[];e.scene.objects.traverse((i,r)=>{let s=r;if(s.type==="TextFrame"){let a=Fi.defaultTwoLayerData("phong"),n=typeof s.color=="string"?e.shared.colors[s.color]:s.color;a.layers[1].data.color={r:n.r,g:n.g,b:n.b},a.layers[1].data.alpha=s.alpha;let o=R6(s.font);e.shared.fonts[o]===void 0&&(e.shared.fonts[o]={name:o});let l={name:s.name,...tr.defaultData,...ml.defaultData,flatShading:!1,wireframe:!1,geometry:{...fl.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:a,states:oi(s.states),events:oi(s.events),visible:s.visible,raycastLock:s.raycastLock,position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix},h=oi(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 z6(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 We,move:new We,jump:new We}});else{let a=new We;Object.assign(s,{actions:a}),(s.type==="MouseDown"||s.type==="MouseUp"||s.type==="KeyDown"||s.type==="KeyUp")&&"url"in s&&a.push({fi:0,id:Re.generateUUID(),data:{type:"Link",url:s.url,delay:0}}),"targets"in s&&(s.targets.forEach((n,o,l)=>{let h={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},d={easing:n.easing,duration:n.duration};n.easing===6?Object.assign(d,Sa(n,"mass","stiffness","damping","velocity")):n.easing===5&&Object.assign(d,{control1:{...n.control1},control2:{...n.control2}});let c={repeat:n.repeat?-1:0,delay:n.delay,delayDirection:n.delayDirection,direction:n.cycle&&n.rewind?"pingpong-rewind":n.cycle?"pingpong":"normal"},u={state:n.state,...c,...d},p={allowSlerp:!0,type:"Transition",object:n.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new We({fi:0,id:Re.generateUUID(),data:h},{fi:1,id:Re.generateUUID(),data:u})};a.push({fi:l,id:o,data:p})}),delete s.targets)}})})}function N6(e){e.scene.objects.traverse((t,i)=>{function r(s,a){let n=new We,o=[];if(i.events.forEach((l,h,d)=>{if(l.type==="Audio"&&l.trigger===a){let c;o.push(h),l.interaction==="play"?c={...Sa(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={...Sa(l,"interaction","delay","object","playAudio"),type:"Audio"}),c&&n.push({fi:d,id:h,data:c})}}),o.forEach(l=>i.events.delete(l)),n.length){let l=i.events.find(h=>h.type===s)?.data;l?"actions"in l&&l.actions.insertBefore(null,n):i.events.insertBefore(null,[{id:Re.generateUUID(),data:{type:s,actions:n}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function Gb(e){let t=e.layers.find(i=>i.type==="light")?.data;if(t?.category==="basic"){let i=lr.defaultData("light","phong"),r=t;Object.assign(r,i),r.visible=!1}}function Hb(e){Xa(e,Gb),Ya(e,Gb)}function k6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="SubdivGeometry"&&(i.geometry.scaleBaked||(i.geometry.scaleBaked=[1,1,1]))})}function U6(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 F6(e){e.scene.objects.traverse((t,i)=>{i.type==="Mesh"&&i.geometry.type==="NonParametricGeometry"&&!("material"in i)&&!("materials"in i)&&(i.material=Fi.defaultTwoLayerData("phong"))})}function V6(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 j6(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 G6(e){e.scene.publish.mouseEventTarget===void 0&&(e.scene.publish.mouseEventTarget="canvas"),e.scene.publish.settings.web.hint===void 0&&(e.scene.publish.settings.web.hint=!1)}function H6(e){let{video:t}=e.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function W6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-i.position[1]))})})}function q6(e){let t=e.scene.environment.usePhysics;e.scene.objects.traverse((i,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function X6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=ap.defaultDataThirdPerson.navmesh)})})}function Y6(e){e.scene.styles||(e.scene.styles=gl.defaultData())}function Wb(e){e.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function Q6(e){e.scene.environment.ambientLight.occlusion===void 0&&(e.scene.environment.ambientLight.occlusion=!1),e.scene.environment.ambientLight.aoFullRes===void 0&&(e.scene.environment.ambientLight.aoFullRes=!1),e.scene.environment.ambientLight.radius===void 0&&(e.scene.environment.ambientLight.radius=256),e.scene.environment.ambientLight.bias===void 0&&(e.scene.environment.ambientLight.bias=.5),e.scene.environment.ambientLight.aoColor===void 0&&(e.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Ya(e,Wb),Xa(e,Wb)}function Z6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new We})})})}function K6(e){e.scene.objects.traverse((t,i)=>{i.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function qb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function J6(e,t){if(t<1&&(Ya(e,kb),Xa(e,kb),e.schema=1),t<2&&(g6(e),e.schema=2),t<3&&(y6(e),e.schema=3),t<4&&(x6(e),e.schema=4),t<5&&(b6(e),e.schema=5),t<6&&(w6(e),e.schema=6),t<7&&(_6(e),e.schema=7),t<8&&(e.schema=8),t<9&&(Fb(e),e.schema=9),t<10&&(E6(e),e.schema=10),t<11&&(C6(e),e.schema=11),t<12&&(Fb(e),e.schema=12),t<13&&(T6(e),e.schema=13),t<14&&(D6(e),e.schema=14),t<15&&(I6(e),e.schema=15),t<16&&(O6(e),e.schema=16),t<17&&(Ya(e,Vb),Xa(e,Vb),e.schema=17),t<18&&(Ya(e,Ub),Xa(e,Ub),e.schema=18),t<19&&(v6(e),e.schema=19),t<20&&(L6(e),B6(e),e.schema=20),t<21&&(z6(e),N6(e),e.schema=21),t<22&&(Hb(e),e.schema=22),t<23&&(k6(e),e.schema=23),t<24&&(U6(e),e.schema=24),(t<25||e.shared.videos===void 0)&&(P6(e),t<25&&(e.schema=25)),t<26&&(S6(e),e.schema=26),t<27&&(A6(e),e.schema=27),t<28&&(Hb(e),e.schema=28),t<29&&(M6(e),e.schema=29),t<30&&(F6(e),e.schema=30),t<31&&(V6(e),e.schema=31),t<33&&(j6(e),e.schema=33),t<34&&(G6(e),e.schema=34),t<35&&(H6(e),e.schema=35),t<36&&(W6(e),e.schema=36),t<37&&(q6(e),e.schema=37),t<38&&(Ya(e,jb),Xa(e,jb),e.schema=38),t<39&&(X6(e),e.schema=39),t<40&&(Y6(e),e.schema=40),t<41&&(Q6(e),e.schema=41),t<42&&(Z6(e),e.schema=42),t<43&&(K6(e),e.schema=43),t<99){Ya(e,qb),Xa(e,qb),e.scene.publish.playCamera===null&&(e.scene.publish.playCamera=rh);let i=oi(e.scene.objects),r=e.scene.objects;e.scene.publish.playPage=sc,r.insertBefore(null,null,[{id:sc,data:{...Ul.defaultData,backgroundColor:e.scene.backgroundColor,fog:e.scene.fog,postprocessing:e.scene.postprocessing,ao:Sa(e.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:e.scene.publish.playCamera,gameControlObject:e.scene.publish.gameControlObject},shadow:Sa(e.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Nl.defaultData,...Sa(e.scene.environment,"usePhysics","gravity")},camera:oi(e.scene.ownerCamera)??Ul.defaultData.camera,name:"Scene"},children:[]}]);for(let n of i)n.id!==vl.TRASH_CAN_ID&&r.move(sc,n.fi,n.id);let s=0,a=0;e.shared.penumbraSize&&e.scene.objects.traverse((n,o)=>{o.type==="DirectionalLight"?(o.penumbraSize=e.shared.penumbraSize[Math.min(s,2)],s+=1):o.type==="SpotLight"&&(o.penumbraSize=e.shared.penumbraSize[3+Math.min(a,1)],a+=1),(o.physics===void 0||o.physics===null)&&o.type!=="Instance"&&(o.physics={},Object.assign(o.physics,zl.defaultData)),o.physics!==void 0&&o.physics!==null&&(o.physics.enabled=o.collision??"visibility",delete o.collision)}),e.schema=99}}function Xb(e){e.layers&&e.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function $6(e){e.scene.objects.traverse((t,i)=>{let r=i.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}var Jo=180/Math.PI;function Yb(e){e.rotation=e.rotation.slice(0,3).map(t=>t*Jo)}function I2(e){Yb(e),e.type==="Page"&&Yb(e.camera),e.states?.forEach(i=>{i.rotation===void 0||i.rotation===null||(i.rotation=i.rotation.slice(0,3).map(r=>r*Jo))});let t=e.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Jo),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Jo),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Jo,t.extrusion.twist*=Jo),e.type==="Mesh"&&e.geometry.type==="TextGeometry"&&(e.geometry.text={textValue:e.geometry.text}),Array.isArray(oi(e.events))&&e.events?.forEach(i=>{(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="MousePress"||i.type==="KeyDown"||i.type==="KeyUp"||i.type==="KeyPress"||i.type==="Collision"||i.type==="Trigger")&&(i.runMode=i.toggle?"Toggle":"Once")})}function eV(e){e.shared.variables=Ca({},nt.prototype)}function tV(e){let t=oi(e.shared.variables);e.shared.variables=Ca(Object.entries(t??{}).map(([i,r],s)=>({fi:s,id:i,data:r})),We.prototype)}var Qa=107;function O2(e,t){t(e.data);for(let i of e.children)O2(i,t)}function iV(e){let t=e.schema??104;t!==Qa&&t<105&&(O2(e.asset,I2),e.schema=105)}function L2(e){let t=e.schema??0;if(t!==Qa){console.warn("updating from ",t,"to ",Qa),J6(e,t),t<100&&(e.scene.publish.joystickSizeAndXYOffset===void 0&&(e.scene.publish.joystickSizeAndXYOffset=Jn.defaultData.joystickSizeAndXYOffset),e.schema=100),t<101&&(Ya(e,Xb),Xa(e,Xb),e.schema=101),t<102&&($6(e),e.schema=102),t<104&&(e.shared.catelogs=new nt,e.shared.lib=Fl.defaultData(),e.schema=104),t<105&&(eV(e),e.scene.objects.traverse((i,r)=>{I2(r)}),e.schema=105);for(let i of Object.values(e.shared.lib.components))iV(i);t<106&&(tV(e),e.schema=106),t<107&&(e.shared.lib.variables=Fl.defaultData().variables,e.schema=107)}}var np;(e=>{e.defaultData={schema:Qa,scene:vl.defaultData,frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:{...ns.emptyData(),colors:ns.defaultColors()}},e.emptyDataForImports=function(s){let a=vl.emptyDataWithPage(s);return{schema:Qa,scene:a,frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:{...ns.emptyData(),colors:ns.defaultColors(),images:ns.defaultImages(s)}}},e.emptyData=function(){return{schema:Qa,scene:vl.emptyDataWithPage(),frames:new nt().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ac.defaultData),shared:ns.emptyData()}},e.collabHelper={...Ag,updateSchema(s){return(s.schema??0)<Qa?wc(s,L2):(s.schema??0)-Qa}};function t(s){let a=e.collabHelper.updateSchema(s);return typeof a=="number"?a===0?s:null:a.data}e.updateSchemaDirectly=t;function i(s){return{...s,shared:{...s.shared,lib:Fl.defaultData()}}}e.withoutLib=i;function r(s,a){let n=s.scene.objects.get(a);if(n&&n.data.type==="Component")return n;{let o=s.shared.lib.components[a];if(o)return o.asset}}e.getComponentData=r})(np||(np={}));function Hn(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)),a={},n={},o=e[0].morphTargetsRelative,l=new Ue,h=0;for(let d=0;d<e.length;++d){let c=e[d],u=0;if(i!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". 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 "+d+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;a[p]===void 0&&(a[p]=[]),a[p].push(c.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+d+". 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 "+d+". .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 "+d+". .morphAttributes must be consistent throughout all geometries."),null;n[p]===void 0&&(n[p]=[]),n[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 "+d+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,d),h+=p}}if(i){let d=0,c=[];for(let u=0;u<e.length;++u){let p=e[u].index;for(let f=0;f<p.count;++f)c.push(p.getX(f)+d);d+=e[u].attributes.position.count}l.setIndex(c)}for(let d in a){let c=Qb(a[d]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" attribute."),null;l.setAttribute(d,c)}for(let d in n){let c=n[d][0].length;if(c===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[d]=[];for(let u=0;u<c;++u){let p=[];for(let m=0;m<n[d].length;++m)p.push(n[d][m][u]);let f=Qb(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+d+" morphAttribute."),null;l.morphAttributes[d].push(f)}}return l}function Qb(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 a=new t(s),n=0;for(let o=0;o<e.length;++o)a.set(e[o].array,n),n+=e[o].array.length;return new Ke(a,i,r)}var rV=Math.pow(2,-24),Dd=class{constructor(){}};function ks(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function Zb(e){let t=-1,i=-1/0;for(let r=0;r<3;r++){let s=e[r+3]-e[r];s>i&&(i=s,t=r)}return t}function Kb(e,t){t.set(e)}function Jb(e,t,i){let r,s;for(let a=0;a<3;a++){let n=a+3;r=e[a],s=t[a],i[a]=r<s?r:s,r=e[n],s=t[n],i[n]=r>s?r:s}}function Id(e,t,i){for(let r=0;r<3;r++){let s=t[e+2*r],a=t[e+2*r+1],n=s-a,o=s+a;n<i[r]&&(i[r]=n),o>i[r+3]&&(i[r+3]=o)}}function Eh(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 sV(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 Ke(s,1));for(let a=0;a<i;a++)s[a]=a}}function aV(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,a)=>s-a);for(let s=0;s<r.length-1;s++){let a=r[s],n=r[s+1];t.push({offset:a/3,count:(n-a)/3})}return t}function Kf(e,t,i,r,s=null){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0,c=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=s!==null;for(let y=t*6,x=(t+i)*6;y<x;y+=6){let b=e[y+0],w=e[y+1],A=b-w,S=b+w;A<a&&(a=A),S>l&&(l=S),v&&b<c&&(c=b),v&&b>f&&(f=b);let _=e[y+2],M=e[y+3],C=_-M,T=_+M;C<n&&(n=C),T>h&&(h=T),v&&_<u&&(u=_),v&&_>m&&(m=_);let D=e[y+4],P=e[y+5],O=D-P,B=D+P;O<o&&(o=O),B>d&&(d=B),v&&D<p&&(p=D),v&&D>g&&(g=D)}r[0]=a,r[1]=n,r[2]=o,r[3]=l,r[4]=h,r[5]=d,v&&(s[0]=c,s[1]=u,s[2]=p,s[3]=f,s[4]=m,s[5]=g)}function nV(e,t,i,r){let s=1/0,a=1/0,n=1/0,o=-1/0,l=-1/0,h=-1/0;for(let d=t*6,c=(t+i)*6;d<c;d+=6){let u=e[d+0];u<s&&(s=u),u>o&&(o=u);let p=e[d+2];p<a&&(a=p),p>l&&(l=p);let f=e[d+4];f<n&&(n=f),f>h&&(h=f)}r[0]=s,r[1]=a,r[2]=n,r[3]=o,r[4]=l,r[5]=h}function oV(e,t,i,r,s){let a=i,n=i+r-1,o=s.pos,l=s.axis*2;for(;;){for(;a<=n&&t[a*6+l]<o;)a++;for(;a<=n&&t[n*6+l]>=o;)n--;if(a<n){for(let h=0;h<3;h++){let d=e[a*3+h];e[a*3+h]=e[n*3+h],e[n*3+h]=d;let c=t[a*6+h*2+0];t[a*6+h*2+0]=t[n*6+h*2+0],t[n*6+h*2+0]=c;let u=t[a*6+h*2+1];t[a*6+h*2+1]=t[n*6+h*2+1],t[n*6+h*2+1]=u}a++,n--}else return a}}var da=32,lV=(e,t)=>e.candidate-t.candidate,Na=new Array(da).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Od=new Float32Array(6);function hV(e,t,i,r,s,a){let n=-1,o=0;if(a===0)n=Zb(t),n!==-1&&(o=(t[n]+t[n+3])/2);else if(a===1)n=Zb(e),n!==-1&&(o=cV(i,r,s,n));else if(a===2){let l=Eh(e),h=1.25*s,d=r*6,c=(r+s)*6;for(let u=0;u<3;u++){let p=t[u],f=(t[u+3]-p)/da;if(s<da/4){let m=[...Na];m.length=s;let g=0;for(let y=d;y<c;y+=6,g++){let x=m[g];x.candidate=i[y+2*u],x.count=0;let{bounds:b,leftCacheBounds:w,rightCacheBounds:A}=x;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,b[S]=1/0,b[S+3]=-1/0;Id(y,i,b)}m.sort(lV);let v=s;for(let y=0;y<v;y++){let x=m[y];for(;y+1<v&&m[y+1].candidate===x.candidate;)m.splice(y+1,1),v--}for(let y=d;y<c;y+=6){let x=i[y+2*u];for(let b=0;b<v;b++){let w=m[b];x>=w.candidate?Id(y,i,w.rightCacheBounds):(Id(y,i,w.leftCacheBounds),w.count++)}}for(let y=0;y<v;y++){let x=m[y],b=x.count,w=s-x.count,A=x.leftCacheBounds,S=x.rightCacheBounds,_=0;b!==0&&(_=Eh(A)/l);let M=0;w!==0&&(M=Eh(S)/l);let C=1+1.25*(_*b+M*w);C<h&&(n=u,h=C,o=x.candidate)}}else{for(let v=0;v<da;v++){let y=Na[v];y.count=0,y.candidate=p+f+v*f;let x=y.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=d;v<c;v+=6){let y=~~((i[v+2*u]-p)/f);y>=da&&(y=da-1);let x=Na[y];x.count++,Id(v,i,x.bounds)}let m=Na[da-1];Kb(m.bounds,m.rightCacheBounds);for(let v=da-2;v>=0;v--){let y=Na[v],x=Na[v+1];Jb(y.bounds,x.rightCacheBounds,y.rightCacheBounds)}let g=0;for(let v=0;v<da-1;v++){let y=Na[v],x=y.count,b=y.bounds,w=Na[v+1].rightCacheBounds;x!==0&&(g===0?Kb(b,Od):Jb(b,Od,Od)),g+=x;let A=0,S=0;g!==0&&(A=Eh(Od)/l);let _=s-g;_!==0&&(S=Eh(w)/l);let M=1+1.25*(A*g+S*_);M<h&&(n=u,h=M,o=y.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:o}}function cV(e,t,i,r){let s=0;for(let a=t,n=t+i;a<n;a++)s+=e[a*6+r*2];return s/i}function dV(e,t){let i=e.attributes.position,r=e.index.array,s=r.length/3,a=new Float32Array(s*6),n=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let d=["getX","getY","getZ"];for(let c=0;c<s;c++){let u=c*3,p=c*6,f,m,g;n?(f=r[u+0],m=r[u+1],g=r[u+2]):(f=r[u+0]*h+l,m=r[u+1]*h+l,g=r[u+2]*h+l);for(let v=0;v<3;v++){let y,x,b;n?(y=i[d[v]](f),x=i[d[v]](m),b=i[d[v]](g)):(y=o[f+v],x=o[m+v],b=o[g+v]);let w=y;x<w&&(w=x),b<w&&(w=b);let A=y;x>A&&(A=x),b>A&&(A=b);let S=(A-w)/2,_=v*2;a[p+_+0]=w+S,a[p+_+1]=S+(Math.abs(w)+S)*rV,w<t[v]&&(t[v]=w),A>t[v+3]&&(t[v+3]=A)}}return a}function uV(e,t){function i(v){u&&u(v/p)}function r(v,y,x,b=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))),x<=d||w>=l)return i(y+x),v.offset=y,v.count=x,v;let A=hV(v.boundingData,b,n,y,x,c);if(A.axis===-1)return i(y+x),v.offset=y,v.count=x,v;let S=oV(o,n,y,x,A);if(S===y||S===y+x)i(y+x),v.offset=y,v.count=x;else{v.splitAxis=A.axis;let _=new Dd,M=y,C=S-y;v.left=_,_.boundingData=new Float32Array(6),Kf(n,M,C,_.boundingData,a),r(_,M,C,a,w+1);let T=new Dd,D=S,P=x-C;v.right=T,T.boundingData=new Float32Array(6),Kf(n,D,P,T.boundingData,a),r(T,D,P,a,w+1)}return v}sV(e,t);let s=new Float32Array(6),a=new Float32Array(6),n=dV(e,s),o=e.index.array,l=t.maxDepth,h=t.verbose,d=t.maxLeafTris,c=t.strategy,u=t.onProgress,p=e.index.count/3,f=!1,m=[],g=aV(e);if(g.length===1){let v=g[0],y=new Dd;y.boundingData=s,nV(n,v.offset,v.count,a),r(y,v.offset,v.count,a),m.push(y)}else for(let v of g){let y=new Dd;y.boundingData=new Float32Array(6),Kf(n,v.offset,v.count,y.boundingData,a),r(y,v.offset,v.count,a),m.push(y)}return m}function pV(e,t){let i=uV(e,t),r,s,a,n=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let d=0;d<i.length;d++){let c=i[d],u=l(c),p=new o(32*u);r=new Float32Array(p),s=new Uint32Array(p),a=new Uint16Array(p),h(0,c),n.push(p)}return n;function l(d){return d.count?1:1+l(d.left)+l(d.right)}function h(d,c){let u=d/4,p=d/2,f=!!c.count,m=c.boundingData;for(let g=0;g<6;g++)r[u+g]=m[g];if(f){let g=c.offset,v=c.count;return s[u+6]=g,a[p+14]=v,a[p+15]=65535,d+32}else{let g=c.left,v=c.right,y=c.splitAxis,x;if(x=h(d+32,g),x/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=x/4,x=h(x,v),s[u+7]=y,x}}}var qs=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){let n=e[s][t];i=n<i?n:i,r=n>r?n:r}this.min=i,this.max=r}setFromPoints(e,t){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){let n=t[s],o=e.dot(n);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}};qs.prototype.setFromBox=function(){let e=new E;return function(t,i){let r=i.min,s=i.max,a=1/0,n=-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 d=t.dot(e);a=Math.min(d,a),n=Math.max(d,n)}this.min=a,this.max=n}}();var PY=function(){let e=new qs;return function(t,i){let r=t.points,s=t.satAxes,a=t.satBounds,n=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let d=a[h],c=s[h];if(e.setFromPoints(c,n),d.isSeparated(e))return!1}for(let h=0;h<3;h++){let d=l[h],c=o[h];if(e.setFromPoints(c,r),d.isSeparated(e))return!1}}}(),fV=function(){let e=new E,t=new E,i=new E;return function(r,s,a){let n=r.start,o=e,l=s.start,h=t;i.subVectors(n,l),e.subVectors(r.end,r.start),t.subVectors(s.end,s.start);let d=i.dot(h),c=h.dot(o),u=h.dot(h),p=i.dot(o),f=o.dot(o)*u-c*c,m,g;f!==0?m=(d*c-p*u)/f:m=0,g=(d+m*c)/u,a.x=m,a.y=g}}(),N0=function(){let e=new k,t=new E,i=new E;return function(r,s,a,n){fV(r,s,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1){r.at(o,a),s.at(l,n);return}else if(o>=0&&o<=1){l<0?s.at(0,n):s.at(1,n),r.closestPointToPoint(n,!0,a);return}else if(l>=0&&l<=1){o<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,n);return}else{let h;o<0?h=r.start:h=r.end;let d;l<0?d=s.start:d=s.end;let c=t,u=i;if(r.closestPointToPoint(d,!0,t),s.closestPointToPoint(h,!0,i),c.distanceToSquared(d)<=u.distanceToSquared(h)){a.copy(c),n.copy(d);return}else{a.copy(h),n.copy(u);return}}}}(),mV=function(){let e=new E,t=new E,i=new Er,r=new Wr;return function(s,a){let{radius:n,center:o}=s,{a:l,b:h,c:d}=a;if(r.start=l,r.end=h,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n||(r.start=l,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n)||(r.start=h,r.end=d,r.closestPointToPoint(o,!0,e).distanceTo(o)<=n))return!0;let c=a.getPlane(i);if(Math.abs(c.distanceToPoint(o))<=n){let u=c.projectPoint(o,t);if(a.containsPoint(u))return!0}return!1}}(),gV=1e-15;function Lo(e){return Math.abs(e)<gV}var Ta=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 qs),this.points=[this.a,this.b,this.c],this.sphere=new vr,this.plane=new Er,this.needsUpdate=!0}intersectsSphere(e){return mV(e,this)}update(){let e=this.a,t=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,n=s[0],o=a[0];this.getNormal(n),o.setFromPoints(n,r);let l=s[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,r);let d=s[2],c=a[2];d.subVectors(t,i),c.setFromPoints(d,r);let u=s[3],p=a[3];u.subVectors(i,e),p.setFromPoints(u,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(n,e),this.needsUpdate=!1}};Ta.prototype.closestPointToSegment=function(){let e=new E,t=new E,i=new Wr;return function(r,s=null,a=null){let{start:n,end:o}=r,l=this.points,h,d=1/0;for(let c=0;c<3;c++){let u=(c+1)%3;i.start.copy(l[c]),i.end.copy(l[u]),N0(i,r,e,t),h=e.distanceToSquared(t),h<d&&(d=h,s&&s.copy(e),a&&a.copy(t))}return this.closestPointToPoint(n,e),h=n.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),a&&a.copy(n)),this.closestPointToPoint(o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(e),a&&a.copy(o)),Math.sqrt(d)}}();Ta.prototype.intersectsTriangle=function(){let e=new Ta,t=new Array(3),i=new Array(3),r=new qs,s=new qs,a=new E,n=new E,o=new E,l=new E,h=new Wr,d=new Wr,c=new Wr;return function(u,p=null,f=!1){this.needsUpdate&&this.update(),u.isExtendedTriangle?u.needsUpdate&&u.update():(e.copy(u),e.update(),u=e);let m=this.plane,g=u.plane;if(Math.abs(m.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;i[0]=u.a,i[1]=u.b,i[2]=u.c;for(let w=0;w<4;w++){let A=v[w],S=y[w];if(r.setFromPoints(S,i),A.isSeparated(r))return!1}let x=u.satBounds,b=u.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let w=0;w<4;w++){let A=x[w],S=b[w];if(r.setFromPoints(S,t),A.isSeparated(r))return!1}for(let w=0;w<4;w++){let A=y[w];for(let S=0;S<4;S++){let _=b[S];if(a.crossVectors(A,_),r.setFromPoints(a,t),s.setFromPoints(a,i),r.isSeparated(s))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}else{let v=this.points,y=!1,x=0;for(let P=0;P<3;P++){let O=v[P],B=v[(P+1)%3];h.start.copy(O),h.end.copy(B),h.delta(n);let G=y?d.start:d.end,F=Lo(g.distanceToPoint(O));if(Lo(g.normal.dot(n))&&F){d.copy(h),x=2;break}if((g.intersectLine(h,G)||F)&&!Lo(G.distanceTo(B))){if(x++,y)break;y=!0}}if(x===1&&u.containsPoint(d.end))return p&&(p.start.copy(d.end),p.end.copy(d.end)),!0;if(x!==2)return!1;let b=u.points,w=!1,A=0;for(let P=0;P<3;P++){let O=b[P],B=b[(P+1)%3];h.start.copy(O),h.end.copy(B),h.delta(o);let G=w?c.start:c.end,F=Lo(m.distanceToPoint(O));if(Lo(m.normal.dot(o))&&F){c.copy(h),A=2;break}if((m.intersectLine(h,G)||F)&&!Lo(G.distanceTo(B))){if(A++,w)break;w=!0}}if(A===1&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(A!==2)return!1;if(d.delta(n),c.delta(o),n.dot(o)<0){let P=c.start;c.start=c.end,c.end=P}let S=d.start.dot(n),_=d.end.dot(n),M=c.start.dot(n),C=c.end.dot(n),T=_<M,D=S<C;return S!==C&&M!==_&&T===D?!1:(p&&(l.subVectors(d.start,c.start),l.dot(n)>0?p.start.copy(d.start):p.start.copy(c.start),l.subVectors(d.end,c.end),l.dot(n)<0?p.end.copy(d.end):p.end.copy(c.end)),!0)}}}();Ta.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Ta.prototype.distanceToTriangle=function(){let e=new E,t=new E,i=["a","b","c"],r=new Wr,s=new Wr;return function(a,n=null,o=null){let l=n||o?r:null;if(this.intersectsTriangle(a,l))return(n||o)&&(n&&l.getCenter(n),o&&l.getCenter(o)),0;let h=1/0;for(let d=0;d<3;d++){let c,u=i[d],p=a[u];this.closestPointToPoint(p,e),c=p.distanceToSquared(e),c<h&&(h=c,n&&n.copy(e),o&&o.copy(p));let f=this[u];a.closestPointToPoint(f,e),c=f.distanceToSquared(e),c<h&&(h=c,n&&n.copy(f),o&&o.copy(e))}for(let d=0;d<3;d++){let c=i[d],u=i[(d+1)%3];r.set(this[c],this[u]);for(let p=0;p<3;p++){let f=i[p],m=i[(p+1)%3];s.set(a[f],a[m]),N0(r,s,e,t);let g=e.distanceToSquared(t);g<h&&(h=g,n&&n.copy(e),o&&o.copy(t))}}return Math.sqrt(h)}}();var Xs=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new E,this.max=new E,this.matrix=new me,this.invMatrix=new me,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 qs),this.alignedSatBounds=new Array(3).fill().map(()=>new qs),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};Xs.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 d=0;d<=1;d++){let c=1*l|2*h|4*d,u=r[c];u.x=l?i.x:t.x,u.y=h?i.y:t.y,u.z=d?i.z:t.z,u.applyMatrix4(e)}let s=this.satBounds,a=this.satAxes,n=r[0];for(let l=0;l<3;l++){let h=a[l],d=s[l],c=1<<l,u=r[c];h.subVectors(n,u),d.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}}();Xs.prototype.intersectsBox=function(){let e=new qs;return function(t){this.needsUpdate&&this.update();let i=t.min,r=t.max,s=this.satBounds,a=this.satAxes,n=this.alignedSatBounds;if(e.min=i.x,e.max=r.x,n[0].isSeparated(e)||(e.min=i.y,e.max=r.y,n[1].isSeparated(e))||(e.min=i.z,e.max=r.z,n[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let l=a[o],h=s[o];if(e.setFromBox(l,t),h.isSeparated(e))return!1}return!0}}();Xs.prototype.intersectsTriangle=function(){let e=new Ta,t=new Array(3),i=new qs,r=new qs,s=new E;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let n=this.satBounds,o=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let c=0;c<3;c++){let u=n[c],p=o[c];if(i.setFromPoints(p,t),u.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,d=this.points;for(let c=0;c<3;c++){let u=l[c],p=h[c];if(i.setFromPoints(p,d),u.isSeparated(i))return!1}for(let c=0;c<3;c++){let u=o[c];for(let p=0;p<4;p++){let f=h[p];if(s.crossVectors(u,f),i.setFromPoints(s,t),r.setFromPoints(s,d),i.isSeparated(r))return!1}}return!0}}();Xs.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}}();Xs.prototype.distanceToPoint=function(){let e=new E;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}();Xs.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map(()=>new Wr),i=new Array(12).fill().map(()=>new Wr),r=new E,s=new E;return function(a,n=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(s),this.closestPointToPoint(s,r),a.closestPointToPoint(r,s),o&&o.copy(r),l&&l.copy(s)),0;let h=n*n,d=a.min,c=a.max,u=this.points,p=1/0;for(let m=0;m<8;m++){let g=u[m];s.copy(g).clamp(d,c);let v=g.distanceToSquared(s);if(v<p&&(p=v,o&&o.copy(g),l&&l.copy(s),v<h))return Math.sqrt(v)}let f=0;for(let m=0;m<3;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){let y=(m+1)%3,x=(m+2)%3,b=g<<y|v<<x,w=1<<m|g<<y|v<<x,A=u[b],S=u[w];t[f].set(A,S);let _=e[m],M=e[y],C=e[x],T=i[f],D=T.start,P=T.end;D[_]=d[_],D[M]=g?d[M]:c[M],D[C]=v?d[C]:c[M],P[_]=c[_],P[M]=g?d[M]:c[M],P[C]=v?d[C]:c[M],f++}for(let m=0;m<=1;m++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=m?c.x:d.x,s.y=g?c.y:d.y,s.z=v?c.z:d.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 m=0;m<12;m++){let g=t[m];for(let v=0;v<12;v++){let y=i[v];N0(g,y,r,s);let x=r.distanceToSquared(s);if(x<p&&(p=x,o&&o.copy(r),l&&l.copy(s),x<h))return Math.sqrt(x)}}return Math.sqrt(p)}}();var Ro=new E,Bo=new E,zo=new E,Ld=new k,Rd=new k,Bd=new k,$b=new E,ew=new E,tw=new E,zd=new E;function vV(e,t,i,r,s,a){let n;return a===Si?n=e.intersectTriangle(r,i,t,!0,s):n=e.intersectTriangle(t,i,r,a!==Cr,s),n===null?null:{distance:e.origin.distanceTo(s),point:s.clone()}}function yV(e,t,i,r,s,a,n,o,l){Ro.fromBufferAttribute(t,a),Bo.fromBufferAttribute(t,n),zo.fromBufferAttribute(t,o);let h=vV(e,Ro,Bo,zo,zd,l);if(h){r&&(Ld.fromBufferAttribute(r,a),Rd.fromBufferAttribute(r,n),Bd.fromBufferAttribute(r,o),h.uv=Ni.getInterpolation(zd,Ro,Bo,zo,Ld,Rd,Bd,new k)),s&&(Ld.fromBufferAttribute(s,a),Rd.fromBufferAttribute(s,n),Bd.fromBufferAttribute(s,o),h.uv1=Ni.getInterpolation(zd,Ro,Bo,zo,Ld,Rd,Bd,new k)),i&&($b.fromBufferAttribute(i,a),ew.fromBufferAttribute(i,n),tw.fromBufferAttribute(i,o),h.normal=Ni.getInterpolation(zd,Ro,Bo,zo,$b,ew,tw,new E),h.normal.dot(e.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:n,c:o,normal:new E,materialIndex:0};Ni.getNormal(Ro,Bo,zo,d.normal),h.face=d,h.faceIndex=a}return h}function R2(e,t,i,r,s){let a=r*3,n=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),{position:h,normal:d,uv:c,uv1:u}=e.attributes,p=yV(i,h,d,c,u,n,o,l,t);return p?(p.faceIndex=r,s&&s.push(p),p):null}function xV(e,t,i,r,s,a){for(let n=r,o=r+s;n<o;n++)R2(e,t,i,n,a)}function bV(e,t,i,r,s){let a=1/0,n=null;for(let o=r,l=r+s;o<l;o++){let h=R2(e,t,i,o);h&&h.distance<a&&(n=h,a=h.distance)}return n}function Rs(e,t,i,r){let s=e.a,a=e.b,n=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),a.x=r.getX(l),a.y=r.getY(l),a.z=r.getZ(l),n.x=r.getX(h),n.y=r.getY(h),n.z=r.getZ(h)}function iw(e,t,i,r,s,a,n){let o=i.index,l=i.attributes.position;for(let h=e,d=t+e;h<d;h++)if(Rs(n,h*3,o,l),n.needsUpdate=!0,r(n,h,s,a))return!0;return!1}var B2=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 Za(e,t){return t[e+15]===65535}function yl(e,t){return t[e+6]}function Ac(e,t){return t[e+14]}function Mc(e){return e+8}function Ec(e,t){return t[e+6]}function wV(e,t){return t[e+7]}var ll=new $t,op=new E,_V=["x","y","z"];function sv(e,t,i,r,s){let a=e*2,n=sh,o=hn,l=cn;if(Za(a,o)){let h=yl(e,l),d=Ac(a,o);xV(t,i,r,h,d,s)}else{let h=Mc(e);lp(h,n,r,op)&&sv(h,t,i,r,s);let d=Ec(e,l);lp(d,n,r,op)&&sv(d,t,i,r,s)}}function av(e,t,i,r){let s=e*2,a=sh,n=hn,o=cn;if(Za(s,n)){let l=yl(e,o),h=Ac(s,n);return bV(t,i,r,l,h)}else{let l=wV(e,o),h=_V[l],d=r.direction[h]>=0,c,u;d?(c=Mc(e),u=Ec(e,o)):(c=Ec(e,o),u=Mc(e));let p=lp(c,a,r,op)?av(c,t,i,r):null;if(p){let m=p.point[h];if(d?m<=a[u+l]:m>=a[u+l+3])return p}let f=lp(u,a,r,op)?av(u,t,i,r):null;return p&&f?p.distance<=f.distance?p:f:p||f||null}}var SV=function(){let e,t,i=[],r=new B2(()=>new $t);return function(...a){e=r.getPrimitive(),t=r.getPrimitive(),i.push(e,t);let n=s(...a);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]),n};function s(a,n,o,l,h=null,d=0,c=0){function u(y){let x=y*2,b=hn,w=cn;for(;!Za(x,b);)y=Mc(y),x=y*2;return yl(y,w)}function p(y){let x=y*2,b=hn,w=cn;for(;!Za(x,b);)y=Ec(y,w),x=y*2;return yl(y,w)+Ac(x,b)}let f=a*2,m=sh,g=hn,v=cn;if(Za(f,g)){let y=yl(a,v),x=Ac(f,g);return ks(a,m,e),l(y,x,!1,c,d+a,e)}else{let y=Mc(a),x=Ec(a,v),b=y,w=x,A,S,_,M;if(h&&(_=e,M=t,ks(b,m,_),ks(w,m,M),A=h(_),S=h(M),S<A)){b=x,w=y;let G=A;A=S,S=G,_=M}_||(_=e,ks(b,m,_));let C=Za(b*2,g),T=o(_,C,A,c+1,d+b),D;if(T===2){let G=u(b),F=p(b)-G;D=l(G,F,!0,c+1,d+b,_)}else D=T&&s(b,n,o,l,h,d,c+1);if(D)return!0;M=t,ks(w,m,M);let P=Za(w*2,g),O=o(M,P,S,c+1,d+w),B;if(O===2){let G=u(w),F=p(w)-G;B=l(G,F,!0,c+1,d+w,M)}else B=O&&s(w,n,o,l,h,d,c+1);return!!B}}}(),AV=function(){let e=new Ta,t=new Ta,i=new me,r=new Xs,s=new Xs;return function a(n,o,l,h,d=null){let c=n*2,u=sh,p=hn,f=cn;if(d===null&&(l.boundingBox||l.computeBoundingBox(),r.set(l.boundingBox.min,l.boundingBox.max,h),d=r),Za(c,p)){let m=o,g=m.index,v=m.attributes.position,y=l.index,x=l.attributes.position,b=yl(n,f),w=Ac(c,p);if(i.copy(h).invert(),l.boundsTree)return ks(n,u,s),s.matrix.copy(i),s.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:A=>s.intersectsBox(A),intersectsTriangle:A=>{A.a.applyMatrix4(h),A.b.applyMatrix4(h),A.c.applyMatrix4(h),A.needsUpdate=!0;for(let S=b*3,_=(w+b)*3;S<_;S+=3)if(Rs(t,S,g,v),t.needsUpdate=!0,A.intersectsTriangle(t))return!0;return!1}});for(let A=b*3,S=w+b*3;A<S;A+=3){Rs(e,A,g,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(Rs(t,_,y,x),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}else{let m=n+8,g=f[n+6];return ks(m,u,ll),!!(d.intersectsBox(ll)&&a(m,o,l,h,d)||(ks(g,u,ll),d.intersectsBox(ll)&&a(g,o,l,h,d)))}}}();function lp(e,t,i,r){return ks(e,t,ll),i.intersectBox(ll,r)}var nv=[],yu,sh,hn,cn;function Xh(e){yu&&nv.push(yu),yu=e,sh=new Float32Array(e),hn=new Uint16Array(e),cn=new Uint32Array(e)}function Nd(){yu=null,sh=null,hn=null,cn=null,nv.length&&Xh(nv.pop())}var Jf=Symbol("skip tree generation"),$f=new $t,em=new $t,No=new me,Dn=new Xs,Ch=new Xs,Th=new E,kd=new E,MV=new E,EV=new E,CV=new E,rw=new $t,_s=new B2(()=>new Ta),nc=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."),nc.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(),a;return t.cloneBuffers?a={roots:r.map(n=>n.slice()),index:s.array.slice()}:a={roots:r,index:s.array},a}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."),nc.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});i={setIndex:!0,...i};let{index:r,roots:s}=e,a=new nc(t,{...i,[Jf]:!0});if(a._roots=s,i.setIndex){let n=t.getIndex();if(n===null){let o=new Ke(e.index,1,!1);t.setIndex(o)}else n.array!==r&&(n.array.set(r),n.needsUpdate=!0)}return a}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,[Jf]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Jf]||(this._roots=pV(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new $t))),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,a,n,o,l=0,h=this._roots;for(let c=0,u=h.length;c<u;c++)s=h[c],a=new Uint32Array(s),n=new Uint16Array(s),o=new Float32Array(s),d(0,l),l+=s.byteLength;function d(c,u,p=!1){let f=c*2;if(n[f+15]===65535){let m=a[c+6],g=n[f+14],v=1/0,y=1/0,x=1/0,b=-1/0,w=-1/0,A=-1/0;for(let S=3*m,_=3*(m+g);S<_;S++){let M=i[S],C=r.getX(M),T=r.getY(M),D=r.getZ(M);C<v&&(v=C),C>b&&(b=C),T<y&&(y=T),T>w&&(w=T),D<x&&(x=D),D>A&&(A=D)}return o[c+0]!==v||o[c+1]!==y||o[c+2]!==x||o[c+3]!==b||o[c+4]!==w||o[c+5]!==A?(o[c+0]=v,o[c+1]=y,o[c+2]=x,o[c+3]=b,o[c+4]=w,o[c+5]=A,!0):!1}else{let m=c+8,g=a[c+6],v=m+u,y=g+u,x=p,b=!1,w=!1;e?x||(b=e.has(v),w=e.has(y),x=!b&&!w):(b=!0,w=!0);let A=x||b,S=x||w,_=!1;A&&(_=d(m,u,x));let M=!1;S&&(M=d(g,u,x));let C=_||M;if(C)for(let T=0;T<3;T++){let D=m+T,P=g+T,O=o[D],B=o[D+3],G=o[P],F=o[P+3];o[c+T]=O<G?O:G,o[c+T+3]=B>F?B:F}return C}}}traverse(e,t=0){let i=this._roots[t],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(n,o=0){let l=n*2,h=s[l+15]===65535;if(h){let d=r[n+6],c=s[l+14];e(o,h,new Float32Array(i,n*4,6),d,c)}else{let d=n+8,c=r[n+6],u=r[n+7];e(o,h,new Float32Array(i,n*4,6),u)||(a(d,o+1),a(c,o+1))}}}raycast(e,t=fs){let i=this._roots,r=this.geometry,s=[],a=t.isMaterial,n=Array.isArray(t),o=r.groups,l=a?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=n?t[o[h].materialIndex].side:l,u=s.length;if(Xh(i[h]),sv(0,r,c,e,s),Nd(),n){let p=o[h].materialIndex;for(let f=u,m=s.length;f<m;f++)s[f].face.materialIndex=p}}return s}raycastFirst(e,t=fs){let i=this._roots,r=this.geometry,s=t.isMaterial,a=Array.isArray(t),n=null,o=r.groups,l=s?t.side:t;for(let h=0,d=i.length;h<d;h++){let c=a?t[o[h].materialIndex].side:l;Xh(i[h]);let u=av(0,r,c,e);Nd(),u!=null&&(n==null||u.distance<n.distance)&&(n=u,a&&(u.face.materialIndex=o[h].materialIndex))}return n}intersectsGeometry(e,t){let i=this.geometry,r=!1;for(let s of this._roots)if(Xh(s),r=AV(0,i,e,t),Nd(),r)break;return r}shapecast(e,t,i){let r=this.geometry;if(e instanceof Function){if(t){let c=t;t=(u,p,f,m)=>{let g=p*3;return c(u,g,g+1,g+2,f,m)}}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=_s.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:n,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let c=o;o=(u,p,f,m,g)=>c(u,p,f,m,g)?!0:iw(u,p,r,l,f,m,s)}else o||(l?o=(c,u,p,f)=>iw(c,u,r,l,p,f,s):o=(c,u,p)=>p);let h=!1,d=0;for(let c of this._roots){if(Xh(c),h=SV(0,r,n,o,a,d),Nd(),h)break;d+=c.byteLength}return _s.releasePrimitive(s),h}bvhcast(e,t,i){let{intersectsRanges:r,intersectsTriangles:s}=i,a=this.geometry.index,n=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;No.copy(t).invert();let h=_s.getPrimitive(),d=_s.getPrimitive();if(s){let u=function(p,f,m,g,v,y,x,b){for(let w=m,A=m+g;w<A;w++){Rs(d,w*3,o,l),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=p,_=p+f;S<_;S++)if(Rs(h,S*3,a,n),h.needsUpdate=!0,s(h,d,S,w,v,y,x,b))return!0}return!1};if(r){let p=r;r=function(f,m,g,v,y,x,b,w){return p(f,m,g,v,y,x,b,w)?!0:u(f,m,g,v,y,x,b,w)}}else r=u}e.getBoundingBox(em),em.applyMatrix4(t);let c=this.shapecast({intersectsBounds:u=>em.intersectsBox(u),intersectsRange:(u,p,f,m,g,v)=>($f.copy(v),$f.applyMatrix4(No),e.shapecast({intersectsBounds:y=>$f.intersectsBox(y),intersectsRange:(y,x,b,w,A)=>r(u,p,y,x,m,g,w,A)}))});return _s.releasePrimitive(h),_s.releasePrimitive(d),c}intersectsBox(e,t){return Dn.set(e.min,e.max,t),Dn.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Dn.intersectsBox(i),intersectsTriangle:i=>Dn.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},r={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Dn.set(e.boundingBox.min,e.boundingBox.max,t),Dn.needsUpdate=!0;let n=this.geometry,o=n.attributes.position,l=n.index,h=e.attributes.position,d=e.index,c=_s.getPrimitive(),u=_s.getPrimitive(),p=kd,f=MV,m=null,g=null;r&&(m=EV,g=CV);let v=1/0,y=null,x=null;return No.copy(t).invert(),Ch.matrix.copy(No),this.shapecast({boundsTraverseOrder:b=>Dn.distanceToBox(b),intersectsBounds:(b,w,A)=>A<v&&A<a?(w&&(Ch.min.copy(b.min),Ch.max.copy(b.max),Ch.needsUpdate=!0),!0):!1,intersectsRange:(b,w)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:A=>Ch.distanceToBox(A),intersectsBounds:(A,S,_)=>_<v&&_<a,intersectsRange:(A,S)=>{for(let _=A*3,M=(A+S)*3;_<M;_+=3){Rs(u,_,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let C=b*3,T=(b+w)*3;C<T;C+=3){Rs(c,C,l,o),c.needsUpdate=!0;let D=c.distanceToTriangle(u,p,m);if(D<v&&(f.copy(p),g&&g.copy(m),v=D,y=C/3,x=_/3),D<s)return!0}}}});{let A=d?d.count:h.count;for(let S=0,_=A;S<_;S+=3){Rs(u,S,d,h),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let M=b*3,C=(b+w)*3;M<C;M+=3){Rs(c,M,l,o),c.needsUpdate=!0;let T=c.distanceToTriangle(u,p,m);if(T<v&&(f.copy(p),g&&g.copy(m),v=T,y=M/3,x=S/3),T<s)return!0}}}}}),_s.releasePrimitive(c),_s.releasePrimitive(u),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(g):r.point=g.clone(),r.point.applyMatrix4(No),f.applyMatrix4(No),r.distance=f.sub(r.point).length(),r.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,r=1/0){let s=i*i,a=r*r,n=1/0,o=null;if(this.shapecast({boundsTraverseOrder:h=>(Th.copy(e).clamp(h.min,h.max),Th.distanceToSquared(e)),intersectsBounds:(h,d,c)=>c<n&&c<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,Th);let c=e.distanceToSquared(Th);return c<n&&(kd.copy(Th),n=c,o=d),c<s}}),n===1/0)return null;let l=Math.sqrt(n);return t.point?t.point.copy(kd):t.point=kd.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ks(0,new Float32Array(t),rw),e.union(rw)}),e}},Ph=gn(UC()),TV=.5*(Math.sqrt(3)-1),Dh=(3-Math.sqrt(3))/6,PV=1/3,Ss=1/6,DY=(Math.sqrt(5)-1)/4,IY=(5-Math.sqrt(5))/20,oc=e=>Math.floor(e)|0,sw=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]),tm=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 im(e=Math.random){let t=z2(e),i=new Float64Array(t).map(s=>sw[s%12*2]),r=new Float64Array(t).map(s=>sw[s%12*2+1]);return function(s,a){let n=0,o=0,l=0,h=(s+a)*TV,d=oc(s+h),c=oc(a+h),u=(d+c)*Dh,p=d-u,f=c-u,m=s-p,g=a-f,v,y;m>g?(v=1,y=0):(v=0,y=1);let x=m-v+Dh,b=g-y+Dh,w=m-1+2*Dh,A=g-1+2*Dh,S=d&255,_=c&255,M=.5-m*m-g*g;if(M>=0){let D=S+t[_],P=i[D],O=r[D];M*=M,n=M*M*(P*m+O*g)}let C=.5-x*x-b*b;if(C>=0){let D=S+v+t[_+y],P=i[D],O=r[D];C*=C,o=C*C*(P*x+O*b)}let T=.5-w*w-A*A;if(T>=0){let D=S+1+t[_+1],P=i[D],O=r[D];T*=T,l=T*T*(P*w+O*A)}return 70*(n+o+l)}}function DV(e=Math.random){let t=z2(e),i=new Float64Array(t).map(a=>tm[a%12*3]),r=new Float64Array(t).map(a=>tm[a%12*3+1]),s=new Float64Array(t).map(a=>tm[a%12*3+2]);return function(a,n,o){let l,h,d,c,u=(a+n+o)*PV,p=oc(a+u),f=oc(n+u),m=oc(o+u),g=(p+f+m)*Ss,v=p-g,y=f-g,x=m-g,b=a-v,w=n-y,A=o-x,S,_,M,C,T,D;b>=w?w>=A?(S=1,_=0,M=0,C=1,T=1,D=0):b>=A?(S=1,_=0,M=0,C=1,T=0,D=1):(S=0,_=0,M=1,C=1,T=0,D=1):w<A?(S=0,_=0,M=1,C=0,T=1,D=1):b<A?(S=0,_=1,M=0,C=0,T=1,D=1):(S=0,_=1,M=0,C=1,T=1,D=0);let P=b-S+Ss,O=w-_+Ss,B=A-M+Ss,G=b-C+2*Ss,F=w-T+2*Ss,z=A-D+2*Ss,X=b-1+3*Ss,H=w-1+3*Ss,j=A-1+3*Ss,N=p&255,q=f&255,V=m&255,W=.6-b*b-w*w-A*A;if(W<0)l=0;else{let re=N+t[q+t[V]];W*=W,l=W*W*(i[re]*b+r[re]*w+s[re]*A)}let U=.6-P*P-O*O-B*B;if(U<0)h=0;else{let re=N+S+t[q+_+t[V+M]];U*=U,h=U*U*(i[re]*P+r[re]*O+s[re]*B)}let ie=.6-G*G-F*F-z*z;if(ie<0)d=0;else{let re=N+C+t[q+T+t[V+D]];ie*=ie,d=ie*ie*(i[re]*G+r[re]*F+s[re]*z)}let Q=.6-X*X-H*H-j*j;if(Q<0)c=0;else{let re=N+1+t[q+1+t[V+1]];Q*=Q,c=Q*Q*(i[re]*X+r[re]*H+s[re]*j)}return 32*(l+h+d+c)}}function z2(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 $r=new Ni,IV=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;$r.a.fromBufferAttribute(e,r),$r.b.fromBufferAttribute(e,r+1),$r.c.fromBufferAttribute(e,r+2),s*=$r.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 a=Math.ceil((i+r)/2);if(a===0||t[a-1]<=e&&t[a]>e){s=a;break}else e<t[a]?r=a-1:i=a+1}return s}sampleFace(e,t,i){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),$r.a.fromBufferAttribute(this.positionAttribute,e*3),$r.b.fromBufferAttribute(this.positionAttribute,e*3+1),$r.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector($r.a,r).addScaledVector($r.b,s).addScaledVector($r.c,1-(r+s)),$r.getNormal(i),this}},OV=gn(xS()),LV=new me,RV=new me,BV=new me,Cc;(e=>{function t(i){return i&&i.__isSPEObject}e.is=t})(Cc||(Cc={}));var k0=e=>class extends e{constructor(){super(...arguments),this.previousModelViewMatrix=new me,this.copyPreviousMatrix=!0,this.hiddenMatrix=new me,this.matrixWorldRigid=new me,this.shearScale=new me,this.shearScaleInv=new me}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Tt&&(t=t.uuid);let i=this;for(;i.parent;){if(i.parent.uuid===t)return!0;i=i.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let i of this.children)i.updateMatrixWorld(t)}updateWorldMatrix(t,i){let r=this.parent;if(t&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,i=0){for(let r of this.children)Cc.is(r)&&r.traverseObject(t,i+1)}traverseObject(t,i=0){if(t(this,i)!==!0)for(let r of this.children)Cc.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:a}=(0,OV.SVD)(i),n=LV.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=RV.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=BV.copy(o).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(o),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l).copyPosition(this.matrixWorld),a.every(h=>Math.abs(a[0]-h)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,i){this.updateWorldMatrix(!0,!1);let r=new me().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),r.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof me?t.hiddenMatrix.premultiply(r):t.applyMatrix4(r),t.updateWorldMatrix(!1,!1),this.add(t),i!==void 0&&(this.children.pop(),this.children.splice(i,0,t)),this}copy(t,i=!1){return super.copy(t,i),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,i,r,s,a,n){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}},zV=class extends k0(Tt){},NV=e=>e.type==="Mesh",Ui=class extends zV{constructor(e){super(),this.object=e,this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let i=this.children[e];i?.object!==t&&(i&&this.remove(i),i=new Ui(t),this.add(i),this.children.splice(e,0,this.children.pop()),i.matrixWorldNeedsUpdate=!0,i.matrixAutoUpdate=!1,i.matrix=t.matrix,i.hiddenMatrix=t.hiddenMatrix),i.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return NV(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}},Un=new E,Fn=new E,xl=new me,N2=[new E(-1,1,1),new E(-1,-1,1),new E(1,-1,1),new E(1,1,1),new E(-1,1,-1),new E(-1,-1,-1),new E(1,-1,-1),new E(1,1,-1)],kV=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],UV=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],aw=(e,t,i)=>{e.updateEntityBoxSize(Un,Fn),xl.copy(t).multiply(e.matrixWorld),Fn.x===0&&Fn.y===0&&Fn.z===0?i.push(new E(Un.x,Un.y,Un.z).applyMatrix4(xl)):N2.forEach(r=>{i.push(r.clone().multiply(Fn).add(Un).applyMatrix4(xl))})},nw=class extends $t{constructor(){super(...arguments),this.matrix=new me,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 me().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,t)}expandByObjectSize(e,t,i=!1){let r=[];return i===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){r.push(new E);return}aw(s,t,r)}}):aw(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(xl.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Fn).multiplyScalar(.5),this.getCenter(Un),xl.copy(this.matrix).setPosition(Un),this.vertices=N2.map(e=>e.clone().multiply(Fn).applyMatrix4(xl))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=kV.map(([e,t])=>new Wr(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=UV.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}},rn={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}},FV=class extends XS{constructor(){super()}getPoints(e=12){let t=[],i,r=this.getCurveLengths(),s=r[r.length-1]/r.length;for(let a=0,n=this.curves;a<n.length;a++){let o=n[a],l=a===0?r[a]:r[a]-r[a-1],h=Math.ceil(e*l/s),d=o.getPoints(h);for(let c=0;c<d.length;c++){let u=d[c];i&&i.equals(u)||(t.push(u),i=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}},ov=.001;function lv(e,t,i){return t.clone().sub(e).cross(t.clone().sub(i)).length()<=ov}function rm(e,t){let i=new E(...e.position),r=new E(...e.controlNext.position),s=new E(...t.controlPrevious.position),a=new E(...t.position);return lv(i,r,a)&&lv(i,s,a)}function k2(e){let t=e.points.map(d=>new E(...d.data.position)),i=[e.points[0]],r=new E(...i[0].data.position);for(let d=0;d<e.points.length-1;d++)lv(r,t[d],t[d+1])||(i.push(e.points[d]),r=t[d]);i.push(e.points[e.points.length-1]);let s=e.isClosed,a=i.length-(s?0:1),n=i.length,o=[];for(let d=0;d<n;d++){let c=i[d].data,u=new E(...c.position),p=new E(...c.controlPrevious.position),f=new E(...c.controlNext.position),m={position:u,baseRoundness:c.roundness,controlPrevious:p,controlNext:f};if(c.roundness===0||!e.isClosed&&(d===0||d===n-1)){o[d]={...m,removedLength:0};continue}let g=s&&d==0?n-1:d-1,v=s&&d==n-1?0:d+1,y=i[g].data,x=i[v].data,b=new E(...y.position),w=new E(...x.position),A=b.clone().sub(u).normalize(),S=w.clone().sub(u).normalize();Object.assign(m,{prevDir:A,nextDir:S});let _=rm(y,c),M=rm(c,x);if(!_||!M)o[d]={...m,removedLength:0};else{let C=A.clone().add(S).normalize(),T=C.clone().cross(A).length()/A.dot(C);o[d]={...m,tan:T,removedLength:c.roundness/T}}}for(let d=0;d<a;d++){let c=d,u=s&&d===n-1?0:d+1,p=o[c],f=o[u];if(p.removedLength!==0||f.removedLength!==0){let m=p.position.distanceTo(f.position);p.removedLength=Math.min(p.removedLength,m/2),f.removedLength=Math.min(f.removedLength,m/2)}}let l=[];for(let d=0;d<a;d++){let c=d,u=s&&d===n-1?0:d+1,p=o[c],f=o[u],m=null;if(!rm(i[c].data,i[u].data))p.position.distanceTo(f.position)>ov&&(m=new pu(p.position,p.controlNext,f.controlPrevious,f.position));else{let g=p.position.clone(),v=f.position.clone();(p.removedLength!==0||f.removedLength!==0)&&(p.nextDir&&g.add(p.nextDir.clone().setLength(p.removedLength)),f.prevDir&&v.add(f.prevDir.clone().setLength(f.removedLength))),g.distanceTo(v)>ov&&(m=new pu(g,g.clone().lerp(v,.3),v.clone().lerp(g,.3),v))}l[2*d+1]=m}for(let d=0;d<n;d++){let c=o[d];if(c.removedLength===0){l[2*d]=null;continue}let u=c.position,p=c.prevDir.clone().multiplyScalar(c.removedLength).add(u),f=c.nextDir.clone().multiplyScalar(c.removedLength).add(u),m=c.tan*c.removedLength,g=c.prevDir.clone().add(c.nextDir).normalize(),v=p.clone().lerp(f,.5),y=p.distanceTo(f)/2,x=g.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(y,2))).add(v),b=g.clone().multiplyScalar(-m).add(x),w=u.distanceTo(b)/u.distanceTo(v),A=c.prevDir.clone().multiplyScalar(w*u.distanceTo(p)).add(u),S=A.clone().lerp(b,2),_=p.clone().lerp(A,4/3),M=f.clone().lerp(S,4/3);l[2*d]=new pu(p,_,M,f)}let h=new FV;return l.forEach(d=>{d&&h.add(d)}),h}var ut;(e=>{function t(i){return i&&i.__isEntity}e.is=t})(ut||(ut={}));var va=e=>ut.is(e),VV={type:"completeState",isfromEntity:!0},jV=["x","y","z"],sm=new E,GV=new E().set(0,1,0),U0=e=>class extends k0(e){constructor(){super(...arguments),this.raycastLock=!1,this.scaleLock=!1,this.disposed=!1,this.stateSelection=null,this.destroyedInAction=!1,this.instances=[],this.prevState=null,this.currentState=null,this.reversibleToState=null,this.currentTransitionEvent=null,this.previousAction=null,this._singleBBox=new nw,this._recursiveBBox=new nw,this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this._needApplyPathSnapping=!0,this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(t){let i=this.children[t];if(ut.is(i))return i}entityChildrenCount(){let t=this.children.length;for(;t--;)if(ut.is(this.children[t]))return t+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let t=this;for(;t.data.type!=="Instance";){let i=t.parent;if(ut.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)Gn.toOps(this.data,s.data).forEach(a=>{let n=Sg.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(n,this.data,i)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Gn.patch(this.data,s),Gn.toOps(this.data,s).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,i)}))}r&&this.updateTransformState(this.dataPatched,i),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=>{va(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(ut.is(i[r]))return i[r];if(ut.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&ut.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)va(i)&&t(i)}traverseEntityAncestors(t){this.traverseAncestors(i=>{ut.is(i)&&t(i)})}traverseConcreteEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)va(r)&&r.isConcreteEntity&&r.traverseEntity(t,i+1)}traverseEntity(t,i=0){if(t(this,i)!==!0)for(let r of this.children)va(r)&&r.traverseEntity(t,i+1)}traverseVisibleEntity(t){t(this);for(let i of this.children)va(i)&&i.visible&&i.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(t){super.updateMatrixWorld(t),this.dispatchEvent({type:"updateMatrixWorld"})}copy(t,i=!1){return super.copy(t,i),this.dataPatched=t.dataPatched,this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),this}hasEntityChild(){return this.children.some(t=>va(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*Re.RAD2DEG,this.rotation.y*Re.RAD2DEG,this.rotation.z*Re.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return _g(i,t)}getTransformValues(t,i,r){return i[t].map((s,a)=>r?.shared.getVariable(s,[this.uuid,t,jV[a]])??s)}updateTransformState(t,i){let r=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,i)),r=!0),t.rotation&&(sm.fromArray(this.getTransformValues("rotation",t,i)).multiplyScalar(Re.DEG2RAD),this.rotation.setFromVector3(sm),r=!0),t.scale&&(this.scale.fromArray(this.getTransformValues("scale",t,i)),r=!0),t.hiddenMatrix!==void 0&&(r=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??Rl.identity)),r&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(s=>{s.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),r}onVariableUpdate(t=!1){if(t){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)ut.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{ut.is(t)&&t.disposeRecursively()})}toState(t=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return _g(i,t)}updateByObjUpdateOp(t,i){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},i,!1)}updateByOp(t,i,r,s){let a=this.data;this.data=i;let n=t,o=Gr(t.path,["states","*"]);if(o!==null){if(t.type===0){let[l]=o;if(this?.stateSelection===l){let h={...t.props};if(delete h.name,Object.values(t.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let c=Zi.zoom(d,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(h[u]=c[u])}}n={...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:d,...c}=l;l=c}if(t.props.material!==void 0&&"material"in l){let{material:d,...c}=l;l=c}let h=Zi.removeOverridden(t.path,t.props,l);n={...t,props:h}}}if(this.updateByPatchedOpBase(n,Gn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r),Gr(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 d of Object.keys(t.props)){l[l.length-1]=d;let c=r.scene.findInstance([this.uuid,...l]);c&&(c.overrideData=t.props[d],c.updateState(on.apply(c.component.data,c.overrideData),r))}}else{let d=r.scene.findInstance([this.uuid,...l]);if(d){let c=Zi.zoom(d.component.data,h);if(t={...t,path:h},t.type===0){let u=t.props;if(c)for(let[p,f]of Object.entries(t.props))f===void 0&&(u===t.props&&(u={...t.props}),u[p]=c[p]);t={...t,props:u}}d.overrideData=tp.resolve(i.overrides,l),d.updateByOp(t,ki.applySimple(d.data,t),r,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let h;for(let d of tn.rootOverrideProps)d in t.props&&(h===void 0&&(h={}),h[d]=t.props[d]);h&&(l={...t,props:h})}else for(let h of tn.rootOverrideProps)if(Gr(t.path,[h])){l=t;break}l!==void 0&&this.instances.forEach(h=>{if(h.isInstanceRoot){let d=on.filterOp(h.overrideData,l);d&&h.updateByOp(d,ki.applySimple(h.data,d),r,!0)}}),this.instances.forEach(h=>{if(!h.isInstanceRoot){let d=on.filterOp(h.overrideData,t);if(d){let c;a===h.data&&t===d?c=i:c=ki.applySimple(h.data,d),h.updateByOp(d,c,r,!0)}}})}}updateByPatchedOpBase(t,i,r){if(this.dataPatched=i,t.path.length===0&&t.type===0)t.props.type!==void 0&&!ao.is(t.props.type)&&rn.changeEntityProptotype(this,i,r);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){rn.changeEntityProptotype(this,i,r);for(let s of this.children)ut.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),Gr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(i.pathSnapping),Gr(t.path,["cloner"])!==null){let s=ki.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.dataPatched.pathSnapping){this._updatedPathSnapping=t,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(t){let i=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,r=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,a=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(i===null)return;let n=t.find(i);if(!n||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let o=n.data;if(o.geometry.path.points.length<=1)return;let l=k2(o.geometry.path),h=(r+s)%1;r+s===1&&h===0&&(h=1);let d=l.getPointAt(h),c=this.parent?this.parent?.matrixWorld:new me;n.updateMatrixWorld();let u=new me().multiplyMatrices(c.clone().invert(),n.matrixWorld);d.applyMatrix4(u);let p={position:d.toArray(),rotation:o.rotation};if(a==="tangential"){let f=new me().extractRotation(n.matrixWorld),m=l.getTangentAt(h).applyMatrix4(f).add(d),g=new me().lookAt(d,m,GV),v=sm.setFromEuler(new _i().setFromRotationMatrix(g)).multiplyScalar(Re.RAD2DEG);p={...p,rotation:v.toArray()}}this.updateTransformState(p),this.traverseEntity(f=>{f._cameraType&&f.dispatchEvent(VV)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}updateState_Entity(t,i){t.name!==void 0&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.visible!==void 0&&(this.updateVisible(),this.resetBBoxNeedsUpdate()),i&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,i),this.updateVisible()),this.updateTransformState(t,i)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof rn.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 rn.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)}},U2=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},e.parameters);i.thetaLength=Re.clamp(i.thetaLength,0,360);let r=i.width/2,s=i.radiusTop??r,a=i.radiusBottom??r;return s===a?(s=r,a=r):s>a?(s=r,a=a*r/s):(s=s*r/a,a=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:a})}}static build(e){let{width:t,depth:i,height:r,radialSegments:s,heightSegments:a,openEnded:n,thetaStart:o,thetaLength:l,radiusTop:h,radiusBottom:d,cornerRadius:c,cornerSegments:u,hollow:p}=e.parameters,f;return l===0?(f=new Ue,f.setAttribute("position",new Te([],3))):c||p?f=new F2(h,d,r,s,a,n,o,l*Math.PI/180,c,c,u,p):f=new i0(h,d,r,s,a,n,o,l*Math.PI/180),f.scale(1,1,i/t),Object.assign(f,{userData:{...e,type:"CylinderGeometry"}})}};function ka(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function ow(e){return new k(e.y,-e.x)}var F2=class extends Ue{constructor(e,t,i,r,s,a,n,o,l,h,d,c,u=!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,a=a!==void 0?a:!1,n=n!==void 0?n:0,o=o!==void 0?o:Math.PI*2,a&&(l=0,h=0);let p=[],f=[],m=[],g=[],v=0,y=i/2,x=new E,b=new E;u&&e==0&&(e=l),u&&t==0&&(t=h);let w=new k(e,y),A=new k(t,-y),S=null,_=null,M=null,C=null,T=w.clone().sub(A),D=0,P=0,O=0;c>0&&(D=Math.min(e,t)*(1-c),P=e-D,O=t-D);let B=w.clone();B.x-=D;let G=Math.PI-T.angle(),F=T.angle(),z=Math.tan(F/2),X=Math.tan(G/2),H=z+X,j=c?H:X,N=c?H:z;if(l=Math.min(l,(e-P)/j,T.length()/H),h=Math.min(h,(t-O)/N,T.length()/H),l>0){let Q=l/z;S=w.clone().sub(new k(Q,l)),c&&(M=S.clone(),M.x-=D-H*l),w.sub(T.clone().setLength(Q))}if(h>0){let Q=h/X;_=A.clone().sub(new k(Q,-h)),A.add(T.clone().setLength(Q)),c&&(C=_.clone(),C.x-=D-H*h,B.sub(T.clone().setLength(Q)))}T=w.clone().sub(A);let q=T.length()<.5,V=[];for(let Q=0;Q<=r;Q++){let re=[],Z=Q/r,pe=Z*o+n,oe=new k(Math.sin(pe),Math.cos(pe));C&&_?(W(re,Z,oe,G,h,C,-1,!0),W(re,Z,oe,F,h,_,-1,!1)):_?(U(re,oe,_.x,0,-1),W(re,Z,oe,F,h,_,-1,!1)):a||U(re,oe,t,O,-1);let ae=ow(T).normalize();if(ka(ae,oe,x),!q)for(let Me=0;Me<=s;Me++){let Ae=Me/s,Ee=T.clone().multiplyScalar(Ae).add(A);ka(Ee,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}if(M&&S?(W(re,Z,oe,G,l,S,1,!1),W(re,Z,oe,F,l,M,1,!0)):S?(W(re,Z,oe,G,l,S,1,!1),U(re,oe,S.x,0,1)):a||U(re,oe,e,P,1),c&&!q){let Me=ow(T).multiplyScalar(-1).normalize();ka(Me,oe,x);for(let Ae=0;Ae<=s;Ae++){let Ee=Ae/s,Ie=T.clone().multiplyScalar(-Ee).add(B);ka(Ie,oe,b),f.push(b.x,b.y,b.z),m.push(x.x,x.y,x.z),g.push(Z,.5+b.y/i),re.push(v++)}}c&&!a&&re.push(re[0]),V.push(re)}for(let Q=0;Q<V.length-1;Q++)for(let re=0;re<V[0].length-1;re++){if(a&&c&&re==s)continue;let Z=V[Q][re],pe=V[Q+1][re],oe=V[Q+1][re+1],ae=V[Q][re+1],Me=f[oe*3+0],Ae=f[oe*3+2];p.push(Z,pe,ae),(Me!=0||Ae!=0)&&p.push(pe,oe,ae)}o<Math.PI*2&&(ie(-1,V[0],n),ie(1,V[V.length-1],n+o)),this.setIndex(p),this.setAttribute("position",new Te(f,3)),this.setAttribute("normal",new Te(m,3)),this.setAttribute("uv",new Te(g,2));function W(Q,re,Z,pe,oe,ae,Me,Ae){for(let Ee=0;Ee<d+1;Ee++){let Ie=Ee/d,be=Me<0?Ie:1-Ie;Ae&&(be-=1),be*=pe;let ye=new k(Math.sin(be),Math.cos(be)*Me),Ne=ye.clone().multiplyScalar(oe).add(ae);ka(Ne,Z,b),f.push(b.x,b.y,b.z),ka(ye,Z,x),m.push(x.x,x.y,x.z),g.push(re,.5+b.y/i),Q.push(v++)}}function U(Q,re,Z,pe,oe){let ae=new E,Me=new k,Ae=[Z,pe];oe<0&&Ae.reverse();for(let Ee of Ae)Me.set(Ee,y*oe),ka(Me,re,ae),f.push(ae.x,ae.y,ae.z),m.push(0,oe,0),g.push(.5,.5),Q.push(v++)}function ie(Q,re,Z){let pe=new k(Math.sin(Z),Math.cos(Z)),oe=new k(-Math.cos(Z),Math.sin(Z)),ae=new E,Me=Q<0?(Ie,be,ye)=>p.push(Ie,be,ye):(Ie,be,ye)=>p.push(Ie,ye,be),Ae=new k((e+t+P+O)/4,0);ka(Ae,pe,ae),f.push(ae.x,ae.y,ae.z),m.push(oe.x,0,oe.y),g.push(.5,.5);let Ee=v++;for(let Ie of re){let be=f.slice(Ie*3,Ie*3+3);f.push(...be),m.push(oe.x,0,oe.y);let ye=g.slice(Ie*2,Ie*2+2);g.push(...ye),v++}for(let Ie=Ee+1;Ie<v-1;Ie++)Me(Ee,Ie,Ie+1);Me(Ee,v-1,Ee+1)}}},HV=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,360),{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:a,openEnded:n,thetaStart:o,thetaLength:l,cornerRadiusTop:h,cornerRadiusBottom:d,cornerSegments:c}=e.parameters,u;return l===0?(u=new Ue,u.setAttribute("position",new Te([],3))):h>0||d>0||l<360?u=new F2(0,t/2,r,s,a,n,o,l*Math.PI/180,h,d,c,0,!0):u=new QS(t/2,r,s,a,n),u.scale(1,1,i/t),Object.assign(u,{userData:{...e,type:"ConeGeometry"}})}},WV=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},e.parameters);return{parameters:Object.assign(i,{width:Math.abs(i.width),height:Math.abs(i.height??i.width),depth:Math.abs(i.depth??i.width)})}}static build(e){let{width:t,height:i,depth:r,widthSegments:s,heightSegments:a,depthSegments:n,cornerRadius:o,cornerSegments:l}=e.parameters,h;return o==0?h=new Hs(t,i,r,s,a,n):h=new qV(t,i,r,s,a,n,o,l),Object.assign(h,{userData:{...e,type:"CubeGeometry"}})}},am=Math.PI/2,qV=class extends Ue{constructor(e=1,t=1,i=1,r=1,s=1,a=1,n=0,o=4){super(),this.type="BoxGeometry";let l=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a),o=Math.floor(o),n=Math.min(n,e/2,t/2,i/2);let h=[],d=[],c=[],u=[],p=0,f=0;m("z","y","x",-1,-1,i,t,e,a,s,0),m("z","y","x",1,-1,i,t,-e,a,s,1),m("x","z","y",1,1,e,i,t,r,a,2),m("x","z","y",1,-1,e,i,-t,r,a,3),m("x","y","z",1,-1,e,t,i,r,s,4),m("x","y","z",-1,-1,e,t,-i,r,s,5),n>0&&(g("z","y","x",-1,-1,1,i,t,e,a,0),g("z","y","x",1,-1,-1,i,t,e,a,1),g("z","y","x",-1,1,-1,i,t,e,a,1),g("z","y","x",1,1,1,i,t,e,a,0),g("x","y","z",-1,-1,-1,e,t,i,r,0),g("x","y","z",1,-1,1,e,t,i,r,1),g("x","y","z",-1,1,1,e,t,i,r,0),g("x","y","z",1,1,-1,e,t,i,r,1),g("y","x","z",-1,-1,1,t,e,i,s,0),g("y","x","z",1,-1,-1,t,e,i,s,1),g("y","x","z",1,1,1,t,e,i,s,1),g("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 Te(d,3)),this.setAttribute("normal",new Te(c,3)),this.setAttribute("uv",new Te(u,2));function m(y,x,b,w,A,S,_,M,C,T,D){let P=(S-2*n)/C,O=(_-2*n)/T,B=S/2-n,G=_/2-n,F=M/2,z=C+1,X=T+1,H=0,j=0,N=new E;for(let q=0;q<X;q++){let V=q*O-G;for(let W=0;W<z;W++){let U=W*P-B;N[y]=U*w,N[x]=V*A,N[b]=F,d.push(N.x,N.y,N.z),N[y]=0,N[x]=0,N[b]=M>0?1:-1,c.push(N.x,N.y,N.z),u.push(W/C),u.push(1-q/T),H+=1}}for(let q=0;q<T;q++)for(let V=0;V<C;V++){let W=p+V+z*q,U=p+V+z*(q+1),ie=p+(V+1)+z*(q+1),Q=p+(V+1)+z*q;h.push(W,U,Q),h.push(U,ie,Q),j+=6}l.addGroup(f,j,D),f+=j,p+=H}function g(y,x,b,w,A,S,_,M,C,T,D){let P=(_-2*n)/T,O=_/2-n,B=M/2-n,G=C/2,F=T+1,z=0,X=0,H=new E,j=new E;for(let N=0;N<o+1;N++){let q=N/o*am,V=Math.sin(q)*n,W=(1-Math.cos(q))*n,U=Math.sin(q),ie=Math.cos(q);H[x]=(B+V)*A,H[b]=(G-W)*S,j[y]=0,j[x]=U*Math.sign(H[x]),j[b]=ie*Math.sign(H[b]);for(let Q=0;Q<F;Q++){let re=Q*P-O;H[y]=re*w,d.push(H.x,H.y,H.z),c.push(j.x,j.y,j.z),u.push(Q/T),u.push(0),z+=1}}for(let N=0;N<o;N++)for(let q=0;q<T;q++){let V=p+q+F*N,W=p+q+F*(N+1),U=p+(q+1)+F*(N+1),ie=p+(q+1)+F*N;h.push(V,W,ie),h.push(W,U,ie),X+=6}l.addGroup(f,X,D),f+=X,p+=z}function v(y,x,b){let w=new E,A=new E(e/2,t/2,i/2);A.subScalar(n);let S=[],_=y*x*b>0?(C,T,D)=>h.push(C,T,D):(C,T,D)=>h.push(C,D,T);for(let C=0;C<=o;C++){let T=[],D=am*(1-C/o),P=Math.cos(D),O=Math.sin(D),B=0;for(let G=0;G<=C;G++){let F=Math.cos(B),z=Math.sin(B);w.x=P*F,w.y=O,w.z=P*z;let X=A.clone().addScaledVector(w,n);d.push(y*X.x,x*X.y,b*X.z),c.push(y*w.x,x*w.y,b*w.z),u.push(0,0),T.push(p++),B+=am/C}S.push(T)}let M=S.length-1;for(let C=0;C<M;C++){let T=S[C],D=S[C+1],P=T.length-1;_(T[0],D[1],D[0]);for(let O=1;O<=P;O++)_(T[O-1],T[O],D[O]),_(T[O],D[O+1],D[O])}}}},F0=class extends Ue{constructor(e=[],t=[],i="",r=1,s=.2,a=4){super(),this.type="PolyhedronGeometryRound";let n=[],o=[],l=[];h(),d(),this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(l,3)),this.setAttribute("uv",new Te(o,2));return;function h(){s=Math.min(1-1e-5,s),s==0&&(a=0);let c={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[i],u=new E,p=u.clone(),f=new Ni,m=s*r,g=r-m,v=a+1,y=new E,x=(F,z)=>y.subVectors(F,z).normalize(),b=(F,z)=>Array(F).fill(void 0).map(z),w=b(e.length/3,(F,z)=>new E().fromArray(e,z*3).setLength(r)),A=[],S=1e6;for(let F=0;F<w.length;F++){let z=w[F],X=[],H,j,N,q=1e10,V=-1;for(;(V=t.indexOf(F,V+1))!=-1;){let Q=V-V%3;H=t[Q+(V+1)%3],j=t[Q+(V+2)%3],N=z.distanceToSquared(w[H]),q=Math.min(q,N),X.push([H,j,N])}q+=1e-6;let W=[],U=0,ie=X.length;for(let Q=0;Q<ie;Q++){[H,j,N]=X[U];let re=A[H]?.includes(F)==!0;N<=q&&W.push(H+ +re*S),U=X.findIndex(Z=>Z[0]==j)}A.push(W)}let _=[];{let F=0,z=0,X,H,j=c==3;for(let N=0;N<=a;N++){X=N*(N+1)/2,H=(N+1)*(N+2)/2;for(let q=0;q<a-N;q++)[F,z]=[X+q+N+2,H+q+N+3],_.push(X,H,...j?[z,X]:[F,H],z,F),[X,H]=[F,z];_.push(X,H,X+a+2)}}let M=u.clone(),C=u.clone(),T=u.clone(),D=u.clone(),P=u.clone(),O=[],B=b(w.length,()=>b(c,()=>u.clone()));for(let F=0;F<w.length;F++){u.copy(w[F]).normalize(),M.copy(u).multiplyScalar(g);let z=A[F];for(let W=0;W<z.length;W++){let U=z[W],ie=z[(W+1)%c];f.setFromPointsAndIndices(w,F,U%S,ie%S),f.b.sub(f.a).setLength(1e10).add(f.a),f.c.sub(f.a).setLength(1e10).add(f.a),f.closestPointToPoint(M,B[F][W])}let X=[],H=[],j=[],N=new E;a==0&&[...B[F]].reduce((W,U)=>W.add(U),N).multiplyScalar(1/c);for(let W=0;W<c;W++){let U=[],ie=(W-1+c)%c,Q=B[F][ie],re=B[F][W];u.copy(Q).sub(M),p.copy(re).sub(M);let Z=M.angleTo(u),pe=u.angleTo(p),oe=Math.cos(Z)*m;a==0?C.copy(N):C.copy(M).setLength(g+oe),H.push(oe);let ae=[C,Q,re];for(let Me=0;Me<2;Me++){let Ae=ae[Me],Ee=ae[Me+1];D.subVectors(Ae,M),P.subVectors(Ee,M),T.crossVectors(D,P).normalize();for(let Ie=0;Ie<v;Ie++){let be=[Z,pe][Me]*Ie/v;u.copy(D).applyAxisAngle(T,be).add(M),X.push(u.clone()),Me&&(x(u,M),U.push([Ie==0?Ae:u.clone(),y.clone()]))}Me&&(x(Ee,M),U.push([Ee,y.clone()]))}j.push(U)}O.push(j);let q=2*v,V=2;for(let W=0;W<c;W++){let U=q*W,ie=q*((W+1)%c),Q=[X[U]];for(let Z=1;Z<v;Z++){D=X[U+Z],P=X[ie+Z],Q.push(D);for(let pe=1,oe=Z-V+1;pe<=oe;pe++)u.lerpVectors(D,P,pe/(oe+1)),u.sub(M).setLength(H[W]).add(M),Q.push(u.clone());Q.push(P)}for(let Z=0;Z<v;Z++)Q.push(X[Z+v+U]);Q.push(X[ie+v]);let re=_.map(Z=>Q[Z]);n.push(...re.map(Z=>[Z.x,Z.y,Z.z]).flat()),l.push(...re.map(Z=>(x(Z,M),[y.x,y.y,y.z])).flat())}}let G=[];for(let F=0;F<A.length;F++)for(let z=0;z<c;z++){let X=A[F][z];if(X<S){let H=A[X].findIndex(q=>q%S==F),j=O[F][z],N=O[X][H];for(let q=0;q<v;q++){let V=j[q],W=N[v-q],U=j[q+1],ie=N[v-(q+1)];[V,W,U,U,W,ie].forEach(Q=>{n.push(Q[0].x,Q[0].y,Q[0].z),l.push(Q[1].x,Q[1].y,Q[1].z)})}G.push(j[0][0],N[v][0],j[v][0],N[0][0])}}for(;G.length;){let F,z,X,H;[F,z]=G.splice(0,2);let j=[F];for(;F!=z;)j.push(z),X=G.indexOf(z),H=X%2,z=G.splice(X-H,2)[1-H];y.subVectors(j[0],j[1]).cross(u.subVectors(j[0],j[2])).normalize();let N=y.dot(j[0])<0;N&&y.negate();for(let q=1;q<=j.length-2;q++)[j[q+ +N],j[q+1-+N],j[0]].forEach(V=>{n.push(V.x,V.y,V.z),l.push(y.x,y.y,y.z)})}}function d(){let c=new E;for(let A=0;A<n.length;A+=3){c.x=n[A+0],c.y=n[A+1],c.z=n[A+2];let S=b(c)/2/Math.PI+.5,_=w(c)/Math.PI+.5;o.push(S,1-_)}let u=new E,p=new E,f=new E,m=new E,g=new k,v=new k,y=new k,x=(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<n.length;A+=9,S+=6){u.set(n[A+0],n[A+1],n[A+2]),p.set(n[A+3],n[A+4],n[A+5]),f.set(n[A+6],n[A+7],n[A+8]),g.set(o[S+0],o[S+1]),v.set(o[S+2],o[S+3]),y.set(o[S+4],o[S+5]),m.copy(u).add(p).add(f).divideScalar(3);let _=b(m);x(g,S+0,u,_),x(v,S+2,p,_),x(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 b(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 F0(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}},XV=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new V2(t*.5,a,n):new ZS(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"DodecahedronGeometry"}})}},V2=class extends F0{constructor(e=1,t=.2,i=4){let r=(1+Math.sqrt(5))/2,s=1/r,a=[-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],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],o="DodecahedronGeometry";super(a,n,o,e,t,i),this.type=o}static fromJSON(e){return new V2(e.radius,e.corner,e.cornerSides)}},Ih=1e-12,V0=class{constructor(e){this.position=new k,this.startPosition=new k,this.uuid=Re.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 V0(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},hv=class extends V0{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new hv(this.parent).copy(this)}},bl=class extends V0{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new hv(this),new hv(this))}static create(e,t){let i=new bl(e,new k(...t.position));return i.controls[0].position.set(...t.controlPrevious.position),i.controls[1].position.set(...t.controlNext.position),i.roundness=t.roundness,i.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,i}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let i=0,r=this.controls.length;i<r;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new bl(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),t=this.curveAfter?.getTangentAt(0);return[e,t]}computeNormals(e=new k,t=new k){let[i,r]=this.computeTangents();return i&&r&&(lw(i,e),lw(r,t)),[e,t]}computeTangent(e=new k){let[t,i]=this.computeTangents();return t&&i&&e.copy(t).add(i).normalize(),e}computeNormal(e=new k){let[t,i]=this.computeNormals();return e.copy(t).add(i).normalize(),e}};function lw(e,t=new k){let i=e.length();return t.set(-e.y/i,e.x/i)}var j0=e=>e,ah=new k,Np=new k,YV=new k,QV=new k,ZV=new k,KV=new k,j2=new E,G2=new E;function JV(e){let t=new k;t.addVectors(e.v0,ah.subVectors(e.v1,e.v0).multiplyScalar(2/3));let i=new k;return i.addVectors(e.v2,Np.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new ls(e.v0,t,i,e.v2)}function Yh(e,t,i=Number.EPSILON){return Math.abs(e-t)<i}function $V(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function e8(e,t,i=Number.EPSILON){return e.distanceTo(t)<i}function H2(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)),a=Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2));return Math.acos((s*s+r*r-a*a)/(2*s*r))}function t8(e,t,i){return cw(e,t)&&cw(t,i)&&cv(e.position,t.position,i.position)}function cv(e,t,i){return ah.copy(t).sub(e).cross(Np.copy(i).sub(e))===0}function i8(e,t,i,r,s){let a=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=(e.y+t.y)/2,o=(e.x+t.x)/2,l=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(e.y-t.y)/a,h=Math.sqrt(Math.pow(i,2)-Math.pow(a/2,2))*(t.x-e.x)/a;return r.set(o+l,n+h),s.set(o-l,n-h),[r,s]}function r8(e,t,i){let r=e.distanceTo(i),s=t.distanceTo(i);return r<s?t:e}function s8(e,t,i,r,s,a){let n=t.x-e.x,o=t.y-e.y,l=i.x-e.x,h=i.y-e.y,d=Math.sqrt((n+l)*(n+l)+(o+h)*(o+h)),c;return H2(t,e,i)>Math.PI&&(d*=-1),Yh(h,o)?c=(o+h)*(r/d-.5)*8/3/(n-l):c=(n+l)*(r/d-.5)*8/3/(h-o),s.set(t.x-c*o,t.y+c*n),a.set(i.x+c*h,i.y-c*l),[s,a]}function hw(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function cw(e,t){return cv(e.position,e.controls[1].position,t.position)&&cv(e.position,t.controls[0].position,t.position)}function a8(e,t,i,r,s=.5){let a=ah.subVectors(t,e).multiplyScalar(s).add(e),n=Np.subVectors(i,t).multiplyScalar(s).add(t),o=YV.subVectors(r,i).multiplyScalar(s).add(i),l=a,h=QV.subVectors(n,a).multiplyScalar(s).add(a),d=ZV.subVectors(o,n).multiplyScalar(s).add(n),c=o,u=KV.subVectors(d,h).multiplyScalar(s).add(h);return[e.x,e.y,l.x,l.y,h.x,h.y,u.x,u.y,d.x,d.y,c.x,c.y,r.x,r.y]}function n8(e,t,i=12,r=!0){let s=G2.set(0,0,0),a,n=0,o=[];for(let l=0;l<t.length;l++){let h=j0(t[l]),d=ah,c=$n(h,i);o.push(c);for(let u=0;u<=c;u++)if(h instanceof ls||h instanceof un||h instanceof ps){if(h.getPoint(u/c,d),s.set(d.x,d.y,0),a!==void 0&&e8(a,s))continue;a===void 0&&(a=j2),a.copy(s),e.setXYZ(n,s.x,s.y,s.z),n++}}return r&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),e}function o8(e,t,i,r=12,s=!0){let a=G2.set(0,0,0),n=0,o=[];for(let l=0;l<t.length;l++){if(i[l]===!1)continue;let h,d=j0(t[l]),c=ah,u=$n(d,r);o.push(u);for(let p=0;p<=u;p++)if(d instanceof ls||d instanceof un||d instanceof ps){if(d.getPoint(p/u,c),a.set(c.x,c.y,0),h?.equals(a))continue;h===void 0?h=j2:(e.setXYZ(n,h.x,h.y,h.z),n++,e.setXYZ(n,a.x,a.y,a.z),n++),h.copy(a)}}return s&&n>1&&!(e.getX(n-1)===e.getX(0)&&e.getY(n-1)===e.getY(0)&&e.getZ(n-1)===e.getZ(0))&&(e.setXYZ(n,e.getX(0),e.getY(0),e.getZ(0)),n++),o}function dw(e,t=12,i=!1){let r=[];for(let s=0,a=e.length;s<a;s++){let n=e[s],o=0;if(i&&n.roundedCurveCorner!==void 0){let l=$n(n.roundedCurveCorner,t)*.5;s>0&&(r[s-1]+=l),o+=l}n.curveAfter!==void 0&&(o+=$n(n.curveAfter,t)),r.push(o)}return e.length>0&&i&&e[0].roundedCurveCorner!==void 0&&(r[e.length-1]+=$n(e[0].roundedCurveCorner,t)*.5),r}function $n(e,t=12){return e&&e instanceof wp?t*2:e&&(e instanceof ps||e instanceof qS)?1:e&&e instanceof t0?t*e.points.length:t}function l8(e,t,i=12,r=!0){let s,a=0;for(let n=0;n<t.length;n++){let o=j0(t[n]),l=$n(o,i),h=ah;for(let d=0;d<=l;d++)if(o instanceof ls||o instanceof un||o instanceof ps){if(o.getPoint(d/l,h),s!==void 0&&$V(s,h,Ih))continue;s===void 0&&(s=Np),s.copy(h),e.push(h.x,h.y),a++}}return Yh(e[0],e[e.length-2],Ih)&&Yh(e[1],e[e.length-1],Ih)&&(e.pop(),e.pop()),r&&a>1&&!(Yh(e[a-1],e[1],Ih)&&Yh(e[a-2],e[0],Ih))&&(e.push(e[0],e[1]),a++),e}var nm=new k,h8=new k,c8=new k,d8=new k,u8=new k,p8=new k,qt=class extends Ou{constructor(e=100,t=100){super(),this.points=[],this.shapeHoles=[],this.plane=new Er(new E(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this.isText=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=Re.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=t}static createFromState(e,t,i){let r=new qt;return r.isClosed=e.isClosed,r.points=e.points.map(s=>bl.create(s.id,s.data)),typeof e.roundness=="number"&&(r.roundness=e.roundness),r.shapeHoles=e.shapeHoles.map(s=>qt.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,a=this.shapeHoles.length;s<a;s++){let n=this.shapeHoles[s],o=n.points.length,l=n.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],a=e-t;if(a<=s.points.length-1)return s.points[a];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],a=s.points.indexOf(e);if(a>=0)return t+a;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=nm.set(e,t);for(let r=0,s=this.points.length;r<s;r++){let a=this.points[r];a.position.multiply(i),a.controls[0].position.multiply(i),a.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=Re.generateUUID()){let r;e instanceof k?r=e:r=new k(e,t);let s=new bl(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 n8(e,i?this.roundedCurves:this.curves,t,this.autoClose),r.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=dw(this.points,e,!1),this.roundedCurveDivisions=dw(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,i=12){return o8(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),l8(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=$n(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=r.reduce((n,o)=>n+o,0));for(let n=0,o=r.length;n<o;n++){let l=r[n];if(a<i+l)return[n,(a-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],a=this.curveDivisions,n=a[e];if(hw(r,s)){let l=r.position.distanceTo(s.position);return r.position.distanceTo(nm.set(i.x,i.y))/l}let o=0;for(let l=0;l<e;l++)o+=a[l];return(t-o)/n}dispose(){}_applyCurveForPoint(e,t){hw(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],a=this.points[i-1]??this.points[this.points.length-1],n=this.points[i+1]??this.points[0],o=s.roundness,l=a&&n&&t8(a,s,n);if(!s.controlsMoved()&&o>0&&!l){let h=s.curveBefore,d=s.curveAfter;if(h===void 0||d===void 0)continue;let c=s.roundedCurveBefore,u=s.roundedCurveAfter,p=h.getLength(),f=d.getLength(),m=Math.min(o,p*.499),g=Math.min(o,f*.499),v=Math.min(m,g),y=1-v/p,x=v/f,b=h.getPointAt(y,nm),w=d.getPointAt(x,h8);this._subSplitCurve(h,c,y,b,void 0),this._subSplitCurve(d,u,x,void 0,w);let A;if(this.useCubicForRoundedCorners){let S=H2(b,s.position,w)/2,_=Math.tan(S)*b.distanceTo(s.position),[M,C]=i8(b,w,_,c8,d8),T=r8(M,C,s.position),[D,P]=s8(T,b,w,_,u8,p8);A=new ls(b.clone(),D.clone(),P.clone(),w.clone())}else A=new un(b.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 ps)r!==void 0&&t.v2.copy(r),s!==void 0&&t.v1.copy(s);else{let a=e,n=t,o=a.getUtoTmapping(i,0),l=a8(a.v0,a.v1,a.v2,a.v3,o);return r!==void 0&&(n.v0.set(l[0],l[1]),n.v1.set(l[2],l[3]),n.v2.set(l[4],l[5]),n.v3.set(l[6],l[7])),s!==void 0&&(n.v0.set(l[6],l[7]),n.v1.set(l[8],l[9]),n.v2.set(l[10],l[11]),n.v3.set(l[12],l[13])),n}return t}clone(){let e=new qt(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],a=e.points[r+1],n=e.points[r+2],o=e.points[r+3],l=e.points[r+4],h=e.points[r+5],d=e.points[r+6],c=new bl(Re.generateUUID(),new k(s,a));c.controls[0].position.set(n,o),c.controls[1].position.set(l,h),c.roundness=d,this.points.push(c)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(i=>{let r=new qt;return r.fromJSON(i),r}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,t=!1){this.isText=t;let i=(s,a)=>{a instanceof ls&&a.v3.equals(s.position)&&s.controls[0].position.copy(a.v2)},r=s=>{let a=[],n,o;for(n=0,o=s.length;n<o;n++)s[n]instanceof un&&(s[n]=JV(s[n]));for(n=0,o=s.length;n<o;n++){let d=s[n],c=n>0?s[n-1]:null,u;d instanceof ls?(u=this.createPoint(d.v0),u.controls[1].position.copy(d.v1)):d instanceof ps&&(u=this.createPoint(d.v1)),u!==void 0&&(c!==null&&i(u,c),a.push(u))}let l=s[s.length-1],h=!1;return l instanceof ls?l.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(l.v2),h=!0):l instanceof ps&&l.v2.equals(a[0].position)&&(h=!0),this.isClosed=h,a};return this.points=r(e.curves),e instanceof Ou&&(this.shapeHoles=e.holes.map(s=>{let a=new qt;return a.fromShape(s),a})),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)}},dv=Math.PI*2;function om({x:e,y:t},i,r,s,a){return{x:e*i+s,y:t*r+a}}function f8(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),a=Math.cos(e+t),n=Math.sin(e+t);return[{x:r-s*i,y:s+r*i},{x:a+n*i,y:n-a*i},{x:a,y:n}]}function uw(e,t,i,r){let s=e*r-t*i<0?-1:1,a=Math.min(1,Math.max(-1,e*i+t*r));return s*Math.acos(a)}function m8(e,t,i,r,s,a,n,o,l,h){let d=Math.pow(s,2),c=Math.pow(a,2),u=Math.pow(n,2),p=Math.pow(o,2),f=d*c-d*p-c*u;f<0&&(f=0),f/=d*p+c*u,f=Math.sqrt(f)*(l===h?-1:1);let m=f*s/a*o,g=f*-a/s*n,v=m+(e+i)/2,y=g+(t+r)/2,x=(n-m)/s,b=(o-g)/a,w=(-n-m)/s,A=(-o-g)/a,S=uw(1,0,x,b),_=uw(x,b,w,A);return!h&&_>0&&(_-=dv),h&&_<0&&(_+=dv),{centerx:v,centery:y,ang1:S,ang2:_}}function g8({px:e,py:t,cx:i,cy:r,rx:s,ry:a,largeArcFlag:n,sweepFlag:o}){let l=[];if(s===0||a===0)return[];let h=(e-i)/2,d=(t-r)/2;if(h===0&&d===0)return[];s=Math.abs(s),a=Math.abs(a);let c=Math.pow(h,2)/Math.pow(s,2)+Math.pow(d,2)/Math.pow(a,2);c>1&&(s*=Math.sqrt(c),a*=Math.sqrt(c));let u=m8(e,t,i,r,s,a,h,d,n,o),{ang1:p,ang2:f}=u,{centerx:m,centery:g}=u,v=Math.abs(f)/(dv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);f/=y;for(let x=0;x<y;x++)l.push(f8(p,f)),p+=f;return l.map(x=>{let{x:b,y:w}=om(x[0],s,a,m,g),{x:A,y:S}=om(x[1],s,a,m,g),{x:_,y:M}=om(x[2],s,a,m,g);return{x1:b,y1:w,x2:A,y2:S,x:_,y:M}})}var Et;(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"})(Et||(Et={}));var ai;(function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ai||(ai={}));function Ye(e,t){if(!e)throw t||"Assertion Failed!"}var Fe=function(){function e(){}return e.vertEq=function(t,i){return t.s===i.s&&t.t===i.t},e.vertLeq=function(t,i){return t.s<i.s||t.s===i.s&&t.t<=i.t},e.transLeq=function(t,i){return t.t<i.t||t.t===i.t&&t.s<=i.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(t,i){return Math.abs(t.s-i.s)+Math.abs(t.t-i.t)},e.edgeEval=function(t,i,r){Ye(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?s<a?i.t-t.t+(t.t-r.t)*(s/(s+a)):i.t-r.t+(r.t-t.t)*(a/(s+a)):0},e.edgeSign=function(t,i,r){Ye(e.vertLeq(t,i)&&e.vertLeq(i,r));var s=i.s-t.s,a=r.s-i.s;return s+a>0?(i.t-r.t)*s+(i.t-t.t)*a:0},e.transEval=function(t,i,r){Ye(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?s<a?i.s-t.s+(t.s-r.s)*(s/(s+a)):i.s-r.s+(r.s-t.s)*(a/(s+a)):0},e.transSign=function(t,i,r){Ye(e.transLeq(t,i)&&e.transLeq(i,r));var s=i.t-t.t,a=r.t-i.t;return s+a>0?(i.s-r.s)*s+(i.s-t.s)*a: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,a){var n,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)?(n=e.edgeEval(t,r,i),o=e.edgeEval(r,i,s),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,i.s)):(n=e.edgeSign(t,r,i),o=-e.edgeSign(t,s,i),n+o<0&&(n=-n,o=-o),a.s=e.interpolate(n,r.s,o,s.s)):a.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)?(n=e.transEval(t,r,i),o=e.transEval(r,i,s),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,i.t)):(n=e.transSign(t,r,i),o=-e.transSign(t,s,i),n+o<0&&(n=-n,o=-o),a.t=e.interpolate(n,r.t,o,s.t)):a.t=(r.t+i.t)/2},e}(),Oh=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}(),Ud=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}(),$o=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}(),pw=function(){function e(){var t=new $o,i=new Oh,r=new Ud(0),s=new Ud(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 Ud(0),r=new Ud(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;Ye(s,"Vertex can't be null!");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i;var n=i;do n.Org=s,n=n.Onext;while(n!==i)},e.prototype.makeFace_=function(t,i,r){var s=t;Ye(s,"Face can't be null");var a=r.prev;s.prev=a,a.next=s,s.next=r,r.prev=s,s.anEdge=i,s.trail=null,s.marked=!1,s.inside=r.inside;var n=i;do n.Lface=s,n=n.Lnext;while(n!==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 a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.killFace_=function(t,i){var r=t.anEdge,s=r;do s.Lface=i,s=s.Lnext;while(s!==r);var a=t.prev,n=t.next;n.prev=a,a.next=n},e.prototype.makeEdge=function(){var t=new $o,i=new $o,r=new Oh,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 a=new $o;this.makeVertex_(a,i,t.Org),t.Org.anEdge=t}if(!r){var n=new Oh;this.makeFace_(n,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 Oh;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 $o;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),a=s.Sym;if(i.Lface!==t.Lface&&(r=!0,this.killFace_(i.Lface,t.Lface)),this.splice_(s,t.Lnext),this.splice_(a,i),s.Org=t.Dst,a.Org=i.Org,s.Lface=a.Lface=t.Lface,t.Lface.anEdge=a,!r){var n=new Oh;this.makeFace_(n,s,t.Lface)}return s},e.prototype.zapFace=function(t){var i=t.anEdge,r,s,a,n,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)),a=r.Sym,a.Onext===a?this.killVertex_(a.Org,null):(a.Org.anEdge=a.Onext,this.splice_(a,a.Oprev)),this.killEdge_(r));while(r!=i);n=t.prev,o=t.next,o.prev=n,n.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,a,n,o,l;for(i=this.fHead.next;i!==this.fHead;i=i.next)if(i.inside)for(r=i.anEdge,n=r.Org;s=r.Lnext,a=r.Sym,a&&a.Lface&&a.Lface.inside&&(o=this.countFaceVerts_(i),l=this.countFaceVerts_(a.Lface),o+l-2<=t&&Fe.vertCCW(r.Lprev.Org,r.Org,a.Lnext.Lnext.Org)&&Fe.vertCCW(a.Lprev.Org,a.Org,r.Lnext.Lnext.Org)&&(s=a.Lnext,this.delete(a),r=null,a=null)),!(r&&r.Lnext.Org===n);)r=s;return!0},e.prototype.check=function(){var t=this.fHead,i=this.vHead,r=this.eHead,s,a,n,o,l,h;for(a=t,a=t;(s=a.next)!==t;a=s){Ye(s.prev===a),l=s.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Lface===s),l=l.Lnext;while(l!==s.anEdge)}for(Ye(s.prev===a&&s.anEdge===null),o=i,o=i;(n=o.next)!==i;o=n){Ye(n.prev===o),l=n.anEdge;do Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l),Ye(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(Ye(n.prev===o&&n.anEdge===null),h=r,h=r;(l=h.next)!==r;h=l)Ye(l.Sym.next===h.Sym),Ye(l.Sym!==l),Ye(l.Sym.Sym===l),Ye(l.Org!==null),Ye(l.Dst!==null),Ye(l.Lnext.Onext.Sym===l),Ye(l.Onext.Sym.Lnext===l);Ye(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}(),fw=function(){function e(){this.handle=null}return e}(),mw=function(){function e(){this.key=null,this.node=0}return e}(),v8=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 fw,this.handles[r]=new mw;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,a,n;for(s=i[t].handle;;){if(n=t<<1,n<this.size&&this.leq(r[i[n+1].handle].key,r[i[n].handle].key)&&++n,Ye(n<=this.max),a=i[n].handle,n>this.size||this.leq(r[s].key,r[a].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},e.prototype.floatUp_=function(t){var i=this.nodes,r=this.handles,s,a,n;for(s=i[t].handle;;){if(n=t>>1,a=i[n].handle,n===0||this.leq(r[a].key,r[s].key)){i[t].handle=s,r[s].node=t;break}i[t].handle=a,r[a].node=t,t=n}},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,a;for(a=this.nodes.length,this.nodes.length=this.max+1,s=a;s<this.nodes.length;s++)this.nodes[s]=new fw;for(a=this.handles.length,this.handles.length=this.max+1,s=a;s<this.handles.length;s++)this.handles[s]=new mw}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;Ye(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}(),lm=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}(),gw=function(){function e(){this.key=null,this.next=null,this.prev=null}return e}(),y8=function(){function e(t,i){this.frame=t,this.leq=i,this.head=new gw,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 gw;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}(),x8=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,a=i.eUp,n=r.eUp;if(a.Dst===s)return n.Dst===s?Fe.vertLeq(a.Org,n.Org)?Fe.edgeSign(n.Dst,a.Org,n.Org)<=0:Fe.edgeSign(a.Dst,n.Org,a.Org)>=0:Fe.edgeSign(n.Dst,s,n.Org)<=0;if(n.Dst===s)return Fe.edgeSign(a.Dst,s,a.Org)>=0;var o=Fe.edgeEval(a.Dst,s,a.Org),l=Fe.edgeEval(n.Dst,s,n.Org);return o>=l},e.deleteRegion=function(t,i){i.fixUpperEdge&&Ye(i.eUp.winding===0),i.eUp.activeRegion=null,t.dict.delete(i.nodeUp)},e.fixUpperEdge=function(t,i,r){Ye(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 lm;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 Et.ODD:return(i&1)!==0;case Et.NONZERO:return i!==0;case Et.POSITIVE:return i>0;case Et.NEGATIVE:return i<0;case Et.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,a=null,n=i,o=i.eUp;n!==r;){if(n.fixUpperEdge=!1,a=e.regionBelow(n),s=a.eUp,s.Org!=o.Org){if(!a.fixUpperEdge){e.finishRegion(t,n);break}s=t.mesh.connect(o.Lprev,s.Sym),e.fixUpperEdge(t,a,s)}o.Onext!==s&&(t.mesh.splice(s.Oprev,s),t.mesh.splice(o,s)),e.finishRegion(t,n),o=a.eUp,n=a}return o},e.addRightEdges=function(t,i,r,s,a,n){var o,l,h,d,c=!0;h=r;do Ye(Fe.vertLeq(h.Org,h.Dst)),e.addRegionBelow(t,i,h.Sym),h=h.Onext;while(h!==s);for(a===null&&(a=e.regionBelow(i).eUp.Rprev),l=i,d=a;o=e.regionBelow(l),h=o.eUp.Sym,h.Org===d.Org;)h.Onext!==d&&(t.mesh.splice(h.Oprev,h),t.mesh.splice(d.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,d),e.deleteRegion(t,l),t.mesh.delete(d)),c=!1,l=o,d=h;l.dirty=!0,Ye(l.windingNumber-h.winding===o.windingNumber),n&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(t,i,r){t.mesh.splice(i,r)},e.vertexWeights=function(t,i,r){var s=Fe.vertL1dist(i,t),a=Fe.vertL1dist(r,t),n=.5*a/(s+a),o=.5*s/(s+a);t.coords[0]+=n*i.coords[0]+o*r.coords[0],t.coords[1]+=n*i.coords[1]+o*r.coords[1],t.coords[2]+=n*i.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,i,r,s,a,n){i.coords[0]=i.coords[1]=i.coords[2]=0,i.idx=-1,e.vertexWeights(i,r,s),e.vertexWeights(i,a,n)},e.checkForRightSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp;if(Fe.vertLeq(s.Org,a.Org)){if(Fe.edgeSign(a.Dst,s.Org,a.Org)>0)return!1;Fe.vertEq(s.Org,a.Org)?s.Org!==a.Org&&(t.pq.delete(s.Org.pqHandle),e.spliceMergeVertices(t,a.Oprev,s)):(t.mesh.splitEdge(a.Sym),t.mesh.splice(s,a.Oprev),i.dirty=r.dirty=!0)}else{if(Fe.edgeSign(s.Dst,a.Org,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),t.mesh.splice(a.Oprev,s)}return!0},e.checkForLeftSplice=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n;if(Ye(!Fe.vertEq(s.Dst,a.Dst)),Fe.vertLeq(s.Dst,a.Dst)){if(Fe.edgeSign(s.Dst,a.Dst,s.Org)<0)return!1;e.regionAbove(i).dirty=i.dirty=!0,n=t.mesh.splitEdge(s),t.mesh.splice(a.Sym,n),n.Lface.inside=i.inside}else{if(Fe.edgeSign(a.Dst,s.Dst,a.Org)>0)return!1;i.dirty=r.dirty=!0,n=t.mesh.splitEdge(a),t.mesh.splice(s.Lnext,a.Sym),n.Rface.inside=i.inside}return!0},e.checkForIntersect=function(t,i){var r=e.regionBelow(i),s=i.eUp,a=r.eUp,n=s.Org,o=a.Org,l=s.Dst,h=a.Dst,d,c,u=new $o,p,f;if(Ye(!Fe.vertEq(h,l)),Ye(Fe.edgeSign(l,t.event,n)<=0),Ye(Fe.edgeSign(h,t.event,o)>=0),Ye(n!==t.event&&o!==t.event),Ye(!i.fixUpperEdge&&!r.fixUpperEdge),n===o||(d=Math.min(n.t,l.t),c=Math.max(o.t,h.t),d>c))return!1;if(Fe.vertLeq(n,o)){if(Fe.edgeSign(h,n,o)>0)return!1}else if(Fe.edgeSign(l,o,n)<0)return!1;return e.debugEvent(t),Fe.intersect(l,n,h,o,u),Ye(Math.min(n.t,l.t)<=u.t),Ye(u.t<=Math.max(o.t,h.t)),Ye(Math.min(h.s,l.s)<=u.s),Ye(u.s<=Math.max(o.s,n.s)),Fe.vertLeq(u,t.event)&&(u.s=t.event.s,u.t=t.event.t),p=Fe.vertLeq(n,o)?n:o,Fe.vertLeq(p,u)&&(u.s=p.s,u.t=p.t),Fe.vertEq(u,n)||Fe.vertEq(u,o)?(e.checkForRightSplice(t,i),!1):!Fe.vertEq(l,t.event)&&Fe.edgeSign(l,t.event,u)>=0||!Fe.vertEq(h,t.event)&&Fe.edgeSign(h,t.event,u)<=0?h===t.event?(t.mesh.splitEdge(s.Sym),t.mesh.splice(a.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(a.Sym),t.mesh.splice(s.Lnext,a.Oprev),r=i,i=e.topRightRegion(i),f=e.regionBelow(i).eUp.Rprev,r.eUp=a.Oprev,a=e.finishLeftRegions(t,r,null),e.addRightEdges(t,i,a.Onext,s.Rprev,f,!0),!0):(Fe.edgeSign(l,t.event,u)>=0&&(e.regionAbove(i).dirty=i.dirty=!0,t.mesh.splitEdge(s.Sym),s.Org.s=t.event.s,s.Org.t=t.event.t),Fe.edgeSign(h,t.event,u)<=0&&(i.dirty=r.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(s.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,s),s.Org.s=u.s,s.Org.t=u.t,s.Org.pqHandle=t.pq.insert(s.Org),e.getIntersectData(t,s.Org,n,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,a;;){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,a=r.eUp,s.Dst!==a.Dst&&e.checkForLeftSplice(t,i)&&(r.fixUpperEdge?(e.deleteRegion(t,r),t.mesh.delete(a),r=e.regionBelow(i),a=r.eUp):i.fixUpperEdge&&(e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r),s=i.eUp)),s.Org!==a.Org)if(s.Dst!==a.Dst&&!i.fixUpperEdge&&!r.fixUpperEdge&&(s.Dst===t.event||a.Dst===t.event)){if(e.checkForIntersect(t,i))return}else e.checkForRightSplice(t,i);s.Org===a.Org&&s.Dst===a.Dst&&(e.addWinding(a,s),e.deleteRegion(t,i),t.mesh.delete(s),i=e.regionAbove(r))}},e.connectRightVertex=function(t,i,r){var s,a=r.Onext,n=e.regionBelow(i),o=i.eUp,l=n.eUp,h=!1;if(o.Dst!==l.Dst&&e.checkForIntersect(t,i),Fe.vertEq(o.Org,t.event)&&(t.mesh.splice(a.Oprev,o),i=e.topLeftRegion(t,i),a=e.regionBelow(i).eUp,e.finishLeftRegions(t,e.regionBelow(i),n),h=!0),Fe.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=e.finishLeftRegions(t,n,null),h=!0),h){e.addRightEdges(t,i,r.Onext,a,a,!0);return}Fe.vertLeq(l.Org,o.Org)?s=l.Oprev:s=o,s=t.mesh.connect(r.Lprev,s),e.addRightEdges(t,i,s,s.Onext,s.Onext,!1),s.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,i)},e.connectLeftDegenerate=function(t,i,r){var s,a,n,o,l;if(s=i.eUp,Fe.vertEq(s.Org,r)){Ye(!1),e.spliceMergeVertices(t,s,r.anEdge);return}if(!Fe.vertEq(s.Dst,r)){t.mesh.splitEdge(s.Sym),i.fixUpperEdge&&(t.mesh.delete(s.Onext),i.fixUpperEdge=!1),t.mesh.splice(r.anEdge,s),e.sweepEvent(t,r);return}Ye(!1),i=e.topRightRegion(i),l=e.regionBelow(i),n=l.eUp.Sym,a=o=n.Onext,l.fixUpperEdge&&(Ye(a!==n),e.deleteRegion(t,l),t.mesh.delete(n),n=a.Oprev),t.mesh.splice(r.anEdge,n),Fe.edgeGoesLeft(a)||(a=null),e.addRightEdges(t,i,n.Onext,o,a,!0)},e.connectLeftVertex=function(t,i){var r,s,a,n,o,l,h=new lm;if(h.eUp=i.anEdge.Sym,r=t.dict.search(h).key,s=e.regionBelow(r),!!s){if(n=r.eUp,o=s.eUp,Fe.edgeSign(n.Dst,i,n.Org)===0){e.connectLeftDegenerate(t,r,i);return}if(a=Fe.vertLeq(o.Dst,n.Dst)?r:s,r.inside||a.fixUpperEdge){if(a===r)l=t.mesh.connect(i.anEdge.Sym,n.Lnext);else{var d=t.mesh.connect(o.Dnext,i.anEdge);l=d.Sym}a.fixUpperEdge?e.fixUpperEdge(t,a,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);Ye(s!==null);var a=e.regionBelow(s),n=a.eUp,o=e.finishLeftRegions(t,a,null);o.Onext===n?e.connectRightVertex(t,s,o):e.addRightEdges(t,s,o.Onext,n,n,!0)},e.addSentinel=function(t,i,r,s){var a=new lm,n=t.mesh.makeEdge();n.Org.s=r,n.Org.t=s,n.Dst.s=i,n.Dst.t=s,t.event=n.Dst,a.eUp=n,a.windingNumber=0,a.inside=!1,a.fixUpperEdge=!1,a.sentinel=!0,a.dirty=!1,a.nodeUp=t.dict.insert(a)},e.initEdgeDict=function(t){t.dict=new y8(t,e.edgeLeq);var i=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],s=t.bmin[0]-i,a=t.bmax[0]+i,n=t.bmin[1]-r,o=t.bmax[1]+r;e.addSentinel(t,s,a,n),e.addSentinel(t,s,a,o)},e.doneEdgeDict=function(t){for(var i,r=0;(i=t.dict.min().key)!==null;)i.sentinel||(Ye(i.fixUpperEdge),Ye(++r===1)),Ye(i.windingNumber===0),e.deleteRegion(t,i)},e.removeDegenerateEdges=function(t){var i,r,s,a=t.mesh.eHead;for(i=a.next;i!==a;i=r)r=i.next,s=i.Lnext,Fe.vertEq(i.Org,i.Dst)&&i.Lnext.Lnext!==i&&(e.spliceMergeVertices(t,s,i),t.mesh.delete(i),i=s,s=i.Lnext),s.Lnext===i&&(s!==i&&((s===r||s===r.Sym)&&(r=r.next),t.mesh.delete(s)),(i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i))},e.initPriorityQ=function(t){var i,r,s,a=0;for(s=t.mesh.vHead,r=s.next;r!==s;r=r.next)a++;for(a+=8,i=t.pq=new v8(a,Fe.vertLeq),s=t.mesh.vHead,r=s.next;r!==s;r=r.next)r.pqHandle=i.insert(r);return r!==s?!1:(i.init(),!0)},e.donePriorityQ=function(t){t.pq=null},e.removeDegenerateFaces=function(t,i){var r,s,a;for(r=i.fHead.next;r!==i.fHead;r=s)s=r.next,a=r.anEdge,Ye(a.Lnext!==a),a.Lnext.Lnext===a&&(e.addWinding(a.Onext,a),t.mesh.delete(a));return!0},e.computeInterior=function(t,i){i===void 0&&(i=!0);var r,s;if(e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;s=t.pq.min(),!(s===null||!Fe.vertEq(s,r));)s=t.pq.extractMin(),e.spliceMergeVertices(t,r.anEdge,s.anEdge);e.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),e.removeDegenerateFaces(t,t.mesh)?(i&&t.mesh.check(),!0):!1},e}(),b8=function(){function e(){this.mesh=new pw,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=Et.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,a,n,o,l=[0,0,0],h=[0,0,0],d=[0,0,0],c=[0,0,0],u=[0,0,0],p=[null,null,null],f=[null,null,null],m=this.mesh.vHead;i=m.next;for(var g=0;g<3;++g)a=i.coords[g],h[g]=a,f[g]=i,l[g]=a,p[g]=i;for(i=m.next;i!==m;i=i.next)for(var v=0;v<3;++v)a=i.coords[v],a<h[v]&&(h[v]=a,f[v]=i),a>l[v]&&(l[v]=a,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],d[0]=r.coords[0]-s.coords[0],d[1]=r.coords[1]-s.coords[1],d[2]=r.coords[2]-s.coords[2],i=m.next;i!==m;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],u[0]=d[1]*c[2]-d[2]*c[1],u[1]=d[2]*c[0]-d[0]*c[2],u[2]=d[0]*c[1]-d[1]*c[0],n=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],n>o&&(o=n,t[0]=u[0],t[1]=u[1],t[2]=u[2]);o<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(d)]=1)},e.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,i,r=this.mesh.vHead,s,a=0,n=t.next;n!==t;n=n.next)if(s=n.anEdge,!(s.winding<=0))do a+=(s.Org.s-s.Dst.s)*(s.Org.t+s.Dst.t),s=s.Lnext;while(s!==n.anEdge);if(a<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,a=!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),a=!0),r=this.sUnit,s=this.tUnit;var n=this.longAxis_(i);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,s[n]=0,s[(n+1)%3]=0,s[(n+2)%3]=i[n]>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);a&&this.checkOrientation_();for(var l=!0,h=t.next;h!==t;h=h.next)l?(this.bmin[0]=this.bmax[0]=h.s,this.bmin[1]=this.bmax[1]=h.t,l=!1):(h.s<this.bmin[0]&&(this.bmin[0]=h.s),h.s>this.bmax[0]&&(this.bmax[0]=h.s),h.t<this.bmin[1]&&(this.bmin[1]=h.t),h.t>this.bmax[1]&&(this.bmax[1]=h.t))},e.prototype.addWinding_=function(t,i){t.winding+=i.winding,t.Sym.winding+=i.Sym.winding},e.prototype.tessellateMonoRegion_=function(t,i){var r,s;if(r=i.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Fe.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Fe.vertLeq(r.Org,r.Dst);r=r.Lnext);s=r.Lprev;for(var a=void 0;r.Lnext!==s;)if(Fe.vertLeq(r.Dst,s.Org)){for(;s.Lnext!==r&&(Fe.edgeGoesLeft(s.Lnext)||Fe.edgeSign(s.Org,s.Dst,s.Lnext.Dst)<=0);)a=t.connect(s.Lnext,s),s=a.Sym;s=s.Lprev}else{for(;s.Lnext!==r&&(Fe.edgeGoesRight(r.Lprev)||Fe.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)a=t.connect(r,r.Lprev),r=a.Sym;r=r.Lnext}if(s.Lnext===r)throw"Mono region invalid";for(;s.Lnext.Lnext!==r;)a=t.connect(s.Lnext,s),s=a.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,a=t.eHead.next;a!==t.eHead;a=s)s=a.next,a.Rface.inside!==a.Lface.inside?a.winding=a.Lface.inside?i:-i:r?t.delete(a):a.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 a,n=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 d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){a=d.anEdge,l=0;do{var h=a.Org;h.n===-1&&(h.n=o,o++),l++,a=a.Lnext}while(a!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=n,++n}this.elementCount=n,i===ai.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*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 u=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(d.inside){a=d.anEdge,l=0;do{var h=a.Org;this.elements[u++]=h.n,l++,a=a.Lnext}while(a!==d.anEdge);for(var p=l;p<r;++p)this.elements[u++]=-1;if(i===ai.CONNECTED_POLYGONS){a=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(a),a=a.Lnext;while(a!==d.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1}}},e.prototype.outputContours_=function(t,i){var r,s,a=0,n=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,d=0;a=0;for(var o=t.fHead.next;o!==t.fHead;o=o.next)if(o.inside){n=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,n++,r=r.Lnext;while(r!==s);this.elements[d++]=a,this.elements[d++]=n,a+=n}},e.prototype.addContour=function(t,i){this.mesh===null&&(this.mesh=new pw),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,a,n){if(t===void 0&&(t=Et.ODD),i===void 0&&(i=ai.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,a&&(this.normal[0]=a[0],this.normal[1]=a[1],this.normal[2]=a[2]),this.windingRule=t,s<2&&(s=2),s>3&&(s=3),!this.mesh)return!1;this.projectPolygon_(),x8.computeInterior(this,n);var o=this.mesh;return i===ai.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),n&&o.check(),i===ai.BOUNDARY_CONTOURS?this.outputContours_(o,s):this.outputPolymesh_(o,i,r,s),!0},e}();function sn(e){var t=e.windingRule,i=t===void 0?Et.ODD:t,r=e.elementType,s=r===void 0?ai.POLYGONS:r,a=e.polySize,n=a===void 0?3:a,o=e.vertexSize,l=o===void 0?2:o,h=e.normal,d=h===void 0?[0,0,1]:h,c=e.contours,u=c===void 0?[]:c,p=e.strict,f=p===void 0?!0:p,m=e.debug,g=m===void 0?!1:m;if(!u&&f)throw new Error("Contours can't be empty");if(u){var v=new b8;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<u.length;y++)v.addContour(l||2,u[y]);return v.tesselate(i,s,n,l,d,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var OY=Et.ODD,LY=Et.NONZERO,RY=Et.POSITIVE,BY=Et.NEGATIVE,zY=Et.ABS_GEQ_TWO,NY=ai.POLYGONS,kY=ai.CONNECTED_POLYGONS,UY=ai.BOUNDARY_CONTOURS,uv=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*uv.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*uv.eSize,r=new ArrayBuffer(i),s=Float32Array.BYTES_PER_ELEMENT,a=0,n=new Float32Array(r,a*s,3*e);a+=3*e;let o=new Float32Array(r,a*s,3*e);a+=3*e;let l=new Float32Array(r,a*s,2*e);t?(n.set(this.positions.subarray(0,this.size*3)),o.set(this.normals.subarray(0,this.size*3)),l.set(this.uvs.subarray(0,this.size*2))):(n.set(this.positions),o.set(this.normals),l.set(this.uvs)),this.buffer=r,this.positions=n,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)}},W2=uv;W2.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var w8=gn(VC()),G0={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},q2={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},X2={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},hm=(e,t)=>([i,r])=>(r<i&&(r+=t),(e>=i?e:e+t)<=r),H0=class extends Ue{constructor(e,t,i=0,r=12,s=3,a=Et.ODD,n=!1){super(),this.forPathBevel=n,this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=t,this._curveSegments=r,this._bevelSegmentsInput=s;let o=this._shape.extractShapePointsToFlatArray([],r),l=this._shape.shapeHoles.map(M=>{let C=M.extractShapePointsToFlatArray([],r),T=[];for(let D=C.length-1;D>=1;D-=2){let P=C[D-1],O=C[D-0];T.push(P,O)}return T}),h=[],d=[];for(let M=0;M<o.length;M+=2)d.push([o[M],o[M+1]]);h.push(d);for(let M=0;M<l.length;M++){let C=l[M],T=[];for(let D=0;D<C.length;D+=2)T.push([C[D],C[D+1]]);h.push(T)}let c;e.isText?c=new cA().setFromPoints(e.points.map(M=>M.position)).getSize(new k).length()*.1:h[0].length===0?c=i:c=(0,w8.default)(h).distance,i<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(i,c,t/2),this._bevelSegments=Math.floor(s));let u;try{u=sn({windingRule:a,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{u=G0}let p;try{p=sn({windingRule:Et.ODD,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{p=q2}if(!u)throw new Error("error generating geometry");let f=u.elementCount;if(p){u.elementCount+=p.elementCount;for(let M=0;M<p.elements.length;M++){let C=p.elements[M],T=M%2===0?u.vertexCount:0;u.elements.push(C+T)}for(let M=0;M<p.vertexIndices.length;M++){let C=p.vertexIndices[M],T=u.vertexCount;u.vertexIndices.push(C+T)}for(let M=0;M<p.vertices.length;M++){let C=p.vertices[M];u.vertices.push(C)}}let m=1/0,g=-1/0,v=1/0,y=-1/0;for(let M=0,C=u.vertexCount;M<C;M++){let T=M*2,D=u.vertices[T+0],P=u.vertices[T+1];D<m&&(m=D),D>g&&(g=D),P<v&&(v=P),P>y&&(y=P)}this._minX=m,this._minY=v,this._width=g-m,this._height=y-v,this._buffer=new W2(this._computeBufferEstimatedSize(u));let x=[],b=[];for(let M=u.elementCount-1;M>=0;M--){let C=M>=f,T=M*2,D=u.elements[T+0],P=u.elements[T+1],O=D+P,B={start:D,count:P,normals:[],continuous:[],concave:[]},G=D,F=O-1,z=D+1,X=this._shape.roundedCurves.length;do{let V=G-D,W=u.vertices[F*2+0],U=u.vertices[F*2+1],ie=u.vertices[G*2+0],Q=u.vertices[G*2+1],re=u.vertices[z*2+0],Z=u.vertices[z*2+1],pe=ie-W,oe=Q-U,ae=Math.sqrt(pe*pe+oe*oe);pe/=ae,oe/=ae;let Me=ie-re,Ae=Q-Z,Ee=Math.sqrt(Me*Me+Ae*Ae);Me/=Ee,Ae/=Ee,B.normals[V*2+0]=-Ae,B.normals[V*2+1]=Me,B.concave[V]=pe*Ae-oe*Me>0;let Ie=u.vertexIndices[G];if(Array.isArray(Ie))B.continuous[V]=!1;else{let[be,ye]=this._shape.getCurveIndexFromVertexId(Ie-1,!0);if(ye>0&&ye<1)B.continuous[V]=!0;else{let Ne=ye===1?be+1:be-1;Ne=(Ne+X)%X;let Je=ye===1?0:1,R=this._shape.roundedCurves[be].getTangent(ye),I=this._shape.roundedCurves[Ne].getTangent(Je);B.continuous[V]=R.dot(I)>.95}}C&&(B.normals[V*2+0]*=-1,B.normals[V*2+1]*=-1),[F,G,z]=[G,z,z+1],z>=O&&(z-=P)}while(z!==D+1);let H=[];H.push({bevelI:0,angle:0,size:0,boundary:{vertices:u.vertices.slice(D*2,O*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((V,W)=>[W,W]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:u.vertices.slice(D*2,O*2)});let j=0;for(let V=1;V<=this._bevelSegments;V++){let W=V/this._bevelSegments*Math.PI/2,U=(1-Math.cos(W))*this._bevel,ie=[],Q=[],re=[],Z=[],pe=0;for(let ae=0;ae<P;ae++){let Me=ae*2,Ae=(ae-1+P)%P*2,Ee=u.vertices[B.start*2+Me+0],Ie=u.vertices[B.start*2+Me+1],be=-B.normals[Ae+0]*U,ye=-B.normals[Ae+1]*U,Ne=-B.normals[Me+0]*U,Je=-B.normals[Me+1]*U;if(B.concave[ae]||!B.concave[ae]&&C){let R=Math.atan2(ye,be),I=Math.atan2(Je,Ne);I>R&&(I-=Math.PI*2);let $=I-R;if(B.continuous[ae]||C){let ge=R+$/2,de=Math.cos(ge)*U,xe=Math.sin(ge)*U;ie[2*pe+0]=Ee+de*(C?-1:1),ie[2*pe+1]=Ie+xe*(C?-1:1),Z[pe]=ae,pe++}else{let ge=Math.max(1,Math.floor(r/4*Math.abs($)/Math.PI));for(let de=0;de<=ge;de++){let xe=R+$*(de/ge),Be=Math.cos(xe)*U,Ce=Math.sin(xe)*U;ie[2*pe+0]=Ee+Be,ie[2*pe+1]=Ie+Ce,Z[pe]=ae,pe++}}}else ie[2*pe+0]=Ee+be,ie[2*pe+1]=Ie+ye,Z[pe]=ae,Q[ae]=pe,pe++,ie[2*pe+0]=Ee,ie[2*pe+1]=Ie,Z[pe]=ae,pe++,ie[2*pe+0]=Ee+Ne,ie[2*pe+1]=Ie+Je,Z[pe]=ae,re[ae]=pe,pe++}let oe=sn({windingRule:Et.POSITIVE,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[ie],edgeCreateCallback:ae=>{let Me=ae.Org.idx,Ae=Z[Me],Ee=Z[(Me+1)%Z.length];ae.idx=[Ae,Ee],ae.Sym.idx=[Ee,Ae]},vertexIdCallback:ae=>{let Me=ae.Lprev.idx;return[Me?Me[1]:0,ae.idx?ae.idx[0]:0]}});if(!oe)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!oe.vertexCount){let ae=(V-1)/this._bevelSegments*Math.PI/2;j=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<oe.vertexIndices.length;ae++){let[Me,Ae]=oe.vertexIndices[ae];if(Me===Ae)continue;let Ee=Ae;Ae<Me&&(Ee+=P);for(let Ie=Me;Ie<Ee;Ie++){let be=Ie%P,ye=(Ie+1)%P;if(!B.continuous[be]||!B.continuous[ye]){oe.vertexIndices[ae]=[Me,be],oe.vertexIndices.splice(ae+1,0,[ye,Ae]),oe.vertices.splice((ae+1)*2,0,oe.vertices[ae*2],oe.vertices[ae*2+1]);break}}}H.push({bevelI:V,angle:W,size:U,boundary:oe,reverseMap:Z,insetPoints:ie})}let N=(V,W,U)=>{let ie=0,Q=V.boundary.vertexIndices.length;for(;ie<Q&&U(V.boundary.vertexIndices[W]);)W=(W+1)%Q,ie++;return ie},q=x.length;for(let V=1;V<H.length;V++){let W=H[V-1],U=H[V],ie=W.boundary.vertexIndices.length,Q=U.boundary.vertexIndices.length;if(!ie||!Q)break;let re=B.concave.length,Z=0,pe=hm(Z,P);for(;!W.boundary.vertexIndices.filter(pe).length||!U.boundary.vertexIndices.filter(pe).length;)Z++,pe=hm(Z,P);let oe=W.boundary.vertexIndices.findIndex(pe),ae=U.boundary.vertexIndices.findIndex(pe);do oe=(oe+1)%ie;while(pe(W.boundary.vertexIndices[oe]));do ae=(ae+1)%Q;while(pe(U.boundary.vertexIndices[ae]));Z=(Z+1)%P;let Me=Z,Ae=0,Ee=this._buildBevelVert(B,W,(oe-1+ie)%ie,void 0,Ae),Ie=this._buildBevelVert(B,U,(ae-1+Q)%Q,void 0,Ae),be=Ee,ye=Ie,Ne,Je,R=!1;do{Ae=(Z||re)/re,pe=hm(Z,P);let I=N(W,oe,pe),$=N(U,ae,pe),ge=R;if(R=!1,I&&!$){for(let de=0;de<I;de++)Ne=this._buildBevelVert(B,W,(oe+de)%ie,de/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne;R=!0}else if(!I&&$)for(let de=0;de<$;de++)Je=this._buildBevelVert(B,U,(ae+de)%Q,de/($-1),Ae),x.push(ye.topN,be.topP,Je.topP),n===!1&&x.push(be.bottomP,ye.bottomN,Je.bottomP),ye=Je;else if(I&&$)if(Ne=this._buildBevelVert(B,W,oe,0,Ae),Je=this._buildBevelVert(B,U,ae,0,Ae),ge?(x.push(be.topN,Je.topP,ye.topN),x.push(be.topN,Ne.topP,Je.topP),n===!1&&(x.push(Je.bottomP,be.bottomN,ye.bottomN),x.push(Je.bottomP,Ne.bottomP,be.bottomN))):(x.push(ye.topN,be.topN,Ne.topP),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&(x.push(Ne.bottomP,be.bottomN,ye.bottomN),x.push(Ne.bottomP,ye.bottomN,Je.bottomP))),be=Ne,ye=Je,I===$)for(let de=1;de<I;de++)Ne=this._buildBevelVert(B,W,(oe+de)%ie,de/(I-1),Ae),Je=this._buildBevelVert(B,U,(ae+de)%Q,de/($-1),Ae),x.push(be.topN,Ne.topP,ye.topN),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&(x.push(Ne.bottomP,be.bottomN,ye.bottomN),x.push(Ne.bottomP,ye.bottomN,Je.bottomP)),be=Ne,ye=Je;else if(I>$){let de=I/$,xe=0;for(let Be=1;Be<I;Be++)Ne=this._buildBevelVert(B,W,(oe+Be)%ie,Be/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne,Be>(xe+1)*de&&(xe++,Je=this._buildBevelVert(B,U,(ae+xe)%Q,xe/($-1),Ae),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&x.push(Ne.bottomP,ye.bottomN,Je.bottomP),ye=Je)}else{let de=$/I,xe=0;for(let Be=1;Be<$;Be++)Je=this._buildBevelVert(B,U,(ae+Be)%Q,Be/($-1),Ae),x.push(ye.topN,Ne.topP,Je.topP),n===!1&&x.push(Ne.bottomP,ye.bottomN,Je.bottomP),ye=Je,Be>(xe+1)*de&&(xe++,Ne=this._buildBevelVert(B,W,(oe+xe)%ie,xe/(I-1),Ae),x.push(be.topN,Ne.topP,ye.topN),n===!1&&x.push(Ne.bottomP,be.bottomN,ye.bottomN),be=Ne)}oe=(oe+I)%ie,ae=(ae+$)%Q,Z=(Z+1)%re}while(Z!==Me)}if(n===!1&&this._depth>this._bevel*2&&this._buildWall(H,B,x),C){let V=[];for(let W=x.length-1;W>=q+2;W-=3){let U=x[W-2],ie=x[W-1],Q=x[W-0];V.push(Q,ie,U)}x.splice(q,x.length-q,...V)}if(C){let V=[];for(let W=H[H.length-1].boundary.vertices.length-1;W>=1;W-=2){let U=H[H.length-1].boundary.vertices[W-1],ie=H[H.length-1].boundary.vertices[W-0];V.push(U,ie)}b.push(V)}if(!C){let V=H[H.length-1],W;try{W=sn({windingRule:H.length>1?Et.POSITIVE:Et.ODD,elementType:ai.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...b]})}catch{W=X2}if(!W)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<c&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let U=0;U<W.elementCount*3;U+=3){let ie=this._buildSurfaceVert(W,W.elements[U+0],j),Q=this._buildSurfaceVert(W,W.elements[U+1],j),re=this._buildSurfaceVert(W,W.elements[U+2],j);x.push(ie.top,Q.top,re.top),n===!1&&x.push(re.bottom,Q.bottom,ie.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ke(Uint32Array.from(x),1),A=new Ke(this._buffer.positions,3),S=new Ke(this._buffer.normals,3),_=new Ke(this._buffer.uvs,2);A.needsUpdate=!0,S.needsUpdate=!0,_.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",A),this.setAttribute("normal",S),this.setAttribute("uv",_),this.setIndex(w)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}_buildSurfaceVert(e,t,i){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],n=(s-this._minX)/this._width,o=(a-this._minY)/this._height;this.forPathBevel&&(o=1);let l=this._buffer.get(this.forPathBevel?1:2),h=l*3,d=l*2,c={top:l+0,bottom:l+1};return this._buffer.positions[h+0]=s,this._buffer.positions[h+1]=a,this._buffer.positions[h+2]=this.forPathBevel?this._bevel:this._depth-i,this._buffer.normals[h+0]=0,this._buffer.normals[h+1]=0,this._buffer.normals[h+2]=1,this._buffer.uvs[d+0]=n,this._buffer.uvs[d+1]=o,this.forPathBevel===!1&&(this._buffer.positions[h+3]=s,this._buffer.positions[h+4]=a,this._buffer.positions[h+5]=i,this._buffer.normals[h+3]=0,this._buffer.normals[h+4]=0,this._buffer.normals[h+5]=-1,this._buffer.uvs[d+2]=n,this._buffer.uvs[d+3]=o),this.vertexCache[r]=c,c}_buildBevelVert(e,t,i,r=1,s){let a=`${t.bevelI}:${i}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[n,o]=t.boundary.vertexIndices[i],l,h,d,c;n!==o?(h=n,l=o,c=!1,d=e.continuous[h]&&e.continuous[l]):(l=n,h=(l-1+e.count)%e.count,c=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||c);let u=Math.cos(t.angle),p=Math.sin(t.angle),f=i*2,m=l*2,g=h*2,v=t.boundary.vertices[f+0],y=t.boundary.vertices[f+1],x=(1-p)*this._bevel,b=(v-this._minX)/this._width,w=(y-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(b=s),w=1);let A=e.normals[m+0],S=e.normals[m+1],_=e.normals[g+0],M=e.normals[g+1];if(c){let O=_-A,B=M-S;A=A+O*(1-r),S=S+B*(1-r);let G=Math.sqrt(A*A+S*S);A/=G,S/=G}let C=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),T=C*3,D=C*2,P={i,fi:l,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1,pathBevelUCoord:s};return this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=A*u,this._buffer.normals[T+1]=S*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=A*u,this._buffer.normals[T+4]=S*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b),d||(this.forPathBevel?(C+=1,T+=3,D+=2):(C+=2,T+=6,D+=4),P.topP=C+0,P.bottomP=C+1,this._buffer.positions[T+0]=v,this._buffer.positions[T+1]=y,this._buffer.positions[T+2]=(this.forPathBevel?this._bevel:this._depth)-x,this._buffer.normals[T+0]=_*u,this._buffer.normals[T+1]=M*u,this._buffer.normals[T+2]=p,this._buffer.uvs[D+0]=b,this._buffer.uvs[D+1]=w,this.forPathBevel===!1&&(this._buffer.positions[T+3]=v,this._buffer.positions[T+4]=y,this._buffer.positions[T+5]=x,this._buffer.normals[T+3]=_*u,this._buffer.normals[T+4]=M*u,this._buffer.normals[T+5]=-p,this._buffer.uvs[D+2]=w,this._buffer.uvs[D+3]=b)),this.vertexCache[a]=P,P}clone(){let e=new H0(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Dp(this.userData),e}},Y2=class extends Ue{constructor(e,t=12,i={}){super(),this.type="ShapeGeometry",this.windingRule=Et.ODD,this.elementType=ai.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Et.ODD,elementType:ai.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let r=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(u=>u.extractShapePointsToFlatArray([],this._curveSegments)),a,n=!0,o=!0,l,h;for(let u=0,p=r.length/2;u<p;u++){let f=u*2,m=r[f+0],g=r[f+1];if(l!==void 0&&m!==l&&(n=!1),h!==void 0&&g!==h&&(o=!1),l=m,h=g,!n&&!o)break}if(!n&&!o)try{a=sn({contours:[r,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=G0}let d=a?.vertexCount??1,c=a?.elementCount??1;if(this._positionAttribute=new Ke(new Float32Array(d*3),3),this._normalAttribute=new Ke(new Float32Array(d*3),3),this._uvAttribute=new Ke(new Float32Array(d*2),2),this._indexAttribute=new Ke(new Uint32Array(c*3),1),a){let u=1/0,p=-1/0,f=1/0,m=-1/0;for(let y=0,x=d;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1];w<u&&(u=w),w>p&&(p=w),A<f&&(f=A),A>m&&(m=A)}let g=p-u,v=m-f;for(let y=0,x=d;y<x;y++){let b=y*2,w=a.vertices[b+0],A=a.vertices[b+1],S=(w-u)/g,_=(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,x=c;y<x;y++){let b=y*3,w=a.elements[b+0],A=a.elements[b+1],S=a.elements[b+2];this._indexAttribute.setX(b+0,w),this._indexAttribute.setX(b+1,A),this._indexAttribute.setX(b+2,S)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new Y2(this._shape,this._curveSegments);return e.userData=Dp(this.userData),e}},Q2=class extends H0{constructor(e,t,i=0,r=12,s=3,a=Et.ODD){super(e,t,i,r,s,a),this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,i){let r=e[0];for(let s=0,a=r.boundary.vertexCount;s<a;s++){let n=this._buildBevelVert(t,r,s),o=this._buildBevelVert(t,r,(s+1)%a);i.push(o.topP,n.topN,n.bottomN),i.push(o.topP,n.bottomN,o.bottomP)}}clone(){let e=new Q2(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Dp(this.userData),e}},uo=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:Et.ODD},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.abs(i.depth??0),n=e.shape??t?.shape,o=n?.roundness??i.roundness;n!==void 0&&(n instanceof qt?(n.width!==r||n.height!==s)&&n.applySize(r,s):n=new qt(r,s).fromJSON(n),e.parameters?.roundness!==void 0&&e.parameters?.roundness>0&&n.update());let l=n??new qt(r,s);return{parameters:Object.assign(i,{width:r,height:s,depth:a,roundness:o}),shape:l}}static build(e){let{depth:t,extrudeBevelSize:i,extrudeBevelSegments:r,subdivisions:s,roundness:a,windingRule:n}=e.parameters;e.shape.roundness=a;let o;return t<=0?o=new Y2(e.shape,s,{windingRule:n}):o=new Q2(e.shape,t,i,s,r,n),Object.assign(o,{userData:{...e,type:"VectorGeometry"}})}},Z2=Math.PI*2,W0=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 i.angle=Re.clamp(i.angle,0,360),{shape:e.shape&&e.shape instanceof qt?e.shape:new qt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h=e.shape,d=t*.5,c=i*.5,u=_8(h,d,c,s*Math.PI/180,r,a);h.isClosed=!0,h.update();let p;return s===0?(p=new Ue,p.setAttribute("position",new Te([],3))):p=uo.create({shape:h,parameters:{subdivisions:u,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}}),Object.assign(p,{userData:{...e,type:"EllipseGeometry"}})}};function _8(e,t,i,r,s,a){if(r>=Z2)return s>30||s%4===0?(A8(e,t,i,a),Math.round(s/4)):vw(e,r,s,t,i,a);r=Math.max(r,.001);let n={x:0,y:i},o=r+Math.PI*.5,l={x:Math.cos(o)*t,y:Math.sin(o)*i},h=g8({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:t,ry:i,largeArcFlag:r>Math.PI,sweepFlag:!0});return s>30||s%h.length===0?S8(e,n.x,n.y,h,s,t,i,a):vw(e,r,s,t,i,a)}function S8(e,t,i,r,s,a,n,o){let l=Math.round(s/r.length);e.addPoint(wl(t,i));for(let h=0,d=r.length;h<d;h++){let c=r[h],u=e.points[h],p=wl(c.x,c.y);u.controls[1].position.set(c.x1,c.y1),p.controls[0].position.set(c.x2,c.y2),e.addPoint(p)}return o>0?K2(e,a,n,o):e.addPoint(wl(0,0)),l}function vw(e,t,i,r,s,a){let n=-t/i;for(let o=0;o<=i;o++){let l=n*o,h=Math.sin(l)*r,d=Math.cos(l)*s;e.addPoint(wl(h,d))}return t<Z2?a>0?K2(e,r,s,a):e.addPoint(wl(0,0)):(e.removePoint(e.points[e.points.length-1]),a>0&&J2(e,r,s,a)),1}function A8(e,t,i,r=0,s=0,a=0){let n=.5522847498,o=t*n,l=i*n;e.addPoint(Fd(s-t,a,s-t,a-l,s-t,a+l)),e.addPoint(Fd(s,a+i,s-o,a+i,s+o,a+i)),e.addPoint(Fd(s+t,a,s+t,a+l,s+t,a-l)),e.addPoint(Fd(s,a-i,s+o,a-i,s-o,a-i)),r>0&&J2(e,t,i,r)}function wl(e,t){return new bl(Re.generateUUID(),new k(e,t))}function Fd(e,t,i,r,s,a){let n=wl(e,t);return n.controls[0].position.set(i,r),n.controls[1].position.set(s,a),n}function K2(e,t,i,r){$2(e,t,i,r).forEach(s=>e.addPoint(s))}function J2(e,t,i,r){let s=$2(e,t,i,r),a=new qt;s.forEach(n=>a.addPoint(n)),a.isClosed=!0,e.shapeHoles.push(a)}function $2(e,t,i,r){let s=r*t/100,a=s*(Math.abs(i)/Math.abs(t)),n=new k(s/t,a/i),o=e.points.map(l=>{let h=l.clone();return h.uuid=Re.generateUUID(),h}).reverse();return o.forEach(l=>{l.position.multiply(n);let h=l.controls[0].position.clone().multiply(n),d=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(d),l.controls[1].position.copy(h)}),o}var M8=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),a=Math.abs(i.depth??r),n=Math.abs(Math.min(r,a))/2;return{parameters:Object.assign(i,{width:r,height:s,depth:a,radius:n,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:a,segments:n,pathRadius:o,pathType:l,pathSegments:h,cornerRadius:d,cornerSegments:c}=e.parameters,u=new eM(!1,t,i,r,s,a,n,o,l,h,d,c);return Object.assign(u,{userData:{...e,type:"HelixGeometry"}})}},cm=new ul([0,0,0],1),eM=class extends Ue{constructor(e=!0,t=1,i=1,r=1,s=1,a=1,n=1,o=1,l=1,h=1,d=1,c=1){if(super(),a===0)return;let u=e&&a===1;u&&(c=0),d>100&&(d=100),d===0&&(c=0);let p=()=>new E,f=new E,m=p(),g=p(),v=p(),y,x,b,w,A,S,_,M,C=p(),T=p(),D=p(),P=p(),O=p(),B=p(),G=p(),F=p(),z=i-2*o+.001,X=z/a,H=Math.ceil(n*a),j=H+1,N=z/H,q=-z/2,V=h+1,W=2*Math.PI/h,U=Math.PI/2/c,ie=.01,Q=Math.min((1-d/100)*o,o-ie),re=o-Q,Z=0,pe=2,oe=c*pe+pe,ae=V*oe/pe,Me=ae+V*j,Ae=Math.max(0,V*(j+oe)),[Ee,Ie,be]=[3,3,2].map(Oe=>Array(Ae*Oe).fill(0)),ye=[],Ne=s-o;function Je(Oe,ze){let Le=Math.PI/2;S=ze*N,M=2*Math.PI*(S%X)/X+Le,S+=q,_=Math.sin(M)*Ne,A=Math.cos(M)*Ne,e?Oe.set(A,_,S):Oe.set(A,S,_)}Je(f,-1e-10),Je(m,0),C.copy(f),Je(f,1);let R=f.distanceTo(m),I=u?0:re+Q,$=R*H+2*I,ge=Q,de=$-I;for(let Oe=0;Oe<=H;Oe++){Je(g,Oe),F.subVectors(g,C).normalize(),C.copy(g),B.copy(g).setComponent(+e+1,0).normalize(),G.crossVectors(F,B).normalize();let ze=Oe===0,Le=Oe===H,Ze=ze?3*Math.PI/2:U,Ve=ze?ge:de,mt=ze?V:Me,zt=ze?0:Ae-V,ti=F.clone().multiplyScalar(ze?-re:re).add(g),Y=F.clone().multiplyScalar(ze?-1:1).normalize();for(let ne=0;ne<V;ne++){let ve=ne*W;if(T.addVectors(f.copy(B).multiplyScalar(o*Math.cos(ve)),m.copy(G).multiplyScalar(o*Math.sin(ve))),D.copy(T).normalize(),ze||Le){u||(Z=zt+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=ti.getComponent(_e),Ie[Z*3+_e]=Y.getComponent(_e)}),be[Z*2]=+Le,be[Z*2+1]=ne/h),m.copy(D).multiplyScalar(Q),v.addVectors(g,m);for(let _e=0;_e<c;_e++){let qe=_e*U+Ze;P.addVectors(f.copy(F).multiplyScalar(re*Math.sin(qe)),m.copy(D).multiplyScalar(re*Math.cos(qe))),O.copy(P).normalize(),m.addVectors(v,P),P.normalize(),Z=mt+_e*V+ne,[0,1,2].forEach(Vt=>{Ee[Z*3+Vt]=m.getComponent(Vt),Ie[Z*3+Vt]=O.getComponent(Vt)});let xt=+ze+Math.sin(qe);be[Z*2]=(Ve+re*xt)/$,be[Z*2+1]=ne/h}}m.addVectors(g,T),Z=ae+Oe*V+ne,[0,1,2].forEach(_e=>{Ee[Z*3+_e]=m.getComponent(_e),Ie[Z*3+_e]=D.getComponent(_e)}),be[Z*2]=(I+Oe*R)/$,be[Z*2+1]=ne/h}}let xe=j+2*c+pe,Be=1,[Ce,ue]=[+u,xe-1];for(let Oe=Ce;Oe<=ue-1;Oe++){let ze=u&&Oe===ue-1;for(let Le=0;Le<V-1;Le++)y=Oe*V+Le,x=y+1,b=(ze?Le:y)+V,w=(ze?Le+1:x)+V,Oe===0?ye.push(x,w,b):Oe===xe-2?ye.push(y,x,b):ye.push(y,x,b,x,w,b)}this.setIndex(ye),this.setAttribute("position",new Te(Ee,3)),this.setAttribute("normal",new Te(Ie,3)),this.setAttribute("uv",new Te(be,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let e=this.userData.parameters,t=Math.ceil(e.tubularSegments),i=e.radialSegments+1,r=Array.from(this.getIndex().array),s,a,n,o,l=6*(t-1)*e.radialSegments,h=t,d=h===t;for(let c=0;c<e.radialSegments;c++)s=h*i+c,a=s+1,n=(d?c:s)+i,o=(d?c+1:a)+i,r[l++]=s,r[l++]=a,r[l++]=n,r[l++]=a,r[l++]=o,r[l++]=n;return r.length=l,cm.array=r,cm.count=r.length,cm}},E8=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:a,cornerSides:n}=e.parameters,o=s===0&&a!==0?new tM(t*.5,a,n):new tA(t*.5,s);return o.scale(1,i/t,r/t),Object.assign(o,{userData:{...e,type:"IcosahedronGeometry"}})}},tM=class extends F0{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],a=[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],n="IcosahedronGeometry";super(s,a,n,e,t,i),this.type=n}static fromJSON(e){return new tM(e.radius,e.corner,e.cornerSides)}},C8=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 Ou;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 a=new YS(s.extractPoints(r).shape,i);return a.rotateZ(Math.PI),Object.assign(a,{userData:{...e,type:"LatheGeometry"}})}},As=new me,dm=new Tt,Vd=new E,hp=class extends Ii{constructor(){super(),this.uuid=Re.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 a=0,n=s.vertexNormals.length;a<n;a++)s.vertexNormals[a].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return As.makeRotationX(e),this.applyMatrix4(As),this}rotateY(e){return As.makeRotationY(e),this.applyMatrix4(As),this}rotateZ(e){return As.makeRotationZ(e),this.applyMatrix4(As),this}translate(e,t,i){return As.makeTranslation(e,t,i),this.applyMatrix4(As),this}scale(e,t,i){return As.makeScale(e,t,i),this.applyMatrix4(As),this}lookAt(e){return dm.lookAt(e),dm.updateMatrix(),this.applyMatrix4(dm.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,a=r.normal,n=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)),n!==void 0&&t.colors.push(new He().fromBufferAttribute(n,c));function h(c,u,p,f){let m=n===void 0?[]:[t.colors[c].clone(),t.colors[u].clone(),t.colors[p].clone()],g=a===void 0?[]:[new E().fromBufferAttribute(a,c),new E().fromBufferAttribute(a,u),new E().fromBufferAttribute(a,p)],v=new pv(c,u,p,g,m,f);t.faces.push(v),o!==void 0&&t.faceVertexUvs[0].push([new k().fromBufferAttribute(o,c),new k().fromBufferAttribute(o,u),new k().fromBufferAttribute(o,p)]),l!==void 0&&t.faceVertexUvs[1].push([new k().fromBufferAttribute(l,c),new k().fromBufferAttribute(l,u),new k().fromBufferAttribute(l,p)])}let d=e.groups;if(d.length>0)for(let c=0;c<d.length;c++){let u=d[c],p=u.start,f=u.count;for(let m=p,g=p+f;m<g;m+=3)i!==void 0?h(i.getX(m),i.getX(m+1),i.getX(m+2),u.materialIndex):h(m,m+1,m+2,u.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(Vd).negate(),this.translate(Vd.x,Vd.y,Vd.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,i=t===0?1:1/t,r=new me;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],a=this.vertices[s.a],n=this.vertices[s.b],o=this.vertices[s.c];e.subVectors(o,n),t.subVectors(a,n),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,a=this.faces.length;s<a;s++){let n=this.faces[s],o=this.vertices[n.a],l=this.vertices[n.b],h=this.vertices[n.c];i.subVectors(h,l),r.subVectors(o,l),i.cross(r),t[n.a].add(i),t[n.b].add(i),t[n.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],a=s.vertexNormals;a.length===3?(a[0].copy(t[s.a]),a[1].copy(t[s.b]),a[2].copy(t[s.c])):(a[0]=t[s.a].clone(),a[1]=t[s.b].clone(),a[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,a=r.vertexNormals.length;s<a;s++)r.__originalVertexNormals[s]?r.__originalVertexNormals[s].copy(r.vertexNormals[s]):r.__originalVertexNormals[s]=r.vertexNormals[s].clone()}let e=new hp;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,a=this.morphNormals[t].vertexNormals;for(let n=0,o=this.faces.length;n<o;n++){let l=new E,h={a:new E,b:new E,c:new E};s.push(l),a.push(h)}}let r=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,a=this.faces.length;s<a;s++){let n=this.faces[s],o=r.faceNormals[s],l=r.vertexNormals[s];o.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.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 $t),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vr),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,a=this.vertices,n=e.vertices,o=this.faces,l=e.faces,h=this.colors,d=e.colors;t!==void 0&&(r=new Ai().getNormalMatrix(t));for(let c=0,u=n.length;c<u;c++){let p=n[c].clone();t!==void 0&&p.applyMatrix4(t),a.push(p)}for(let c=0,u=d.length;c<u;c++)h.push(d[c].clone());for(let c=0,u=l.length;c<u;c++){let p=l[c],f,m,g=p.vertexNormals,v=p.vertexColors,y=new pv(p.a+s,p.b+s,p.c+s);y.normal.copy(p.normal),r!==void 0&&y.normal.applyMatrix3(r).normalize();for(let x=0,b=g.length;x<b;x++)f=g[x].clone(),r!==void 0&&f.applyMatrix3(r).normalize(),y.vertexNormals.push(f);y.color.copy(p.color);for(let x=0,b=v.length;x<b;x++)m=v[x],y.vertexColors.push(m.clone());y.materialIndex=p.materialIndex+i,o.push(y)}for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++)v.push(g[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],d=Math.round(h.x*s)+"_"+Math.round(h.y*s)+"_"+Math.round(h.z*s);t[d]===void 0?(t[d]=o,i.push(this.vertices[o]),r[o]=i.length-1):r[o]=r[t[d]]}let a=[];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 d=[h.a,h.b,h.c];for(let c=0;c<3;c++)if(d[c]===d[(c+1)%3]){a.push(o);break}}for(let o=a.length-1;o>=0;o--){let l=a[o];this.faces.splice(l,1);for(let h=0,d=this.faceVertexUvs.length;h<d;h++)this.faceVertexUvs[h].splice(l,1)}let n=this.vertices.length-i.length;return this.vertices=i,n}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],a,n;r&&r.length===t&&(a=[]),s&&s.length===t&&(n=[]);for(let o=0;o<t;o++){let l=e[o]._id;a&&a.push(r[l]),n&&n.push(s[l])}a&&(this.faceVertexUvs[0]=a),n&&(this.faceVertexUvs[1]=n)}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={},a=[],n={},o=[],l={};for(let p=0;p<this.faces.length;p++){let f=this.faces[p],m=!0,g=!1,v=this.faceVertexUvs[0][p]!==void 0,y=f.normal.length()>0,x=f.vertexNormals.length>0,b=f.color.r!==1||f.color.g!==1||f.color.b!==1,w=f.vertexColors.length>0,A=0;if(A=h(A,0,0),A=h(A,1,m),A=h(A,2,g),A=h(A,3,v),A=h(A,4,y),A=h(A,5,x),A=h(A,6,b),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(u(S[0]),u(S[1]),u(S[2]))}if(y&&i.push(d(f.normal)),x){let S=f.vertexNormals;i.push(d(S[0]),d(S[1]),d(S[2]))}if(b&&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,m){return m?p|1<<f:p&~(1<<f)}function d(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 n[f]!==void 0||(n[f]=a.length,a.push(p.getHex())),n[f]}function u(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,a.length>0&&(e.data.colors=a),o.length>0&&(e.data.uvs=[o]),e.data.faces=i,e}clone(){return new hp().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,u=t.length;c<u;c++)this.vertices.push(t[c].clone());let i=e.colors;for(let c=0,u=i.length;c<u;c++)this.colors.push(i[c].clone());let r=e.faces;for(let c=0,u=r.length;c<u;c++)this.faces.push(r[c].clone());for(let c=0,u=e.faceVertexUvs.length;c<u;c++){let p=e.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let f=0,m=p.length;f<m;f++){let g=p[f],v=[];for(let y=0,x=g.length;y<x;y++){let b=g[y];v.push(b.clone())}this.faceVertexUvs[c].push(v)}}let s=e.morphTargets;for(let c=0,u=s.length;c<u;c++){let p={};if(p.name=s[c].name,s[c].vertices!==void 0){p.vertices=[];for(let f=0,m=s[c].vertices.length;f<m;f++)p.vertices.push(s[c].vertices[f].clone())}if(s[c].normals!==void 0){p.normals=[];for(let f=0,m=s[c].normals.length;f<m;f++)p.normals.push(s[c].normals[f].clone())}this.morphTargets.push(p)}let a=e.morphNormals;for(let c=0,u=a.length;c<u;c++){let p={};if(a[c].vertexNormals!==void 0){p.vertexNormals=[];for(let f=0,m=a[c].vertexNormals.length;f<m;f++){let g=a[c].vertexNormals[f],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),p.vertexNormals.push(v)}}if(a[c].faceNormals!==void 0){p.faceNormals=[];for(let f=0,m=a[c].faceNormals.length;f<m;f++)p.faceNormals.push(a[c].faceNormals[f].clone())}this.morphNormals.push(p)}let n=e.skinWeights;for(let c=0,u=n.length;c<u;c++)this.skinWeights.push(n[c].clone());let o=e.skinIndices;for(let c=0,u=o.length;c<u;c++)this.skinIndices.push(o[c].clone());let l=e.lineDistances;for(let c=0,u=l.length;c<u;c++)this.lineDistances.push(l[c]);let h=e.boundingBox;h!==null&&(this.boundingBox=h.clone());let d=e.boundingSphere;return d!==null&&(this.boundingSphere=d.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 T8().fromGeometry(this),t=new Ue,i=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",jd.call(new Ke(i,3),e.vertices)),e.normals.length>0){let r=new Float32Array(e.normals.length*3);t.setAttribute("normal",jd.call(new Ke(r,3),e.normals))}if(e.colors.length>0){let r=new Float32Array(e.colors.length*3);t.setAttribute("color",yw.call(new Ke(r,3),e.colors))}if(e.uvs.length>0){let r=new Float32Array(e.uvs.length*2);t.setAttribute("uv",xw.call(new Ke(r,2),e.uvs))}if(e.uvs2.length>0){let r=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",xw.call(new Ke(r,2),e.uvs2))}t.groups=e.groups;for(let r in e.morphTargets){let s=[],a=e.morphTargets[r];for(let n=0,o=a.length;n<o;n++){let l=a[n],h=new Te(l.data.length*3,3);h.name=l.name,s.push(jd.call(h,l.data))}t.morphAttributes[r]=s}if(e.skinIndices.length>0){let r=new Te(e.skinIndices.length*4,4);t.setAttribute("skinIndex",bw.call(r,e.skinIndices))}if(e.skinWeights.length>0){let r=new Te(e.skinWeights.length*4,4);t.setAttribute("skinWeight",bw.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 Ue,i=e.geometry;if(e.isPoints||e.isLine){let r=new Te(i.vertices.length*3,3),s=new Te(i.colors.length*3,3);if(t.setAttribute("position",jd.call(r,i.vertices)),t.setAttribute("color",yw.call(s,i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){let a=new Te(i.lineDistances.length,1);t.setAttribute("lineDistance",P8.call(a,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}};hp.prototype.isGeometry=!0;var T8=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,a=e.faces;for(r=0;r<a.length;r++){let n=a[r];n.materialIndex!==s&&(s=n.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,a=r[1]&&r[1].length>0,n=e.morphTargets,o=n.length,l;if(o>0){l=[];for(let g=0;g<o;g++)l[g]={name:n[g].name,data:[]};this.morphTargets.position=l}let h=e.morphNormals,d=h.length,c;if(d>0){c=[];for(let g=0;g<d;g++)c[g]={name:h[g].name,data:[]};this.morphTargets.normal=c}let u=e.skinIndices,p=e.skinWeights,f=u.length===i.length,m=p.length===i.length;i.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){let v=t[g];this.vertices.push(i[v.a],i[v.b],i[v.c]);let y=v.vertexNormals;if(y.length===3)this.normals.push(y[0],y[1],y[2]);else{let b=v.normal;this.normals.push(b,b,b)}let x=v.vertexColors;if(x.length===3)this.colors.push(x[0],x[1],x[2]);else{let b=v.color;this.colors.push(b,b,b)}if(s===!0){let b=r[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new k,new k,new k))}if(a===!0){let b=r[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new k,new k,new k))}for(let b=0;b<o;b++){let w=n[b].vertices;l[b].data.push(w[v.a],w[v.b],w[v.c])}for(let b=0;b<d;b++){let w=h[b].vertexNormals[g];c[b].data.push(w.a,w.b,w.c)}f&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),m&&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}},pv=class{constructor(e,t,i,r,s,a=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 He,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=a}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 P8(e){return this.array.set(e),this}function yw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),a=new He),t[i++]=a.r,t[i++]=a.g,t[i++]=a.b}return this}function xw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),a=new k),t[i++]=a.x,t[i++]=a.y}return this}function jd(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),a=new E),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z}return this}function bw(e){let t=this.array,i=0;for(let r=0,s=e.length;r<s;r++){let a=e[r];a===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),a=new rt),t[i++]=a.x,t[i++]=a.y,t[i++]=a.z,t[i++]=a.w}return this}var D8=["a","b","c"];function I8(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function um(e,t,i){let r=Math.min(e,t),s=Math.max(e,t),a=r+"_"+s;return i.get(a)}function pm(e,t,i,r,s,a){let n=Math.min(e,t),o=Math.max(e,t),l=n+"_"+o,h;if(r.has(l))h=r.get(l);else{let d=i[n],c=i[o];h={a:d,b:c,newEdge:null,faces:[]},r.set(l,h)}h.faces.push(s),a[e].edges.push(h),a[t].edges.push(h)}function O8(e,t,i,r){let s,a,n;for(s=0,a=e.length;s<a;s++)i[s]={edges:[]};for(s=0,a=t.length;s<a;s++)n=t[s],pm(n.a,n.b,e,r,n,i),pm(n.b,n.c,e,r,n,i),pm(n.c,n.a,e,r,n,i)}function Gd(e,t,i,r,s){e.push(new pv(t,i,r,void 0,void 0,s))}function ko(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function Hd(e,t,i,r){e.push([t.clone(),i.clone(),r.clone()])}var L8=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Ue?e=new hp().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,a,n,o=e.vertices,l=e.faces,h=e.faceVertexUvs[0],d=h!==void 0&&h.length>0,c=[],u=new Map;O8(o,l,c,u);let p=[],f,m,g,v,y,x,b;for(let ie of Array.from(u.keys())){for(m=u.get(ie),g=new E,y=3/8,x=1/8,b=m.faces.length,b!=2&&(y=.5,x=0,b!=1),g.addVectors(m.a,m.b).multiplyScalar(y),t.set(0,0,0),a=0;a<b;a++){for(v=m.faces[a],n=0;n<3&&(f=o[I8(v,D8[n])],!(f!==m.a&&f!==m.b));n++);f&&t.add(f)}t.multiplyScalar(x),g.add(t),m.newEdge=p.length,p.push(g)}let w,A,S,_,M,C,T,D=[];for(r=0,s=o.length;r<s;r++){for(C=o[r],M=c[r].edges,i=M.length,i==3?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),a=0;a<i;a++)_=M[a],f=_.a!==C?_.a:_.b,t.add(f);t.multiplyScalar(Number(S)),T.add(t),D.push(T)}let P=D.concat(p),O=D.length,B,G,F,z=[],X=[],H,j,N,q,V=new k,W=new k,U=new k;for(r=0,s=l.length;r<s;r++)v=l[r],B=Number(um(v.a,v.b,u).newEdge)+O,G=Number(um(v.b,v.c,u).newEdge)+O,F=Number(um(v.c,v.a,u).newEdge)+O,Gd(z,B,G,F,v.materialIndex),Gd(z,v.a,B,F,v.materialIndex),Gd(z,v.b,G,B,v.materialIndex),Gd(z,v.c,F,G,v.materialIndex),d&&(H=h[r],j=H[0],N=H[1],q=H[2],V.set(ko(j.x,N.x),ko(j.y,N.y)),W.set(ko(N.x,q.x),ko(N.y,q.y)),U.set(ko(j.x,q.x),ko(j.y,q.y)),Hd(X,V,W,U),Hd(X,j,V,U),Hd(X,N,W,V),Hd(X,q,U,W));e.vertices=P,e.faces=z,d&&(e.faceVertexUvs[0]=X)}},ci=new E,R8=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let i=e.geometry??t?.geometry??new Ue().copy(new Hs(100,100,100)),r;t===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ci),r={width:ci.x,height:ci.y,depth:ci.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,a=e.geometry??new Ue().copy(new Hs(100,100,100)),n=a.userData.parameters;n===void 0?(a.computeBoundingBox(),a.boundingBox.getSize(ci)):ci.set(n.width,n.height,n.depth),(t!==ci.x||i!==ci.y||r!==ci.z)&&a.scale(ci.x===0?1:t/ci.x,ci.y===0?1:i/ci.y,ci.z===0?1:r/ci.z);let o=a.originalGeometry;try{s>0?(o===void 0||n?.subdivisions!==s)&&(o===void 0&&(o=a),a=new L8(s).modify(o).toBufferGeometry()):(o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals())}catch{o!==void 0&&(a=o),o=void 0,a.getAttribute("normal")===void 0&&a.computeVertexNormals()}return o!==void 0&&Object.assign(a,{originalGeometry:o}),delete e.geometry,Object.assign(a,{userData:{...e,type:"NonParametricGeometry"}})}static loadFromUrl(e,t,i){new lA(i).load(e,r=>{let s=this.normalizeInputs({geometry:r});r.boundingBox.getSize(ci);let a=100/ci.x;Object.assign(s.parameters,{width:100,height:ci.y*a,depth:ci.z*a}),t(this.build(s))})}},iM=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 qt?e.shape:new qt,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:a,extrudeBevelSize:n,extrudeBevelSegments:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5,c=0,u=0,p=2*Math.PI/r;for(let m=0;m<r;m++){let g=p*m,v=c+Math.sin(g)*h,y=u+Math.cos(g)*d;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let m=0,g=l.points.length;m<g;m++)l.points[m].roundness=s;l.roundness=s,l.update();let f=uo.create({shape:l,parameters:{roundness:s,depth:a,extrudeBevelSize:n,extrudeBevelSegments:o}});return Object.assign(f,{userData:{...e,type:"PolygonGeometry"}})}},B8=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:a,openEnded:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=new N8(t*.5,i,s,a,n,o,l);return h.scale(1,1,r/t),Object.assign(h,{userData:{...e,type:"PyramidGeometry"}})}};function Lh(e,t,i){i.x=e.x*t.x,i.y=e.y,i.z=e.x*t.y}function fm(e,t,i,r,s,a){let n=t.clone().sub(e),o=i.clone().sub(e),l=n.angleTo(o);if(n.normalize(),o.normalize(),r===s){let h=n.add(o).normalize();a.copy(e).addScaledVector(h,r/Math.sin(l/2))}else{let h=n.angleTo(o);a.copy(e),a.addScaledVector(n,s/Math.sin(h)),a.addScaledVector(o,r/Math.sin(h))}}function z8(e,t,i){let r=e.clone().sub(t),s=i.clone().sub(t);return r.projectOnVector(s),r.add(t)}var N8=class extends Ue{constructor(e=.5,t=1,i=4,r=1,s=!1,a=0,n=4){super(),i=Math.floor(Math.max(3,i)),r=Math.floor(r),n=Math.floor(n);let o=[],l=[],h=[],d=[],c=0,u=t/2,p=Math.PI/i,f=e*Math.cos(Math.PI/i),m=2*Math.PI/i,g=(i-2)*Math.PI/i,v=Math.PI-g,y=new E(0,-u,0),x=new E(0,u,0),b=new k(e,-u),w=new k(f,-u),A=new k(0,x.y).sub(w),S=new k(0,x.y).sub(b),_=new k(A.y,-A.x).normalize(),M=new k(S.y,-S.x).normalize(),C=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,C);let T;{let z=new E(_.x,_.y,0),X=new E(Math.cos(m)*z.x,z.y,Math.sin(m)*z.x);T=z.angleTo(X)}let D=a/Math.tan((Math.PI-A.angle())/2),P=a/Math.tan((Math.PI-T)/2),O=new E;if(!s){l.push(y.x,y.y,y.z),h.push(0,-1,0),d.push(0,0);let z=c++,X=[],H=b.clone(),j=D/Math.cos(Math.PI/i);H.x-=j;for(let N=0;N<i;N++){let q=N/i*Math.PI*2+p,V=new k(Math.sin(q),Math.cos(q));Lh(H,V,O),l.push(O.x,O.y,O.z),h.push(0,-1,0),d.push(0,0),X.push(c++)}for(let N=0;N<X.length;N++)o.push(X[N],z,X[(N+1)%X.length])}let B=[];{let z=new E,X=new E,H=new E,j=new E,N=new E,q=new E;for(let V=0;V<i;V++){let W=V/i*Math.PI*2+p,U=(V+.5)/i*Math.PI*2+p,ie=(V+1)/i*Math.PI*2+p,Q=new k(Math.sin(W),Math.cos(W)),re=new k(Math.sin(U),Math.cos(U)),Z=new k(Math.sin(ie),Math.cos(ie));Lh(b,Q,X),Lh(b,Z,H),Lh(_,re,z),fm(x,X,H,P,P,j),l.push(j.x,j.y,j.z),fm(X,x,H,P,D,N),l.push(N.x,N.y,N.z),fm(H,X,x,D,P,q),l.push(q.x,q.y,q.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),h.push(z.x,z.y,z.z),d.push(0,0),d.push(0,0),d.push(0,0);let pe=c++,oe=c++,ae=c++;if(o.push(pe,oe,ae),a>0){{let Ee=X.clone().add(H).multiplyScalar(.5),Ie=x.clone().sub(Ee).normalize(),be=y.clone().sub(Ee).normalize().add(Ie).normalize().multiplyScalar(-1),ye=q.clone().sub(N);G(Ee,ye,be,A.angle())}let Me,Ae;{let Ee=new E;Lh(M,Z,Ee);let Ie=q.clone().add(j).multiplyScalar(.5);Ie=z8(Ie,H,x);let be=q.clone().sub(j);[Me,Ae]=G(Ie,be,Ee,T,j.y)}{let Ee=Me,Ie=Ee.clone().setY(0).normalize(),be=new E(0,-1,0),ye=Ie.clone().cross(be);F(Ee,Ie,be,ye)}B.concat(Ae);{let Ee=A.angle(),Ie=Math.PI-Ee,be=x.clone();be.y-=a/Math.sin(Ee-Math.PI/2);let ye=new E,Ne=[];for(let R=0;R<n;R++){let I=[],$=Math.PI/2-Ie*R/n,ge=Math.cos($),de=Math.sin($),xe=U;for(let Be=0;Be<=R;Be++){let Ce=Math.cos(xe),ue=Math.sin(xe);z.x=ge*ue,z.y=de,z.z=ge*Ce,ye.copy(be).addScaledVector(z,a),l.push(ye.x,ye.y,ye.z),h.push(z.x,z.y,z.z),d.push(0,0),I.push(c++),xe+=Math.PI*2/R/i}Ne.push(I)}Ae.reverse(),Ne.push(Ae);let Je=Ne.length-1;for(let R=0;R<Je;R++){let I=Ne[R],$=Ne[R+1],ge=I.length-1;o.push($[1],I[0],$[0]);for(let de=1;de<=ge;de++)o.push(I[de],I[de-1],$[de]),o.push($[de+1],I[de],$[de])}}}}}this.setIndex(o),this.setAttribute("position",new Te(l,3)),this.setAttribute("normal",new Te(h,3)),this.setAttribute("uv",new Te(d,2));function G(z,X,H,j,N){let q=-j/2,V=(Math.PI-j)/2,W=X.clone().normalize().cross(H);z.addScaledVector(H,-a/Math.sin(V));let U=new E,ie=new E,Q=1,re=c,Z=[];for(let pe=0;pe<=n;pe++){let oe=q+pe/n*j;ie.set(0,0,0),ie.addScaledVector(W,Math.sin(oe)),ie.addScaledVector(H,Math.cos(oe));for(let ae=0;ae<=Q;ae++){let Me=ae/Q-.5;if(U.copy(z),U.addScaledVector(X,Me),U.addScaledVector(ie,a),N!=null){let Ae=Math.max(0,U.y-N);U.addScaledVector(X,-Ae/X.y)}l.push(U.x,U.y,U.z),h.push(ie.x,ie.y,ie.z),d.push(0,0),ae===0&&Z.push(c),c++}}for(let pe=0;pe<n;pe++)for(let oe=0;oe<Q;oe++){let ae=re+oe+(Q+1)*pe,Me=ae+(Q+1),Ae=Me+1,Ee=ae+1;o.push(ae,Me,Ee),o.push(Me,Ae,Ee)}return[z.clone().addScaledVector(X,.5),Z]}function F(z,X,H,j){let N=Math.PI/2,q=S.angle()-N,V=[],W=new E,U=new E;for(let Q=0;Q<=n;Q++){let re=[],Z=Q/n;for(let pe=0;pe<=Q;pe++){let oe=((Q?pe/Q:0)-.5)*v,ae=Math.cos(oe),Me=Math.sin(oe),Ae=Math.atan(Math.tan(q)*ae),Ee=(N+Ae)*Z,Ie=Math.cos(Ee),be=Math.sin(Ee);W.set(0,0,0),W.addScaledVector(X,be*ae),W.addScaledVector(H,Ie),W.addScaledVector(j,be*Me),U.copy(z).addScaledVector(W,a),l.push(U.x,U.y,U.z),h.push(W.x,W.y,W.z),d.push(0,0),re.push(c++)}V.push(re)}let ie=V.length-1;for(let Q=0;Q<ie;Q++){let re=V[Q],Z=V[Q+1],pe=re.length-1;o.push(re[0],Z[1],Z[0]);for(let oe=1;oe<=pe;oe++)o.push(re[oe-1],re[oe],Z[oe]),o.push(re[oe],Z[oe+1],Z[oe])}}}},rM=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 qt?e.shape:new qt,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:a,depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}=e.parameters,h={x:i*.5,y:r*.5},d={x:-h.x,y:-h.y},c={x:h.x,y:h.y};function u(b,w,A){return w>i&&A>r?Math.min(b*i/w,b*r/A):w>i?b*i/w:A>r?b*r/A:b}let p=[];p[0]=s[0]===0?0:u(s[0],s[0]+s[3],s[0]+s[1]),p[1]=s[1]===0?0:u(s[1],s[1]+s[2],s[1]+s[0]),p[2]=s[2]===0?0:u(s[2],s[2]+s[1],s[2]+s[3]),p[3]=s[3]===0?0:u(s[3],s[3]+s[0],s[3]+s[2]);let f=d.x,m=c.x,g=c.y,v=d.y;t.addPoint(t.createPoint(f,g)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(f,v)),t.isClosed=!0;let y=!0;for(let b=0,w=t.points.length;b<w;b++)t.points[b].roundness=p[b],b>0&&p[b]!==p[b-1]&&(y=!1);y&&(t.roundness=p[0]),t.useCubicForRoundedCorners=a!==1,t.update();let x=uo.create({shape:t,parameters:{depth:n,extrudeBevelSize:o,extrudeBevelSegments:l}});return Object.assign(x,{userData:{...e,type:"RectangleGeometry"}})}},k8=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:180},e.parameters);return i.thetaLength=Re.clamp(i.thetaLength,0,180),{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:a=64,phiStart:n,phiLength:o,thetaStart:l,thetaLength:h}=e.parameters,d;return h===0?(d=new Ue,d.setAttribute("position",new Te([],3))):d=new s0(.5*t,s,a,n,o,l,h*Re.DEG2RAD),d.scale(1,i/t,r/t),Object.assign(d,{userData:{...e,type:"SphereGeometry"}})}},U8=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,a=new xp(t,i,r,s);return a.scale(1,1,1),Object.assign(a,{userData:{...e,type:"PlaneGeometry"}})}},F8=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:a,cornerSegments:n}=e.parameters,o=new V8(t,i,r,s,a,n);return Object.assign(o,{userData:{...e,type:"BackdropGeometry"}})}},V8=class extends Ue{constructor(e=1,t=1,i=1,r=90,s=10,a=24){super(),this.type="BackdropGeometry";let n=[],o=[],l=[],h=.001;s==0&&(a=1),a=Math.max(1,Math.floor(a)),s=Math.min(s,100),r=Math.min(180-h,r),r*=Math.PI/180;let d=[],c=Math.PI/2,u=(ie=0,Q=0,re=0)=>new E(ie,Q,re),p=u(),f=u(),[m,g,v]=[t/2,e/2,i/2],y=-g,x=+g,[b,w,A]=[u(y,-m,+v),u(y,-m,-v),u(y,+m,-v)],S=(ie,Q=!1)=>Math.sin(ie-Math.PI/(1+ +Q)),_=(ie,Q=!1)=>Math.cos(ie-Math.PI/(1+ +Q));A.y=Math.sin(r)*t-m;let M=Math.cos(r)*t-v,C=b.z-h;r<=c?(A.z=Math.min(M,C),A.z==C&&(A.y-=(M-C)/Math.tan(c-r))):w.z=Math.min(w.z-M-v,b.z-h),p.subVectors(b,w),f.subVectors(A,w);let T=Math.min(p.length(),f.length())*s/100,D=T*Math.tan(r/2),P=T/Math.cos(r/2),O=p.clone().normalize().add(f.normalize()).setLength(P).add(w);p.set(0,S(r,!0),_(r,!0)),d.push([A,p.clone()]);let B=(Math.PI-r)/a;for(let ie=0;ie<=a;ie++){let Q=c+r+ie*B;p.set(0,Math.sin(Q)*D,Math.cos(Q)*D),p.add(O),f.set(0,S(Q),_(Q)),d.push([p.clone(),f.clone()])}d.push([b,u(0,1,0)]);let G=Math.sin(B/2)*D*2,F=d.length-1,z=d[0][0].distanceTo(d[1][0]),X=d[F-1][0].distanceTo(d[F][0]),H=z+G*a+X;d[0].push(1);for(let ie=0;ie<=a;ie++)d[ie+1].push(1-(z+ie*G)/H);d[F].push(0);let[j,N,q]=d[0],V,W,U;for(let ie=1;ie<d.length;ie++)[V,W,U]=d[ie],n.push(y,j.y,j.z,y,V.y,V.z,x,j.y,j.z,x,j.y,j.z,y,V.y,V.z,x,V.y,V.z),o.push(0,N.y,N.z,0,W.y,W.z,0,N.y,N.z,0,N.y,N.z,0,W.y,W.z,0,W.y,W.z),l.push(0,q,0,U,1,q,1,q,0,U,1,U),[j,N,q]=[V,W,U];this.setAttribute("position",new Te(n,3)),this.setAttribute("normal",new Te(o,3)),this.setAttribute("uv",new Te(l,2))}},sM=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 qt?e.shape:new qt,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:a,angle:n,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}=e.parameters,d=e.shape,c=t*.5,u=i*.5,p=0,f=0,m=n*Math.PI/360/s,g=Math.PI/2*3*-1,v=c*r/100,y=u*r/100;if(s===3&&r===50){m=2*Math.PI/s;for(let b=0;b<s;b++){let w=m*b,A=p+Math.sin(w)*c,S=f+Math.cos(w)*u;d.addPoint(d.createPoint(A,S))}}else for(let b=0;b<s;b++){let w=p+Math.cos(g)*c,A=f+Math.sin(g)*u;d.addPoint(d.createPoint(w,A)),g+=m,w=p+Math.cos(g)*v,A=f+Math.sin(g)*y,b<=s,d.addPoint(d.createPoint(w,A)),g+=m}d.isClosed=!0;for(let b=0,w=d.points.length;b<w;b++)d.points[b].roundness=a;d.roundness=a,d.update();let x=uo.create({shape:d,parameters:{roundness:a,depth:o,extrudeBevelSize:l,extrudeBevelSegments:h}});return Object.assign(x,{userData:{...e,type:"StarGeometry"}})}},j8=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 xp(t,i);return Object.assign(r,{userData:{...e,type:"TextFrameGeometry"}})}},G8=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:360,cornerRadius:30,cornerSegments:8},e.parameters),r=Math.abs(i.width),s=Math.abs(i.height??i.width),a=Math.round(Math.abs(i.depth??i.width*.25));return{parameters:Object.assign(i,{width:r,height:s,depth:a})}}static build(e){let{width:t,height:i,depth:r,radialSegments:s,tubularSegments:a,arc:n,cornerRadius:o,cornerSegments:l}=e.parameters,h=H8(t,i,r,t*.5,n,a,0,0,s,o,l);return h.scale(1,i/t,1),Object.assign(h,{userData:{...e,type:"TorusGeometry"}})}};function H8(e,t,i,r,s,a,n,o,l,h,d){[t,i]=[i,t],n=t/2;let c=Re.clamp(s/360,0,1);if(c===0){let u=new Ue;return u.setAttribute("position",new Te([],3)),u}return c===1&&(h=0),new eM(!0,e,t,i,r,c,a,n,o,l,h,d)}var W8=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:a,q:n}=e.parameters,o=t*.5;o!==i&&(o-=i);let l=new iA(o,i,r,s,a,n);return Object.assign(l,{userData:{...e,type:"TorusKnotGeometry"}})}},q8=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 qt?e.shape:new qt,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:a,extrudeBevelSegments:n,isRect:o}=e.parameters,l=e.shape,h=t*.5,d=i*.5;o?(l.addPoint(l.createPoint(-h,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))):(l.addPoint(l.createPoint(0,d)),l.addPoint(l.createPoint(h,-d)),l.addPoint(l.createPoint(-h,-d))),l.isClosed=!0;for(let u=0,p=l.points.length;u<p;u++)l.points[u].roundness=r;l.roundness=r,l.update();let c=uo.create({shape:l,parameters:{roundness:r,depth:s,extrudeBevelSize:a,extrudeBevelSegments:n}});return Object.assign(c,{userData:{...e,type:"TriangleGeometry"}})}};function X8(e,t){let i=2*Math.PI;return(e%i+i)%i===(t%i+i)%i}var Y8=class{add(e,t,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(r){this[r]=this[r]||[],t&&this[r][i?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(i){i.call(t&&t.context?t.context:t,t)})}},Q8=class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(t=>{if(typeof t!="object"||!t.name||!t.init)throw new Error("Invalid JSEP plugin format");this.registered[t.name]||(t.init(this.jsep),this.registered[t.name]=t)})}},se=class{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+se.version}static addUnaryOp(e){return se.max_unop_len=Math.max(e.length,se.max_unop_len),se.unary_ops[e]=1,se}static addBinaryOp(e,t,i){return se.max_binop_len=Math.max(e.length,se.max_binop_len),se.binary_ops[e]=t,i?se.right_associative.add(e):se.right_associative.delete(e),se}static addIdentifierChar(e){return se.additional_identifier_chars.add(e),se}static addLiteral(e,t){return se.literals[e]=t,se}static removeUnaryOp(e){return delete se.unary_ops[e],e.length===se.max_unop_len&&(se.max_unop_len=se.getMaxKeyLen(se.unary_ops)),se}static removeAllUnaryOps(){return se.unary_ops={},se.max_unop_len=0,se}static removeIdentifierChar(e){return se.additional_identifier_chars.delete(e),se}static removeBinaryOp(e){return delete se.binary_ops[e],e.length===se.max_binop_len&&(se.max_binop_len=se.getMaxKeyLen(se.binary_ops)),se.right_associative.delete(e),se}static removeAllBinaryOps(){return se.binary_ops={},se.max_binop_len=0,se}static removeLiteral(e){return delete se.literals[e],se}static removeAllLiterals(){return se.literals={},se}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new se(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(t=>t.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return se.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!se.binary_ops[String.fromCharCode(e)]||se.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return se.isIdentifierStart(e)||se.isDecimalDigit(e)}throwError(e){let t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(se.hooks[e]){let i={context:this,node:t};return se.hooks.run(e,i),i.node}return t}searchHook(e){if(se.hooks[e]){let t={context:this};return se.hooks[e].find(function(i){return i.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===se.SPACE_CODE||e===se.TAB_CODE||e===se.LF_CODE||e===se.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=e.length===1?e[0]:{type:se.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],i,r;for(;this.index<this.expr.length;)if(i=this.code,i===se.SEMCOL_CODE||i===se.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(i===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,se.max_binop_len),t=e.length;for(;t>0;){if(se.binary_ops.hasOwnProperty(e)&&(!se.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,i,r,s,a,n,o,l;if(a=this.gobbleToken(),!a||(t=this.gobbleBinaryOp(),!t))return a;for(s={value:t,prec:se.binaryPrecedence(t),right_a:se.right_associative.has(t)},n=this.gobbleToken(),n||this.throwError("Expected expression after "+t),r=[a,s,n];t=this.gobbleBinaryOp();){if(i=se.binaryPrecedence(t),i===0){this.index-=t.length;break}s={value:t,prec:i,right_a:se.right_associative.has(t)},l=t;let h=d=>s.right_a&&d.right_a?i>d.prec:i<=d.prec;for(;r.length>2&&h(r[r.length-2]);)n=r.pop(),t=r.pop().value,a=r.pop(),e={type:se.BINARY_EXP,operator:t,left:a,right:n},r.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),r.push(s,e)}for(o=r.length-1,e=r[o];o>1;)e={type:se.BINARY_EXP,operator:r[o-1].value,left:r[o-2],right:e},o-=2;return e}gobbleToken(){let e,t,i,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"),r)return this.runHook("after-token",r);if(e=this.code,se.isDecimalDigit(e)||e===se.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===se.SQUOTE_CODE||e===se.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===se.OBRACK_CODE)r=this.gobbleArray();else{for(t=this.expr.substr(this.index,se.max_unop_len),i=t.length;i>0;){if(se.unary_ops.hasOwnProperty(t)&&(!se.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!se.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=i;let s=this.gobbleToken();return s||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:se.UNARY_EXP,operator:t,argument:s,prefix:!0})}t=t.substr(0,--i)}se.isIdentifierStart(e)?(r=this.gobbleIdentifier(),se.literals.hasOwnProperty(r.name)?r={type:se.LITERAL,value:se.literals[r.name],raw:r.name}:r.name===se.this_str&&(r={type:se.THIS_EXP})):e===se.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===se.PERIOD_CODE||t===se.OBRACK_CODE||t===se.OPAREN_CODE||t===se.QUMARK_CODE;){let i;if(t===se.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==se.PERIOD_CODE)break;i=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===se.OBRACK_CODE?(e={type:se.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()},this.gobbleSpaces(),t=this.code,t!==se.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===se.OPAREN_CODE?e={type:se.CALL_EXP,arguments:this.gobbleArguments(se.CPAREN_CODE),callee:e}:(t===se.PERIOD_CODE||i)&&(i&&this.index--,this.gobbleSpaces(),e={type:se.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),i&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,i;for(;se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===se.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(t=this.char,t==="e"||t==="E"){for(e+=this.expr.charAt(this.index++),t=this.char,(t==="+"||t==="-")&&(e+=this.expr.charAt(this.index++));se.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);se.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return i=this.code,se.isIdentifierStart(i)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(i===se.PERIOD_CODE||e.length===1&&e.charCodeAt(0)===se.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:se.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,i=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let s=this.expr.charAt(this.index++);if(s===i){r=!0;break}else if(s==="\\")switch(s=this.expr.charAt(this.index++),s){case"n":e+=`
3139
3139
  `;break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=s}else e+=s}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:se.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(se.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(e=this.code,se.isIdentifierPart(e));)this.index++;return{type:se.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],i=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let s=this.code;if(s===e){i=!0,this.index++,e===se.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}else if(s===se.COMMA_CODE){if(this.index++,r++,r!==t.length){if(e===se.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===se.CBRACK_CODE)for(let a=t.length;a<r;a++)t.push(null)}}else if(t.length!==r&&r!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===se.COMPOUND)&&this.throwError("Expected comma"),t.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(se.CPAREN_CODE);if(this.code===se.CPAREN_CODE)return this.index++,e.length===1?e[0]:e.length?{type:se.SEQUENCE_EXP,expressions:e}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:se.ARRAY_EXP,elements:this.gobbleArguments(se.CBRACK_CODE)}}},Z8=new Y8;Object.assign(se,{hooks:Z8,plugins:new Q8(se),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});se.max_unop_len=se.getMaxKeyLen(se.unary_ops);se.max_binop_len=se.getMaxKeyLen(se.binary_ops);var Vl=e=>new se(e).parse(),K8=Object.getOwnPropertyNames(se);K8.forEach(e=>{Vl[e]===void 0&&e!=="prototype"&&(Vl[e]=se[e])});Vl.Jsep=se;var J8="ConditionalExpression",$8={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let i=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:J8,test:i,consequent:r,alternate:s},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;t.node.test=a.right,a.right=t.node,t.node=i}}else this.throwError("Expected :")}})}};Vl.plugins.register($8);var ej=["+","-","*","/","(",")","==","!=",">","<",">=","<=","and","or","!","%","^",","],tj=["0","1","2","3","4","5","6","7","8","9","."],ij=["sin","cos","tan","asin","acos","atan","atan2","sqrt","abs","log","exp","floor","ceil","round","min","max","random"];function rj(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))}Vl.addBinaryOp("^",11,!0);function aM(e,t,i="number"){let r="";for(let n=0;n<e.length;n++){let o=e[n];if("id"in o){let l=e[n-1];if(n>0&&"id"in l){console.error("Two variables in a row",e);return}let h=t.getVariable(o.id),d=Dr.getDisplayedValue(h);i==="number"&&Dr.isTextValue(h)&&Array.isArray(h.textValue)&&h.textValue.length===1?d=parseFloat(d).toString():i==="boolean"&&Dr.isBoolean(h)?d=h?"true":"false":i==="boolean"&&Dr.isTextValue(h)&&!Array.isArray(h.textValue)&&(d='"'+d+'"'),r+=d;continue}else if(i==="string"){o.name!=='"'&&o.name!=="+"&&(r+=o.name),o.name==="+"&&r[r.length-1]==="\\"&&(r=r.slice(0,-1)+o.name);continue}if(o.name==="and"){r+="&&";continue}if(o.name==="or"){r+="||";continue}if(o.name==="True"){r+="true";continue}if(o.name==="False"){r+="false";continue}if(i==="boolean"&&!rj(o.name)&&!tj.includes(o.name)&&!ej.includes(o.name)&&!ij.includes(o.name.replace(/\($/g,""))){r+='"'+o.name+'"';continue}r+=o.name}if(i==="string")return r;if(e.length===0){if(i==="number")return 0;if(i==="boolean")return!1}let s;try{s=Vl(r)}catch(n){console.error(r,n);return}let a;try{a=yt(s)}catch(n){console.error(r,s,n)}return a}function yt(e){switch(e.type){case"BinaryExpression":switch(e.operator){case"==":return Number(yt(e.left)===yt(e.right));case"!=":return Number(yt(e.left)!==yt(e.right));case">":return Number(yt(e.left)>yt(e.right));case">=":return Number(yt(e.left)>=yt(e.right));case"<":return Number(yt(e.left)<yt(e.right));case"<=":return Number(yt(e.left)<=yt(e.right));case"+":return yt(e.left)+yt(e.right);case"-":return yt(e.left)-yt(e.right);case"*":return yt(e.left)*yt(e.right);case"/":return yt(e.left)/yt(e.right);case"%":return yt(e.left)%yt(e.right);case"&&":return yt(e.left)&&yt(e.right);case"||":return yt(e.left)||yt(e.right);case"^":return Math.pow(yt(e.left),yt(e.right));default:throw new Error("Unknown operator: "+e.operator)}case"UnaryExpression":switch(e.operator){case"-":return-yt(e.argument);case"!":return Number(!yt(e.argument));default:throw new Error("Unknown operator: "+e.operator)}case"Identifier":throw new Error("Unknown identifier: "+e.name);case"Literal":return e.value;case"CallExpression":if(e.callee.type==="Identifier"){if(e.callee.name==="random"){let t=0,i=1;if(e.arguments.length>=1)try{t=yt(e.arguments[0])}catch(r){console.warn(r)}if(e.arguments.length>=2)try{i=yt(e.arguments[1])}catch(r){console.warn(r)}return t=Math.min(i,t),i=Math.max(i,t),t+Math.random()*(i-t)}return Math[e.callee.name].apply(null,e.arguments.map(yt))}else throw new Error("Unknown node");default:throw new Error("Unknown node type: "+e.type)}}var sj=new me,aj=new me;function nj(e,t,i){let r=[new E,new E,new E],s=[new E,new E,new E];return e.extractBasis(r[0],r[1],r[2]),t.extractBasis(s[0],s[1],s[2]),r.forEach((a,n)=>{let o=s[n],l=Re.lerp(a.length(),o.length(),i);a.lerp(o,i).setLength(l)}),new me().makeBasis(r[0],r[1],r[2])}var oj=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),a=Math.abs(i.depth??0),n=t?.shapeData??W0.create({parameters:T2}).userData.shape;return{path:e.path??Ju.defaultData(),parameters:Object.assign(i,{width:r,height:s,depth:a,extrusion:{...P2,...i.extrusion}}),shapeData:n}}static build(e){if(e.path.points.length>=2){let t=new lj(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}else return Object.assign(new Ue,{userData:{...e,type:"PathGeometry"}})}},lj=class extends Ue{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)||!X8(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;i=Math.max(0,Math.min(i,1)),r=Math.max(0,Math.min(r,1));let s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(r*s),n=this.inputs.path.isClosed?Math.ceil((i+r)*s):Math.ceil(Math.min(1,i+r)*s),o=Math.min(Math.max(2,n-a+1),s+2),l=[],h=[];for(let F=0;F<o;F++){let z=this.inputs.path.isClosed?(F+a)%e.length:Math.min(F+a,e.length-1);l.push(e[z].clone()),h.push(t[z].clone())}let d=(F,z,X)=>{l[F]=l[F].clone().lerp(l[z],X),h[F]=nj(h[F],h[z],X)},c=0,u=r*s%1;(!this.inputs.path.isClosed||i<=1)&&(u||r===0)&&(c=u,d(0,1,c));let p=0,f=(r+i)*s%1;if((this.inputs.path.isClosed&&i<=1||!this.inputs.path.isClosed&&r+i<1)&&f&&(p=f,d(l.length-1,l.length-2,1-p)),i===0){let F=l.length-1;l[F].copy(l[0]),h[F].copy(h[0])}this._applyPathModifiers(h,c,p);let{bevel:m,bevelSides:g}=this.inputs.parameters.extrusion,v=m>0?this.inputs.parameters.extrusion.capType:"flat",y=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(y=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:x,infos:b,vertices:w}=this._computeShapePoints(y),A=0,S;v==="round"&&(S=new H0(this.inputs.shapeData,2*m,m,y,g,void 0,!0),A=S.getAttribute("position").count);let _=0,M=0;b.sort((F,z)=>F.start-z.start),b.forEach(F=>{F.verticesStart=_,F.verticesCount=F.continuous.reduce((z,X,H)=>z+(H===0||!X?2:1),0),M+=F.verticesCount,_=M});let C=M*o,T,D=0;if(this._isOpenEnded()&&v==="flat"){try{T=sn({windingRule:Et.ODD,elementType:ai.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:x})}catch{T=X2}D=T.vertexCount}let P=C+2*D+A*2,O=C+2*D,B={positions:new Float32Array(P*3),normals:new Float32Array(P*3),uvs:new Float32Array(P*2)},G=[];if(b.forEach(F=>{this._extrudeRegion(F,w,h,l,B,G,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(this._closeEnd(T,C,G,B,h[0],l[0],!1),this._closeEnd(T,C+D,G,B,h[h.length-1],l[l.length-1],!0)),S){B.positions.set(S.getAttribute("position").array,O*3),B.normals.set(S.getAttribute("normal").array,O*3),B.uvs.set(S.getAttribute("uv").array,O*2);let F=G.length;G.push(...S.getIndex().array.map(H=>H+O)),O+=A,B.positions.set(S.getAttribute("position").array,O*3),B.normals.set(S.getAttribute("normal").array,O*3),B.uvs.set(S.getAttribute("uv").array,O*2);let z=G.length;G.push(...S.getIndex().array.map(H=>H+O)),this.setAttribute("position",new Ke(B.positions,3)),this.setAttribute("normal",new Ke(B.normals,3)),this.setAttribute("uv",new Ke(B.uvs,2)),this.setIndex(G);let X=sj;X.copy(h[h.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(X,O,P),X.copy(h[0]).setPosition(l[0]).multiply(aj.makeScale(1,1,-1)),this.applyMatrix4OnRange(X,O-A,O),this.reverseIndicesOnRange(F,z)}else this.setAttribute("position",new Ke(B.positions,3)),this.setAttribute("normal",new Ke(B.normals,3)),this.setAttribute("uv",new Ke(B.uvs,2)),this.setIndex(G)}_extractPathPoints(){let e=k2(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(e.length<2)return[];let t=[e[0]];return e.forEach(i=>{t[t.length-1].distanceToSquared(i)>.001&&t.push(i)}),this.inputs.path.isClosed&&t[t.length-1].distanceTo(t[0])<.001&&t.pop(),t}_computeBasisMatrices(e){let t=[],i=e.length,r=this.inputs.path.isClosed,s=new E,a=new E,n=new E,o=new E,l=new E(0,1,0);for(let f=0;f<i;f++){let m=e[f],g;f===0?g=r?e[e.length-2]:m.clone().multiplyScalar(2).sub(e[1]):g=e[f-1];let v;f===i-1?v=r?e[1]:m.clone().multiplyScalar(2).sub(e[f-1]):v=e[f+1];let y=m.clone().sub(g).normalize(),x=v.clone().sub(m).normalize(),b=y.clone().add(x).normalize();n.copy(b),f===0&&(b.equals(l)||b.clone().negate().equals(l))&&l.set(0,0,1);let w=l.clone().cross(b).normalize(),A=b.clone().cross(w).normalize();l.copy(A),o.copy(w),f===0&&(s.copy(A),a.copy(b));let S=new me().makeBasis(w,A,b);t.push(S)}let h=r?a:n,d=r?s:new E(0,1,0),c=h.clone().cross(o).normalize(),u=Math.acos(d.dot(c));if(isNaN(u))return t;let p=d.clone().cross(c);h.dot(p)>0&&(u*=-1);for(let f=1;f<t.length;f++){let m=new me().makeRotationZ(u*f/t.length);t[f].multiply(m)}return t}_applyPathModifiers(e,t,i){let r=e.length,{angle:s,twist:a,startScale:n,endScale:o}=this.inputs.parameters.extrusion,l=new me,h=new me;return e.forEach((d,c)=>{let u=c===0?0:c===r-1?1:(c-t)/(r-(i===0?0:1)-(t+(1-i)));l.makeRotationZ(Re.lerp(s,s+a,u)*Re.DEG2RAD);let p=Re.lerp(n,o,u);h.makeScale(p,p,p),d.multiply(l).multiply(h)}),e}_computeShapePoints(e=12,t=Et.ODD){let i=this.inputs.shapeData,r=i.extractShapePointsToFlatArray([],e),s=i.shapeHoles.map(p=>{let f=p.extractShapePointsToFlatArray([],e),m=[];for(let g=f.length-1;g>=1;g-=2){let v=f[g-1],y=f[g-0];m.push(v,y)}return m}),a;try{a=sn({windingRule:t,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[r]})}catch{a=G0}let n;try{n=sn({windingRule:Et.ODD,elementType:ai.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{n=q2}if(!a)throw new Error("error generating geometry");let o=a.elementCount;if(n){a.elementCount+=n.elementCount;for(let p=0;p<n.elements.length;p++){let f=n.elements[p],m=p%2===0?a.vertexCount:0;a.elements.push(f+m)}for(let p=0;p<n.vertexIndices.length;p++){let f=n.vertexIndices[p],m=a.vertexCount;a.vertexIndices.push(f+m)}for(let p=0;p<n.vertices.length;p++){let f=n.vertices[p];a.vertices.push(f)}}let l=1/0,h=-1/0,d=1/0,c=-1/0;for(let p=0,f=a.vertexCount;p<f;p++){let m=p*2,g=a.vertices[m+0],v=a.vertices[m+1];g<l&&(l=g),g>h&&(h=g),v<d&&(d=v),v>c&&(c=v)}let u=[];for(let p=a.elementCount-1;p>=0;p--){let f=p>=o,m=p*2,g=a.elements[m+0],v=a.elements[m+1],y=g+v,x={start:g,count:v,normals:[],isHole:f,continuous:[],verticesStart:0,verticesCount:0};u.push(x);let b=g,w=y-1,A=g+1,S=i.roundedCurves.length;do{let _=b-g,M=a.vertices[w*2+0],C=a.vertices[w*2+1],T=a.vertices[b*2+0],D=a.vertices[b*2+1],P=a.vertices[A*2+0],O=a.vertices[A*2+1],B=T-M,G=D-C,F=Math.sqrt(B*B+G*G);B/=F,G/=F;let z=T-P,X=D-O,H=Math.sqrt(z*z+X*X);z/=H,X/=H,x.normals[_*2+0]=-X,x.normals[_*2+1]=z;let j=a.vertexIndices[b];if(Array.isArray(j))x.continuous[_]=!1;else{let[N,q]=i.getCurveIndexFromVertexId(j-1,!0);if(q>0&&q<1)x.continuous[_]=!0;else{let V=q===1?N+1:N-1;V=(V+S)%S;let W=q===1?0:1,U=i.roundedCurves[N].getTangent(q),ie=i.roundedCurves[V].getTangent(W);x.continuous[_]=U.dot(ie)>.95}}f&&(x.normals[_*2+0]*=-1,x.normals[_*2+1]*=-1),[w,b,A]=[b,A,A+1],A>=y&&(A-=v)}while(A!==g+1)}return{regions:[r,...s],infos:u,vertices:a.vertices}}_insertVertex(e,t,i,r,s){let a=t*2,n=t*3;e.positions[n+0]=i.x,e.positions[n+1]=i.y,e.positions[n+2]=i.z,e.normals[n+0]=r.x,e.normals[n+1]=r.y,e.normals[n+2]=r.z,e.uvs[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,i,r,s,a,n){let o=new E,l=new E,h=new E,d=new E,c=new k;i.forEach((p,f)=>{let m=r[f],g=e.verticesStart*i.length+e.verticesCount*f;for(let v=0;v<e.count;v++){let y=(e.start+v)*2;if(o.set(t[y+0],t[y+1],0),h.copy(o).applyMatrix4(p).add(m),e.continuous[v])d.set(e.normals[v*2+0],e.normals[v*2+1],0);else{let x=v===0?(e.start+e.count-1)*2:y-2;l.set(t[x+0],t[x+1],0),d.copy(o).sub(l),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(p).normalize(),c.set(v===0?1:v/e.count,f/(i.length-1)),this._insertVertex(s,g,h,d,c),g++,!e.continuous[v]||v===0){if(v===0)d.set(e.normals[v*2+0],e.normals[v*2+1],0),c.set(0,f/(i.length-1));else{let x=v===e.count-1?e.start*2:y+2;l.set(t[x+0],t[x+1],0),d.copy(l).sub(o),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(p).normalize(),this._insertVertex(s,g,h,d,c),g++}}});let u=i.length-1;for(let p=0;p<u;p++){let f=e.verticesStart*i.length+e.verticesCount*p,m=e.verticesStart*i.length+e.verticesCount*(p+1),g=0;for(let v=0;v<e.count;v++){(!e.continuous[v]||v===0)&&g++;let y=v===e.count-1?0:g+1,x=f+g,b=f+y,w=m+y,A=m+g;e.isHole?a.push(x,w,b,x,A,w):a.push(x,b,w,x,w,A),g++}}}_closeEnd(e,t,i,r,s,a,n){let o=e.vertexCount,l=new E(0,0,n?-1:1).applyMatrix4(s),h=new E,d=new k;for(let u=0;u<o;u++){let p=2*u;h.set(e.vertices[p+0],e.vertices[p+1],0).applyMatrix4(s).add(a),this._insertVertex(r,t+u,h,l,d)}let c=e.elements;for(let u=0;u<e.elementCount;u++){let p=3*u,f=c[p+0]+t,m=c[p+(n?1:2)]+t,g=c[p+(n?2:1)]+t;i.push(f,m,g)}}applyMatrix4OnRange(e,t,i){let r=e.elements,s=new Ai().getNormalMatrix(e).elements,a,n,o,l,h=this.attributes.position,d=this.attributes.normal;if(!h||!d)return;let c=h.array,u=d.array,p=h.itemSize;for(let f=t*p,m=i*p;f<m;f+=p){if(f===t)debugger;a=c[f+0],n=c[f+1],o=c[f+2],l=1/(r[3]*a+r[7]*n+r[11]*o+r[15]),c[f+0]=(r[0]*a+r[4]*n+r[8]*o+r[12])*l,c[f+1]=(r[1]*a+r[5]*n+r[9]*o+r[13])*l,c[f+2]=(r[2]*a+r[6]*n+r[10]*o+r[14])*l,a=u[f+0],n=u[f+1],o=u[f+2],u[f+0]=s[0]*a+s[3]*n+s[6]*o,u[f+1]=s[1]*a+s[4]*n+s[7]*o,u[f+2]=s[2]*a+s[5]*n+s[8]*o}h.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,t){let i=this.index;if(i){for(let r=e;r<t;r+=3){let s=i.getX(r),a=i.getX(r+1),n=i.getX(r+2);i.setXYZ(r,n,a,s)}i.needsUpdate=!0}}};function nM(){let e=new Ue;return e.setAttribute("position",new Ke(new Float32Array([]),3)),e.setIndex(new Ke(new Uint16Array([]),1)),e}var hj=nM().attributes,cj=12,dj=1,oM=class extends Ue{constructor(e,t){super(),this.charWidths=[],this.charCoords=[],this.wrappedText=[],this.isLowResolution=!1,this.vectorShapes=[],Object.assign(this.attributes,hj),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:a,extrudeBevelSegments:n,text:o,textTransform:l}=e,h=Dr.getDisplayedValue(o),d=l===2?h.toUpperCase():l===3?h.toLowerCase():h,c=uj(e,t,d),{shapes:u,charWidths:p,charCoords:f}=t.generateShapes(c,e),m=(typeof i=="number"?i:1)*.5,g=(typeof r=="number"?r:1)*.5,v=u.map(b=>new qt().fromShape(b,!0));this.vectorShapes=v;let y=v.map(b=>uo.create({shape:b,parameters:{depth:s,extrudeBevelSegments:n,extrudeBevelSize:a,windingRule:s<=0?Et.NONZERO:Et.ODD,subdivisions:this.isLowResolution&&s>0?dj:cj}})),x=y.length?Hn(y):nM();x.translate(-m,g,0),this.dispose(),this.wrappedText=c,this.charCoords=f,this.charWidths=p,this.deleteAttribute("extrudeNormal"),Object.entries(x.attributes).forEach(([b,w])=>{this.setAttribute(b,w)}),this.setIndex(x.index),this.computeBoundingSphere()}clone(){let e=Ca(new Ue,oM.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 uj(e,t,i){let r=[""],s="";for(let a of i)s+=a,a===" "||a===`
3140
3140
  `?(r[r.length-1]+=s,s="",a===`
3141
- `&&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 lM,q0=new Promise(e=>{lM=e}),ww=!1,Wd;function pj(){if(ww)return;if(Wd)return Wd;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.496/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});lM(n),ww=!0}return Wd=e(),Wd}function cp(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let d=a;for(let c of h)d=d[c];for(s in d){let c=d[s];p6(c)&&(d[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=qt.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new lA().parse(a);else if(a.type==="SubdivGeometry"){let h=new Qi(a,i);return h.data=e,h}else if(a.type==="TextGeometry")return new oM(a,t);let l;try{l=Ew(o)}catch(h){console.error(h)}if(!l){let h=qt.createFromState(Ku.defaultData(),100,100);o.shape=h,l=Ew(o)}return l}var fj=new me;function fv(e,t,i,r){let s=e.position.array,a=e.normal.array,n=fj.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=a[d],l=a[d+1],h=a[d+2],a[d]=n[0]*o+n[4]*l+n[8]*h,a[d+1]=n[1]*o+n[5]*l+n[9]*h,a[d+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var qd=new $t,Uo=new E,je;q0.then(e=>{je=e});var _w=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Sw=new Uint32Array([0,1,2,3]),Aw=new Uint8Array([4]),Qi=class extends Ue{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=Kn.div(t,i);this.subdividedGeometry&&fv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&fv(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(Uo.fromArray(r));let a=Uo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Qi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Hs(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&&(Qi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;qd.setFromBufferAttribute(t),qd.getCenter(i),e.boundingSphere.radius=i.distanceTo(qd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qd.getSize(Uo);let r={width:Uo.x,height:Uo.y,depth:Uo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(je.free_bvh(t),je.free_subdivision_surface(t));try{s=Qi.allocate(e,r)}catch(l){console.error(l,e),s=Qi.allocate({positionWASM:_w,indexWASM:Sw,verticesPerFaceWASM:Aw},r)}if(je.set_destination_refinement_level(s,0),a=Qi.buildLevel(s,!0,o),e.subdivisions>0)try{je.set_destination_refinement_level(s,e.subdivisions),n=Qi.buildLevel(s,!1,o)}catch{try{je.set_destination_refinement_level(s,e.subdivisions-1),n=Qi.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:cp(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=kp(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:n,verticesPerFace:o}=hM(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=_w,r=Sw,s=Aw);let o=i.length,l=r.length,h=s.length,d=i.length+a.length+n.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=je._malloc(u),g=new Float32Array(je.HEAPF32.buffer,m,d),v=new Uint32Array(je.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?je.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):je.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return je._free(m),x}static buildLevel(e,t,i,r,s){let a=s?je.get_mesh_data2(e,t?je.Level.CONTROL:je.Level.REFINED,i,s.elements):je.get_mesh_data(e,t?je.Level.CONTROL:je.Level.REFINED,i),n=8,o=je.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,d=je.HEAPU32[o[h]>>2],c=je.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=je.HEAPU32[o[h]>>2],p=je.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=je.HEAPU32[o[h]>>2],m=je.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=je.HEAPU32[o[h]>>2],v=je.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new Ue;if(y.setIndex(new ul(v,1)),y.setAttribute("position",new Te(c,3)),y.setAttribute("normal",new Te(p,3)),t){y.setAttribute("faceMap",new ul(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ke(x,4))}return je.free_mesh_data(a),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,je.free_mesh_data(a)}static freeSubdivPointer(e){je.free_bvh(e),je.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=je.get_wireframe_data_for_base_level(e),s=4,a=je.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=je.HEAPU32[a[o]>>2],h=je.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let d=je.HEAPU32[a[o]>>2],c=je.HEAPU32.subarray(d>>2,(d>>2)+n[o]);if(t===void 0){let u=new Ue;u.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ke(p,3)),u.setIndex(new ul(c,1)),je.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,je.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||je.set_destination_refinement_level(e,t);let s=i?je.get_topological_data2(e,r?je.Level.CONTROL:je.Level.REFINED,i.elements):je.get_topological_data(e,r?je.Level.CONTROL:je.Level.REFINED),a=6,n=je.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=je.HEAPU32[n[l]>>2],d=new Float32Array(je.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=je.HEAPU32[n[l]>>2],u=new Uint32Array(je.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=je.HEAPU32[n[l]>>2],f=new Uint8Array(je.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return je.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},Mw=["getX","getY","getZ"];function kp(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[Mw[u]](d)*o)},`;if(c in i)a.push(i[c]);else{for(let u=0;u<3;u++)n.push(e[Mw[u]](d));i[c]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var Xd=new E,mm=new E,gm=new E,vm=new E;function hM(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let d=0;for(let u=0;u<l.length;u+=2)d+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let c=0;if(d<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),s.push(c++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),s.push(c++);return a.push(c),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Xd.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),mm.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),gm.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),vm.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),mm.sub(Xd).normalize(),gm.sub(Xd).normalize(),vm.sub(Xd).normalize();let l=mm.cross(gm).dot(vm);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:o>=r[d]&&o<r[d+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],d=0;for(let c=0,u=0;c<e.length;c+=3,u++)e[c+2]===0&&(l.push(u),d++),e[c+2]===n&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(d,d)}return{indices:s,verticesPerFace:a}}var fa={};NC(fa,{calcBoolean:()=>xj,calcBooleanTopological:()=>yj,freeMeshSet:()=>Sj,getMeshSet:()=>bj,hasOpenEdges:()=>wj,transformMeshSet:()=>_j});var cM,mj=new Promise(e=>{cM=e}),Yd;function gj(){if(Yd)return Yd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.496/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});cM(n)}return Yd=e(),Yd}var lt,_l;mj.then(e=>lt=e);function vj(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=kp(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=hM(a,n,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=n[h++],r[d++]=n[h++],r[d++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function dM(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=lt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(lt.HEAPU32.buffer,a,t):new Float32Array(lt.HEAPF32.buffer,a,t)).set(e,0),a}function uM(e){switch(e){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function yj(e,t){_l===void 0&&(_l=lt.init_csg());let i=dM(e),r=lt.csg_calc_topological(_l,i,e.length,uM(t));lt._free(i);let s=6,a=lt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=lt.HEAPU32[a[o]>>2],h=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let d=lt.HEAPU32[a[o]>>2],c=new Uint32Array(lt.HEAPU32.subarray(d>>2,(d>>2)+n[o]));o++;let u=lt.HEAPU32[a[o]>>2],p=new Uint8Array(lt.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return lt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function xj(e,t,i,r){_l===void 0&&(_l=lt.init_csg());let s=dM(e),a=lt.csg_calc(_l,s,e.length,r,uM(t));lt._free(s);let n=5,o=lt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,d=lt.HEAPU32[o[h]>>2],c=lt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=lt.HEAPU32[o[h]>>2],p=lt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Te(c,3)),i.setAttribute("normal",new Te(p,3));let m=lt.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new vr),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},lt.free_mesh_data(a),f}function bj(e,t,i){if(lt===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let g=e.userData;a=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let b=0;b<g.verticesPerFace[v];b++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:a}=vj(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=lt._malloc(d),f=new Float32Array(lt.HEAPF32.buffer,p,l),m=new Uint32Array(lt.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),lt.get_csg_mesh(p,n,p+c,o,a)}function wj(e){return lt.has_open_edges(e)}function _j(e,t){lt.transform_csg_mesh(e,t.elements)}function Sj(e){lt.free_csg_mesh(e)}var Aj={ConeGeometry:HV,CubeGeometry:WV,CylinderGeometry:U2,DodecahedronGeometry:XV,EllipseGeometry:W0,HelixGeometry:M8,IcosahedronGeometry:E8,LatheGeometry:C8,NonParametricGeometry:R8,PolygonGeometry:iM,PyramidGeometry:B8,RectangleGeometry:rM,SphereGeometry:k8,PlaneGeometry:U8,BackdropGeometry:F8,StarGeometry:sM,TextFrameGeometry:j8,TorusGeometry:G8,TorusKnotGeometry:W8,TriangleGeometry:q8,PathGeometry:oj,VectorGeometry:uo},Ew=e=>Aj[e.type].create(e);function Fo(e){return e!==null&&"booleanOp"in e}var pM=class extends U0(ur){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(){super.updateVisible(),this.visible=!Fo(this.parent)&&this.visible,Fo(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(fa.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fo(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof pM&&(e.freeBooleanPointer(),Fo(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Fo(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Fo(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Qd=new $t;function X0(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),f=e.getZ(c);u<a&&(a=u),p<n&&(n=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>d&&(d=f)}Qd.min.set(a,n,o),Qd.max.set(l,h,d),Qd.getCenter(r),Qd.getSize(s).multiplyScalar(.5)}var Mj=new Ue,Ej=new Lc,yr=class extends pM{constructor(e,t){super(Mj,Ej),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?X0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Cw=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}},yn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=Re.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,a){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 yn&&(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}},Cj=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}},dr=new Cj,Pt=class extends yn{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=Re.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,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}},xr=class extends Pt{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,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},Di=class extends xr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},kr=class extends xr{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,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},gr=class extends He{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],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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}},ma=class extends xr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof gr?e:new gr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Tj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Tw=/[a-z_0-9]+/gi,Se=class extends Pt{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 a,n=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(;a=Tw.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&dr.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=dr.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||dr.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[d.index+n-1]!=="."&&(o=o.substring(0,d.index+n)+p+o.substring(d.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&dr.contains(p)&&e.include(dr.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=Tj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(Tw);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Pj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,fM=class extends Pt{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||fM.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 a,n,o="",l=Pj.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,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)}},Mt=fM;Mt.PI="PI",Mt.PI2="PI2",Mt.RECIPROCAL_PI="RECIPROCAL_PI",Mt.RECIPROCAL_PI2="RECIPROCAL_PI2",Mt.LOG2="LOG2",Mt.EPSILON="EPSILON";var Dj=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3141
+ `&&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 lM,q0=new Promise(e=>{lM=e}),ww=!1,Wd;function pj(){if(ww)return;if(Wd)return Wd;async function e(){let t="https://unpkg.com/@splinetool/modelling-wasm@0.9.497/build",i=import("./process.js"),[r,s]=await Promise.all([i,fetch(`${t}/process.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});lM(n),ww=!0}return Wd=e(),Wd}function cp(e,t,i,r){let s,a,n;e.type==="PathGeometry"?(a=JSON.parse(JSON.stringify(e)),n=[[],["extrusion"]]):(a={...e},n=[[]]);for(let h of n){let d=a;for(let c of h)d=d[c];for(s in d){let c=d[s];p6(c)&&(d[s]=t.getVariable(c,[r.uuid,"geometry",...h,s]))}}let o={parameters:a,type:a.type};if(a.type==="PathGeometry")o.path=a.path;else if(a.type==="VectorGeometry"){let h=qt.createFromState(a.shape,a.width,a.height);o.shape=h}else if(a.type==="NonParametricGeometry")a.data.groups&&a.data.groups?.forEach(h=>h.materialIndex=Math.max(h.materialIndex??0,0)),o.geometry=new lA().parse(a);else if(a.type==="SubdivGeometry"){let h=new Qi(a,i);return h.data=e,h}else if(a.type==="TextGeometry")return new oM(a,t);let l;try{l=Ew(o)}catch(h){console.error(h)}if(!l){let h=qt.createFromState(Ku.defaultData(),100,100);o.shape=h,l=Ew(o)}return l}var fj=new me;function fv(e,t,i,r){let s=e.position.array,a=e.normal.array,n=fj.makeScale(t,i,r).invert().elements,o,l,h;for(var d=0,c=s.length;d<c;d+=3)s[d]*=t,s[d+1]*=i,s[d+2]*=r,o=a[d],l=a[d+1],h=a[d+2],a[d]=n[0]*o+n[4]*l+n[8]*h,a[d+1]=n[1]*o+n[5]*l+n[9]*h,a[d+2]=n[2]*o+n[6]*l+n[10]*h;e.position.needsUpdate=!0,e.normal.needsUpdate=!0}var qd=new $t,Uo=new E,je;q0.then(e=>{je=e});var _w=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Sw=new Uint32Array([0,1,2,3]),Aw=new Uint8Array([4]),Qi=class extends Ue{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=Kn.div(t,i);this.subdividedGeometry&&fv(this.subdividedGeometry.attributes,...r),this.originalGeometry&&fv(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(Uo.fromArray(r));let a=Uo.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,i;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:i}=Qi.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Hs(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&&(Qi.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new vr,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,i=e.boundingSphere.center;qd.setFromBufferAttribute(t),qd.getCenter(i),e.boundingSphere.radius=i.distanceTo(qd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),qd.getSize(Uo);let r={width:Uo.x,height:Uo.y,depth:Uo.z};return this.userData.parameters=r,r}static build(e,t,i,r){let s,a,n,o=e?.phongAngle??35;i===!1&&(o=-1),t&&(je.free_bvh(t),je.free_subdivision_surface(t));try{s=Qi.allocate(e,r)}catch(l){console.error(l,e),s=Qi.allocate({positionWASM:_w,indexWASM:Sw,verticesPerFaceWASM:Aw},r)}if(je.set_destination_refinement_level(s,0),a=Qi.buildLevel(s,!0,o),e.subdivisions>0)try{je.set_destination_refinement_level(s,e.subdivisions),n=Qi.buildLevel(s,!1,o)}catch{try{je.set_destination_refinement_level(s,e.subdivisions-1),n=Qi.buildLevel(s,!1,o)}catch{n=null}}else n=null;return{subdivPointer:s,originalGeometry:a,subdividedGeometry:n}}static primitiveToQuads(e,t,i){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let r=e.shape!==void 0||e.path!==void 0?t.geometry:cp(e,i,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=r.getClosedTorusIndicesForBooleanOrSubdiv():s=r.getIndex();let a,n,o,l;({positions:a,triIndices:l}=kp(r.getAttribute("position"),s));let h;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,c=d+e.radialSegments*3;h=[d,c]}return{indices:n,verticesPerFace:o}=hM(a,l,r,h),{positions:a,indices:n,verticesPerFace:o}}static allocate(e,t){let i,r,s,a=[],n=[];e.positionWASM&&e.positionWASM.length>0?(i=e.positionWASM,r=e.indexWASM,s=e.verticesPerFaceWASM):(i=_w,r=Sw,s=Aw);let o=i.length,l=r.length,h=s.length,d=i.length+a.length+n.length,c=r.length+s.length,u=d*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=d*Float32Array.BYTES_PER_ELEMENT,f=c*Uint32Array.BYTES_PER_ELEMENT,m=je._malloc(u),g=new Float32Array(je.HEAPF32.buffer,m,d),v=new Uint32Array(je.HEAPU32.buffer,m+p,c);g.set(i,0),g.set(a,i.length),g.set(n,i.length+a.length),v.set(r,0),v.set(s,r.length);let y;e?.scaleBaked?.some(b=>b!==1)&&(y=new me().makeScale(...e.scaleBaked)),t&&(y?y.premultiply(t):y=t);let x=y?je.alloc_subdivision_surface2(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h,y.elements):je.alloc_subdivision_surface(m,o,m+p,l,m+p+r.length*Uint32Array.BYTES_PER_ELEMENT,h);return je._free(m),x}static buildLevel(e,t,i,r,s){let a=s?je.get_mesh_data2(e,t?je.Level.CONTROL:je.Level.REFINED,i,s.elements):je.get_mesh_data(e,t?je.Level.CONTROL:je.Level.REFINED,i),n=8,o=je.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(4,4+4),h=0,d=je.HEAPU32[o[h]>>2],c=je.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=je.HEAPU32[o[h]>>2],p=je.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=je.HEAPU32[o[h]>>2],m=je.HEAPU32.subarray(f>>2,(f>>2)+l[h]);h++;let g=je.HEAPU32[o[h]>>2],v=je.HEAPU32.subarray(g>>2,(g>>2)+l[h]);if(h++,r===void 0){let y=new Ue;if(y.setIndex(new ul(v,1)),y.setAttribute("position",new Te(c,3)),y.setAttribute("normal",new Te(p,3)),t){y.setAttribute("faceMap",new ul(m,1));let x=new Float32Array(p.length/3*4).fill(0);y.setAttribute("color",new Ke(x,4))}return je.free_mesh_data(a),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,je.free_mesh_data(a)}static freeSubdivPointer(e){je.free_bvh(e),je.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,i){let r=je.get_wireframe_data_for_base_level(e),s=4,a=je.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(2,2+2),o=0,l=je.HEAPU32[a[o]>>2],h=je.HEAPF32.subarray(l>>2,(l>>2)+n[o]);o++;let d=je.HEAPU32[a[o]>>2],c=je.HEAPU32.subarray(d>>2,(d>>2)+n[o]);if(t===void 0){let u=new Ue;u.setAttribute("position",new Te(h,3));let p=new Float32Array(h.length);for(let f=0,m=h.length;f<m;)p[f++]=i.r,p[f++]=i.g,p[f++]=i.b;return u.setAttribute("color",new Ke(p,3)),u.setIndex(new ul(c,1)),je.free_wireframe_data_for_base_level(r),u}t.getAttribute("position").copyArray(h),t.attributes.position.needsUpdate=!0,je.free_wireframe_data_for_base_level(r)}static updateCollabMesh(e,t,i){let r=t===0;r||je.set_destination_refinement_level(e,t);let s=i?je.get_topological_data2(e,r?je.Level.CONTROL:je.Level.REFINED,i.elements):je.get_topological_data(e,r?je.Level.CONTROL:je.Level.REFINED),a=6,n=je.HEAPU32.subarray(s>>2,(s>>2)+a),o=n.subarray(3,3+3),l=0,h=je.HEAPU32[n[l]>>2],d=new Float32Array(je.HEAPF32.subarray(h>>2,(h>>2)+o[l]));l++;let c=je.HEAPU32[n[l]>>2],u=new Uint32Array(je.HEAPU32.subarray(c>>2,(c>>2)+o[l]));l++;let p=je.HEAPU32[n[l]>>2],f=new Uint8Array(je.HEAPU32.subarray(p>>2,(p>>2)+o[l]));return je.free_topological_data(s),{positions:d,indices:u,verticesPerFace:f}}},Mw=["getX","getY","getZ"];function kp(e,t){let i={},r=t?t.count:e.count,s=0,a=[],n=[],o=1e4;for(let h=0;h<r;h++){let d=t?t.getX(h):h,c="";for(let u=0;u<3;u++)c+=`${~~(e[Mw[u]](d)*o)},`;if(c in i)a.push(i[c]);else{for(let u=0;u<3;u++)n.push(e[Mw[u]](d));i[c]=s,a.push(s),s++}}let l=[];for(let h=0;h<a.length;h+=3)a[h]===a[h+1]||a[h]===a[h+2]||a[h+1]===a[h+2]||l.push(a[h],a[h+1],a[h+2]);return{positions:n,triIndices:l}}var Xd=new E,mm=new E,gm=new E,vm=new E;function hM(e,t,i,r){let s=[],a=[];if(i.userData.shape!==void 0&&i.userData.parameters.depth===0&&i.userData.shape.shapeHoles.length===0){let l=i.userData.shape.extractShapePointsToFlatArray([]),h=i.userData.parameters.spikes;if(i.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&i.userData.parameters.angle>=360){let u=l.length/2/h;l=l.filter((p,f)=>Math.floor(f/2)%u===0)}let d=0;for(let u=0;u<l.length;u+=2)d+=(l[u]-l[(u===0?l.length:u)-2])*(l[u+1]+l[(u===0?l.length:u)-1]);e.length=0;let c=0;if(d<0)for(let u=0;u<l.length;u+=2)e.push(l[u],l[u+1],0),s.push(c++);else for(let u=l.length-2;u>=0;u-=2)e.push(l[u],l[u+1],0),s.push(c++);return a.push(c),{indices:s,verticesPerFace:a}}let n=new Float32Array([i.userData.parameters.depth])[0],o=0;for(;o<t.length;){if(i.useNgonForTopBottomFaceDuringBake){let l=0;if((e[t[o]*3+2]===n||e[t[o]*3+2]===0)&&l++,(e[t[o+1]*3+2]===n||e[t[o+1]*3+2]===0)&&l++,(e[t[o+2]*3+2]===n||e[t[o+2]*3+2]===0)&&l++,l===3)break}if(t[o+1]===t[o+3]&&t[o+2]===t[o+5]||t[o+0]===t[o+3]&&t[o+2]===t[o+4]){Xd.set(e[t[o]*3],e[t[o]*3+1],e[t[o]*3+2]),mm.set(e[t[o+1]*3],e[t[o+1]*3+1],e[t[o+1]*3+2]),gm.set(e[t[o+4]*3],e[t[o+4]*3+1],e[t[o+4]*3+2]),vm.set(e[t[o+5]*3],e[t[o+5]*3+1],e[t[o+5]*3+2]),mm.sub(Xd).normalize(),gm.sub(Xd).normalize(),vm.sub(Xd).normalize();let l=mm.cross(gm).dot(vm);Math.abs(l)>.005||r&&r.some((h,d)=>d%2===1?!1:o>=r[d]&&o<r[d+1])?(s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3):(s.push(t[o],t[o+1],t[o+4],t[o+5]),a.push(4),o+=6)}else s.push(t[o],t[o+1],t[o+2]),a.push(3),o+=3}if(i.useNgonForTopBottomFaceDuringBake){let l=[],h=[],d=0;for(let c=0,u=0;c<e.length;c+=3,u++)e[c+2]===0&&(l.push(u),d++),e[c+2]===n&&h.push(u);if(i.userData.parameters.extrudeBevelSize===0){let c=h[0];h[0]=h[1],h[1]=c}l.reverse(),s.push(...l,...h),a.push(d,d)}return{indices:s,verticesPerFace:a}}var fa={};NC(fa,{calcBoolean:()=>xj,calcBooleanTopological:()=>yj,freeMeshSet:()=>Sj,getMeshSet:()=>bj,hasOpenEdges:()=>wj,transformMeshSet:()=>_j});var cM,mj=new Promise(e=>{cM=e}),Yd;function gj(){if(Yd)return Yd;async function e(){let t="https://unpkg.com/@splinetool/boolean-wasm@0.9.497/build",i=import("./boolean.js"),[r,s]=await Promise.all([i,fetch(`${t}/boolean.wasm`).then(o=>o.arrayBuffer())]),a=r.default,n=await a({wasmBinary:s});cM(n)}return Yd=e(),Yd}var lt,_l;mj.then(e=>lt=e);function vj(e,t,i){let r,s;e.userData.parameters.type==="TorusGeometry"&&e.userData.parameters.arc===Math.PI*2?s=e.getClosedTorusIndicesForBooleanOrSubdiv():s=e.getIndex();let{positions:a,triIndices:n}=kp(e.getAttribute("position"),s),o;if(t&&i){let{indices:l,verticesPerFace:h}=hM(a,n,e);o=h.length,r=[];for(let d=0,c=0;d<o;d++){r.push(h[d]);for(let u=0;u<h[d];u++)r.push(l[c++])}}else{let l=n.length;r=Array(l+l/3),o=0;for(let h=0,d=0;d<r.length;)r[d++]=3,o++,r[d++]=n[h++],r[d++]=n[h++],r[d++]=n[h++]}return{positions:a,faceIndices:r,nFaces:o}}function dM(e){let t=e.length,i=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,s=Number.isInteger(e[0])?i:r,a=lt._malloc(s);return(Number.isInteger(e[0])?new Uint32Array(lt.HEAPU32.buffer,a,t):new Float32Array(lt.HEAPF32.buffer,a,t)).set(e,0),a}function uM(e){switch(e){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+e)}}function yj(e,t){_l===void 0&&(_l=lt.init_csg());let i=dM(e),r=lt.csg_calc_topological(_l,i,e.length,uM(t));lt._free(i);let s=6,a=lt.HEAPU32.subarray(r>>2,(r>>2)+s),n=a.subarray(3,3+3),o=0,l=lt.HEAPU32[a[o]>>2],h=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+n[o]));o++;let d=lt.HEAPU32[a[o]>>2],c=new Uint32Array(lt.HEAPU32.subarray(d>>2,(d>>2)+n[o]));o++;let u=lt.HEAPU32[a[o]>>2],p=new Uint8Array(lt.HEAPU32.subarray(u>>2,(u>>2)+n[o]));return lt.free_mesh_data(r),{positions:h,indices:c,verticesPerFace:p}}function xj(e,t,i,r){_l===void 0&&(_l=lt.init_csg());let s=dM(e),a=lt.csg_calc(_l,s,e.length,r,uM(t));lt._free(s);let n=5,o=lt.HEAPU32.subarray(a>>2,(a>>2)+n),l=o.subarray(2,2+3),h=0,d=lt.HEAPU32[o[h]>>2],c=lt.HEAPF32.subarray(d>>2,(d>>2)+l[h]);h++;let u=lt.HEAPU32[o[h]>>2],p=lt.HEAPF32.subarray(u>>2,(u>>2)+l[h]);h++;let f=l[h];i.setAttribute("position",new Te(c,3)),i.setAttribute("normal",new Te(p,3));let m=lt.HEAPF32.subarray((a>>2)+5,(a>>2)+5+6);return i.boundingSphere===null&&(i.boundingSphere=new vr),i.boundingSphere.radius=-1,i.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},lt.free_mesh_data(a),f}function bj(e,t,i){if(lt===void 0)return-1;let r,s,a;if(t&&e.userData.positions!==void 0){let g=e.userData;a=g.verticesPerFace.length,r=g.positions,s=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+a);for(let v=0,y=0,x=0;v<g.verticesPerFace.length;v++){s[x++]=g.verticesPerFace[v];for(let b=0;b<g.verticesPerFace[v];b++)s[x++]=g.indices[y++]}}else({positions:r,faceIndices:s,nFaces:a}=vj(e,t,i));let n=r.length,o=s.length,l=r.length,h=s.length,d=l*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,c=l*Float32Array.BYTES_PER_ELEMENT,u=h*Uint32Array.BYTES_PER_ELEMENT,p=lt._malloc(d),f=new Float32Array(lt.HEAPF32.buffer,p,l),m=new Uint32Array(lt.HEAPU32.buffer,p+c,h);return f.set(r,0),m.set(s,0),lt.get_csg_mesh(p,n,p+c,o,a)}function wj(e){return lt.has_open_edges(e)}function _j(e,t){lt.transform_csg_mesh(e,t.elements)}function Sj(e){lt.free_csg_mesh(e)}var Aj={ConeGeometry:HV,CubeGeometry:WV,CylinderGeometry:U2,DodecahedronGeometry:XV,EllipseGeometry:W0,HelixGeometry:M8,IcosahedronGeometry:E8,LatheGeometry:C8,NonParametricGeometry:R8,PolygonGeometry:iM,PyramidGeometry:B8,RectangleGeometry:rM,SphereGeometry:k8,PlaneGeometry:U8,BackdropGeometry:F8,StarGeometry:sM,TextFrameGeometry:j8,TorusGeometry:G8,TorusKnotGeometry:W8,TriangleGeometry:q8,PathGeometry:oj,VectorGeometry:uo},Ew=e=>Aj[e.type].create(e);function Fo(e){return e!==null&&"booleanOp"in e}var pM=class extends U0(ur){constructor(){super(...arguments),this.booleanMeshSetAddress=-1,this.booleanWasTransformed=!1,this.booleanMatrixInvOld=new me}updateVisible(){super.updateVisible(),this.visible=!Fo(this.parent)&&this.visible,Fo(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(fa.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Fo(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof pM&&(e.freeBooleanPointer(),Fo(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let i=super.updateTransformState(e,t);return i&&Fo(this.parent)&&this.invalidateDownstreamBooleanData(!0),i}onVariableUpdate(e=!1){super.onVariableUpdate(e),Fo(this.parent)&&this.invalidateDownstreamBooleanData(!0)}},Qd=new $t;function X0(e,t=0,i=e.count,r,s){let a=1/0,n=1/0,o=1/0,l=-1/0,h=-1/0,d=-1/0;for(let c=t;c<i;c++){let u=e.getX(c),p=e.getY(c),f=e.getZ(c);u<a&&(a=u),p<n&&(n=p),f<o&&(o=f),u>l&&(l=u),p>h&&(h=p),f>d&&(d=f)}Qd.min.set(a,n,o),Qd.max.set(l,h,d),Qd.getCenter(r),Qd.getSize(s).multiplyScalar(.5)}var Mj=new Ue,Ej=new Lc,yr=class extends pM{constructor(e,t){super(Mj,Ej),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?X0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Cw=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}},yn=class{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=Re.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,a){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 yn&&(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}},Cj=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}},dr=new Cj,Pt=class extends yn{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=Re.generateUUID()),i=e.getUUID(i??this.getUUID(),!s);let a=e.getNodeData(i),n=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,i)):super.build(e,t,i);if(s)return a.name=a.name||super.build(e,t,i),a.name;if(!this.getLabel()&&(!this.getShared(e,n)||e.context.ignoreCache||a.deps===1))return super.build(e,t,i);i=this.getUUID(!1);let o=this.getTemp(e,i);if(o)return e.format(o,n,t);{o=super.generate(e,t,i,a.output,r);let l=this.generate(e,n,i);return e.addNodeCode(o+" = "+l+";"),e.format(o,n,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}},xr=class extends Pt{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,a){i=e.getUUID(i??this.getUUID()),r=r??this.getType(e);let n=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,i,r,s,a):e.isShader("vertex")?(n.vertex||(n.vertex=e.createVertexUniform(r,this,s,a,this.getLabel())),e.format(n.vertex.name,r,t)):(n.fragment||(n.fragment=e.createFragmentUniform(r,this,s,a,this.getLabel())),e.format(n.fragment.name,r,t))}},Di=class extends xr{constructor(e=0,t){super("v2"),this.nodeType="Vector2",this.value=e instanceof k?e:new k(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,i,r,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",r,t)}},kr=class extends xr{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,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",r,t)}},gr=class extends He{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],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))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(a))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}},ma=class extends xr{constructor(e){super("v4"),this.nodeType="Vector4",this.value=e instanceof gr?e:new gr(e.r,e.g,e.b,e.a)}generateReadonly(e,t,i,r,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",r,t)}},Tj=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Tw=/[a-z_0-9]+/gi,Se=class extends Pt{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 a,n=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(;a=Tw.exec(this.src);)l.push(a);for(let h=0;h<l.length;h++){let d=l[h],c=d[0],u=this.isMethod?!this.getInputByName(c):!0,p=c;if(this.keywords[c]||this.useKeywords&&u&&dr.containsKeyword(c)){let f=this.keywords[c];if(!f){let m=dr.getKeywordData(c);m.cache&&(f=e.keywords[c]),f=f||dr.getKeyword(c,e),m.cache&&(e.keywords[c]=f)}p=f.build(e)}c!==p&&o[d.index+n-1]!=="."&&(o=o.substring(0,d.index+n)+p+o.substring(d.index+c.length+n),n+=p.length-c.length),this.getIncludeByName(p)===void 0&&dr.contains(p)&&e.include(dr.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=Tj.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(Tw);if(a){let n=0;for(;n<a.length;){let o=a[n++],l;o==="in"||o==="out"||o==="inout"?l=a[n++]:(l=o,o="");let h=a[n++];this.inputs.push({name:h,type:l,qualifier:o})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}},Pj=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,fM=class extends Pt{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||fM.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 a,n,o="",l=Pj.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(n=l[1],a=l[2],o=l[3]):(a=this.src,n="f"),this.name=a,this.type=n,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)}},Mt=fM;Mt.PI="PI",Mt.PI2="PI2",Mt.RECIPROCAL_PI="RECIPROCAL_PI",Mt.RECIPROCAL_PI2="RECIPROCAL_PI2",Mt.LOG2="LOG2",Mt.EPSILON="EPSILON";var Dj=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3142
3142
  )*?)}`,"gim"),Ij=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),mM=class extends Pt{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=Dj.exec(e);if(t){let i=t[2],r;for(;r=Ij.exec(i);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}},Y0=class extends Pt{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)}};dr.addKeyword("uv",function(){return new Y0});dr.addKeyword("uv2",function(){return new Y0(1)});var el=class extends Pt{constructor(e,t){super("v4"),this.nodeType="ColorSpace",this.input=e,this.method=t??el.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Gs:return["Linear"];case tt:return["sRGB"];default:return[]}}generate(e,t){let i=this.input.build(e,"v4"),r=this.getType(e),s=el.Nodes[this.method],a=e.include(s);if(a===el.LINEAR_TO_LINEAR)return e.format(i,r,t);if(s.inputs?.length===2){let n=this.factor.build(e,"f");return e.format(a+"( "+i+", "+n+" )",r,t)}else return e.format(a+"( "+i+" )",r,t)}fromEncoding(e){let t=el.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=el.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Fs=el;Fs.Nodes={LinearToLinear:new Se(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3143
3143
  `)),sRGBToLinear:new Se(["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(`
3144
3144
  `)),LinearTosRGB:new Se(["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(`
@@ -3393,7 +3393,7 @@ gVelocity = vec4(velocity, 0.0, 1.0);
3393
3393
 
3394
3394
  vec3 col = tmp.rgb;
3395
3395
  float lalpha = alpha * tmp.a;
3396
- ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${a}));`}
3396
+ ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, ${a}));`}
3397
3397
 
3398
3398
  if ( crop > 0.5 ) {
3399
3399
  if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
@@ -6236,7 +6236,7 @@ gl_FragColor = vec4(resultColor, vColor.r);
6236
6236
  }
6237
6237
  `,Rm=new Bt({vertexShader:L7,fragmentShader:R7,uniforms:{depthContrast:{value:1}}}),y_=new fi,B7=class extends GS{constructor(e){super(e),this._pixelRatio=this.getPixelRatio(),this.viewportWidth=1,this.viewportHeight=1,this.resolution=new k,this.pipeline=new C7(this),this.dummyCamera=new Vi,this.sceneTransitionDuration=0,this.sceneTransitionTimeRemaining=-1,this.isXRCopyPassSet=!1,this.clear=(s=!0,a=!0,n=!0)=>{let o=this.getContext(),l=0;s&&(l|=o.COLOR_BUFFER_BIT),a&&(l|=o.DEPTH_BUFFER_BIT),n&&(l|=o.STENCIL_BUFFER_BIT),o.clear(l),o.clearBufferfv(o.COLOR,1,[0,0,0,1])},this.autoClear=!1;let t=this.setPixelRatio.bind(this),i=this.setSize.bind(this);this.shadowMap.enabled=!0,this.shadowMap.type=Hv,this.dummyCamera.matrixAutoUpdate=!1;let r=this.getContext();if(r&&"drawingBufferColorSpace"in r)try{r.drawingBufferColorSpace="display-p3"}catch(s){console.warn(s)}this.setPixelRatio=s=>{this._pixelRatio!==s&&(this._pixelRatio=s,t(s))},this.setSize=(s,a,n=!0)=>{(this.viewportWidth!==s||this.viewportHeight!==a)&&(this.viewportWidth=s,this.viewportHeight=a,i(s,a,n),this.normalRenderTarget?.setSize(s*this._pixelRatio,a*this._pixelRatio),this._resizeTransmission(s,a),this.transmissionDepthTarget?.setSize(s*this._pixelRatio/2,a*this._pixelRatio/2),this.pipeline.resize(s,a,n))},this._superDispose=this.dispose,this.dispose=this._currentDispose}createAORenderTarget(){this.aoRenderTarget===void 0&&(this.aoRenderTarget=new Ct(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:ot,magFilter:ot,wrapS:Kt,wrapT:Kt,depthBuffer:!1}))}_resizeTransmission(e,t){this.transmissionRenderTarget?.setSize(e*this._pixelRatio/(this.hdTransmission?1:2),t*this._pixelRatio/(this.hdTransmission?1:2)),this.aoRenderTarget?.setSize(e*this._pixelRatio/1,t*this._pixelRatio/1)}get hdTransmission(){return Ge.transmissionLod.value===1}set hdTransmission(e){Ge.transmissionLod.value=e===!0?1:2,this._resizeTransmission(this.viewportWidth,this.viewportHeight)}createTransmissionRenderTarget(){this.transmissionRenderTarget===void 0&&(this.transmissionRenderTarget=new Ct(this.viewportWidth*this._pixelRatio/(this.hdTransmission?1:2),this.viewportHeight*this._pixelRatio/(this.hdTransmission?1:2),{generateMipmaps:!0,minFilter:Cl,magFilter:ot,wrapS:Kt,wrapT:Kt,depthBuffer:!1}),this.transmissionDepthTarget=new Ct(this.viewportWidth*this._pixelRatio/2,this.viewportHeight*this._pixelRatio/2,{minFilter:Rt,magFilter:Rt,depthBuffer:!1}))}createNormalRenderTarget(){this.normalRenderTarget===void 0&&(this.normalRenderTarget=new Ct(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio,{generateMipmaps:!1,minFilter:Rt,magFilter:Rt,type:Tr,depthTexture:new Dl(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio)}))}renderNormal(e,t,i){this.normalRenderTarget&&(this.setClearColor(0),i.layers.enable(8),i.layers.disable(0),i.layers.disable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!1)}),this.setRenderTarget(this.normalRenderTarget),this.clear(),i instanceof Vi?Rm.uniforms.depthContrast.value=(i.far-i.near)/1e4:Rm.uniforms.depthContrast.value=1,t.overrideMaterial=Rm,this.render(t,i),this.setClearColor(t.bgColor,t.bgColor.a),this.setRenderTarget(null),t.overrideMaterial=e.wireframeState?Iv:null,i.layers.enable(0),i.layers.enable(3),t.traverseEntity(r=>{r.layers.isEnabled(8)&&(r.copyPreviousMatrix=!0)}))}renderSplineSceneWithDummyCamera(e,t,i=1){this.dummyCamera.updateCameraState(t.dataPatched),this.dummyCamera.matrix.copy(t.matrixWorld);let r=t.height,s=t.width,a=this.viewportWidth/this.viewportHeight;s<r?s=r*a:r=s/a,this.dummyCamera.setViewplaneSize(s,r);for(let n=0;n<i;n++)this.renderSplineScene(e,this.dummyCamera)}renderSplineScene(e,t,{sceneHelpers:i=void 0,sceneHelpersOnTop:r=void 0,overrideTransmission:s=void 0,overrideNormal:a=void 0}={}){let n=e instanceof ly?e.activePage:e,o=n.visible;n.visible=!0;let l=n.scene;this.xr.enabled&&(this.isXRCopyPassSet===!1&&this.getRenderTarget()!==null&&(this.pipeline.setCopyPass(this.getRenderTarget()),this.isXRCopyPassSet=!0),this.xr.updateCamera(t)),this.setClearColor(n.bgColor,n.bgColor.a),n.penumbraSizeArray.forEach((u,p)=>{Ge.penumbraSize.value[p]=u}),Ge.pixelRatioNode.value=this.getPixelRatio(),this.resolution.x!==0&&this.resolution.y!==0?Ge.resolution.value.set(this.resolution.x,this.resolution.y):Ge.resolution.value.set(this.viewportWidth*this._pixelRatio,this.viewportHeight*this._pixelRatio),a!==void 0?(Ge.normalRenderTarget.value=a,Ge.normalRenderTargetDepth.value=y_):l.needsNormal()&&(this.createNormalRenderTarget(),Ge.normalRenderTarget.value=this.normalRenderTarget.texture,Ge.normalRenderTargetDepth.value=this.normalRenderTarget.depthTexture,this.renderNormal(l,n,t));let h=n.data.ao,d=h.occlusion;d&&(this.createAORenderTarget(),Ge.aoRenderTarget.value=this.aoRenderTarget.texture),Ge.aoEnabled.value=d,this.pipeline.setAmbientOcclusionParams(h.occlusion,h.radius,h.bias,n.aoColor,n.fog!==null,n.backupFog.near,n.backupFog.far,h.aoFullRes),this.pipeline.aoPass.setBlueNoiseTexture(this.pipeline.blueNoiseTexture);let c=!1;if(s!==void 0)Ge.transmissionRenderTarget.value=s,Ge.transmissionRenderTargetDepth.value=y_,this.pipeline.setTransmissionPassEnabled(!1);else{let u=l.needsTransmission();u&&(this.transmissionRenderTarget===void 0&&(c=!0),this.createTransmissionRenderTarget(),Ge.transmissionRenderTarget.value=this.transmissionRenderTarget.texture,Ge.aspectRatio.value=qj(this.viewportWidth,this.viewportHeight),Ge.transmissionRenderTargetDepth.value=this.transmissionDepthTarget.texture),this.pipeline.setTransmissionPassEnabled(u)}t.layers.enable(3),t.layers.enable(8),this.pipeline.sceneHelpers=i,this.pipeline.sceneHelpersOnTop=r,this.pipeline.scene=n,this.pipeline.camera=t,c&&this.pipeline.transmissionPass.updatePasses(this),this.pipeline.postprocessingState!==n.postprocessing&&(this.pipeline.updatePostprocessing(n.postprocessing),!i&&!r&&this.pipeline.disableHelpers()),this.clearAlphaOverride!==void 0&&this.setClearAlpha(this.clearAlphaOverride),n.overrideMaterial=l.wireframeState?Iv:null,this.pipeline.render(),Ge.frameIndex.value=(Ge.frameIndex.value+1)%16,t instanceof Vi&&t.copyHistory(),n.visible=o}renderFromSceneForSceneTransitionPass(e,t,i){this.pipeline.renderToScreen=!1,this.pipeline.renderTarget,this.renderSplineScene(e,t),this.pipeline.sceneTransitionFromTexture=this.pipeline.renderTarget.texture,this.sceneTransitionDuration=i,this.sceneTransitionTimeRemaining=i,this.pipeline.renderToScreen=!0;let r=this.pipeline.sceneTransitionPass.uniforms;r.uDPR.value=window.devicePixelRatio,r.uResolution.value.set(this.domElement.width,this.domElement.height).divideScalar(window.devicePixelRatio)}_currentDispose(){this._superDispose(),this.pipeline.dispose(),this.aoRenderTarget?.dispose(),this.transmissionRenderTarget?.dispose(),this.transmissionDepthTarget?.dispose(),this.normalRenderTarget?.dispose(),this.normalRenderTarget?.depthTexture?.dispose()}},rE=class extends Uc(o4){constructor(e,t=15,i=10066329){super(e,t,i),this.object=e,this.added=!1,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Fc(this.object,rE.geometryHelper,e,t)}},sE=class extends Uc(n4){constructor(e,t=15,i=6710886){super(e,t,i),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Fc(this.object,sE.geometryHelper,e,t)}},Pv=class extends Uc(a4){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Fc(this.object,Pv.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Pv._vector,t=this.object.distance?this.object.distance:1e3,i=t*Math.tan(this.object.angle);this.cone.scale.set(i,i,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let r=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(r);else this.cone.material.color.set(r)}}},aE=Pv;aE._vector=new E;function z7(e,t){e.shadow.camera.right=t/2,e.shadow.camera.left=-t/2,e.shadow.camera.top=t/2,e.shadow.camera.bottom=-t/2,e.shadow.needsUpdate=!0}var nE=class extends iy(GL,rE){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=-1e4,r.far=2500;let s=new Bu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Bu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t);let i=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;e.size!==void 0&&z7(this,e.size),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),i&&this.update()}},x_=new E,b_=new E,w_=new it,oE=class extends iy(UL,aE){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=Re.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let s=new Bu(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this.gizmos){let t=this.gizmos[e];t instanceof Bu&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),b_.setFromMatrixPosition(this.matrixWorld),w_.setFromRotationMatrix(this.matrixWorld),x_.copy(this.up).applyQuaternion(w_).negate().multiplyScalar(this.distance),this.target.position.copy(b_).add(x_),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.penumbraSize!==void 0&&t.scene.markPenumbraSizeDirty(),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},dn=class extends U0(nn){constructor(e,t){super(),this.data=t,this.bgColor=new gr(1,1,1,1),this.fog=null,this.backupFog=new HS(16777215,.1,2e3),this.fogUseBGColor=!1,this.isActive=!1,this.aoColor=new He,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new Vi(rh,{..._c.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new NL(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=$i(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof nh)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&O7(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let i=this.scene;i.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=$i(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=$i(e.aoColor,t))}updateByOp(e,t,i,r){super.updateByOp(e,t,i,r);let s=t;Gr(e.path,["fog"])?this.updateFog(s.fog,i.shared):Gr(e.path,["ao"])?this.updateAo(s.ao,i.shared):Gr(e.path,["ambient"])?this.updateAmbientLight(s.ambient,i.shared):Gr(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor($i(e.backgroundColor,t.shared)),e.fog!==void 0&&this.updateFog(e.fog,t.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,t.shared),e.ao!==void 0&&this.updateAo(e.ao,t.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,t=0;this.traverseEntity(i=>{if(!i.visible)return!0;i instanceof nE&&i.visible&&e<3&&(this.penumbraSizeArrayCache[e]=i.data.penumbraSize,e+=1),i instanceof oE&&i.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=i.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;ut.is(s)&&(s.visible||a?.object.data.visible)&&((os(s)||Sv(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Dv(s,e,t,!0)),i(s))}};return i(this),t}},N7=class extends iy(VL,sE){constructor(e,t,i){super(),this.super_Entity(e,t),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let s=new E(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),a=new E(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new $t(s,a),o=new zu(n,new He(16755200));o.visible=!1,this.gizmos.shadowmap=o,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let e in this.gizmos){let t=this.gizmos[e];if(t instanceof zu){let i=this.shadow.camera,r=new E(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new E(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);t.box.set(r,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.objectHelper&&this.objectHelper.update()}updateState(e,t){this.updateState_Light(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}},k7=class extends er{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?X0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},ay=class extends er{constructor(e,t,i){super(e,t,i),this._shapeId=null,this._context=i}updateState(e,t){super.updateState(e,t),this.updateShape()}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let r in e)typeof e[r]=="string"&&(e[r]=this._context.shared.getVariable(e[r],[this.uuid,"geometry","extrusion","shape",r]));let t;if(e.type==="Custom"){let r=e.shapeId;if(r!==this._shapeId&&this.detachShape(),r){this._shapeId=r;let s=this._context.scene.find(r);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let r;switch(e.type){case"Rectangle":r=rM;break;case"Ellipse":r=W0;break;case"Polygon":r=iM;break;case"Star":r=sM;break;default:throw new Error(`Unknown shape type: ${e.type}`)}t=r.create({parameters:e}).userData.shape}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build(),this.attachedSurfaceCloners.forEach(r=>r.update()))}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let i=this.geometry.getAttribute("position");i!==void 0?X0(i,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:i.count,e,t):super.updateEntityBoxSize(e,t)}},Ml=class extends Vc(al,Up){constructor(e,t,i){super(),t.type==="Instance"&&typeof e=="string"&&(t=this.transformAssignData(t,i)),this.super_Entity(e,t),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,t){let i=np.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(i){let r,s;for(let a of tn.rootOverrideProps)e[a]===void 0?(r===void 0&&(r={...e}),r[a]=i.data[a]):(s===void 0&&(s={}),s[a]=e[a],r===void 0&&(r={...e}),r[a]=on.apply(i.data[a],e[a]));return this.overrideData=s,r}else return{...tr.defaultData,...e,...Sa(tr.defaultData,tn.rootOverrideProps)}}updateByOp(e,t,i,r){let s;if(this.isInstanceRoot&&!r){if(t=this.transformAssignData(t,i),e.type===0&&e.path.length===0&&this.component)for(let a of tn.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&tn.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??e,t,i,r)}updateState(e,t){this.updateState_Entity(e,t)}expandInstanceChildren(e){let t=this.data;if(this.component===void 0){let i=e.scene.find(t.component)??null,r=!1;if(i!==this.oldComponent){if(this.oldComponent){let s=0;for(let a of this.children)if(ut.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),ny(a),s+=1;else break;this.children.splice(0,s)}r=!0}if(i){let s={};lE(e,[this.uuid],t.overrides,this,i,i,0,r,s);for(let a of this.children)if(ut.is(a)){let n=a.data;n.type==="Empty"&&n.animations&&a.traverseEntity(o=>{if(o instanceof er&&o.isSkinnedMesh){let l=o.dataPatched;if(l.bones&&l.boneInverses){let h=l.bones.map(u=>e.scene.find(s[u])),d=l.boneInverses.map(u=>new me().fromArray(u)),c=new $v(h,d);o.bind(c,o.bindMatrix)}}else o.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function ny(e){if(e.component){let t=e.component.instances.indexOf(e);t>=0&&e.component.instances.splice(t,1);for(let i of e.children)ut.is(i)&&ny(i)}}function __(e,t,i,r){return e.component===t&&qA(e.identity,r)?e.overrideData===i?2:1:0}function lE(e,t,i,r,s,a,n,o,l){if(n>50)return!1;if(r.component!==s){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}s.instances.push(r),r.component=s}s instanceof Ml&&s.isInstanceRoot&&s.expandInstanceChildren(e);let h=0;for(let d of s.children)if(ut.is(d)){let c=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],u=tp.resolve(i,c,1);u!=null&&!(u instanceof mi)&&(Object.setPrototypeOf(u,mi.prototype),console.error("wrong prototype"));let p=null,f;if(!o){let m=r.children[h];if(p=ut.is(m)?m:null,p!==null){let g=__(p,d,u,c);f=g>=1?p.stateSelection:void 0,g!==2&&(p=null)}if(p===null&&(p=e.scene.findInstance(c)??null,p!==null)){let g=__(p,d,u,c);if(f=g>=1?p.stateSelection:void 0,g!==2)p=null;else{let v=p.parent.children.indexOf(p);p.parent.children.splice(v,1),r.children.splice(h,0,p),p.parent===r?v<=h&&console.error("not possible"):(p.parent=r,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),e.pendingDeletes.delete(p))}}}if(p===null){let m=u?on.apply(d.data,u):d.data;ao.is(m.type)&&(m={...m,type:"Empty"}),p=rn.createEntity(c,m,e),p.overrideData=u,r.add(p),r.children.splice(r.children.length-1,1),r.children.splice(h,0,p),p.updateState(p.data,e),f&&p.changeSelectedState(f,e),e.scene.registerInstanceAndSetUuid(p)}if(p.isBone){let m=p.identity[p.identity.length-1];l[m]=p.uuid}h+=1,lE(e,t,i,p,d,a,n+1,o,l)}if(!o){let d=h;for(;;){let c=r.children[h];if(ut.is(c))e.pendingDeletes.add(c);else break;h+=1}r.children.splice(d,h-d)}return!0}var U7=class extends Vc(WS,Up){constructor(e,t){super(),this.super_Entity(e,t),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(e,t){this.updateState_Entity(e,t)}};function F7(e,t,i){let r;return t.geometry.type==="TextGeometry"?new QM(e,t,i):(t.geometry.type==="SubdivGeometry"?r=new Tc(e,t,i):t.geometry.type==="PathGeometry"?r=new ay(e,t,i):t.geometry.type==="VectorGeometry"?r=new k7(e,t,i):t.geometry.type==="BooleanGeometry"?r=new Gl(e,t,i):r=new er(e,t,i),r)}function oy(e,t,i){return t.type==="Mesh"?F7(e,t,i):t.type==="Empty"?new Pc(e,t):t.type==="Bone"?new U7(e,t):t.type==="Page"?new dn(e,t):t.type==="PointLight"?new N7(e,t,i):t.type==="SpotLight"?new oE(e,t,i):t.type==="DirectionalLight"?new nE(e,t,i):t.type==="Component"||t.type==="Instance"?new Ml(e,t,i):ao.is(t.type)?new Vi(e,t):(console.error(t),new Pc(e,t))}rn.createEntity=oy;function V7(e,t,i){let r=oy(e.identity,t,i),s=e.children,a=e.attachedPaths,n=e.parent,o=e.component,l=e.instances,h=e.overrideData,d=e.uuid,c=e.stateSelection;e.dispose();for(let u of Object.keys(e))delete e[u];Object.setPrototypeOf(e,Object.getPrototypeOf(r));for(let u of Object.keys(r))e[u]=r[u];e.children=[...e.children,...s],e.attachedPaths=a,e.parent=n,e.component=o,e.instances=l,e.uuid=d,e.overrideData=h,e.updateState(e.data,i),c&&e.changeSelectedState(c,i),e.resetBBoxNeedsUpdate()}rn.changeEntityProptotype=V7;rn.Cloner=ds;function j7(e,t,i,r){e.updateByOp(t,i,r,!1)}function S_(e,t){let i=!1,r=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline");return s.length>0&&(e.layers.set(8),r.length>0&&e.layers.enable(3),i=!0,ty(e),ey(e)),r.length===0&&s.length===0&&e.layers.set(0),e instanceof nh&&e.needsAO&&e.layers.enable(5),i}function A_(e,t){if(!t.layers)return!1;let i=!1,r=t.getLayersOfType("transmission").filter(a=>a.data.visible),s=t.getLayersOfType("outline").filter(a=>a.data.visible);return r.length>0&&(e.layers.set(3),s.length>0&&e.layers.enable(8),i=!0),r.length===0&&s.length===0&&e.layers.set(0),e.needsAO&&e.layers.enable(5),i}function G7(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof nh)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)S_(i,i.material[r])&&(t=!0);else S_(i,i.material)&&(t=!0)}),t}function H7(e){let t=!1;return e.traverseEntity(i=>{if(i instanceof nh)if(Array.isArray(i.material))for(let r=0;r<i.material.length;r++)A_(i,i.material[r])&&(t=!0);else A_(i,i.material)&&(t=!0)}),t}var W7=new hA,q7=new me,X7=new Wl;function Dv(e,t,i,r=!1){let s=e.cloner;if(s)for(let a of s.children){let n=q7.copy(a.matrixWorld).invert(),o=X7.copy(t.ray).applyMatrix4(n),l=e.matrixWorld;o.applyMatrix4(l);let h=W7;h.set(o.origin,o.direction),h.near=t.near,h.far=t.far;let d=h.intersectObject(e,!1);d.length>0&&i.push({...d[0],object:r?a:e})}}var Y7=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],a=i;for(;this._constraints.has(a);)a=this._constraints.get(a),t.has(a)||s.push(a);for(let n=s.length-2;n>=0;n--)if(!t.has(s[n])){let o=e.find(s[n]);o?o.applyPathSnapping(e):console.warn(`missing entity ${s[n]}`),t.add(s[n])}})}findDependency(e,t){let i=e;for(;this._constraints.has(i);)if(i=this._constraints.get(i),i===t)return!0;return!1}},Iv=new Lc;Iv.wireframe=!0;var M_=new E,ly=class extends nn{constructor(e,t){super(),this.data=e,this.enableHelpers=!1,this.wireframeState=!1,this.needsTransmissionDirty=!0,this.needsNormalDirty=!0,this._needsTransmission=!1,this._needsNormal=!1,this.geometryCacheChanged=!1,this.entityByUuid={},this.entityIdentityToEntity={},this.toExpandCloner=new Set,this.toUpdateCloner=new Set,this.pendingCommands=[],this.pathConstraints=new Y7,this.errorPage=new dn("fdasfa",{...Ul.defaultData,name:""}),this.invisibleObjects=new Pc("jflkdsafjasdifjaslk",{...Jg.defaultData,visible:!1,name:"buildin invisible"}),this.needsRecomputeInstances=!1,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=H7(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=G7(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let t=e.identity.join("-"),i=this.entityIdentityToEntity[t];i&&(e.uuid=i.uuid),this.entityIdentityToEntity[t]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof dn&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let t=this.find(e);if(t===void 0)return;let i=[],r=t;for(;r!==this;){let s=r;r=r.parent;let a=r.children.indexOf(s);i.splice(0,0,a)}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)=>LF(i.sortKey,r.sortKey)),t.map(i=>i.entity)}nonExistOrDescendantOf(e,t){let i=this.find(e);if(i===void 0)return!0;for(;i;){if(i.uuid===t)return!0;i=i.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===rh)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}debugEnsureEntity(e){let t=this.find(e);if(t){if(Array.isArray(t.identity)&&this.findInstance(t.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(t=>{this.toExpandCloner.add(t)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,t){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,t)}updateTreeByOp(e,t){if(e.path.length===0&&e.type===7){let i=e.parent===null?this:this.find(e.parent);if(i===void 0)throw new Error("unexpected");let r=this.createObject(e.id,e.data,e.children,i,e.localIndex,t);r.updateVisible(),r.resetBBoxNeedsUpdate(),os(r)&&Us(r.parent)&&(r.invalidateUpstreamBooleanData(),r.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(r),this.markToExpandCloner(r),this.markPenumbraSizeDirty(),r.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markToExpandCloner(i),i.resetBBoxNeedsUpdate(),this.unregisterObject(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),this.markNeedsRecomputeInstancesForChildren(i),this.markPenumbraSizeDirty(),i.parent.remove(i),Us(i.parent)&&(i.parent.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),os(i)&&(i.freeBooleanPointer(),r instanceof Gl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i instanceof ay&&i.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),this.pathConstraints.removeDependencies(i.uuid),i.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let i=this.find(e.id);if(i===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(i);let r=i.parent;this.markNeedsRecomputeInstancesForAncessors(r),i.cloner?.resetOnMove(),this.markToExpandCloner(i);let s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(i),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(i),i.invalidateClonerTransform(i),i.updateVisible(),i.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),os(i)&&(i.invalidateUpstreamBooleanData(),Us(i.parent)?i.parent.invalidateDownstreamBooleanData().recomputeBoolean():r instanceof Gl&&r.invalidateDownstreamBooleanData().recomputeBoolean()),i.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let t of this.children)t instanceof dn&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}updateEntityByOp(e,t,i,r){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),"visible"in t.props&&this.markPenumbraSizeDirty(),t.path.includes("overrides")&&"states"in t.props){let{rest: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{j7(s,t,i,{scene:this,shared:r}),s instanceof er&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,t){let i=Object.entries(t.data.lib.components).map((r,s)=>({data:r[1].asset.data,children:r[1].asset.children,id:r[0],fi:s}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:t}),this.add(this.invisibleObjects),this.createChildrenObjects(i,this.invisibleObjects,t),this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(r=>{Us(r)&&r.recomputeBoolean(),r instanceof Vi&&r.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(t=>{(t.data.type==="Component"||t.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ut.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{ut.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,i,r,s,a,n){if(e){let o=r.find(e);o&&o!==r&&s.forInstancesRec(l=>{l.data=wc(l.data,h=>{let d=h.events.data(n.id),c=l.goUp(a);if(c){let u=[...YA(c.identity),e].join("-"),p=this.entityIdentityToEntity[u];if(p){let f=p.uuid,m=Zi.zoom(d,t);m[i]=f}else console.warn("cannot find instance")}}).data})}}rewriteActions(e,t,i,r,s,a){e.forEach(n=>{n.data.type==="Transition"?this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a):n.data.type==="Animation"&&this.relativeizeInner(n.data.object,[...t,n.id],"object",i,r,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof Ml&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,i)=>{t.data.events.forEach(r=>{if(r.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=wc(a.data,n=>{a.isInstanceRoot||(n.events.delete(r.id),s=!0)}).data}),s===!1)for(let a of sp.list)this.rewriteActions(r.data.gameActions[a],["gameActions",a],e,t,i,r)}else r.data.type==="Conditional"?(r.data.condition.type==="Distance"?(this.relativeizeInner(r.data.condition.fromObject,["condition"],"fromObject",e,t,i,r),this.relativeizeInner(r.data.condition.toObject,["condition"],"toObject",e,t,i,r)):r.data.condition.type==="State"?this.relativeizeInner(r.data.condition.object,["condition"],"object",e,t,i,r):r.data.condition.type==="Comparison"&&(r.data.condition.lOperand.type==="Property"&&this.relativeizeInner(r.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,t,i,r),r.data.condition.rOperand.type==="Property"&&this.relativeizeInner(r.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,t,i,r)),this.rewriteActions(r.data.inActions,["inActions"],e,t,i,r),this.rewriteActions(r.data.outActions,["outActions"],e,t,i,r)):"actions"in r.data&&this.rewriteActions(r.data.actions,["actions"],e,t,i,r)})}),!0})}expandInstances(e,t,i){let r=new Set;this.traverseEntity(s=>{if(s instanceof Ml&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:r}),t||s.resetBBoxNeedsUpdate(),i&&s.traverseEntity(a=>{i.addClip(a)}),!0});for(let s of r)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),ny(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(i=>{i instanceof Ml&&i.isInstanceRoot&&(i.component=void 0)}),this.expandInstances(e,!1,t))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(t=>{let i=typeof t.identity=="string"?t.identity:t.identity.join("-");this.entityIdentityToEntity[i]===t&&(delete this.entityByUuid[t.uuid],delete this.entityIdentityToEntity[i]),t.dispose()})}clearScene(){for(let e of this.children)ut.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}raycast(e){return this.raycast1(e,!1)}raycast1(e,t){let i=[],r=s=>{for(let a of s.children){let n=a.cloner;if(ut.is(a)&&!a.raycastLock&&(a.visible||n?.object.data.visible))if(t===!0&&a.isInstanceRoot){let o=[];if(e.intersectObject(a,!0,o),o.length){let l=o[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let h=a.matrixWorld.clone().invert();l.point.applyMatrix4(h),i.push(l)}}else(os(a)||Sv(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,i),Dv(a,e,i)),r(a)}};return r(this),i}raycastWithClones(e){let t=[],i=r=>{for(let s of r.children){let a=s.cloner;ut.is(s)&&(s.visible||a?.object.data.visible)&&((os(s)||Sv(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),Dv(s,e,t,!0)),i(s))}};return i(this),t}forEachEntity(e){for(let t of this.children)ut.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)ut.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)ut.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(i=>{if(i instanceof er&&i.data.type==="Mesh"&&i.data.geometry.type==="TextGeometry"&&i.data.geometry.font===e){let r=i.geometry,s=i.data.geometry;r.updateFont(e,t).then(()=>{r.update(s);let a=i.invalidateDownstreamBooleanData();Us(a)&&a.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)Cc.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)ut.is(t)&&t.visible&&t.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,t,i){let r=0;for(let s of e)this.createObject(s.id,s.data,s.children,t,r,i),r+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createObject(e,t,i,r,s,a){let n={scene:this,shared:a},o=oy(e,t,n);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,a)),o.updateState(t,n),o instanceof er&&o.updateGeometryGroupsIfNeeded(),o.updateVisible(),o.cloner&&this.toExpandCloner.add(o),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&o.traverseEntity(l=>{if(l instanceof er&&l.isSkinnedMesh){let h=l.dataPatched;if(h.bones&&h.boneInverses){let d=h.bones.map(p=>this.find(p)),c=h.boneInverses.map(p=>new me().fromArray(p)),u=new $v(d,c);l.bind(u,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),o}getCenter(e){let t=[];for(let r=0,s=e.length;r<s;++r){let{id:a,recursive:n}=e[r],o=this.find(a),l=n?o.recursiveBBox:o.singleBBox;t.push(...l.vertices)}let i=new $t;return i.setFromPoints(t),i.getCenter(M_),M_}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 yr)if(Array.isArray(t.material))for(let i=0;i<t.material.length;i++)t.material[i]instanceof fn&&e(t.material[i]);else t.material instanceof fn&&e(t.material)})}updateViewPlaneSize(e,t,i=!1){this.traverseConcreteEntity(r=>{r instanceof Vi&&r.setViewplaneSize(e,t,i)})}},xu=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return Math.sqrt(i*i+r*r)},Q7=(e,t)=>{let i=t.x-e.x,r=t.y-e.y;return K7(Math.atan2(r,i))},Z7=(e,t,i)=>{let r={x:0,y:0};return i=Ov(i),r.x=e.x-t*Math.cos(i),r.y=e.y-t*Math.sin(i),r},Ov=e=>e*(Math.PI/180),K7=e=>e*(180/Math.PI),J7=e=>isNaN(e.buttons)?e.pressure!==0:e.buttons!==0,Bm=new Map,E_=e=>{Bm.has(e)&&clearTimeout(Bm.get(e)),Bm.set(e,setTimeout(e,100))},fp=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.addEventListener?e.addEventListener(s,i,!1):e.attachEvent&&e.attachEvent(s,i)},C_=(e,t,i)=>{let r=t.split(/[ ,]+/g),s;for(let a=0;a<r.length;a+=1)s=r[a],e.removeEventListener?e.removeEventListener(s,i):e.detachEvent&&e.detachEvent(s,i)},hE=e=>(e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e),T_=()=>{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}},Lv=(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")},hy=(e,t,i)=>{let r=cE(e);for(let s in r)if(r.hasOwnProperty(s))if(typeof t=="string")r[s]=t+" "+i;else{let a="";for(let n=0,o=t.length;n<o;n+=1)a+=t[n]+" "+i+", ";r[s]=a.slice(0,-2)}return r},$7=(e,t)=>{let i=cE(e);for(let r in i)i.hasOwnProperty(r)&&(i[r]=t);return i},cE=e=>{let t={};return t[e]="",["webkit","Moz","o"].forEach(function(i){t[i+e.charAt(0).toUpperCase()+e.slice(1)]=""}),t},zm=(e,t)=>{for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},eW=(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},Rv=(e,t)=>{if(e.length)for(let i=0,r=e.length;i<r;i+=1)t(e[i]);else t(e)},tW=(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"&&(dE="ontouchstart"in window,uE=!!window.PointerEvent,pE=!!window.MSPointerEvent);var dE,uE,pE,kh={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"}},cl,Dc={};uE?cl=kh.pointer:pE?cl=kh.MSPointer:dE?(cl=kh.touch,Dc=kh.mouse):cl=kh.mouse;function po(){}po.prototype.on=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]=i._handlers_[s]||[],i._handlers_[s].push(t);return i};po.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};po.prototype.trigger=function(e,t){var i=this,r=e.split(/[ ,]+/g),s;i._handlers_=i._handlers_||{};for(var a=0;a<r.length;a+=1)s=r[a],i._handlers_[s]&&i._handlers_[s].length&&i._handlers_[s].forEach(function(n){n.call(i,{type:s,target:i},t)})};po.prototype.config=function(e){var t=this;t.options=t.defaults||{},e&&(t.options=eW(t.options,e))};po.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.')},fp(e,cl[t],i._domHandlers_[t]),Dc[t]&&fp(e,Dc[t],i._domHandlers_[t]),i};po.prototype.unbindEvt=function(e,t){var i=this;return i._domHandlers_=i._domHandlers_||{},C_(e,cl[t],i._domHandlers_[t]),Dc[t]&&C_(e,Dc[t],i._domHandlers_[t]),delete i._domHandlers_[t],this};var cy=po;function yi(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=yi.id,yi.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}yi.prototype=new cy;yi.constructor=yi;yi.id=0;yi.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)};yi.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=$7("borderRadius","50%"),i=hy("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)"},zm(r.el,i),this.options.shape==="circle"&&zm(r.back,t),zm(r.front,t),this.applyStyles(r),this};yi.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};yi.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};yi.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};yi.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};yi.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};yi.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};yi.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=hy("transition",["top","left"],r);var a={front:{}};a.front={left:i.frontPosition.x+"px",top:i.frontPosition.y+"px"},i.applyStyles(s),i.applyStyles(a),i.restTimeout=setTimeout(function(){typeof e=="function"&&e.call(i),i.restCallback()},i.options.fadeTime)};yi.prototype.restCallback=function(){var e=this,t={};t.front=hy("transition","none",""),e.applyStyles(t),e.trigger("rested",e.instance)};yi.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};yi.prototype.computeDirection=function(e){var t=e.angle.radian,i=Math.PI/4,r=Math.PI/2,s,a,n;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?a="left":a="right"),e.lockX||(t>0?n="up":n="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:a,y:n,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:"+a,e),h.y||this.trigger("plain:"+n,e),h.angle||this.trigger("dir dir:"+s,e)}else this.resetDirection();return e};var iW=yi;function ei(e,t){var i=this;i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.pressureIntervals={},i.manager=e,i.id=ei.id,ei.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}ei.prototype=new cy;ei.constructor=ei;ei.id=0;ei.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}};ei.prototype.bindings=function(){var e=this;e.bindEvt(e.options.zone,"start"),e.options.zone.style.touchAction="none",e.options.zone.style.msTouchAction="none"};ei.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)}};ei.prototype.createNipple=function(e,t){var i=this,r=i.manager.scroll,s={},a=i.options,n={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-n.x,y:e.y-n.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",a.zone.appendChild(o);var l=o.getBoundingClientRect();a.zone.removeChild(o),s=e,e={x:l.left+r.x,y:l.top+r.y}}var h=new iW(i,{color:a.color,size:a.size,threshold:a.threshold,fadeTime:a.fadeTime,dataOnly:a.dataOnly,restJoystick:a.restJoystick,restOpacity:a.restOpacity,mode:a.mode,identifier:t,position:e,zone:a.zone,frontPosition:{x:0,y:0},shape:a.shape});return a.dataOnly||(Lv(h.ui.el,s),Lv(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};ei.prototype.updateBox=function(){var e=this;e.box=e.options.zone.getBoundingClientRect()};ei.prototype.bindNipple=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};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)};ei.prototype.pressureFn=function(e,t,i){var r=this,s=0;clearInterval(r.pressureIntervals[i]),r.pressureIntervals[i]=setInterval(function(){var a=e.force||e.pressure||e.webkitForce||0;a!==s&&(t.trigger("pressure",a),r.trigger("pressure "+t.identifier+":pressure",a),s=a)}.bind(r),100)};ei.prototype.onstart=function(e){var t=this,i=t.options,r=e;e=hE(e),t.updateBox();var s=function(a){t.actives.length<i.maxNumberOfNipples?t.processOnStart(a):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(n){if(Object.values(r.touches).findIndex(function(l){return l.identifier===n})<0){var o=[e[0]];o.identifier=n,t.processOnEnd(o)}}),t.actives.length<i.maxNumberOfNipples&&t.processOnStart(a))};return Rv(e,s),t.manager.bindDocument(),!1};ei.prototype.processOnStart=function(e){var t=this,i=t.options,r,s=t.manager.getIdentifier(e),a=e.force||e.pressure||e.webkitForce||0,n={x:e.pageX,y:e.pageY},o=t.getOrCreate(s,n);o.identifier!==s&&t.manager.removeIdentifier(o.identifier),o.identifier=s;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),a>0&&t.pressureFn(e,d,d.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=xu(n,o.position);if(h<=i.catchDistance)l(o);else{o.destroy(),t.processOnStart(e);return}}return o};ei.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)};ei.prototype.processOnMove=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=t.manager.scroll;if(!J7(e)){this.processOnEnd(e);return}if(!s){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(i.dynamicPage){var n=s.el.getBoundingClientRect();s.position={x:a.x+n.left,y:a.y+n.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=xu(l,s.position),d=Q7(l,s.position),c=Ov(d),u=h/o,p={distance:h,position:l},f,m;if(s.options.shape==="circle"?(f=Math.min(h,o),m=Z7(s.position,f,d)):(m=tW(l,s.position,o),f=xu(m,s.position)),i.follow){if(h>o){let x=l.x-m.x,b=l.y-m.y;s.position.x+=x,s.position.y+=b,s.el.style.top=s.position.y-(t.box.top+a.y)+"px",s.el.style.left=s.position.x-(t.box.left+a.x)+"px",h=xu(l,s.position)}}else l=m,h=f;var g=l.x-s.position.x,v=l.y-s.position.y;s.frontPosition={x:g,y:v},i.dataOnly||Lv(s.ui.front,s.frontPosition);var y={identifier:s.identifier,position:l,force:u,pressure:e.force||e.pressure||e.webkitForce||0,distance:h,angle:{radian:c,degree:d},vector:{x:g/o,y:-v/o},raw:p,instance:s,lockX:i.lockX,lockY:i.lockY};y=s.computeDirection(y),y.angle={radian:Ov(180-d),degree:180-d},s.trigger("move",y),t.trigger("move "+s.id+":move",y)};ei.prototype.processOnEnd=function(e){var t=this,i=t.options,r=t.manager.getIdentifier(e),s=t.nipples.get(r),a=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[a.id]=a.identifier))};ei.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()};ei.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 rW=ei;function Ei(e){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=T_(),t.config(e),t.prepareCollections();var i=function(){var s;t.collections.forEach(function(a){a.forEach(function(n){s=n.el.getBoundingClientRect(),n.position={x:t.scroll.x+s.left,y:t.scroll.y+s.top}})})};if(typeof window>"u")return t.collections;fp(window,"resize",function(){E_(i)});var r=function(){t.scroll=T_()};return fp(window,"scroll",function(){E_(r)}),t.collections}Ei.prototype=new cy;Ei.constructor=Ei;Ei.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}};Ei.prototype.create=function(e){return this.createCollection(e)};Ei.prototype.createCollection=function(e){var t=this,i=new rW(t,e);return t.bindCollection(i),t.collections.push(i),i};Ei.prototype.bindCollection=function(e){var t=this,i,r=function(s,a){i=s.type+" "+a.id+":"+s.type,t.trigger(i,a)};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)};Ei.prototype.bindDocument=function(){var e=this;e.binded||(e.bindEvt(document,"move").bindEvt(document,"end"),e.binded=!0)};Ei.prototype.unbindDocument=function(e){var t=this;(!Object.keys(t.ids).length||e===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Ei.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]};Ei.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};Ei.prototype.onmove=function(e){var t=this;return t.onAny("move",e),!1};Ei.prototype.onend=function(e){var t=this;return t.onAny("end",e),!1};Ei.prototype.oncancel=function(e){var t=this;return t.onAny("end",e),!1};Ei.prototype.onAny=function(e,t){var i=this,r,s="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=hE(t);var a=function(o,l,h){h.ids.indexOf(l)>=0&&(h[s](o),o._found_=!0)},n=function(o){r=i.getIdentifier(o),Rv(i.collections,a.bind(null,o,r)),o._found_||i.removeIdentifier(r)};return Rv(t,n),!1};Ei.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(t){t.destroy()}),e.off()};Ei.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 sW=Ei,P_=new sW,aW={create:function(e){return P_.create(e)},factory:P_},fE=new Map,lc=new Map,qn=class{constructor(e,t,i,r){this.data=t;let{audio:s,volume:a,delay:n,loop:o}=t;if(!s)throw new Error("Missing property");let l=typeof s=="string"?r.getAudio(s).src:s.data;this.audioPlayer=new Jh({src:l,volume:a,delay:n,loop:o}),lc.has(i.uuid)?lc.get(i.uuid).push(this):lc.set(i.uuid,[this]),fE.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()}},Bv=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=fE.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=lc.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=[...lc.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}},mE=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new qn(e,t,i,r);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Bv(t);else throw new Error("Missing property")}dispatchBasic(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof qn?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof qn?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof qn&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}},nW="text/plain",oW="us-ascii",D_=(e,t)=>t.some(i=>i instanceof RegExp?i.test(e):i===e),lW=(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:a}=i.groups,n=r.split(";");a=t?"":a;let o=!1;n[n.length-1]==="base64"&&(n.pop(),o=!0);let l=(n.shift()||"").toLowerCase(),h=[...n.map(d=>{let[c,u=""]=d.split("=").map(p=>p.trim());return c==="charset"&&(u=u.toLowerCase(),u===oW)?"":`${c}${u?`=${u}`:""}`}).filter(Boolean)];return o&&h.push("base64"),(h.length>0||l&&l!==nW)&&h.unshift(l),`data:${h.join(";")},${o?s.trim():s}${a?`#${a}`:""}`};function hW(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 lW(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 a=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,n=0,o="";for(;;){let h=a.exec(r.pathname);if(!h)break;let d=h[0],c=h.index,u=r.pathname.slice(n,c);o+=u.replace(/\/{2,}/g,"/"),o+=d,n=c+d.length}let l=r.pathname.slice(n,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 a=r.pathname.split("/"),n=a[a.length-1];D_(n,t.removeDirectoryIndex)&&(a=a.slice(0,-1),r.pathname=a.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 a of[...r.searchParams.keys()])D_(a,t.removeQueryParameters)&&r.searchParams.delete(a);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 cW=class{constructor({url:e,context:t},i,r,s){if(this.controlsManager=i,this.shared=r,this.condition=s,!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:hW(e,{removeTrailingSlash:!1,removeSingleSlash:!1}),this.context=t??"tab"}dispatch(){if(li(this.shared,this.condition)===!1)return!1;XA?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.controlsManager.orbitControls?.onPointerUp(Xe[0]),RF())}},gE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.timeoutIdQueue=[],this.dispatchInner=()=>{this.objects.forEach(this.destroyCallback)},this.destroyCallback=a=>{this.timeoutIdQueue.shift();let n=this.page.scene.find(a);if(n===void 0)return;let o=this.controlsManager.sharedGameControlGlobals.rapierWorld,l=o?n.dataPatched.physics?.fusedBody:!0;if(n.cloner){for(let h of n.cloner.children)l?(h.playModeVisible=!1,h.rigidBody&&n.dataPatched.physics?.rigidBody==="positioned"&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0),h.bvhGeometry&&(h.bvhGeometry=void 0)):this.clone===void 0||this.clone===h?(h.playModeVisible=!1,h.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(h.rigidBody.collider(0).handle),o.removeRigidBody(h.rigidBody),h.rigidBody=void 0)):h.playModeVisible===void 0&&(h.playModeVisible=!0);(l||this.clone===void 0||this.clone===!1)&&(n.visible=!1,n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0))}else n.rigidBody&&(this.controlsManager.sharedGameControlGlobals.colliderToEntity.delete(n.rigidBody.collider(0).handle),o.removeRigidBody(n.rigidBody),n.rigidBody=void 0),n.bvhGeometry&&(n.bvhGeometry=void 0),n.visible=!1;o===void 0?this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.bvhGeometry!==void 0):this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim=this.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.filter(h=>h.rigidBody!==void 0),n.destroyedInAction=!0,this.controlsManager.requestRender()},this.objects=[...e.objects]}dispatch(e){if(li(this.shared,this.condition)===!1)return!1;this.clone=e,this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()}dispatchFromStart(){if(li(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))}dispose(){this.timeoutIdQueue.forEach(e=>window.clearTimeout(e))}},vE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.shared=i,this.eventManager=r,this.condition=s,this.shared=i}dispatch(){if(li(this.shared,this.condition)===!1)return!1;clearTimeout(this.timeoutId),delete this.timeoutId,this.timeoutId=window.setTimeout(()=>{this.shared.reset(this.shared.data,!0),by(this.page,this.shared,!0),this.eventManager.reset(),this.eventManager.controlsManager.gameControl?.reset(!0),this.page.switchToPlayCamera(),this.eventManager.controlsManager.requestRender(),delete this.timeoutId},(this.data.delay??0)*1e3)}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},yE={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},dy={duration:1e3,delay:0,endDelay:0,startOnceDelay:0,pingPongDelayCorrection:0,pingPongEndDelayCorrection:0,easing:"easeOutElastic(1, .5)",round:0},dW=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],mp={CSS:{},springs:{}};function us(e,t,i){return Math.min(Math.max(e,t),i)}function hc(e,t){return e.indexOf(t)>-1}function Nm(e,t){return e.apply(null,t)}var Qe={arr:function(e){return Array.isArray(e)},obj:function(e){return hc(Object.prototype.toString.call(e),"Object")},pth:function(e){return Qe.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||Qe.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 Qe.hex(e)||Qe.rgb(e)||Qe.hsl(e)},key:function(e){return!yE.hasOwnProperty(e)&&!dy.hasOwnProperty(e)&&e!=="targets"&&e!=="keyframes"}};function xE(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map(function(i){return parseFloat(i)}):[]}function bE(e,t){var i=xE(e),r=us(Qe.und(i[0])?1:i[0],.1,100),s=us(Qe.und(i[1])?100:i[1],.1,100),a=us(Qe.und(i[2])?10:i[2],.1,100),n=us(Qe.und(i[3])?0:i[3],.1,100),o=Math.sqrt(s/r),l=a/(2*Math.sqrt(s*r)),h=l<1?o*Math.sqrt(1-l*l):0,d=1,c=l<1?(l*o+-n)/h:-n+o;function u(f){var m=t?t*f/1e3:f;return l<1?m=Math.exp(-m*l*o)*(d*Math.cos(h*m)+c*Math.sin(h*m)):m=(d+c*m)*Math.exp(-m*o),f===0||f===1?f:1-m}function p(){var f=mp.springs[e];if(f)return f;for(var m=1/6,g=0,v=0;;)if(g+=m,u(g)===1){if(v++,v>=16)break}else v=0;var y=g*m*1e3;return mp.springs[e]=y,y}return t?u:p}function uW(e){return e===void 0&&(e=10),function(t){return Math.ceil(us(t,1e-6,1)*e)*(1/e)}}var pW=function(){var e=11,t=1/(e-1);function i(d,c){return 1-3*c+3*d}function r(d,c){return 3*c-6*d}function s(d){return 3*d}function a(d,c,u){return((i(c,u)*d+r(c,u))*d+s(c))*d}function n(d,c,u){return 3*i(c,u)*d*d+2*r(c,u)*d+s(c)}function o(d,c,u,p,f){var m,g,v=0;do g=c+(u-c)/2,m=a(g,p,f)-d,m>0?u=g:c=g;while(Math.abs(m)>1e-7&&++v<10);return g}function l(d,c,u,p){for(var f=0;f<4;++f){var m=n(c,u,p);if(m===0)return c;var g=a(c,u,p)-d;c-=g/m}return c}function h(d,c,u,p){if(!(0<=d&&d<=1&&0<=u&&u<=1))return;var f=new Float32Array(e);if(d!==c||u!==p)for(var m=0;m<e;++m)f[m]=a(m*t,d,u);function g(v){for(var y=0,x=1,b=e-1;x!==b&&f[x]<=v;++x)y+=t;--x;var w=(v-f[x])/(f[x+1]-f[x]),A=y+w*t,S=n(A,d,u);return S>=.001?l(v,A,d,u):S===0?A:o(v,y,y+t,d,u)}return function(v){return d===c&&u===p||v===0||v===1?v:a(g(v),c,p)}}return h}(),wE=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,a=4;r<((s=Math.pow(2,--a))-1)/11;);return 1/Math.pow(4,3-a)-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 a=us(r,1,10),n=us(s,.1,2);return function(o){return o===0||o===1?o:-a*Math.pow(2,10*(o-1))*Math.sin((o-1-n/(Math.PI*2)*Math.asin(1/a))*(Math.PI*2)/n)}}},i=["Quad","Cubic","Quart","Quint","Expo"];return i.forEach(function(r,s){t[r]=function(){return function(a){return Math.pow(a,s+2)}}}),Object.keys(t).forEach(function(r){var s=t[r];e["easeIn"+r]=s,e["easeOut"+r]=function(a,n){return function(o){return 1-s(a,n)(1-o)}},e["easeInOut"+r]=function(a,n){return function(o){return o<.5?s(a,n)(o*2)/2:1-s(a,n)(o*-2+2)/2}}}),e}();function uy(e,t){if(Qe.fnc(e))return e;var i=e.split("(")[0],r=wE[i],s=xE(e);switch(i){case"spring":return bE(e,t);case"cubicBezier":return Nm(pW,s);case"steps":return Nm(uW,s);default:return Nm(r,s)}}function _E(e){try{var t=document.querySelectorAll(e);return t}catch{return}}function Vp(e,t){for(var i=e.length,r=arguments.length>=2?arguments[1]:void 0,s=[],a=0;a<i;a++)if(a in e){var n=e[a];t.call(r,n,a,e)&&s.push(n)}return s}function jp(e){return e.reduce(function(t,i){return t.concat(Qe.arr(i)?jp(i):i)},[])}function I_(e){return Qe.arr(e)?e:(Qe.str(e)&&(e=_E(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function py(e,t){return e.some(function(i){return i===t})}function fy(e){var t={};for(var i in e)t[i]=e[i];return t}function zv(e,t){var i=fy(e);for(var r in e)i[r]=t.hasOwnProperty(r)?t[r]:e[r];return i}function Gp(e,t){var i=fy(e);for(var r in t)i[r]=Qe.und(e[r])?t[r]:e[r];return i}function fW(e){var t=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(e);return t?"rgba("+t[1]+",1)":e}function mW(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i=e.replace(t,function(o,l,h,d){return l+l+h+h+d+d}),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),s=parseInt(r[1],16),a=parseInt(r[2],16),n=parseInt(r[3],16);return"rgba("+s+","+a+","+n+",1)"}function gW(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,a=t[4]||1;function n(u,p,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(p-u)*6*f:f<1/2?p:f<2/3?u+(p-u)*(2/3-f)*6:u}var o,l,h;if(r==0)o=l=h=s;else{var d=s<.5?s*(1+r):s+r-s*r,c=2*s-d;o=n(c,d,i+1/3),l=n(c,d,i),h=n(c,d,i-1/3)}return"rgba("+o*255+","+l*255+","+h*255+","+a+")"}function vW(e){if(Qe.rgb(e))return fW(e);if(Qe.hex(e))return mW(e);if(Qe.hsl(e))return gW(e)}function Ma(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 yW(e){if(hc(e,"translate")||e==="perspective")return"px";if(hc(e,"rotate")||hc(e,"skew"))return"deg"}function Nv(e,t){return Qe.fnc(e)?e(t.target,t.id,t.total):e}function Vs(e,t){return e.getAttribute(t)}function my(e,t,i){var r=Ma(t);if(py([i,"deg","rad","turn"],r))return t;var s=mp.CSS[t+i];if(!Qe.und(s))return s;var a=100,n=document.createElement(e.tagName),o=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;o.appendChild(n),n.style.position="absolute",n.style.width=a+i;var l=a/n.offsetWidth;o.removeChild(n);var h=l*parseFloat(t);return mp.CSS[t+i]=h,h}function SE(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?my(e,s,i):s}}function gy(e,t){if(Qe.dom(e)&&!Qe.inp(e)&&(Vs(e,t)||Qe.svg(e)&&e[t]))return"attribute";if(Qe.dom(e)&&py(dW,t))return"transform";if(Qe.dom(e)&&t!=="transform"&&SE(e,t))return"css";if(e[t]!=null)return"object"}function AE(e){if(Qe.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 xW(e,t,i,r){var s=hc(t,"scale")?1:0+yW(t),a=AE(e).get(t)||s;return i&&(i.transforms.list.set(t,a),i.transforms.last=t),r?my(e,a,r):a}function vy(e,t,i,r){switch(gy(e,t)){case"transform":return xW(e,t,r,i);case"css":return SE(e,t,i);case"attribute":return Vs(e,t);default:return e[t]||0}}function yy(e,t){var i=/^(\*=|\+=|-=)/.exec(e);if(!i)return e;var r=Ma(e)||0,s=parseFloat(t),a=parseFloat(e.replace(i[0],""));switch(i[0][0]){case"+":return s+a+r;case"-":return s-a+r;case"*":return s*a+r}}function ME(e,t){if(Qe.col(e))return vW(e);if(/\s/g.test(e))return e;var i=Ma(e),r=i?e.substr(0,e.length-i.length):e;return t?r+t:r}function xy(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function bW(e){return Math.PI*2*Vs(e,"r")}function wW(e){return Vs(e,"width")*2+Vs(e,"height")*2}function _W(e){return xy({x:Vs(e,"x1"),y:Vs(e,"y1")},{x:Vs(e,"x2"),y:Vs(e,"y2")})}function EE(e){for(var t=e.points,i=0,r,s=0;s<t.numberOfItems;s++){var a=t.getItem(s);s>0&&(i+=xy(r,a)),r=a}return i}function SW(e){var t=e.points;return EE(e)+xy(t.getItem(t.numberOfItems-1),t.getItem(0))}function CE(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return bW(e);case"rect":return wW(e);case"line":return _W(e);case"polyline":return EE(e);case"polygon":return SW(e)}}function AW(e){var t=CE(e);return e.setAttribute("stroke-dasharray",t),t}function MW(e){for(var t=e.parentNode;Qe.svg(t)&&Qe.svg(t.parentNode);)t=t.parentNode;return t}function TE(e,t){var i=t||{},r=i.el||MW(e),s=r.getBoundingClientRect(),a=Vs(r,"viewBox"),n=s.width,o=s.height,l=i.viewBox||(a?a.split(" "):[0,0,n,o]);return{el:r,viewBox:l,x:l[0]/1,y:l[1]/1,w:n/l[2],h:o/l[3]}}function EW(e,t){var i=Qe.str(e)?_E(e)[0]:e,r=t||100;return function(s){return{property:s,el:i,svg:TE(i),totalLength:CE(i)*(r/100)}}}function CW(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=TE(e.el,e.svg),s=i(),a=i(-1),n=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(n.y-a.y,n.x-a.x)*180/Math.PI}}function O_(e,t){var i=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,r=ME(Qe.pth(e)?e.totalLength:e,t)+"";return{original:r,numbers:r.match(i)?r.match(i).map(Number):[0],strings:Qe.str(e)||t?r.split(i):[]}}function PE(e){var t=e?jp(Qe.arr(e)?e.map(I_):I_(e)):[];return Vp(t,function(i,r,s){return s.indexOf(i)===r})}function DE(e){var t=PE(e);return t.map(function(i,r){return{target:i,id:r,total:t.length,transforms:{list:AE(i)}}})}function TW(e,t){var i=fy(t);if(/^spring/.test(i.easing)&&(i.duration=bE(i.easing)),Qe.arr(e)){var r=e.length,s=r===2&&!Qe.obj(e[0]);s?e={value:e}:Qe.fnc(t.duration)||(i.duration=t.duration/r)}var a=Qe.arr(e)?e:[e];return a.map(function(n,o){var l=Qe.obj(n)&&!Qe.pth(n)?n:{value:n};return Qe.und(l.delay)&&(l.delay=o?0:t.delay),Qe.und(l.endDelay)&&(l.endDelay=o===a.length-1?t.endDelay:0),l}).map(function(n){return Gp(n,i)})}function PW(e){for(var t=Vp(jp(e.map(function(a){return Object.keys(a)})),function(a){return Qe.key(a)}).reduce(function(a,n){return a.indexOf(n)<0&&a.push(n),a},[]),i={},r=function(a){var n=t[a];i[n]=e.map(function(o){var l={};for(var h in o)Qe.key(h)?h==n&&(l.value=o[h]):l[h]=o[h];return l})},s=0;s<t.length;s++)r(s);return i}function DW(e,t){var i=[],r=t.keyframes;r&&(t=Gp(PW(r),t));for(var s in t)Qe.key(s)&&i.push({name:s,tweens:TW(t[s],e)});return i}function IW(e,t){var i={};for(var r in e){var s=Nv(e[r],t);Qe.arr(s)&&(s=s.map(function(a){return Nv(a,t)}),s.length===1&&(s=s[0])),i[r]=s}return i.duration=parseFloat(i.duration),i.delay=parseFloat(i.delay),i}function OW(e,t){var i;return e.tweens.map(function(r){var s=IW(r,t),a=s.value,n=Qe.arr(a)?a[1]:a,o=Ma(n),l=vy(t.target,e.name,o,t),h=i?i.to.original:l,d=Qe.arr(a)?a[0]:h,c=Ma(d)||Ma(l),u=o||c;return Qe.und(n)&&(n=h),s.from=O_(d,u),s.to=O_(yy(n,d),u),s.start=i?i.end:0,s.end=s.start+s.delay+s.duration+s.endDelay,s.easing=uy(s.easing,s.duration),s.isPath=Qe.pth(a),s.isColor=Qe.col(s.from.original),s.isColor&&(s.round=1),i=s,s})}var IE={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 a="";r.list.forEach(function(n,o){a+=o+"("+n+") "}),e.style.transform=a}}};function OE(e,t){var i=DE(e);i.forEach(function(r){for(var s in t){var a=Nv(t[s],r),n=r.target,o=Ma(a),l=vy(n,s,o,r),h=o||Ma(l),d=yy(ME(a,h),l),c=gy(n,s);IE[c](n,s,d,r.transforms,!0)}})}function LW(e,t){var i=gy(e.target,t.name);if(i){var r=OW(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 RW(e,t){return Vp(jp(e.map(function(i){return t.map(function(r){return LW(i,r)})})),function(i){return!Qe.und(i)})}function LE(e,t){var i=e.length,r=function(a){return a.timelineOffset?a.timelineOffset:0},s={};return s.duration=i?Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+l+a.duration*(a.loop??1)})):t.duration,s.delay=i?Math.min.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0;return r(a)+n+o+a.delay})):t.delay,s.endDelay=i?s.duration-Math.max.apply(Math,e.map(function(a){let n=a.startOnceDelay??0,o=a.pingPongDelayCorrection??0,l=a.pingPongEndDelayCorrection??0;return r(a)+n+o+a.duration*(a.loop??1)-a.endDelay-l})):t.endDelay,s}var L_=0;function BW(e){var t=zv(yE,e),i=zv(dy,e),r=DW(i,e),s=DE(e.targets),a=RW(s,r),n=LE(a,i),o=L_;return L_++,Gp(t,{id:o,children:[],animatables:s,animations:a,duration:n.duration,delay:n.delay,endDelay:n.endDelay,startOnceDelay:i.startOnceDelay,pingPongDelayCorrection:i.pingPongDelayCorrection,pingPongEndDelayCorrection:i.pingPongEndDelayCorrection})}var qr=[],R_=[],bu,zW=function(){function e(){bu=requestAnimationFrame(t)}function t(i){var r=qr.length;if(r){for(var s=0;s<r;){var a=qr[s];a.paused?(qr.splice(s,1),r-=1):(a.tick(i),s++)}e()}else bu=cancelAnimationFrame(bu)}return e}();function NW(e){document.hidden?(qr.forEach(function(t){return t.pause(e.timeStamp)}),R_=qr.slice(0),Jt.running=qr=[]):R_.forEach(function(t){return t.play(e.timeStamp)})}typeof document<"u"&&document.addEventListener("visibilitychange",NW);function Jt(e){e===void 0&&(e={});var t=0,i=0,r=0,s,a,n=0,o=null;function l(S){var _=window.Promise&&new Promise(function(M){return o=M});return S.finished=_,_}var h=BW(e),d=l(h);function c(){var S=h.direction;S!=="alternate"&&(h.direction=S!=="normal"?"normal":"reverse"),h.reversed=!h.reversed,a.forEach(function(_){(_.loop===1||_.loop%2===0)&&(_.reversed=h.reversed)})}function u(){h.direction="normal",h.reversed=!1,a.forEach(function(S){return S.reversed=!1})}function p(S){return h.reversed?h.duration-S:S}function f(){t=0,i=p(h.currentTime)*(1/Jt.speed)}function m(S,_,M=!1){_&&(h.reversed?_.seek(_.duration*_.loop-(S-_.timelineOffset-_.pingPongDelayCorrection),M):_.seek(S-_.timelineOffset-_.startOnceDelay-_.pingPongDelayCorrection,M))}function g(S,_=!1){if(h.reversed)for(var M=n;M--;)m(S,a[M],_);else for(var C=0;C<n;C++)m(S,a[C],_)}function v(S){var _=0,M=h.animations,C=M.length;for(h.direction!=="alternate"&&h.parent?.direction==="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S):w(!1,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)&&(h.parent?.reversed&&h.direction==="alternate"?S=h.duration-h.delay+h.endDelay-S:S=h.duration+h.delay-h.endDelay-S);_<C;){var T=M[_],D=T.animatable,P=T.tweens,O=P.length-1,B=P[O];O&&(B=Vp(P,function(Z){return S<Z.end})[0]||B);let re;h.parent?.reversed&&h.direction==="alternate"?re=us(S-B.start-B.endDelay,0,B.duration)/B.duration:re=us(S-B.start-B.delay,0,B.duration)/B.duration;for(var G=isNaN(re)?1:B.easing(re),F=B.to.strings,z=B.round,X=[],H=B.to.numbers.length,j=void 0,N=0;N<H;N++){var q=void 0;let Z,pe;h.direction!=="alternate"?h.parent?.rewind===!1&&h.reversePlayback===!0&&h.rewind===!1?(Z=B.to.numbers[N],pe=B.from.numbers[N]||0):(pe=B.to.numbers[N],Z=B.from.numbers[N]||0):w(!0,h.parent?.rewind,h.rewind,h.parent?.reversePlayback,h.reversePlayback)?(Z=B.to.numbers[N],pe=B.from.numbers[N]||0):(pe=B.to.numbers[N],Z=B.from.numbers[N]||0),B.isPath?q=CW(B.value,G*pe):q=Z+G*(pe-Z),z&&(B.isColor&&N>2||(q=Math.round(q*z)/z)),X.push(q)}var V=F.length;if(!V)j=X[0];else{j=F[0];for(var W=0;W<V;W++){var U=F[W],ie=F[W+1],Q=X[W];isNaN(Q)||(ie?j+=Q+ie:j+=Q+" ")}}IE[T.type](D.target,T.property,j,D.transforms),T.currentValue=j,_++}}function y(S){h[S]&&!h.passThrough&&h[S](h)}function x(){h.remaining&&h.remaining!==!0&&h.remaining--}let b={0:!1,1:!0,2:!1,3:!0,4:!1,5:!1,6:!1,7:!1,8:!1,9:!0,10:!0,11:!1,12:!1,13:!1,14:!0,15:!0,16:!1,17:!0,18:!0,19:!1,20:!1,21:!1,22:!0,23:!0,24:!1,25:!0,26:!1,27:!0,28:!1,29:!1,30:!1,31:!1};function w(S,_,M,C,T){return b[S<<4|_<<3|M<<2|C<<1|T]}function A(S,_=!1){var M=h.duration;let C=h.delay,T=M-h.endDelay;h.parent?.reversed&&h.direction==="alternate"&&(C=h.endDelay,T=M-h.delay);var D=p(S);if(h.progress=us(D/M*100,0,100),_||(h.reversePlayback=D<h.currentTime),n&&g(D,_),!h.began&&h.currentTime>=0&&(h.began=!0,y("begin")),!h.loopBegan&&h.currentTime>0&&(h.loopBegan=!0,y("loopBegin")),(h.reversed||D>=0)&&D<=C&&h.currentTime!==0&&(v(0),y("change")),(D>=T&&h.currentTime!==M+h.pingPongDelayCorrection||!M)&&(v(M),y("change")),D>C&&D<T?(h.changeBegan||(h.changeBegan=!0,h.changeCompleted=!1,y("changeBegin")),v(D),y("change")):h.changeBegan?(h.changeCompleted=!0,h.changeBegan=!1,y("change"),n&&y("timelineChangeComplete")):h.began&&D>T&&y("changeComplete"),h.currentTime=us(D,0,M+h.pingPongDelayCorrection),h.began&&y("update"),S>=M)if(x(),!h.remaining)h.paused=!0,h.completed||(h.completed=!0,y("loopComplete"),y("complete"),!h.passThrough&&"Promise"in window&&(o(),d=l(h)));else{n?t+=h.duration/Jt.speed:t+=h.duration;for(let P of a)P.setStartTime(0),P.remaining=P.loop;y("loopComplete"),h.loopBegan=!1,h.direction==="alternate"?c():n&&u()}}return h.reset=function(){var S=h.direction;h.passThrough=!1,h.currentTime=0,h.progress=0,h.paused=!0,h.began=!1,h.loopBegan=!1,h.changeBegan=!1,h.completed=!1,h.changeCompleted=!1,h.reversePlayback=!1,h.reversed=S==="reverse",h.remaining=h.loop,a=h.children,n=a.length;for(var _=n;_--;)h.children[_].reset();v(h.reversed?h.duration:0)},h.setStartTime=function(S){t=S},h.set=function(S,_){return OE(S,_),h},h.tick=function(S){r=S,t||(t=r),A((r+(i-t))*Jt.speed)},h.seek=function(S,_=!1){A(S-t,_)},h.pause=function(S){h.paused=!0,n&&(s=S??performance.now())},h.play=function(S){!h.paused||(h.completed&&h.reset(),h.paused=!1,qr.push(h),n&&s!==void 0&&(t+=(S??performance.now())-s),bu||zW())},h.reverse=function(){c(),h.completed=!h.reversed,f()},h.restart=function(){h.reset(),h.play()},h.reset(),h.autoplay&&h.play(),h}function B_(e,t){for(var i=t.length;i--;)py(e,t[i].animatable.target)&&t.splice(i,1)}function kW(e){for(var t=PE(e),i=qr.length;i--;){var r=qr[i],s=r.animations,a=r.children;B_(t,s);for(var n=a.length;n--;){var o=a[n],l=o.animations;B_(t,l),!l.length&&!o.children.length&&a.splice(n,1)}!s.length&&!a.length&&r.pause()}}function UW(e,t){t===void 0&&(t={});var i=t.direction||"normal",r=t.easing?uy(t.easing):null,s=t.grid,a=t.axis,n=t.from||0,o=n==="first",l=n==="center",h=n==="last",d=Qe.arr(e),c=parseFloat(d?e[0]:e),u=d?parseFloat(e[1]):0,p=Ma(d?e[1]:e)||0,f=t.start||0+(d?c:0),m=[],g=0;return function(v,y,x){if(o&&(n=0),l&&(n=(x-1)/2),h&&(n=x-1),!m.length){for(var b=0;b<x;b++){if(!s)m.push(Math.abs(n-b));else{var w=l?(s[0]-1)/2:n%s[0],A=l?(s[1]-1)/2:Math.floor(n/s[0]),S=b%s[0],_=Math.floor(b/s[0]),M=w-S,C=A-_,T=Math.sqrt(M*M+C*C);a==="x"&&(T=-M),a==="y"&&(T=-C),m.push(T)}g=Math.max.apply(Math,m)}r&&(m=m.map(function(P){return r(P/g)*g})),i==="reverse"&&(m=m.map(function(P){return a?P<0?P*-1:-P:Math.abs(g-P)}))}var D=d?(u-c)/g:c;return f+D*(Math.round(m[y]*100)/100)+p}}function FW(e){e===void 0&&(e={});var t=Jt(e);return t.duration=0,t.add=function(i,r){var s=qr.indexOf(t),a=t.children;s>-1&&qr.splice(s,1);function n(u){u.passThrough=!0}for(var o=0;o<a.length;o++)n(a[o]);var l=Gp(i,zv(dy,e));l.targets=l.targets||e.targets;var h=t.duration;l.autoplay=!1,l.timelineOffset=Qe.und(r)?h:yy(r,h),n(t);var d=Jt(l);n(d),a.push(d),d.parent=t;var c=LE(a,e);return t.delay=c.delay,t.endDelay=c.endDelay,t.duration=c.duration,d.loop===!0&&(t.duration=1/0),t.seek(0),t.reset(),t.autoplay&&t.play(),t},t}Jt.version="3.2.0";Jt.speed=1;Jt.running=qr;Jt.remove=kW;Jt.get=vy;Jt.set=OE;Jt.convertPx=my;Jt.path=EW;Jt.setDashoffset=AW;Jt.stagger=UW;Jt.timeline=FW;Jt.easing=uy;Jt.penner=wE;Jt.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};var RE=Jt,z_=new E,N_=new E,k_=new it;function VW(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 a=1-s*s;if(a<=Number.EPSILON){let d=1-r;return i.w=d*e.w+r*t.w,i.x=d*e.x+r*t.x,i.y=d*e.y+r*t.y,i.z=d*e.z+r*t.z,i.normalize(),i}let n=Math.sqrt(a),o=Math.atan2(n,s),l=Math.sin((1-r)*o)/n,h=Math.sin(r*o)/n;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 oo(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(o==null)return;let l=n!=null?typeof n=="string"?Number(s.getVariable(n)??0):n:t[e],h=typeof o=="string"?Number(s.getVariable(o)??0):o;if(l!==h)return{update:d=>{let c=Re.lerp(l,h,d);a?t[e]=Math.trunc(c):t[e]=c},start:()=>{t[e]=l},end:()=>{t[e]=h}}}function BE(e,t,i,r,s,a){let n=i[e]?i[e]:void 0,o=r[e];if(!o)return;let l=t[e],h=[...n??l].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c),d=[...o].map(c=>typeof c=="string"?Number(s.getVariable(c)??0):c);if(!(h.length!==d.length||qA(h,d)))return{update:c=>{h.forEach((u,p)=>{let f=Re.lerp(u,d[p],c);t[e][p]=a?Math.trunc(f):f})},start:()=>{Object.assign(t[e],h)},end:()=>{Object.assign(t[e],d)}}}function gp(e,t,i){return t.forEach((r,s)=>{e.setComponent(s,typeof r=="string"?Number(i.getVariable(r)??0):r)}),e}function U_(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?gp(new E,a,s):o.clone(),h=gp(new E,n,s);if(!l.equals(h))return{update:d=>{o.lerpVectors(l,h,d)},start:()=>{o.copy(l)},end:()=>{o.copy(h)}}}function jW(e,t,i,r){let s=i[e]?i[e]:void 0,a=r[e];if(!a)return;let n=t[e],o=s?new me().fromArray(s):n.clone(),l=new E,h=new it,d=new E;o.decompose(l,h,d);let c=new me().fromArray(a),u=new E,p=new it,f=new E;if(c.decompose(u,p,f),!o.equals(c))return{update:m=>{k_.slerpQuaternions(h,p,m),z_.lerpVectors(l,u,m),N_.lerpVectors(d,f,m),n.compose(z_,k_,N_)},start:()=>{n.compose(l,h,d)},end:()=>{n.compose(u,p,f)}}}function GW(e,t,i,r,s){let a=i[e]?i[e]:void 0,n=r[e];if(!n)return;let o=t[e],l=a?typeof a=="string"?s.getColor(a).clone():new He().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new He().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let d=o.clone();return t[e]=d,{update:c=>{d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function xn(e,t,i,r,s){if(typeof t[e]=="number")return oo(e,t,i??{},r,s);if(Array.isArray(t[e]))return BE(e,t,i??{},r,s)}function HW(e,t,i,r){let s=[],a=e.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom,n=e.cameraType==="OrthographicCamera"?i.orthographic?.zoom:i.perspective?.zoom;if(n!==void 0){let o=a??e.zoom,l=n;o!==l&&s.push({update:h=>{e.zoom=Re.lerp(o,l,h),e.updateProjectionMatrix()},start:()=>{e.zoom=o,e.updateProjectionMatrix()},end:()=>{e.zoom=l,e.updateProjectionMatrix()}})}if(i.targetOffset!==void 0){let o=oo("targetOffset",e,t,i,r);o&&s.push(o)}return s}function WW(e,t,i,r){if(i.scaleBaked===void 0)return;let s=(t.scaleBaked??e.data.geometry.scaleBaked).map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o),a=i.scaleBaked.map(o=>typeof o=="string"?Number(r.getVariable(o)??0):o);if(Kn.isEqual(s,a))return;let n=[];return n.push({update:o=>{e.updateGeometryInteractions({scaleBaked:[Re.lerp(s[0],a[0],o),Re.lerp(s[1],a[1],o),Re.lerp(s[2],a[2],o)]},r),e.invalidateDownstreamBooleanData()},start:()=>{e.updateGeometryInteractions({scaleBaked:s},r),e.invalidateDownstreamBooleanData()},end:()=>{e.updateGeometryInteractions({scaleBaked:a},r),e.invalidateDownstreamBooleanData()}}),n}function qW(e,t,i,r){if(!i.extrusion)return;let s=e.extrusion,a=t.extrusion??{},n=i.extrusion,o=[];return D2.forEach(l=>{let h=xn(l,s,a,n,r);h&&o.push(h)}),o}function XW(e,t,i,r){let s=[];if(!("geometry"in i))return s;let a=e.geometry.userData.parameters,n="geometry"in t?t.geometry:{},o=i.geometry;if(e instanceof Tc){let l=WW(e,n,o,r);l&&s.push(...l)}else{let l={};if(Object.assign(l,Sa(a,Lb)),Lb.forEach(h=>{let d=xn(h,l,n,o,r);d&&s.push(d)}),e instanceof ay){Object.assign(l,{extrusion:{...a.extrusion}});let h=qW(l,n,o,r);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 YW(e,t,i,r){let s=[];if(i.intensity!==void 0){let a=oo("intensity",e,t,i,r);a&&s.push(a)}if(i.color!==void 0){let a=GW("color",e,t,i,r);a&&s.push(a)}return s}function QW(e,t,i,r){let s=[];if(Array.isArray(e.material)){if(!("materials"in i&&i.materials))return s;let a="materials"in t&&t.materials?t.materials:[],n=i.materials;e.material.forEach((o,l)=>{if(!n[l])return;let h=a[l]??{},d=n[l];typeof h=="string"||typeof d=="string"||s.push(...F_(o,h,d,r))})}else{if(!("material"in i&&i.material))return s;let a="material"in t&&t.material?t.material:{},n=i.material;if(typeof a=="string"||typeof n=="string")return s;s.push(...F_(e.material,a,n,r))}return s}function F_(e,t,i,r){let s=[],a=hl(i,r)||!!t.layers&&hl(t,r);s.push(sq(e,a));for(let n of e.layers){let o=t.layers?.data(n.uuid),l=i.layers.data(n.uuid);if(!l||n.type!=="light"&&(!(n.visible??!0)||!(l.visible??!0)))continue;let h=n.getNames().filter(d=>!C2.some(c=>d.includes(c)));for(let d of h)try{let c=n.getValue(d),u;if(d==="colors")u=iq(n,o,l,d);else if(Array.isArray(c))d==="steps"&&(u=tq(n,o,l,d));else if(typeof c=="number")u=ZW(n,o,l,d,r);else{if(typeof c=="boolean")continue;c instanceof k?u=KW(n,o,l,d):c instanceof E?u=JW(n,o,l,d,r):c instanceof gr?u=eq(n,o,l,d,r):c instanceof He?u=$W(n,o,l,d,r):"isTexture"in c&&(u=rq(n,o,l,d))}u&&(Array.isArray(u)?s.push(...u):s.push(u))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${d}`,c)}}return s}function ZW(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:e.getValue(r),n=i[r],o=typeof a=="string"?Number(s.getVariable(a)??0):a,l=typeof n=="string"?Number(s.getVariable(n)??0):n;if(o!==l)return{update:h=>{e.setValue(r,Re.lerp(o,l,h))},start:()=>{e.setValue(r,o)},end:()=>{e.setValue(r,l)}}}function KW(e,t,i,r){if(!e.hasValue(r)||!(r in i))return;let s=e.getValue(r),a=t?new k().fromArray(t[r]):s.clone(),n=new k().fromArray(i[r]);if(!a.equals(n))return{update:o=>{s.lerpVectors(a,n,o)},start:()=>{s.copy(a)},end:()=>{s.copy(n)}}}function JW(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=e.getValue(r),n=t?t[r]:void 0,o=i[r],l=n?gp(new E,n,s):a.clone(),h=gp(new E,o,s);if(!l.equals(h))return{update:d=>{a.lerpVectors(l,h,d)},start:()=>{a.copy(l)},end:()=>{a.copy(h)}}}function $W(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new He().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new He().setRGB(n.r,n.g,n.b);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function eq(e,t,i,r,s){if(!e.hasValue(r)||!(r in i))return;let a=t?t[r]:void 0,n=i[r],o=e.getValue(r),l=a?typeof a=="string"?s.getColor(a).clone():new He().setRGB(a.r,a.g,a.b):o.clone(),h=typeof n=="string"?s.getColor(n).clone():new gr(n.r,n.g,n.b,n.a);if(l.equals(h))return;let d=o.clone();return{update:c=>{e.getValue(r)!==d&&e.setValue(r,d),d.lerpColors(l,h,c)},start:()=>{d.copy(l)},end:()=>{d.copy(h)}}}function tq(e,t,i,r="steps"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a,o=i[r];for(let l=0;l<a.length;++l){let h=n[l],d=o[l];h!==d&&s.push({update:c=>{a[l]=Re.lerp(h,d,c)},start:()=>{a[l]=h},end:()=>{a[l]=d}})}return s.length?s:void 0}function iq(e,t,i,r="colors"){if(!e.hasValue(r)||!(r in i))return;let s=[],a=e.getValue(r),n=t?t[r]:a.map(l=>l.toArray()),o=i[r];for(let l=0;l<a.length;++l){let h=[...n[l]],d=[...o[l]];Qu.isEqual(h,d)||s.push({update:c=>{a[l].fromArray(Qu.lerp(h,d,c))},start:()=>{a[l].fromArray(h)},end:()=>{a[l].fromArray(d)}})}return s.length?s:void 0}function rq(e,t,i,r="texture"){if(!e.hasValue(r)||!(r in i))return;let s=e.getNode("mat");if(!s)return;let a=t?t[r]:s,n=i[r],o=[...a.repeat],l=[...a.offset],h=[...n.repeat],d=[...n.offset];if(!ol.isEqual(o,h)||!ol.isEqual(l,d))return{update:c=>{s.repeat=ol.lerp(o,h,c),s.offset=ol.lerp(l,d,c),s.updateMatrix()},start:()=>{s.repeat=[...o],s.offset=[...l],s.updateMatrix()},end:()=>{s.repeat=[...h],s.offset=[...d],s.updateMatrix()}}}function sq(e,t){return{update:()=>{e.transparent=t}}}var km=new E,V_=new _i;function aq(e,t,i,r,s){let a=[],n,o,l,h,d,c,u={slide:t.pathSnapping?.slide??e.updatedPathSnapping?.slide??e.dataPatched.pathSnapping?.slide??0,offset:t.pathSnapping?.offset??e.updatedPathSnapping?.offset??e.dataPatched.pathSnapping?.offset??0};if(d=oo("slide",u,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),d&&a.push(d),c=oo("offset",u,t.pathSnapping??e.updatedPathSnapping??e.dataPatched.pathSnapping,i.pathSnapping??e.dataPatched.pathSnapping,s),c&&a.push(c),!d&&!c&&(n=U_("position",e,t,i,s),n&&a.push(n),o=U_("scale",e,t,i,s),o&&a.push(o),l=nq(e,t,i,r,s),l&&a.push(l),h=jW("hiddenMatrix",e,t,i),h&&a.push(h)),n||o||l||h||d||c){let p=()=>{e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD()),e.parent?.matrixWorldFusedFalse&&(e.matrixWorld.multiplyMatrices(e.parent.matrixWorldFusedFalse,e.matrix),e.matrixWorldNeedsUpdate=!1),os(e)&&Us(e.parent)&&e.invalidateDownstreamBooleanData(!0),e.updatePathSnapping(Object.assign({},t.pathSnapping,u))};a.push({update:p,start:p,end:p})}return a}function nq(e,t,i,r,s){let a=t?.rotation?t.rotation.map(d=>(typeof d=="string"?Number(s.getVariable(d)??0):d)*Re.DEG2RAD):void 0,n=i.rotation?.map(d=>(typeof d=="string"?Number(s.getVariable(d)??0):d)*Re.DEG2RAD);if(!n)return;let o=a?new E().fromArray(a):new E().setFromEuler(e.rotation),l=new E().fromArray(n);if(o.equals(l))return;let h=km.subVectors(l,o);if(r&&h.toArray().every(d=>Math.abs(d)<2*Math.PI)){let d=new it().setFromEuler(V_.setFromVector3(o)),c=new it().setFromEuler(V_.setFromVector3(l));return{update:u=>{VW(d,c,e.quaternion,u)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}else return{update:d=>{km.lerpVectors(o,l,d),e.rotation.setFromVector3(km)},start:()=>{e.rotation.setFromVector3(o)},end:()=>{e.rotation.setFromVector3(l)}}}function oq(e,t,i,r){let s=[];if(!("cloner"in i)||!e.cloner)return s;let a=e.cloner,n="cloner"in t?t.cloner:{},o=i.cloner;w2.forEach(p=>{let f;p==="count"?f=oo("count",a.parameters,n,o,r,!0):f=xn(p,a.parameters,n??{},o,r),f&&s.push(f)});let l=lq(a,n,o,r);l?.length&&s.push(...l);let h=hq(a,n,o,r);h?.length&&s.push(...h);let d=cq(a,n,o,r);d?.length&&s.push(...d);let c=dq(a,n,o,r);c?.length&&s.push(...c);let u=uq(a,n,o,r);return u?.length&&s.push(...u),s.length&&s.push({update:()=>{a.update()}}),s}function lq(e,t,i,r){if(e.parameters.type!=="radial")return;let s=t.radial,a=i.radial;if(!a)return;let n=e.parameters.radial,o=[];return _2.forEach(l=>{let h=xn(l,n,s??{},a,r);h&&o.push(h)}),o}function hq(e,t,i,r){if(e.parameters.type!=="linear")return;let s=t.linear,a=i.linear;if(!a)return;let n=[],o=e.parameters.linear;return S2.forEach(l=>{let h=xn(l,o,s??{},a,r);h&&n.push(h)}),n}function cq(e,t,i,r){if(e.parameters.type!=="grid")return;let s=t.grid,a=i.grid;if(!a)return;let n=[],o=e.parameters.grid;return A2.forEach(l=>{let h;l==="count"?h=BE(l,o,s??{},a,r,!0):h=xn(l,o,s??{},a,r),h&&n.push(h)}),n}function dq(e,t,i,r){if(e.parameters.type!=="toObject")return;let s=t.toObject,a=i.toObject;if(!a)return;let n=[],o=e.parameters.toObject;return M2.forEach(l=>{let h;l==="count"?h=oo(l,o,s??{},a,r,!0):h=xn(l,o,s??{},a,r),h&&n.push(h)}),n}function uq(e,t,i,r){if(!e.parameters.randomness)return;let s=t.randomnessObject,a=i.randomnessObject;if(!a)return;let n=[],o=e.parameters.randomnessObject;return E2.forEach(l=>{let h=xn(l,o,s??{},a,r);h&&n.push(h)}),n}function j_(e,t,i,r,s){let a=[];return e.data.visible&&a.push(...aq(e,t,i,s,r)),e.data.visible&&a.push(...oq(e,t,i,r)),os(e)?(e instanceof er&&e.data.visible&&a.push(...XW(e,t,i,r)),e.data.visible&&a.push(...QW(e,t,i,r))):TH(e)?e.data.visible&&a.push(...YW(e,t,i,r)):CH(e)&&a.push(...HW(e,t,i,r)),a.length?{update:n=>{a.forEach(o=>o.update(n))},start:n=>{a.forEach(o=>o.start?.(n))},end:n=>{a.forEach(o=>o.end?.(n))}}:void 0}var G_=new E;function by(e,t,i=!1){let r=[];e.traverseChildren(s=>{if(i&&(s.rigidBody?.setTranslation(s.position0,!0),s.rigidBody?.setRotation(s.rotation0,!0),s.rigidBody?.setLinvel(G_,!0),s.rigidBody?.setAngvel(G_,!0)),!ut.is(s))return;let a=s.uuid,n=s.data;if(delete s.states,s.uuid===rh)return;let o=!1;r.some(l=>e.scene.find(a)?.isDescendantOf(l))?o=!0:n.physics?.fusedBody===!0&&n.physics.rigidBody==="dynamic"&&r.push(a),s.data=n,s.currentState=null,s.reversibleToState=null,s.currentTransitionEvent=null;for(let l of n.states){let h={...l.data};e.data.globalPhysics.usePhysics===!0&&n.physics&&(n.physics.rigidBody==="dynamic"||o)&&(l.data.position!==void 0&&delete h.position,l.data.rotation!==void 0&&delete h.rotation,l.data.hiddenMatrix!==void 0&&delete h.hiddenMatrix),s.states||(s.states={}),s.states[l.id]=Gn.patch(n,h)}fq(e.scene,s,null,t,n.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0),pq(e)})}function pq(e){e.traverseEntity(t=>{for(let i of t.data.events){let r=[];switch(i.data.type){case"Follow":case"MouseHover":case"Scroll":case"MouseDown":case"MouseUp":case"MousePress":case"KeyUp":case"KeyDown":case"KeyPress":case"Collision":r.push(...i.data.actions);break;case"GameControl":for(let s of Object.values(i.data.gameActions))r.push(...s);break;case"DragDrop":r.push(...i.data.dragDropActions.drag,...i.data.dragDropActions.drop);break;case"Conditional":r.push(...i.data.inActions,...i.data.outActions);break}for(let s of r)if(s.data.type==="Create"&&s.data.hideBase==="Yes"){let a=e.scene.find(s.data.object);a&&(a.visible=!1)}}})}function fq(e,t,i,r,s=!1){if(t instanceof er&&t.removeInteractionGeometry(),t.changeSelectedState(i,{scene:e,shared:r},s),t instanceof er&&t.updateGeometryGroupsIfNeeded(),t instanceof Vi&&t.updateCameraState(t.dataPatched,{scene:e,shared:r}),t.cloner)for(let a of t.cloner.children)a.playModeVisible=void 0;t.updateVisible()}function zE(e){let t;if(e.easing===5){let{control1:i,control2:r}=e;t=`cubicBezier(
6238
6238
  ${i[0]}, ${i[1]}, ${r[0]}, ${r[1]}
6239
- )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=qa.linear;break;case 1:i=qa.ease;break;case 2:i=qa.easeIn;break;case 3:i=qa.easeOut;break;case 4:i=qa.easeInOut;break;default:i=qa.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:e.duration,easing:t}}function kv(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var mq={type:"beginState"},gq={type:"completeState",isfromEntity:!1},H_=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,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 n=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=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(mq)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=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=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(gq)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=j_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=wu(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=wu(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=wu(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...kv(r),...zE(r),change:this.onChange},this.callback=j_(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}},NE=class extends Ii{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,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,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,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.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=wu(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=kv(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=RE.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new H_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[n]=d,this.timeline.add(d.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new H_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[n-1]=d,this.timeline.add(d.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(li(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=kv(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(li(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),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 wu(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var vq={type:"beginState"},W_={type:"completeState",isfromEntity:!1},q_={type:"requestRender"},kE=class extends Ii{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=RE({targets:i,t:1,...zE(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(vq));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(q_),i.t===1&&r.dispatchEvent(W_)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(li(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(li(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(W_),this.page.activeCamera.dispatchEvent(q_))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},UE=class extends Ii{constructor(e,t,i,r,s){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(li(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Re.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(li(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},FE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(li(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),by(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},VE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=li(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=aM(this.data.expression,this.shared,Dr.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},jE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(li(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function li(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=aM(t.expression,e,"boolean");return t.negate?!i:!!i}function rr(e,t,i,r,s,a){let n={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:d})=>{try{d.type==="Audio"?Ar[e.type].includes("Audio")&&n.Audio.push(new mE(h,d,a,r,l)):d.type==="Video"?Ar[e.type].includes("Video")&&n.Video.push(new HE(h,d,a,r,l)):d.type==="Link"?Ar[e.type].includes("Link")&&n.Link.push(new cW(d,s.controlsManager,r,l)):d.type==="Create"?Ar[e.type].includes("Create")&&n.Create.push(new WE(d,i,s.controlsManager,r,l)):d.type==="Destroy"?Ar[e.type].includes("Destroy")&&n.Destroy.push(new gE(d,i,s.controlsManager,r,l)):d.type==="Reset"?Ar[e.type].includes("Reset")&&n.Reset.push(new vE(d,i,r,s,l)):d.type==="Transition"?Ar[e.type].includes("Transition")&&n.Transition.push(new NE(d,i,r,l)):d.type==="SwitchCamera"?Ar[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new kE(d,i,r,l)):d.type==="SceneTransition"?Ar[e.type].includes("SceneTransition")&&n.SceneTransition.push(new FE(d,i,s,r,l)):d.type==="Animation"?Ar[e.type].includes("Animation")&&n.Animation.push(new UE(d,i,s.animationControls,r,l)):d.type==="SetVariable"?Ar[e.type].includes("SetVariable")&&n.SetVariable.push(new VE(d,i,r,l)):d.type==="DynamicVariablePlay"?Ar[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new jE(d,i,r,l)):d.type==="Conditional"&&Ar[e.type].includes("Conditional")&&(d.ifActions.forEach(o({expression:d.condition,negate:!1})),d.elseActions.forEach(o({expression:d.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Mi(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof mE||i instanceof HE||i instanceof UE||i instanceof NE||i instanceof WE||i instanceof gE||i instanceof kE||i instanceof FE||i instanceof vE||i instanceof VE||i instanceof jE)&&i.dispose()})})}function yq(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var GE=new Map,cc=new Map,El=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=yq(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),cc.has(i.uuid)?cc.get(i.uuid).push(this):cc.set(i.uuid,[this]),GE.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Uv=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=GE.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=cc.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=[...cc.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}},HE=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new El(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Uv(t);else throw new Error("Missing property")}dispatchBasic(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof El?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof El?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},X_=(()=>{let e,t,i,r;function s(o){!e&&!Y_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,d=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,u=0;for(;u<c;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&d[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(d[p.userData.actionId]>p.userData.quantity&&d[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=u>0?requestAnimationFrame(a):void 0,i=u>0?o:void 0}function n(){Y_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function Y_(){return!!document&&document.hidden}var Q_=new it,xq=new E,bq=new E,WE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Re.generateUUID(),this.dispatch=()=>{if(li(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(li(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=wF(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new Ui(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),X_(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof ds)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof Ui)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof ds)return;n instanceof Ui?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new E().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(xq,Q_,bq),l.applyQuaternion(Q_),this.data.velocity.some(d=>d!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(d=>d!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");X_(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},qE=200,Um=.02,Fm=.3,wq=65,rQ=new E,Z_=new E,K_=new E,_q=new E,qi=new E,nr=new E,ja=new E,Vm=new me,J_=new me,Sq=new me,sQ=new me,is=new it,oa=new it,Cs=new _i(0,0,0,"YXZ"),Aq=new E(1,0,0),rs=new E(0,1,0),Mq=new E(0,0,1),$_=new E(1,1,1),aQ=new vr,Eq=1,Cq=.025,Tq=16e-6,eS=12,Pq=20,bi=new Wr,zr=new $t,Dq={type:"requestRender"},Iq={type:"updateMatrix"},tS=Math.PI/6,Fv=class extends Ii{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new me,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=qE,this.euler0=new _i(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new it,this.scale0Cam=new E,this.hiddenMatrix0Cam=new me,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Wr(new E(0,-40,0),new E(0,40,0)),matrix:new me,position:new E,rotation:new it},this.euler=new _i(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new it,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new k,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new me,this.nonColliderPosOffset=new me,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new me,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new it,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new me,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new E,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new it,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Pr&&(!sb||ab>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(sb&&ab<15.5&&!Pr?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Fv.isLocked=!0:Fv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),m=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let y=new _i().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Vi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*Eq,this.speedOrbit=(i.speedRotate??100)*Cq,this.mouseOrbitSensitivity=(i.speedRotate??100)*Tq,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Nl.defaultData.gravity)*eS,this.usePhysics=this.gloabalPhysics.usePhysics??Nl.defaultData.usePhysics,this.jumpPower=i.jumpPower*Pq,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??ap.defaultDataThirdPerson.orientWith,this.slopeThresh=wq*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Um/this.pixelsPerMeter,this.stepThresh=i.collider.height*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Um/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Um/this.pixelsPerMeter,this.stepThresh=i.collider.height*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),u=new it().setFromEuler(new _i().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(c,u,$_),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new We;f.push({fi:0,data:{...lr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...lr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new J0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ur(U2.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new _i().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Vi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},sp.list.forEach(i=>{this.actions[i]=rr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Mi(this.actions.idle),Mi(this.actions.move),Mi(this.actions.run),Mi(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=nr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*eS),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(qi,oa,nr),this.groundVelocity.subVectors(qi,d.prevT),this.object.getWorldPosition(nr).add(this.collider.position).sub(qi),this.groundYRotation=Cs.setFromQuaternion(oa).y-d.prevR.y,ja.copy(nr).applyAxisAngle(rs,this.groundYRotation),this.groundVelocity.add(ja.sub(nr)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=qi.subVectors(this.path[1],this.position),h=nr.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=_q.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=nr.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=qi;this.camera.getWorldDirection(o);let l=ja.copy(rs).multiplyScalar(o.dot(rs));o.sub(l);let h=nr.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Cs.setFromVector3(this.rot),this.moveMode==="walk"&&(Cs.x=0),n.applyEuler(Cs),a&&(oa.setFromUnitVectors(rs,this.groundNormal),n.applyQuaternion(oa)),i){let o=Cs.set(0,this.vrEulerYOffset*tS,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=nr;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=ja.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),d=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),qi.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=ut.is(l)?l:l.object;if(d!==null&&this.lastHitObj!==c){let u;l instanceof Ui&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),c.dispatchEvent(jv));this.lastHitObj=c}if(d!==null){this.pushedVelocity.copy(h),o.copy(d.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(rs,this.euler.y-this.euler0.y);let o=nr.copy(this.objectToCamXZ).normalize(),l=ja.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(qi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Re.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(Cs.copy(t),Cs.y=0):(Cs.copy(this.euler),Cs.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Cs)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*tS),is.setFromAxisAngle(Aq,this.rot.x),oa.setFromAxisAngle(rs,this.rot.y),oa.multiply(is),is.setFromAxisAngle(Mq,this.rot.z),oa.multiply(is),this.quaternion.copy(oa),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=nr.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let d=0;d<5;d++){let c=o.length(),u=ja.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let w of p.cloner.children)if(w.rigidBody===x){b=w;break}}y.dispatch(b),p.dispatchEvent(jv)}}}let f=Z_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=K_.copy(u).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(u,g)),o.copy(u).multiplyScalar(c-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=ja.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(qi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(is.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Vm.lookAt(l,o,rs).setPosition(l),Vm.decompose(this.targetPos,this.targetQuat,qi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Re.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Re.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(Iq),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Dq),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=is.setFromAxisAngle(rs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Re.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=oa.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){rs.angleTo(e)*180/Math.PI<15||rs.angleTo(e)*180/Math.PI>85?is.identity():is.setFromUnitVectors(rs,e),this.groundTilt.slerp(is,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=K_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Vm.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qi,is,nr).compose(qi,is,$_);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;zr.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=J_.copy(a).invert(),o=Sq.copy(J_).multiply(i);bi.copy(this.collider.segment),bi.start.applyMatrix4(o),bi.end.applyMatrix4(o);let l=Z_.copy(this.position).applyMatrix4(n);zr.expandByPoint(bi.start),zr.expandByPoint(bi.end),zr.min.addScalar(-this.collider.radius),zr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(bi.end)},intersectsBounds:h=>h.intersectsBox(zr),intersectsTriangle:h=>{let d=qi,c=nr,u=h.closestPointToSegment(bi,d,c);if(u<this.collider.radius){let p=this.collider.radius-u,f=c.sub(d).normalize(),m=ja.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(a).sub(this.position);t.add(g),bi.start.addScaledVector(f,p),bi.end.addScaledVector(f,p)}}})}),zr.makeEmpty(),bi.copy(this.collider.segment),bi.start.applyMatrix4(i),bi.end.applyMatrix4(i),zr.expandByPoint(bi.start),zr.expandByPoint(bi.end),zr.min.addScalar(-this.collider.radius),zr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(bi.end)},intersectsBounds:s=>s.intersectsBox(zr),intersectsTriangle:s=>{let a=qi,n=nr,o=s.closestPointToSegment(bi,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),bi.start.addScaledVector(h,l),bi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},XE=Fv;XE.isLocked=!1;var Oq=gn(xS());function ya(e,t){let i=new Ue;if(!e.getAttribute("position"))return i.setAttribute("position",new Te([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=kp(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Te(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var Lq=new me,Rq=new me,Ts=[[0,0,0],[0,0,0],[0,0,0]];function YE(e){let t=e.elements;Ts[0][0]=t[0],Ts[0][1]=t[4],Ts[0][2]=t[8],Ts[1][0]=t[1],Ts[1][1]=t[5],Ts[1][2]=t[9],Ts[2][0]=t[2],Ts[2][1]=t[6],Ts[2][2]=t[10];let{u:i,v:r}=(0,Oq.SVD)(Ts),s=Lq.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),a=Rq.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(a.transpose())}var Bq=class extends hA{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 vn({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)),a=new Ue;return a.setFromPoints([t,s]),new Du(a,e)}},QE=e=>e instanceof Pc||e instanceof Ml;function zq(e,t){return e.distance-t.distance}function ZE(e,t,i){if(!(!va(t)||!t.visible)){os(t)&&t.raycast(e,i);for(let r of t.children)ZE(e,r,i)}}function _u(e,t,i,r=!1){if(!r&&!i.some(a=>vp(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>ZE(e,a,s)),s.sort(zq),s}function Vv(e){let t=[];if(e.length){let i=e[0].object;va(i)&&t.push(i);let r=i.parent;for(;r;)QE(r)&&t.push(r),r=r.parent}return t}function vp(e,t){if(os(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(QE(t))return KE(e,t)}function KE(e,t){if(!(!va(t)||!t.visible)){if(os(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=KE(e,i);if(r)return r}}}function Nq(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 kq=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new Bq,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.updateDomRect(),this.raycaster.setFromCamera(Nq(t,i,this.domRect),this.getCamera())}},JE=(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))(JE||{}),ys=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},wy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],$E=e=>wy.find(([t,i])=>i===e)?.[0],Gc=e=>wy.find(([t])=>t===e)?.[1],Uq=(e,t)=>{let i=$E(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Fq=class extends ys{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[$E(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of wy)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=Uq(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}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)})})}},Vq=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},jq=class extends ys{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=a=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(a);let{raycaster:n,page:o}=this.eventContext,l=_u(n,o,[],!0);this.sceneInterects=l,l.length&&(this.eventContext.sharedAssets.raycastProperty={x:l[0].point.x,y:l[0].point.y,z:l[0].point.z,objX:l[0].object.matrixWorld.elements[12],objY:l[0].object.matrixWorld.elements[13],objZ:l[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(a),n.dispatch())})},this.onCanvasMouseUp=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(a),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseDown"))},this.onMouseUp=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent())},this.onMousePressRelease=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent(!0))},this.onKeyDown=a=>{this.heldKeys[a.key]||(this.handleKeyEvent(a,"KeyDown"),this.handleKeyEventHeld(a,"KeyDown",!0)),this.heldKeys[a.key]=!0},this.onKeyUp=a=>{this.handleKeyEvent(a,"KeyUp"),this.handleKeyEventHeld(a,"KeyUp",!0)},this.onKeyPressDown=a=>{this.heldKeysPress[a.key]?this.handleKeyEventHeld(a,"KeyPress"):(this.handleKeyEvent(a,"KeyPress"),this.handleKeyEventHeld(a,"KeyPress",!0)),this.heldKeysPress[a.key]=!0},this.onKeyPressUp=a=>{this.handleKeyEvent(a,"KeyPress",!0)},this.releaseHeldKey=a=>{delete this.heldKeys[a.key]},this.releaseHeldKeyPress=a=>{delete this.heldKeysPress[a.key]},this._onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=Gc(a);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(a=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let c=new Vq(h,d,a,r,s,t);c.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(c):l[a.uuid]?l[a.uuid].push(c):l[a.uuid]=[c]}catch{}}),l[a.uuid]?.length&&this.objectsPerTypes[o].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(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.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(!(!s.length&&!this.useForRaycastProperty)){if(t||this.useForRaycastProperty){let a;this.sceneInterects===null?a=_u(i,r,s,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),t&&Vv(a).forEach(n=>{this.eventsPerObjects[e][n.uuid]&&this.handleObjectMouseEventDispatch(n,e)})}t||s.forEach(a=>{vp(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:a,page:n}=this.eventContext;if(s){let o=_u(a,n,i);r=Vv(o)}else i.forEach(o=>{vp(a,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:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},Gq=new E,Hq=new E,eC=class{constructor(e,t,i,r,s){this.actionsIn=rr(e,e.inActions,i,r,s,t),this.actionsOut=rr(e,e.outActions,i,r,s,t)}disconnect(){Mi(this.actionsIn),Mi(this.actionsOut)}},Wq=class extends eC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let u of this.objects)if(!u.visible)return;let h=Gq.setFromMatrixPosition(this.objects[0].matrixWorld),d=Hq.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch()),u.SetVariable.forEach(p=>p.checkConditions()),u.SetVariable.forEach(p=>p.dispatch()),u.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},qq=class extends eC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Link.forEach(d=>d.dispatch()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsOut.Animation.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()),this.actionsOut.SceneTransition.forEach(d=>d.dispatch()),this.actionsOut.SetVariable.forEach(d=>d.checkConditions()),this.actionsOut.SetVariable.forEach(d=>d.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(d=>d.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Link.forEach(d=>d.dispatch()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsIn.Animation.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()),this.actionsIn.SceneTransition.forEach(d=>d.dispatch()),this.actionsIn.SetVariable.forEach(d=>d.checkConditions()),this.actionsIn.SetVariable.forEach(d=>d.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(d=>d.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,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.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Xq=class extends ys{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new Wq(a,n,s,i,r,t):n.condition.type==="State"&&(o=new qq(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Uh=new E,Ga=new E,On=new E,iS=new Er,Yq=.01,_t=new E,ui=new E,rS=new E,Xn=new it,jm=new _i,Qq=new me,Gm=new Ai,Go=new E,Ps=new E,Ho=.2;function Hm(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Zq=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Hm(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Hm(s.position,t.limits):t.reference==="local"&&(Xn.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Xn),Hm(s.position,t.limits),Xn.invert(),s.position.applyQuaternion(Xn),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(_t,s.quaternion,ui),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof yr&&Us(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),Kq=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=rr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=rr(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&n.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Mi(this.actionsDrag),Mi(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Jq=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Xe.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||ut.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(_t,Xn,ui),jm.setFromQuaternion(Xn),u.prevR===void 0?(u.prevR=jm.clone(),u.prevT=_t.clone()):(u.prevR.copy(jm),u.prevT.copy(_t)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Xe.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(Xe.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||ut.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Pc)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||a.scene.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=rS.copy(l.face.normal).applyMatrix3(Gm.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){_t.copy(h).applyMatrix3(Gm.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;_t.x>Ho?ui.x=-d.recursiveBBox.min.x:_t.x<-Ho&&(ui.x=-d.recursiveBBox.max.x),_t.y>Ho?ui.y=-d.recursiveBBox.min.y:_t.y<-Ho&&(ui.y=-d.recursiveBBox.max.y),_t.z>Ho?ui.z=-d.recursiveBBox.min.z:_t.z<-Ho&&(ui.z=-d.recursiveBBox.max.z),ui.applyMatrix3(Gm.invert())}else ui.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(ui)}this.activeEvent.data.autoOrient&&(_t.set(0,1,0).cross(h),_t.length()<1e-4&&_t.set(-1,0,0).cross(h),ui.crossVectors(rS,_t),o.orientationMatrix.makeBasis(_t,ui,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Animation.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new Kq(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(Ga),Ga.negate();let n=Xn.identity();switch(r==="parent"?Qq.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(_t,n,ui):r==="local"&&e.matrixWorld.decompose(_t,n,ui),i){case"x":_t.set(1,0,0).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"y":_t.set(0,1,0).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"z":_t.set(0,0,1).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"xy":Ps.set(0,0,1).applyQuaternion(n);break;case"yz":Ps.set(1,0,0).applyQuaternion(n);break;case"xz":Ps.set(0,1,0).applyQuaternion(n);break;case"adaptive":Ga.angleTo(ui.set(0,1,0))>Math.PI/6?(_t.crossVectors(ui.set(0,1,0),Ga),Ps.crossVectors(_t,ui)):Ps.set(0,1,0);break;default:Ps.copy(Ga);break}On.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:On;if(iS.setFromNormalAndCoplanarPoint(Ps,o),!!a.ray.intersectPlane(iS,t)&&(i==="x"||i==="y"||i==="z")){let l=ui.subVectors(t,o).dot(_t);t.copy(o).addScaledVector(_t,l)}}updateDragItem(e,t=!1){On.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Uh.subVectors(e.fromPosition,On).divideScalar(e.currentDampingFactor):e.reset==="original"?(Uh.subVectors(e.obj.userData.worldPosition0,On).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Uh.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(On).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Uh.length()<Yq:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Zq(e,Uh.add(On),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Wo=new E,Wm=new E,la=new E,ha=new E,sS=new Er,$q=.01,eX={type:"requestRender"},tX=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}(),aS=function(){let e=new me;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 yr&&Us(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iX=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Lg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=rr(e,e.actions,i,r,s,t)}},rX=class extends ys{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Xe.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iX(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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(),Pr&&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,Mi(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(la),e.isReset)ha.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ha);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Wm),Wm.negate(),Wo.copy(Wm)):i==="xy"?Wo.set(0,0,1):i==="xz"?Wo.set(0,1,0):i==="yz"&&Wo.set(1,0,0),sS.setFromNormalAndCoplanarPoint(Wo,la),!o.ray.intersectPlane(sS,ha))return}if(!e.isReset){if(ha.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ha.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&&(ha.x=la.x),e.data.enabledTranslation[1]===!1&&(ha.y=la.y),e.data.enabledTranslation[2]===!1&&(ha.z=la.z);let a=tX(la,ha,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Wo.subVectors(a,la).divideScalar(e.currentDampingFactor);la.add(n),t&&aS(e.object,la),e.paused=n.length()<$q}else aS(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(eX)}},Fh=new E,ou=new E,Vh=new me,qo=new it,Ha=new it,jh=new E,Gh=new E,Ln=new E,ca=new E,qm=new Er,sX=1e-6,aX={type:"requestRender"},nX={type:"changeRotation"},nS=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(YE(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof yr&&Us(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),oX=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Rg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},lX=class extends ys{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Xe.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=Gc(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new oX(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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 a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(jh),!e.isReset)if(e.target)e.target.getWorldPosition(Gh);else{if(s==="custom"?(l().getWorldDirection(ou),ou.negate(),qm.setFromNormalAndCoplanarPoint(ou,jh)):(s==="xy"?Fh.set(0,0,1):s==="xz"?Fh.set(0,1,0):s==="yz"&&Fh.set(1,0,0),qm.setFromNormalAndCoplanarPoint(Fh,jh)),!h.ray.intersectPlane(qm,Gh))return;r>0&&(s==="custom"||s===void 0)&&Gh.addScaledVector(ou,r)}if(e.isReset||(c?t==="target"?Ln.copy(c.up).applyMatrix4(Vh.extractRotation(c.matrixWorld)).normalize():n.some(u=>u===!1)?(i==="x"?(ca.set(0,0,1),n[2]===!1&&ca.set(0,1,0)):i==="y"?(ca.set(1,0,0),n[0]===!1&&ca.set(0,0,1)):(ca.set(0,1,0),n[1]===!1&&ca.set(1,0,0)),Ln.copy(ca).applyQuaternion(e.worldQuaternion0).normalize()):Ln.set(0,1,0):s==="custom"?Ln.set(0,1,0):Ln.copy(Fh)),e.isReset)Ha.copy(e.worldQuaternion0);else if(jh.distanceTo(Gh)>a&&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)Ha.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;hX(Vh,Gh,jh,Ln,i,ca),Ha.setFromRotationMatrix(Vh),qo.setFromUnitVectors(ca.applyQuaternion(Ha),Ln),n.some(u=>u===!1)&&t!=="target"&&Ha.premultiply(qo).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),qo.setFromRotationMatrix(YE(d.matrixWorld)),qo.slerp(Ha,1/e.currentDampingFactor),nS(d,Vh.makeRotationFromQuaternion(qo)),e.paused=8*(1-qo.dot(Ha))<sX):(nS(d,Vh.makeRotationFromQuaternion(Ha)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(aX),d.dispatchEvent(nX)}},Nr=new E,di=new E,Zt=new E;function hX(e,t,i,r,s,a){let n=e.elements;Zt.subVectors(t,i),Zt.lengthSq()===0&&(Zt.z=1),Zt.normalize(),di.crossVectors(r,Zt),di.lengthSq()===0&&(Math.abs(r.z)===1?Zt.x+=1e-4:Zt.z+=1e-4,Zt.normalize(),di.crossVectors(r,Zt)),di.normalize(),Nr.crossVectors(Zt,di),s==="x"?a.z===1?[di,Nr,Zt]=[Zt,di,Nr]:(di.negate(),[di,Zt]=[Zt,di]):s==="y"?a.x===1?[di,Nr,Zt]=[Nr,Zt,di]:(di.negate(),[Nr,Zt]=[Zt,Nr]):a.x===1&&(di.negate(),[di,Nr]=[Nr,di]),n[0]=di.x,n[4]=Nr.x,n[8]=Zt.x,n[1]=di.y,n[5]=Nr.y,n[9]=Zt.y,n[2]=di.z,n[6]=Nr.z,n[10]=Zt.z}var cX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},dX=class extends ys{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Xe.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Xe.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Xe.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:a,reverse:n})=>{if(!s||!a)return;let o=Gc(s);o&&o==="MouseHover"&&(a.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[a.uuid]?.forEach(l=>l.dispatchUserEvent(n)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="MouseHover")try{let o=new cX(a,n,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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(),Pr&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let a=_u(r,s,this.objects);t=Vv(a)}else this.objects.forEach(a=>{vp(r,a)&&t.push(a)})}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}},uX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=rr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Mi(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},pX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=rr(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Mi(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},fX=class extends ys{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([n,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=n=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=n=>{!this.isInview||n.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:n.deltaY}),l.forEach(h=>h.dispatch(n.deltaY))})},this.onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=Gc(n);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext;i.traverseEntity(n=>{if(n.data?.events.length){for(let{id:o,data:l}of n.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!a){let h=new uX(o,l,n,i,r,t);this.wheelEventsPerObject.has(n)?this.wheelEventsPerObject.get(n)?.push(h):this.wheelEventsPerObject.set(n,[h])}else{let h=new pX(o,l,n,i,r,s,t);this.scrollEventsPerObject.has(n)?this.scrollEventsPerObject.get(n)?.push(h):this.scrollEventsPerObject.set(n,[h])}}}),this.intersectionObserver=new IntersectionObserver(n=>{let o=n[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},mX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof qn?t.interaction.audioPlayer.play():t.interaction instanceof Bv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof El?t.interaction.play(i==="autoplay"):t.interaction instanceof Uv&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof qn?t.interaction.audioPlayer.play():t.interaction instanceof Bv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof El?t.interaction.play():t.interaction instanceof Uv&&t.interaction.dispatch()})}},gX=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof qn&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof El&&a.interaction.play(n==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Gc(i);a&&a==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let a=new mX(r,s,i,t,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(a):this.eventsPerObject.set(i,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},vX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=rr(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Mi(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},yX=class extends ys{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:u,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(u),g=zg.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[c].prevValue=m instanceof E?m.clone():m:(m instanceof E?!m.equals(f):f!==m)&&(l.push({objId:u,property:p}),m instanceof E?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:u,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(u);f!==p&&(o.push(u),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:u,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[c],y=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?y=1:m.dynamicVariableType==="counter"?y=m.updateInterval:m.dynamicVariableType==="random"&&(y=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y;continue}if(!((this.shared.getDynamicVariablePlayState(u)==="Stopped"||this.shared.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y,m.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==v&&(this.shared.updateVariable(u,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==v&&(this.dynamicVars[c].timerSeconds=v,this.shared.updateVariable(u,ns.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(u)==="Restarted"&&this.shared.setDynamicVariablePlayState(u,"Playing"),this.shared.getDynamicVariablePlayState(u)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(y-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=y,m.dynamicVariableType==="random"){let x=m.min+Math.random()*(m.max-m.min),b=m.decimals;x=Math.round(x*Math.pow(10,b))/Math.pow(10,b),this.shared.updateVariable(u,x),o.push(u),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let x=this.shared.getVariable(u),b=this.shared.getDynamicVariableToggleIsForward(u)??!0,w=this.shared.getVariable(u)+m.increment*(b?1:-1);m.hasEnd&&(w=m.increment>0?Re.clamp(w,v,m.endValue):Re.clamp(w,m.endValue,v),w===v&&this.shared.setDynamicVariableToggleIsForward(u,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),w!==x&&(o.push(u),this.shared.updateVariable(u,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(u,Vw(n,m)),o.push(u),this.eventManager.requestRender();else{let x=Dr.isTextValue(m.endValue)?oS(m.endValue.textValue):m.endValue,b=this.shared.getDynamicVariableToggleIsForward(u)??!0,w=g+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(b?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Re.clamp(w,v,x):Re.clamp(w,x,v),w===v&&this.shared.setDynamicVariableToggleIsForward(u,void 0),m.repeat?Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),w!==g&&(o.push(u),this.dynamicVars[c].timerSeconds=w,this.shared.updateVariable(u,ns.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let d=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,d=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(u=>u.objId===c.data.objectId&&u.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&d)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new xX(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Dr.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,Vw(new Date,n)),n.dynamicVariableType==="counter"&&(o=Dr.isTextValue(n.value)?oS(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},xX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=rr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Mi(this.actions)}};function oS(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var bX="https://unpkg.com/@splinetool/runtime@0.9.496/build/",wX="https://unpkg.com/@splinetool/navmesh-wasm@0.9.496/build/",_X=`
6239
+ )`}else if(e.easing===6){let{mass:i,stiffness:r,damping:s,velocity:a}=e;t=`spring( ${i}, ${r}, ${s}, ${a} )`}else{let i;switch(e.easing){case 0:i=qa.linear;break;case 1:i=qa.ease;break;case 2:i=qa.easeIn;break;case 3:i=qa.easeOut;break;case 4:i=qa.easeInOut;break;default:i=qa.linear}let[r,s,a,n]=i;t=`cubicBezier( ${r}, ${s}, ${a}, ${n} )`}return{duration:e.duration,easing:t}}function kv(e){let t={delay:0,loop:e.repeat===-1?!0:e.repeat+1};if(e.repeat===0)t.direction="normal",t.rewind=!1;else switch(e.direction){case"pingpong":t.direction="alternate",t.rewind=!1;break;case"pingpong-rewind":t.direction="alternate",t.rewind=!0;break;default:t.direction="normal",t.rewind=!1;break}switch(t.delay=0,t.endDelay=0,t.startOnceDelay=0,t.pingPongDelayCorrection=0,t.pingPongEndDelayCorrection=0,e.delayDirection){case"start-once":t.startOnceDelay=e.delay;break;case"start":t.delay=e.delay;break;case"end":t.endDelay=e.delay;break;case"start-end":case void 0:t.delay=e.delay,t.endDelay=e.delay;break}return t.direction==="alternate"&&(t.delay/=2,t.endDelay/=2,e.delayDirection==="start"?(t.pingPongDelayCorrection=t.delay,typeof t.loop=="number"&&t.loop%2===0&&(t.pingPongEndDelayCorrection=t.delay)):e.delayDirection==="end"?typeof t.loop=="number"&&t.loop%2!==0&&(t.pingPongEndDelayCorrection=t.endDelay):e.delayDirection==="start-end"&&(t.pingPongDelayCorrection=t.delay,t.pingPongEndDelayCorrection=t.endDelay)),t}var mq={type:"beginState"},gq={type:"completeState",isfromEntity:!1},H_=class{constructor(e,t,i,r,s,a){if(this.object=e,this.data=r,this.sharedAssets=s,this.allowSlerp=a,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 n=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=n,this.object.dispatchEvent({type:"beginState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(mq)})},this.onChangeComplete=()=>{this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.reversibleToState=this.to.id;let n=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=n,this.object.dispatchEvent({type:"completeState",state:n}),this.object.traverseEntity(o=>{o!==this.object&&o instanceof Vi&&o.dispatchEvent(gq)})},this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=j_(this.object,this.from.data,this.to.data,this.sharedAssets,this.allowSlerp))},t===void 0){let n=wu(this.object,this.object.currentState===i?this.object.prevState:this.object.currentState);if(!n)throw new Error("Missing property");this.from=n}else{let n=wu(this.object,t);if(!n)throw new Error("Missing property");this.from=n}if(i===void 0)throw new Error("Missing property");{let n=wu(this.object,i);if(!n)throw new Error("Missing property");this.to=n}this.useCurrentState=t===void 0||i===void 0,this.params={targets:this.targets,t:1,autoplay:!1,...kv(r),...zE(r),change:this.onChange},this.callback=j_(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}},NE=class extends Ii{constructor(e,t,i,r){if(super(),this.data=e,this.page=t,this.shared=i,this.condition=r,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,needsRebuild:!1,isRebuild:!0}),this.timeline.play())},!e.object)throw new Error("Missing property");let s=this.page.scene.find(e.object);if(!s)throw new Error("Missing property");if(!s.states)throw new Error("Missing property");if(this.object=s,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.timeline&&this.timeline.paused===!1}init(){this.initialCurrentState=wu(this.object,this.object.currentState).id,this.toggleIsForward=!1}get currentState(){return this.useToggle?this.initialCurrentState:this.object.currentState}buildTimeline({isForward:e=!0,needsRebuild:t=!1,isRebuild:i=!1}={}){try{let r=kv(this.data.tweens[0].data);i&&typeof r.loop=="number"&&r.loop--,this.timeline?.pause(),this.timeline=RE.timeline({autoplay:!1,...r,...r.loop===!0||r.loop>1?{timelineChangeComplete:this.onTimelineChangeComplete}:{}});let s=this.tweens.findIndex(a=>a?.changeBegan);if(t===!0&&(this.timelineNeedsRebuild=!0),e){let a=s===-1?0:s;for(let n=a;n<this.data.tweens.length-1;n++){let o=this.data.tweens[n],l=this.data.tweens[n+1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new H_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,l.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[n]=d,this.timeline.add(d.params,this.timeline.duration+(n===a?r.delay:0))}this.timeline.duration+=r.endDelay}else{let a=s===-1?this.data.tweens.length-1:s+1;for(let n=a;n>0;n--){let o=this.data.tweens[n],l=this.data.tweens[n-1],h;n===a&&(this.object.wasMovedByUser===!0||this.object.previousAction?.playing===!0)?(h=void 0,this.object instanceof Vi&&(this.object.wasMovedByUser=!1)):h=o.data.state===void 0?this.currentState:o.data.state;let d=new H_(this.object,h,l.data.state===void 0?this.currentState:l.data.state,o.data,this.shared,this.data.allowSlerp??!1);s!==-1&&n===a&&Object.assign(d.params,{startOnceDelay:0}),this.tweens[n-1]=d,this.timeline.add(d.params,this.timeline.duration+(n===a?r.endDelay:0))}this.timeline.duration+=r.delay}}catch(r){r instanceof Error&&console.error(r.message)}this.object.previousAction?.playing===!0&&this.object.previousAction.pause(),this.object.previousAction=this}play(){if(li(this.shared,this.condition)===!1||this.playing)return!1;clearTimeout(this.timeoutId);let e=kv(this.data.tweens[0].data).pingPongDelayCorrection;this.timeoutId=window.setTimeout(()=>{try{this.buildTimeline(),this.timeline.play()}catch(t){t instanceof Error&&console.error(t.message)}},this.startOnceDelay+e)}pause(){this.timeline?.pause(),clearTimeout(this.timeoutId),this.tweens=Array(this.data.tweens.length-1),delete this.timeoutId}stop(){this.pause();let e=this.data.tweens[0].data.state===void 0?this.initialCurrentState:this.data.tweens[0].data.state;this.object.changeSelectedState(e,{scene:this.page.scene,shared:this.shared}),this.object.currentState=e}seek(e){this.timeline===void 0&&this.buildTimeline(),this.timeline?.seek(e*this.timeline.duration,!0)}toggle(e){if(li(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward,this.playing?(this.timeline?.pause(),this.buildTimeline({isForward:this.toggleIsForward,needsRebuild:!0}),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 wu(e,t){let i,r;if(typeof t=="string"?(i=t,r=e.states?.[i]):t===null&&(i=null,r=e.data),!(i===void 0||r===void 0))return{id:i,data:r}}var vq={type:"beginState"},W_={type:"completeState",isfromEntity:!1},q_={type:"requestRender"},kE=class extends Ii{constructor(e,t,i,r){super(),this.data=e,this.page=t,this.shared=i,this.condition=r,this.toggleIsForward=!1,this.useToggle=!1,this.posStart=new E,this.posEnd=new E,this.qStart=new it,this.qEnd=new it,this.zoomStart=1,this.zoomEnd=1}init(){}get playing(){return this.animation&&this.animation.began&&!this.animation.completed}buildAnimation(e=!1){if(!this.data.animate)return;let t=this.page.scene.find(this.data.targetCamera);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");let i={t:0};this.posStart.copy(this.page.activeCamera.position),this.qStart.copy(this.page.activeCamera.quaternion),this.zoomStart=this.page.activeCamera.zoom,this.animation=RE({targets:i,t:1,...zE(this.data),update:()=>{i.t===0&&(this.useToggle&&!this.toggleIsForward?(this.posEnd.copy(this.fromCamera.position),this.qEnd.copy(this.fromCamera.quaternion),this.zoomEnd=this.fromCamera.zoom,this.switchCamera(this.fromCamera.uuid)):(this.posEnd.copy(t.position),this.qEnd.copy(t.quaternion),this.zoomEnd=t.zoom,this.fromCamera=this.page.activeCamera,this.switchCamera(t.uuid)),this.page.activeCamera.dispatchEvent(vq));let r=this.page.activeCamera;r.position.lerpVectors(this.posStart,this.posEnd,i.t),r.quaternion.slerpQuaternions(this.qStart,this.qEnd,i.t),r.zoom=this.zoomStart+(this.zoomEnd-this.zoomStart)*i.t,r.wasMovedBySwitchCameraAction=!0,r.updateMatrix(),r.updateMatrixWorld(),r.updateProjectionMatrix(),r.dispatchEvent(q_),i.t===1&&r.dispatchEvent(W_)}})}switchCamera(e){let t=this.page.scene.find(e);if(!t||!t.visible)throw new ReferenceError("Target camera not founded or not visible");this.page.switchActiveCamera(t),this.page.activeCamera.dispatchEvent({type:"cameraChange",camera:t})}play(){if(li(this.shared,this.condition)===!1)return!1;if(!this.playing&&this.page.activeCamera.uuid!==this.data.targetCamera)try{clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.buildAnimation(),this.animation?.play()):this.switchCamera(this.data.targetCamera)},this.data.delay*1e3)}catch{}}pause(){this.animation?.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}toggle(e){if(li(this.shared,this.condition)===!1)return!1;this.useToggle=!0,clearTimeout(this.timeoutId),this.toggleIsForward=e??!this.toggleIsForward;try{this.playing?(this.animation?.pause(),this.buildAnimation(!0),this.animation?.play()):this.timeoutId=window.setTimeout(()=>{delete this.timeoutId,this.data.animate?(this.animation?.pause(),this.buildAnimation(),this.animation?.play()):(this.toggleIsForward?(this.fromCamera=this.page.activeCamera,this.switchCamera(this.data.targetCamera)):this.switchCamera(this.fromCamera.uuid),this.page.activeCamera.dispatchEvent(W_),this.page.activeCamera.dispatchEvent(q_))},this.data.delay*1e3)}catch{}}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){this.pause(),this.toggleIsForward=!1}},UE=class extends Ii{constructor(e,t,i,r,s){super(),this.page=t,this.animationControls=i,this.shared=r,this.condition=s,this.startOnceDelay=0,this.toggleIsForward=!1;let a=e.object,n=t.scene.find(e.object);n&&Array.isArray(n.identity)&&(a=n.identity[0]),this.data={...e,object:a};let o=this.animationControls.clipIdToAction[e.clipId+"/"+a];this.duration=o?.getClip()?.duration??1;let l=o?.getClip()?.tracks[0]?.times.length??1/0;this.leftFrameTime=this.data.crop[0]/l*this.duration,this.rightFrameTime=this.data.crop[1]/l*this.duration,this.startOnceDelay=e.delay}get playing(){return this.threeAnimAction?.isRunning()??!1}play(e=!1){if(li(this.shared,this.condition)===!1)return!1;window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),!this.threeAnimAction)return;this.threeAnimAction.reset(),this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime;let t=this.data.object;Object.entries(this.animationControls.clipIdToAction).forEach(([i,r])=>{let s=i.split("/")[1];this.threeAnimAction!==r&&s===t&&r.isRunning()&&(e?r.fadeOut(.2):r.stop())}),e&&this.threeAnimAction?.fadeIn(.2)},this.startOnceDelay)}pause(){this.threeAnimAction&&(this.threeAnimAction.paused=!0),window.clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.threeAnimAction?.fadeOut(.2)}seek(e){this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction&&(this.threeAnimAction.paused=!0,this.threeAnimAction.time=Re.clamp(this.threeAnimAction.time+1/60*e,this.leftFrameTime,this.rightFrameTime-16e-5),this.animationControls.needsUpdate=!0,this.animationControls.requestRender())}toggle(e,t=!1){if(li(this.shared,this.condition)===!1)return!1;this.toggleIsForward=e??!this.toggleIsForward,this.threeAnimAction&&(this.threeAnimAction._loopCount=0),this.playing?this.threeAnimAction&&(this.threeAnimAction.timeScale=this.toggleIsForward?1:-1,this.toggleIsForward?(this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime)):this.timeoutId=window.setTimeout(()=>{if(this.threeAnimAction=this.animationControls.play(this.data),this.threeAnimAction){this.toggleIsForward?(this.threeAnimAction.time=this.leftFrameTime,this.threeAnimAction._clip.start=this.leftFrameTime,this.threeAnimAction._clip.duration=this.rightFrameTime):(this.threeAnimAction.time=this.rightFrameTime,this.threeAnimAction._clip.start=this.rightFrameTime,this.threeAnimAction._clip.duration=this.leftFrameTime),this.threeAnimAction.paused=!1,this.threeAnimAction.timeScale=this.toggleIsForward?1:-1;let i=this.data.clipId.split("/")[1];Object.entries(this.animationControls.clipIdToAction).forEach(([r,s])=>{let a=r.split("/")[1];this.threeAnimAction!==s&&a===i&&s.isRunning()&&(t?s.fadeOut(.2):s.stop())}),t&&this.threeAnimAction?.fadeIn(.2)}},this.startOnceDelay)}playFromCurrent(){this.toggle(!0)}reverseFromCurrent(){this.toggle(!1)}dispose(){let e=this.animationControls.clipIdToAction[this.data.clipId+"/"+this.data.object]?.getClip();e&&(e.duration=this.duration),this.pause()}},FE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.eventManager=i,this.shared=r,this.condition=s,this.timeOutId=-1,this.scene=t.scene}dispatch(){if(li(this.shared,this.condition)===!1)return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},this.data.delay*1e3))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target))return;this.data.transition==="fade"&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,this.data.duration*1e3),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),by(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}},VE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.evaluatedCondition=!1}checkConditions(){this.evaluatedCondition=li(this.shared,this.condition)}dispatch(){if(this.evaluatedCondition===!1)return!1;let e=this.shared.getVariable(this.data.variableId),t=aM(this.data.expression,this.shared,Dr.typeOfVariable(e));t!==void 0&&this.shared.updateVariable(this.data.variableId,typeof t=="string"?{textValue:t}:t)}dispose(){}},jE=class{constructor(e,t,i,r){this.data=e,this.page=t,this.shared=i,this.condition=r,this.timeoutId=null}dispatchInner(){if(li(this.shared,this.condition)===!1)return!1;let e=this.shared.getDynamicVariablePlayState(this.data.variableId);if(this.data.mode==="PlayPause")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,e==="Playing"?"Paused":"Playing");else if(this.data.mode==="Play"&&e!=="Playing")this.shared.getDynamicVariableToggleIsForward(this.data.variableId)===void 0&&this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!0),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing");else if(this.data.mode==="Stop"&&e!=="Stopped")this.shared.setDynamicVariablePlayState(this.data.variableId,"Stopped");else if(this.data.mode==="Pause"&&e!=="Paused")this.shared.setDynamicVariablePlayState(this.data.variableId,"Paused");else if(this.data.mode==="Restart")this.shared.setDynamicVariablePlayState(this.data.variableId,"Restarted");else if(this.data.mode==="Toggle"){let t=this.shared.getDynamicVariableToggleIsForward(this.data.variableId);e==="Playing"?this.shared.setDynamicVariableToggleIsForward(this.data.variableId,t===void 0?!1:!t):(this.shared.setDynamicVariableToggleIsForward(this.data.variableId,!t),this.shared.setDynamicVariablePlayState(this.data.variableId,"Playing"))}}dispatch(){let e=this.data.delay,t=this.shared.getDynamicVariablePlayState(this.data.variableId);this.data.mode==="PlayPause"&&t==="Playing"&&(e=this.data.pauseDelay),e!==0?(this.timeoutId&&window.clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>{this.timeoutId=null,this.dispatchInner()},e)):this.dispatchInner()}dispose(){this.timeoutId&&window.clearTimeout(this.timeoutId)}};function li(e,t){if(t===void 0)return!0;if(t.expression.length===0)return!1;let i=aM(t.expression,e,"boolean");return t.negate?!i:!!i}function rr(e,t,i,r,s,a){let n={Audio:[],Video:[],Link:[],Destroy:[],Create:[],Reset:[],Transition:[],SwitchCamera:[],Animation:[],SceneTransition:[],SetVariable:[],DynamicVariablePlay:[]},o=l=>({id:h,data:d})=>{try{d.type==="Audio"?Ar[e.type].includes("Audio")&&n.Audio.push(new mE(h,d,a,r,l)):d.type==="Video"?Ar[e.type].includes("Video")&&n.Video.push(new HE(h,d,a,r,l)):d.type==="Link"?Ar[e.type].includes("Link")&&n.Link.push(new cW(d,s.controlsManager,r,l)):d.type==="Create"?Ar[e.type].includes("Create")&&n.Create.push(new WE(d,i,s.controlsManager,r,l)):d.type==="Destroy"?Ar[e.type].includes("Destroy")&&n.Destroy.push(new gE(d,i,s.controlsManager,r,l)):d.type==="Reset"?Ar[e.type].includes("Reset")&&n.Reset.push(new vE(d,i,r,s,l)):d.type==="Transition"?Ar[e.type].includes("Transition")&&n.Transition.push(new NE(d,i,r,l)):d.type==="SwitchCamera"?Ar[e.type].includes("SwitchCamera")&&n.SwitchCamera.push(new kE(d,i,r,l)):d.type==="SceneTransition"?Ar[e.type].includes("SceneTransition")&&n.SceneTransition.push(new FE(d,i,s,r,l)):d.type==="Animation"?Ar[e.type].includes("Animation")&&n.Animation.push(new UE(d,i,s.animationControls,r,l)):d.type==="SetVariable"?Ar[e.type].includes("SetVariable")&&n.SetVariable.push(new VE(d,i,r,l)):d.type==="DynamicVariablePlay"?Ar[e.type].includes("DynamicVariablePlay")&&n.DynamicVariablePlay.push(new jE(d,i,r,l)):d.type==="Conditional"&&Ar[e.type].includes("Conditional")&&(d.ifActions.forEach(o({expression:d.condition,negate:!1})),d.elseActions.forEach(o({expression:d.condition,negate:!0})))}catch{}};return t.forEach(o()),n}function Mi(e){Object.values(e).forEach(t=>{t.forEach(i=>{(i instanceof mE||i instanceof HE||i instanceof UE||i instanceof NE||i instanceof WE||i instanceof gE||i instanceof kE||i instanceof FE||i instanceof vE||i instanceof VE||i instanceof jE)&&i.dispose()})})}function yq(e,t){let i;if("material"in e){let r=e.material;Array.isArray(r)?i=e.material[0].layers.find(s=>s.uuid===t):i=e.material.layers.find(s=>s.uuid===t)}if(i)return i.color.texture.image.img instanceof HTMLVideoElement?i.color.texture.image.img:void 0}var GE=new Map,cc=new Map,El=class{constructor(e,t,i){this.data=t,this.delay=0,this.status="stopped";let{layerId:r,loop:s,volume:a,delay:n}=t;if(this.object=i,r===void 0)throw new Error("Missing property");let o=yq(i,r);o&&(this.videoElement=o,this.videoElement.loop=s===1/0,this.videoElement.autoplay=!0,a!==void 0&&(this.videoElement.volume=a)),n!==void 0&&(this.delay=n),cc.has(i.uuid)?cc.get(i.uuid).push(this):cc.set(i.uuid,[this]),GE.set(e,this),this.pause()}mute(){!this.videoElement||(this.videoElement.muted=!0)}unMute(){!this.videoElement||(this.videoElement.muted=!1)}play(e){if(!this.videoElement)return;let t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);e?(this.mute(),this.delay+=150):t?(this.mute(),window.setTimeout(()=>{this.unMute()},100)):this.unMute(),this.delayTimerId=window.setTimeout(()=>{if(!this.videoElement)return;let i=this.videoElement.play();i!==void 0&&i.then(r=>{}).catch(r=>{this.play()}),this.clearDelay()},this.delay),this.status="playing"}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}pause(){!this.videoElement||(this.videoElement.pause(),this.status="paused")}stop(){!this.videoElement||(this.videoElement.pause(),this.videoElement.currentTime=0,this.status="stopped",this.clearDelay())}playByToggle(){this.data.toggle==="stop"?this.status==="playing"?this.stop():(this.stop(),this.play()):this.data.toggle==="pause"?this.status==="playing"?this.pause():this.play():(this.stop(),this.play())}dispose(){!this.videoElement||(this.stop(),this.videoElement.muted=!0)}},Uv=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=GE.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=cc.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=[...cc.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}},HE=class{constructor(e,t,i,r,s){if(this.data=t,this.shared=r,this.condition=s,t.interaction==="play")this.interaction=new El(e,t,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new Uv(t);else throw new Error("Missing property")}dispatchBasic(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof El?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(li(this.shared,this.condition)===!1)return!1;this.interaction instanceof El?this.interaction.play():this.interaction.dispatch()}dispose(){this.interaction.dispose()}},X_=(()=>{let e,t,i,r;function s(o){!e&&!Y_()&&t?.sharedGameControlGlobals.createdObjects.length>0&&(e=requestAnimationFrame(a)),o&&(t=o,r=o.requestRender)}function a(o){let l=i?o-i:0,h=t.sharedGameControlGlobals.createdObjects,d=t.sharedGameControlGlobals.nCreatedPerAction,c=h.length,u=0;for(;u<c;){let p=h[u];p.userData.createdTime===void 0&&(p.userData.createdTime=o),p.userData.lifetime===void 0&&p.userData.quantity===void 0||p.userData.lifetime&&o-p.userData.createdTime<p.userData.lifetime||p.userData.quantity&&d[p.userData.actionId]<=p.userData.quantity?(p.userData.velocity&&(p.position.addScaledVector(p.userData.velocity,l/1e3),p.updateMatrix(),r()),u++):(d[p.userData.actionId]>p.userData.quantity&&d[p.userData.actionId]--,h.splice(u,1),p.removeFromParent(),t.sharedGameControlGlobals.rapierWorld&&p.rigidBody?(t.sharedGameControlGlobals.colliderToEntity.delete(p.rigidBody.collider(0).handle),t.sharedGameControlGlobals.rapierWorld.removeRigidBody(p.rigidBody)):(p.bvhGeometry=void 0,t.sharedGameControlGlobals.entitiesWithTransformAnim=t.sharedGameControlGlobals.entitiesWithTransformAnim.filter(f=>f.bvhGeometry!==void 0)),c--,r())}e=u>0?requestAnimationFrame(a):void 0,i=u>0?o:void 0}function n(){Y_()?e&&(cancelAnimationFrame(e),e=void 0,i=void 0):s()}return typeof document<"u"&&document.addEventListener("visibilitychange",n),s})();function Y_(){return!!document&&document.hidden}var Q_=new it,xq=new E,bq=new E,WE=class{constructor(e,t,i,r,s){this.data=e,this.page=t,this.controlsManager=i,this.shared=r,this.condition=s,this.intervalId=null,this.timeoutIdQueue=[],this.uniqueId=Re.generateUUID(),this.dispatch=()=>{if(li(this.shared,this.condition)===!1)return!1;this.data.delay?this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3)):this.dispatchInner()},this.dispatchFromStart=()=>{if(li(this.shared,this.condition)===!1)return!1;this.timeoutIdQueue.push(window.setTimeout(this.dispatchInner,this.data.delay*1e3))},this.dispatchThrottled=wF(this.dispatch,1e3/this.data.creationSpeed),this.dispatchStart=()=>{this.intervalId===null&&(this.intervalId=window.setInterval(this.dispatch,1e3/this.data.creationSpeed))},this.dispatchStop=()=>{this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null)},this.dispatchInner=()=>{this.timeoutIdQueue.shift();let n=new Ui(this.object);if(n.playModeVisible=!0,n.expand(),this.data.coordinateSystem!=="world"){let l=this.data.coordinateSystem,h=this.page.scene.find(l);h&&(h.updateMatrixWorldSVD(),n.hiddenMatrix.copy(h.matrixWorldRigid))}n.position.fromArray(this.data.position),n.rotation.fromArray(this.data.rotation),n.updateMatrix(),this.page.add(n);let o=this.controlsManager.sharedGameControlGlobals;o.createdObjects.push(n),o.nCreatedPerAction[this.uniqueId]===void 0?o.nCreatedPerAction[this.uniqueId]=1:o.nCreatedPerAction[this.uniqueId]++,n.updateWorldMatrix(!0,!0),n.traverseObject(this.traverseObjectCB),X_(),this.controlsManager.requestRender()},this.traverseObjectCB=n=>{n.hasNonUniformScale&&n.updateMatrixWorldSVD();let o;if(this.controlsManager.sharedGameControlGlobals.rapierWorld){if(n instanceof ds)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof Ui)o=n.object;else if(o=n,o.dataPatched.cloner?.hideBase)return!0}else{if(n instanceof ds)return;n instanceof Ui?o=n.object:o=n}this.data.destroy==="Time"?n.userData.lifetime=this.data.lifetime*1e3:this.data.destroy==="Quantity"&&(n.userData.quantity=this.data.destroyAfterQuantity,n.userData.actionId=this.uniqueId);let l=new E().fromArray(this.data.velocity),h=o.dataPatched;if(!(h.physics.enabled==="visibility"?!h.visible:!h.physics.enabled)&&(this.controlsManager.sharedGameControlGlobals.rapierWorld?(this.controlsManager.addRigidBody(n,o,{fromCreate:!0,dynamic:this.data.dynamic}),this.data.destroy==="Collision"&&(n.rigidBody?.collider(0).setActiveEvents(1),n.userData.hasCollisionDestroy=!0),n.matrixWorld.decompose(xq,Q_,bq),l.applyQuaternion(Q_),this.data.velocity.some(d=>d!==0)&&this.data.dynamic&&n.rigidBody?.setLinvel(l.divideScalar(this.controlsManager.pixelsPerMeter),!0)):("geometry"in n.object&&this.controlsManager.addBoundsTree(n),this.data.velocity.some(d=>d!==0)&&this.data.dynamic&&(n.userData.velocity=l)),o.dataPatched.physics?.fusedBody===!0))return!0};let a=this.page.scene.find(this.data.object);if(!a)throw new Error("Missing Property");if(this.object=a,this.data.coordinateSystem!=="world"&&!this.page.scene.find(this.data.coordinateSystem))throw new Error("Missing Property");X_(i)}dispose(){this.intervalId!==null&&(window.clearInterval(this.intervalId),this.intervalId=null),this.timeoutIdQueue.forEach(e=>window.clearTimeout(e)),this.dispatchThrottled.cancel(),this.page.remove(...this.controlsManager.sharedGameControlGlobals.createdObjects),this.controlsManager.sharedGameControlGlobals.createdObjects=[]}},qE=200,Um=.02,Fm=.3,wq=65,rQ=new E,Z_=new E,K_=new E,_q=new E,qi=new E,nr=new E,ja=new E,Vm=new me,J_=new me,Sq=new me,sQ=new me,is=new it,oa=new it,Cs=new _i(0,0,0,"YXZ"),Aq=new E(1,0,0),rs=new E(0,1,0),Mq=new E(0,0,1),$_=new E(1,1,1),aQ=new vr,Eq=1,Cq=.025,Tq=16e-6,eS=12,Pq=20,bi=new Wr,zr=new $t,Dq={type:"requestRender"},Iq={type:"updateMatrix"},tS=Math.PI/6,Fv=class extends Ii{constructor(e,t,i,r,s,a,n,o,l){super(),this.object=e,this.domElement=t,this.data=i,this.gloabalPhysics=r,this.controlsManager=s,this.cameraFollow=a,this.camera=n,this.page=o,this.sharedAssets=l,this.enableDamping=!0,this.hiddenMatrix0=new me,this.target0=new E,this.zoom0=1,this.rotForce=1,this.moveForce=1,this.pixelsPerMeter=qE,this.euler0=new _i(0,0,0,"YXZ"),this.position0Cam=new E,this.quat0Cam=new it,this.scale0Cam=new E,this.hiddenMatrix0Cam=new me,this.threshEndTranslate=.01,this.threshEndRotate=1e-8,this.threshEndRotVel=.005,this.collider={type:"capsule",radius:40,segment:new Wr(new E(0,-40,0),new E(0,40,0)),matrix:new me,position:new E,rotation:new it},this.euler=new _i(0,0,0,"YXZ"),this.eulerDelta=new E,this.lastPosition=new E,this.lastCameraQuaternion=new it,this.lastCameraPosition=new E,this.PI_2=Math.PI/2,this.prevMouse=new k,this.velocityTarget=new E,this.velocity=new E,this.directionXZ=new E,this.rotVelocityStick=new E,this.rotVelocityTarget=new E,this.rotVelocity=new E,this.rotDirection=new E,this.nonColliderRotOffset=new me,this.nonColliderPosOffset=new me,this.firstPointerId=-1,this.rot=new E,this.path=[],this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.vrEulerYOffset=0,this.onObject=!1,this.actionState={},this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]],this.collisionEnabled=!0,this.offsetMatrix=new me,this.objectToTarget=new E,this.objectToTarget0=new E,this.objectToCamXZ=new E,this.objectToCamXZ0=new E,this.targetToCamera=new E,this.targetToCamera0=new E,this.cameraPolarAxis0=new E,this.targetPos=new E,this.targetQuat=new it,this.lerpFactorPos=new E().setScalar(.3),this.lerpFactorPosStart=.3,this.lerpFactorPosEnd=.3,this.lerpFactorRotStart=.3,this.lerpFactorRotEnd=.3,this.lerpFactorPosCamera=.3,this.lerpFactorRotCamera=.3,this.objXZQuat=new it,this.objXZQuatInv=new it,this.objXZRotMat=new me,this.isFirstPerson=!1,this.didHit=!1,this.groundVelocity=new E,this.pushedVelocity=new E,this.groundYRotation=0,this.objectRealQuat=new it,this.colliderWorldQuat=new it,this.groundNormal=new E,this.groundTilt=new it,this.groundTiltInv=new it,this.lastHitObj=null,this.isFirstFrame=!0,this.rotationAccumWhenOrientWithCamera=0,this.navMeshPathDest=null,this.position=new E,this.quaternion=new it,this.scale=new E,this.initialAction=!0,this.onPointerDown=f=>{f.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=f.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Pr&&(!sb||ab>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(f.clientX,f.clientY))},this.onPointerUp=f=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),f.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()},this.onPointerMove=f=>{if(f.pointerId!==this.firstPointerId)return;let m=f.clientX-this.prevMouse.x,g=f.clientY-this.prevMouse.y;this.prevMouse.set(f.clientX,f.clientY),f.pointerType==="mouse"&&this.rotBy!=="keys"&&(sb&&ab<15.5&&!Pr?(this.eulerDelta.y=-m*this.mouseOrbitSensitivity,this.eulerDelta.x=-g*this.mouseOrbitSensitivity):(this.eulerDelta.y=-f.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-f.movementY*this.mouseOrbitSensitivity)),f.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-m*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-g*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()},this.onPointerlockChange=f=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Fv.isLocked=!0:Fv.isLocked=!1},this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")},this.handleVisibilityChange=()=>{if(document?.hidden)for(let f in this.movementState)this.movementState[f]=0},this.onKeyDown=f=>{!(f.target instanceof HTMLInputElement)&&(f.code==="ArrowLeft"||f.code==="ArrowUp"||f.code==="ArrowRight"||f.code==="ArrowDown"||f.code==="Space")&&f.preventDefault();for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]){this.movementState[m[0]]=1;break}this.controlsManager.requestRender()},this.onKeyUp=f=>{for(let m of this.keyAssignments)if(f.key.toUpperCase()===m[1]||f.key===m[1]||f.code.slice(3,f.code.length).toUpperCase()===m[1]){this.movementState[m[0]]=0;break}},this.copyVRGamePadValues=(f,m)=>{for(let g=2;g<4;g++){let v=f.axes[g];m===0?g===2?this.movementState.movePosX=v:this.movementState.movePosZ=v:(f.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,g===2?(Math.abs(this.movementState.rotPosY)<.3&&Math.abs(v)>=.3&&(this.vrEulerYOffset+=v<0?1:-1),this.movementState.rotPosY=v):this.moveMode==="fly"&&(this.movementState.moveNegY=v))}},this.sharedGameControlGlobals=s.sharedGameControlGlobals,e===n&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let h=this.euler0.clone(),d=h.y;if(this.objectRealQuat.copy(this.quaternion),h.y=0,this.quaternion.setFromEuler(h),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),h.set(0,d,0),this.quaternion.setFromEuler(h),this.rot.setFromEuler(h),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let f=new E(0,0,-1).applyQuaternion(this.camera.quaternion),m=new E().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(m),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g,v;Math.abs(f.y)<1e-6?(m.y=0,f.y=0,v=m.projectOnVector(f)):m.y/f.y>0?v=f.multiplyScalar(m.y/f.y):v=f.multiplyScalar(m.length()),this.targetToCamera0.copy(v).negate(),g=this.camera.position.clone().add(v),this.objectToTarget0.subVectors(g,this.position);let y=new _i().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-y.x,y.x=0,y.z=0,y.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(y)}if(this.object instanceof Vi&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=i.rotByTouch??"joystick",this.rotBy=i.rotBy??"keys",this.rotationMode=i.rotationMode??"normal",this.moveMode=i.moveMode??"walk",this.collisionEnabled=i.collisionEnabled,this.speedTranslate=(i.speedTranslate??250)*Eq,this.speedOrbit=(i.speedRotate??100)*Cq,this.mouseOrbitSensitivity=(i.speedRotate??100)*Tq,this.keyAssignments=i.keyAssignments.map(f=>{let m=[f[0],f[1]];return m[1]==="\u25B2"?m[1]="ArrowUp":m[1]==="\u25C0"?m[1]="ArrowLeft":m[1]==="\u25BC"?m[1]="ArrowDown":m[1]==="\u25B6"?m[1]="ArrowRight":m[1]==="\u21E7"?m[1]="Shift":m[1]==="\u21B5"?m[1]="Enter":m[1]==="Space"?m[1]=" ":m[1]==="\u2318"?m[1]="Meta":m[1]==="Ctrl"?m[1]="Control":m[1]==="Esc"&&(m[1]="Escape"),m}),i.rotBy==="mouse"){let f;f=this.keyAssignments.findIndex(m=>m[0]==="rotNegX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosX"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotPosY"),f!==-1&&(this.keyAssignments[f][1]=""),f=this.keyAssignments.findIndex(m=>m[0]==="rotNegY"),f!==-1&&(this.keyAssignments[f][1]="")}this.lerpFactorPosStart=1-.02**(1/((i.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((i.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((i.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((i.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((i.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((i.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??Nl.defaultData.gravity)*eS,this.usePhysics=this.gloabalPhysics.usePhysics??Nl.defaultData.usePhysics,this.jumpPower=i.jumpPower*Pq,this.resetYPosition=this.position.y+Math.abs(i.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=i.alignToGround??!1,this.orientMode=i.autoOrientMove?i.orientMode:"none",this.orientWith=i.orientWith??ap.defaultDataThirdPerson.orientWith,this.slopeThresh=wq*Math.PI/180,i.collider.type==="capsule"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=i.collider.height/2-i.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=i.collider.height*Um/this.pixelsPerMeter,this.stepThresh=i.collider.height*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.height):i.collider.type==="sphere"?(this.collider.radius=i.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*i.collider.radius*Um/this.pixelsPerMeter,this.stepThresh=2*i.collider.radius*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.radius*2):(this.offset=i.collider.height*Um/this.pixelsPerMeter,this.stepThresh=i.collider.height*Fm/this.pixelsPerMeter,this.colliderHeight=i.collider.height),this.collider.type=i.collider.type;let c=new E().fromArray(i.collider.position),u=new it().setFromEuler(new _i().fromArray([...i.collider.rotation,"XYZ"]));this.collider.position.copy(c).multiply(this.scale),this.collider.rotation.copy(u),this.collider.matrix.compose(c,u,$_),i.cameraXAxis!==void 0&&(this.cameraXAxis=i.cameraXAxis,this.cameraYAxis=i.cameraYAxis,this.minPolarAngle=i.cameraRotXLimits[0],this.maxPolarAngle=i.cameraRotXLimits[1],this.minAzimuthAngleRel=i.cameraRotYLimits[0],this.maxAzimuthAngleRel=i.cameraRotYLimits[1]),this.forwardDir=i.forwardDirection??"-z",this.runMultiplier=i.runMultiplier??2;let p=i.navmesh.destinationHelperRadius*2;if(p>0){let f=new We;f.push({fi:0,data:{...lr.defaultData("light","phong"),alpha:0},id:"layer1"}),f.push({fi:0,data:{...lr.defaultData("color"),color:i.navmesh.destinationHelperColor,alpha:i.navmesh.destinationHelperColor.a},id:"layer2"});let m=new J0({layers:f},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new ur(U2.create({parameters:{width:p,height:p/10,hollow:.7}}),m),this.navMeshPathDest.material.userData.opacity0=i.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let t=new _i().setFromQuaternion(this.quaternion,"YXZ"),i=t.y;this.objectRealQuat.copy(this.quaternion),t.y=0,this.quaternion.setFromEuler(t),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),t.set(0,i,0),this.quaternion.setFromEuler(t),this.rot.setFromEuler(t),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof Vi?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,t=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},sp.list.forEach(i=>{this.actions[i]=rr({...e,disabled:!1,type:"GameControl"},e.gameActions[i],this.page,t,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),Mi(this.actions.idle),Mi(this.actions.move),Mi(this.actions.run),Mi(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(t=>{t.play()}),this.actions[e].Animation.forEach(t=>{t.play(this.initialAction===!1)}),this.actions[e].Create.forEach(t=>{t.dispatchStart()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(t=>{t.stop(),t.object.currentState!==null&&t.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].Create.forEach(t=>{t.dispatchStop()}),this.actions[e].Audio.forEach(t=>{t.dispatchGameControl("stop")})))}get colliderWorldPosition(){return qi.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e,t,i){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let s=r*60,a=!1;if(this.usePhysics&&this.collisionEnabled){let o=nr.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*eS),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,16,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(a=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let h=l.collider.parent();this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let d of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(d.rigidBody===h&&d.userData.isFollowingObj!==this.object.uuid){(d.hasNonUniformScale?d.matrixWorldRigid:d.matrixWorld).decompose(qi,oa,nr),this.groundVelocity.subVectors(qi,d.prevT),this.object.getWorldPosition(nr).add(this.collider.position).sub(qi),this.groundYRotation=Cs.setFromQuaternion(oa).y-d.prevR.y,ja.copy(nr).applyAxisAngle(rs,this.groundYRotation),this.groundVelocity.add(ja.sub(nr)).divideScalar(r);break}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*s),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let o=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=qi.subVectors(this.path[1],this.position),h=nr.subVectors(this.path[1],this.path[0]);l.dot(h)<0?this.path.shift():(this.directionXZ.x=h.x,this.directionXZ.z=h.z),o.opacity=o.userData.opacity0}else o.opacity-=.05*o.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**s),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**s),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**s)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let n=_q.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=nr.copy(n);o.y=0,n.set(0,n.y,o.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none")if(this.orientWith==="camera"&&this.path.length<=1){let o=qi;this.camera.getWorldDirection(o);let l=ja.copy(rs).multiplyScalar(o.dot(rs));o.sub(l);let h=nr.copy(this.directionXZ);h.x*=-1,this.rot.y=o.angleTo(h)*(o.cross(h).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Cs.setFromVector3(this.rot),this.moveMode==="walk"&&(Cs.x=0),n.applyEuler(Cs),a&&(oa.setFromUnitVectors(rs,this.groundNormal),n.applyQuaternion(oa)),i){let o=Cs.set(0,this.vrEulerYOffset*tS,0);i.applyEuler(o),n.x+=i.x,n.z+=i.z,this.nonColliderPosOffset.elements[13]+=i.y*r}if(this.usePhysics===!0){let o=nr;this.pushedVelocity.set(0,0,0);for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){let h=ja.setFromMatrixPosition(l.matrixWorld).sub(l.prevT).divideScalar(r).divideScalar(this.pixelsPerMeter),d=l.rigidBody.collider(0).castCollider(h,this.object.rigidBody.collider(0),qi.copy(n).divideScalar(this.pixelsPerMeter),r,!1);h.multiplyScalar(this.pixelsPerMeter);let c=ut.is(l)?l:l.object;if(d!==null&&this.lastHitObj!==c){let u;l instanceof Ui&&(u=l);let p=this.sharedGameControlGlobals.entityToCollisionEvents[c.uuid];if(p)for(let f of p)f.data.target==="character"&&(f.dispatch(u),c.dispatchEvent(jv));this.lastHitObj=c}if(d!==null){this.pushedVelocity.copy(h),o.copy(d.normal1).applyQuaternion(l.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let l=o.dot(n);l<0&&n.addScaledVector(o,-l),n.add(this.pushedVelocity)}else n.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**s):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**s),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(rs,this.euler.y-this.euler0.y);let o=nr.copy(this.objectToCamXZ).normalize(),l=ja.copy(n).multiplyScalar(r);l.y=0;let h=l.sub(qi.copy(o).multiplyScalar(l.dot(o))).cross(o).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=Re.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(t?(Cs.copy(t),Cs.y=0):(Cs.copy(this.euler),Cs.y=0),this.nonColliderRotOffset.makeRotationFromEuler(Cs)),t&&(this.moveMode==="walk"?(this.rot.y=t.y,this.rot.x=0,this.rot.z=0):this.rot.setFromEuler(t),this.rot.y+=this.vrEulerYOffset*tS),is.setFromAxisAngle(Aq,this.rot.x),oa.setFromAxisAngle(rs,this.rot.y),oa.multiply(is),is.setFromAxisAngle(Mq,this.rot.z),oa.multiply(is),this.quaternion.copy(oa),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.objectRealQuat.multiply(this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){let o=nr.copy(n).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let h=new E;for(let d=0;d<5;d++){let c=o.length(),u=ja.copy(o).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),this.colliderWorldQuat,u,this.object.rigidBody?.collider(0).shape,c,!1,24,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let p=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(p!==this.lastHitObj&&d===0){this.lastHitObj=p;let v=this.sharedGameControlGlobals.entityToCollisionEvents[p?.uuid];if(v){for(let y of v)if(y.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,b;if(p.cloner){for(let w of p.cloner.children)if(w.rigidBody===x){b=w;break}}y.dispatch(b),p.dispatchEvent(jv)}}}let f=Z_.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),m=K_.copy(u).multiplyScalar(l.toi).dot(f),g=l.toi;if(g===0&&(this.position.y+=this.offset*this.pixelsPerMeter),m>this.offset&&(g=l.toi*(m-this.offset)/m,h.addScaledVector(u,g)),o.copy(u).multiplyScalar(c-g),Math.acos(-f.y)>this.slopeThresh){let v=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(h),y=ja.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);y.y=0;let x=v.add(y);x.y+=this.stepThresh;let b=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,!1,24,void 0,void 0,this.object.rigidBody);b!==null&&b.toi===0&&(f.y=0,f.normalize())}o.addScaledVector(f,-o.dot(f))}else{d===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),h.add(o);break}}this.position.addScaledVector(h,this.pixelsPerMeter),this.object.rigidBody?.setTranslation(qi.copy(this.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(is.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,l=n.multiplyScalar(r/o);for(let h=0;h<o;h++)this.position.add(l),this.collisionAdjustment(r/o)}else this.position.addScaledVector(n,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.position),l=this.targetToCamera.add(o);Vm.lookAt(l,o,rs).setPosition(l),Vm.decompose(this.targetPos,this.targetQuat,qi),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**s),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**s),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Re.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Re.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(Iq),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(Dq),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=is.setFromAxisAngle(rs,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Re.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let t;this.cameraXAxis==="Limit"?t=Re.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):t=Re.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=qi.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(e);let r=oa.setFromAxisAngle(i,t);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(r)}groundTiltAdjustment(e){rs.angleTo(e)*180/Math.PI<15||rs.angleTo(e)*180/Math.PI>85?is.identity():is.setFromUnitVectors(rs,e),this.groundTilt.slerp(is,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let t=K_.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let i=Vm.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(qi,is,nr).compose(qi,is,$_);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(s=>{if(s===this.object||s.isDescendantOf(this.object))return;zr.makeEmpty(),s.updateMatrixWorldSVD();let a=s.matrixWorldRigid,n=J_.copy(a).invert(),o=Sq.copy(J_).multiply(i);bi.copy(this.collider.segment),bi.start.applyMatrix4(o),bi.end.applyMatrix4(o);let l=Z_.copy(this.position).applyMatrix4(n);zr.expandByPoint(bi.start),zr.expandByPoint(bi.end),zr.min.addScalar(-this.collider.radius),zr.max.addScalar(this.collider.radius),s.bvhGeometry.boundsTree.shapecast({traverseBoundsOrder(h){return h.distanceToPoint(bi.end)},intersectsBounds:h=>h.intersectsBox(zr),intersectsTriangle:h=>{let d=qi,c=nr,u=h.closestPointToSegment(bi,d,c);if(u<this.collider.radius){let p=this.collider.radius-u,f=c.sub(d).normalize(),m=ja.copy(l);m.addScaledVector(f,p);let g=m.applyMatrix4(a).sub(this.position);t.add(g),bi.start.addScaledVector(f,p),bi.end.addScaledVector(f,p)}}})}),zr.makeEmpty(),bi.copy(this.collider.segment),bi.start.applyMatrix4(i),bi.end.applyMatrix4(i),zr.expandByPoint(bi.start),zr.expandByPoint(bi.end),zr.min.addScalar(-this.collider.radius),zr.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({traverseBoundsOrder(s){return s.distanceToPoint(bi.end)},intersectsBounds:s=>s.intersectsBox(zr),intersectsTriangle:s=>{let a=qi,n=nr,o=s.closestPointToSegment(bi,a,n);if(o<this.collider.radius){let l=this.collider.radius-o,h=n.sub(a).normalize();this.alignToGround&&this.groundTiltAdjustment(h),t.addScaledVector(h,l),bi.start.addScaledVector(h,l),bi.end.addScaledVector(h,l)}}}),this.onObject=Math.abs(t.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let r=Math.max(0,t.length()-1e-5);t.normalize().multiplyScalar(r),this.position.add(t)}},XE=Fv;XE.isLocked=!1;var Oq=gn(xS());function ya(e,t){let i=new Ue;if(!e.getAttribute("position"))return i.setAttribute("position",new Te([],3)),i.setIndex([]),i;let{positions:r,triIndices:s}=kp(e.getAttribute("position"),e.getIndex());return i.setAttribute("position",new Te(r,3)),i.setIndex(s),t&&i.applyMatrix4(t),i}var Lq=new me,Rq=new me,Ts=[[0,0,0],[0,0,0],[0,0,0]];function YE(e){let t=e.elements;Ts[0][0]=t[0],Ts[0][1]=t[4],Ts[0][2]=t[8],Ts[1][0]=t[1],Ts[1][1]=t[5],Ts[1][2]=t[9],Ts[2][0]=t[2],Ts[2][1]=t[6],Ts[2][2]=t[10];let{u:i,v:r}=(0,Oq.SVD)(Ts),s=Lq.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),a=Rq.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(a.transpose())}var Bq=class extends hA{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 vn({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)),a=new Ue;return a.setFromPoints([t,s]),new Du(a,e)}},QE=e=>e instanceof Pc||e instanceof Ml;function zq(e,t){return e.distance-t.distance}function ZE(e,t,i){if(!(!va(t)||!t.visible)){os(t)&&t.raycast(e,i);for(let r of t.children)ZE(e,r,i)}}function _u(e,t,i,r=!1){if(!r&&!i.some(a=>vp(e,a)!==void 0))return[];let s=[];return t.children.forEach(a=>ZE(e,a,s)),s.sort(zq),s}function Vv(e){let t=[];if(e.length){let i=e[0].object;va(i)&&t.push(i);let r=i.parent;for(;r;)QE(r)&&t.push(r),r=r.parent}return t}function vp(e,t){if(os(t)){if(t.visible){let i=[];return t.raycast(e,i),i.length?i[0]:void 0}}else if(QE(t))return KE(e,t)}function KE(e,t){if(!(!va(t)||!t.visible)){if(os(t)){let i=[];if(t.raycast(e,i),i.length)return i[0]}for(let i of t.children){let r=KE(e,i);if(r)return r}}}function Nq(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 kq=class{constructor(e,t,i,r,s,a,n,o){this.renderer=e,this.publish=t,this.scene=i,this.getCamera=r,this.sharedAssets=s,this.requestRender=a,this.isExport=n,this.frame=o,this.raycaster=new Bq,this.raycasterNeedsUpdate=!0,this._useWindowEvents=!1,this._useWindowEvents=t.mouseEventTarget==="window",this.domElement=e.domElement,this.eventElement=this._useWindowEvents?window:e.domElement,this.domRect=this.domElement.getBoundingClientRect()}get stopRaycast(){return this.publish.stopRaycast}get page(){return this.scene.activePage}set useWindowEvents(e){this._useWindowEvents=e,this.eventElement=e?window:this.renderer.domElement}get useWindowEvents(){return this._useWindowEvents}updateDomRect(){this.domRect=this.domElement.getBoundingClientRect()}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{pageX:t,pageY:i}=e.touches?.length>0?e.touches[0]:e;this.updateDomRect(),this.raycaster.setFromCamera(Nq(t,i,this.domRect),this.getCamera())}},JE=(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))(JE||{}),ys=class{constructor(e){this.eventContext=e,this.domEventsNeeded=new Set,this.hasVideoAction=!1}connect(){}disconnect(){}},wy=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],$E=e=>wy.find(([t,i])=>i===e)?.[0],Gc=e=>wy.find(([t])=>t===e)?.[1],Uq=(e,t)=>{let i=$E(e);if(i){let r=new CustomEvent(i,{bubbles:!0});return Object.defineProperty(r,"target",{writable:!1,value:t}),r}},Fq=class extends ys{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[$E(i.eventName)]?.[i.target.uuid];if(!r)return;i.eventName==="Scroll"&&i.deltaY!==void 0&&Object.assign(r,{deltaY:i.deltaY});let{domElement:s}=this.eventContext;s.dispatchEvent(r)};let{page:t}=this.eventContext;t.traverseEntity(i=>{if(i.data?.events.length){for(let[r,s]of wy)if(i.data.events.some(a=>a.data.type===s&&!a.data.disabled)){this.objectsPerEvents.has(r)?this.objectsPerEvents.get(r)?.push(i):this.objectsPerEvents.set(r,[i]);let a={id:i.uuid,name:i.name},n=Uq(s,a),o=this.splineEvents[r];o?o[i.uuid]=n:this.splineEvents[r]={[i.uuid]:n}}}})}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)})})}},Vq=class{constructor(e,t,i,r,s,a){if(this.id=e,this.data=t,this.object=i,this.entered=!1,this.alreadyPlayedNonTogglingActions=new Set,this.useToggle=t.runMode==="Toggle",(t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress")&&!t.key)throw new Error("Missing property");this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatchHeld(e){this.actions.Create.forEach(t=>{e&&t.dispatchThrottled.cancel(),t.dispatchThrottled()})}dispatch(e=!1){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()}),this.actions.SwitchCamera.forEach(t=>{t.toggle()})):this.data.type==="MousePress"||this.data.type==="KeyPress"?this.entered||(this.entered=!0,this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatchStart())):(this.actions.Transition.some(t=>t.playing)||this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.SwitchCamera.some(t=>t.playing)||this.actions.SwitchCamera.forEach(t=>{t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),e===!1&&this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}dispatchRelease(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.Animation.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()),this.actions.Create.forEach(e=>e.dispatchStop()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},jq=class extends ys{constructor(e,t,i){super(e),this.useForRaycastProperty=i,this.objectsPerTypes={MouseDown:[],MouseUp:[],MousePress:[],KeyDown:[],KeyUp:[],KeyPress:[]},this.canvasMouseEvents=[],this.eventsPerObjects={MouseDown:{},MouseUp:{},MousePress:{},KeyDown:{},KeyUp:{},KeyPress:{}},this.heldKeys={},this.heldKeysPress={},this._prevObjects=[],this.sceneInterects=null,this.onCanvasRaycast=a=>{if(this.useForRaycastProperty===!0&&this.sceneInterects===null){this.eventContext.updateRaycaster(a);let{raycaster:n,page:o}=this.eventContext,l=_u(n,o,[],!0);this.sceneInterects=l,l.length&&(this.eventContext.sharedAssets.raycastProperty={x:l[0].point.x,y:l[0].point.y,z:l[0].point.z,objX:l[0].object.matrixWorld.elements[12],objY:l[0].object.matrixWorld.elements[13],objZ:l[0].object.matrixWorld.elements[14]})}},this.onCanvasMouseDown=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{(n.data.type==="MouseDown"||n.data.type==="MousePress")&&(this.onCanvasRaycast(a),n.dispatch())})},this.onCanvasMouseUp=a=>{(a.target===this.eventContext.domElement||a.target.tagName==="SPLINE-VIEWER")&&this.canvasMouseEvents.forEach(n=>{n.data.type==="MouseUp"?(this.onCanvasRaycast(a),n.dispatch()):n.data.type==="MousePress"&&n.dispatchRelease()})},this.onMouseDown=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseDown"))},this.onMouseUp=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMouseEvent("MouseUp"))},this.onMousePressDown=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent())},this.onMousePressRelease=a=>{Xe.length>1||(this.eventContext.updateRaycaster(a),this.handleMousePressEvent(!0))},this.onKeyDown=a=>{this.heldKeys[a.key]||(this.handleKeyEvent(a,"KeyDown"),this.handleKeyEventHeld(a,"KeyDown",!0)),this.heldKeys[a.key]=!0},this.onKeyUp=a=>{this.handleKeyEvent(a,"KeyUp"),this.handleKeyEventHeld(a,"KeyUp",!0)},this.onKeyPressDown=a=>{this.heldKeysPress[a.key]?this.handleKeyEventHeld(a,"KeyPress"):(this.handleKeyEvent(a,"KeyPress"),this.handleKeyEventHeld(a,"KeyPress",!0)),this.heldKeysPress[a.key]=!0},this.onKeyPressUp=a=>{this.handleKeyEvent(a,"KeyPress",!0)},this.releaseHeldKey=a=>{delete this.heldKeys[a.key]},this.releaseHeldKeyPress=a=>{delete this.heldKeysPress[a.key]},this._onUserEvent=({eventName:a,target:n,reverse:o})=>{if(!a||!n)return;let l=Gc(a);l&&(l==="MouseDown"||l==="MouseUp"||l==="MousePress"?(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent(o)})):(l==="KeyDown"||l==="KeyUp"||l==="KeyPress")&&(n.dispatchEvent({type:"beginEvent",eventName:l}),this.eventsPerObjects[l]?.[n.uuid]?.forEach(h=>{h.dispatchUserEvent()})))};let{page:r,sharedAssets:s}=this.eventContext;r.traverseEntity(a=>{if(!a.data?.events.length)return;let n=["MouseDown","MouseUp","MousePress","KeyDown","KeyUp","KeyPress"];for(let o of n){let l=this.eventsPerObjects[o];a.data.events.filter(({data:h})=>h.type===o&&h.disabled!==!0).forEach(({id:h,data:d})=>{try{let c=new Vq(h,d,a,r,s,t);c.actions.Video.length&&(this.hasVideoAction=!0),(d.type==="MouseDown"||d.type==="MouseUp"||d.type==="MousePress")&&(d.mode==="Canvas"||d.mode==="Window")?this.canvasMouseEvents.push(c):l[a.uuid]?l[a.uuid].push(c):l[a.uuid]=[c]}catch{}}),l[a.uuid]?.length&&this.objectsPerTypes[o].push(a)}})}connect(){let{domElement:e}=this.eventContext;this.heldKeys={},this.heldKeysPress={},this.domEventsNeeded.clear(),e.addEventListener("pointerdown",this.onCanvasMouseDown),e.addEventListener("pointerup",this.onCanvasMouseUp),(this.objectsPerTypes.MouseDown?.length||this.useForRaycastProperty)&&(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.onCanvasMouseDown),e.removeEventListener("pointerup",this.onCanvasMouseUp),e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerdown",this.onMousePressDown),e.removeEventListener("pointerup",this.onMouseUp),e.removeEventListener("pointerup",this.onMousePressRelease),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keydown",this.onKeyPressDown),document.removeEventListener("keyup",this.onKeyPressUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(t=>{Object.values(t).forEach(i=>{i.forEach(r=>{r.disconnect()})})}),this.canvasMouseEvents.forEach(t=>{t.disconnect()}),Object.entries(this.objectsPerTypes).forEach(([t,i])=>{i.forEach(r=>{r.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(e){let{stopRaycast:t,raycaster:i,page:r}=this.eventContext,s=this.objectsPerTypes[e];if(!(!s.length&&!this.useForRaycastProperty)){if(t||this.useForRaycastProperty){let a;this.sceneInterects===null?a=_u(i,r,s,this.useForRaycastProperty):(a=this.sceneInterects,this.sceneInterects=null),this.useForRaycastProperty&&a.length&&(this.eventContext.sharedAssets.raycastProperty={x:a[0].point.x,y:a[0].point.y,z:a[0].point.z,objX:a[0].object.matrixWorld.elements[12],objY:a[0].object.matrixWorld.elements[13],objZ:a[0].object.matrixWorld.elements[14]}),t&&Vv(a).forEach(n=>{this.eventsPerObjects[e][n.uuid]&&this.handleObjectMouseEventDispatch(n,e)})}t||s.forEach(a=>{vp(i,a)&&this.handleObjectMouseEventDispatch(a,e)})}}handleMousePressEvent(e=!1){let t="MousePress",i=this.objectsPerTypes[t],r=[];if(i.length){if(!e){let{stopRaycast:s,raycaster:a,page:n}=this.eventContext;if(s){let o=_u(a,n,i);r=Vv(o)}else i.forEach(o=>{vp(a,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:a})=>"key"in a&&a.key===e.key)&&r.dispatchEvent({type:"beginEvent",eventName:t}),s.forEach(a=>{"key"in a.data&&a.data.key===e.key&&(i?a.dispatchRelease():a.dispatch(!0))})})}handleKeyEventHeld(e,t,i=!1){this.objectsPerTypes[t].forEach(r=>{this.eventsPerObjects[t][r.uuid].forEach(s=>{"key"in s.data&&s.data.key===e.key&&s.dispatchHeld(i)})})}},Gq=new E,Hq=new E,eC=class{constructor(e,t,i,r,s){this.actionsIn=rr(e,e.inActions,i,r,s,t),this.actionsOut=rr(e,e.outActions,i,r,s,t)}disconnect(){Mi(this.actionsIn),Mi(this.actionsOut)}},Wq=class extends eC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.stage="out",this.objects=[],this.onUpdateMatrixWorld=()=>{for(let u of this.objects)if(!u.visible)return;let h=Gq.setFromMatrixPosition(this.objects[0].matrixWorld),d=Hq.setFromMatrixPosition(this.objects[1].matrixWorld),c=h.distanceTo(d)<=this.distance?"in":"out";if(this.stage!==c){this.stage=c;let u=c==="in"?this.actionsIn:this.actionsOut;u.Audio.forEach(p=>p.dispatchConditional()),u.Video.forEach(p=>p.dispatchConditional()),u.Link.forEach(p=>p.dispatch()),u.Create.forEach(p=>p.dispatch()),u.Destroy.forEach(p=>p.dispatch()),u.Reset.forEach(p=>p.dispatch()),u.Transition.forEach(p=>{p.object.currentTransitionEvent!==this&&(p.object.currentTransitionEvent=this),p.init()}),u.Transition.forEach(p=>p.play()),u.Animation.forEach(p=>p.play()),u.SwitchCamera.forEach(p=>p.play()),u.SceneTransition.forEach(p=>p.dispatch()),u.SetVariable.forEach(p=>p.checkConditions()),u.SetVariable.forEach(p=>p.dispatch()),u.DynamicVariablePlay.forEach(p=>p.dispatch())}};let{distance:n,fromObject:o,toObject:l}=t.condition;this.distance=n;for(let h of[o,l]){if(!h)throw new Error("Missing property");let d=r.find(h);if(!d)throw new Error("Missing property");this.objects.push(d)}}connect(){window.setTimeout(()=>{this.objects.forEach(e=>{e.addEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)}),this.onUpdateMatrixWorld()},0)}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(e=>{e.removeEventListener("updateMatrixWorld",this.onUpdateMatrixWorld)})}},qq=class extends eC{constructor(e,t,i,r,s,a){super(t,i,r,s,a),this.id=e,this.data=t,this.object=i,this.onBegin=({target:l,state:h})=>{this.toState!==h&&(this.actionsOut.Audio.forEach(d=>d.dispatchConditional()),this.actionsOut.Video.forEach(d=>d.dispatchConditional()),this.actionsOut.Link.forEach(d=>d.dispatch()),this.actionsOut.Create.forEach(d=>d.dispatch()),this.actionsOut.Destroy.forEach(d=>d.dispatch()),this.actionsOut.Reset.forEach(d=>d.dispatch()),this.actionsIn.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsOut.Transition.forEach(d=>d.play()),this.actionsOut.Animation.forEach(d=>d.play()),this.actionsIn.SwitchCamera.forEach(d=>d.pause()),this.actionsOut.SwitchCamera.forEach(d=>d.play()),this.actionsOut.SceneTransition.forEach(d=>d.dispatch()),this.actionsOut.SetVariable.forEach(d=>d.checkConditions()),this.actionsOut.SetVariable.forEach(d=>d.dispatch()),this.actionsOut.DynamicVariablePlay.forEach(d=>d.dispatch()))},this.onComplete=({target:l,state:h})=>{this.toState===h&&(this.actionsIn.Audio.forEach(d=>d.dispatchConditional()),this.actionsIn.Video.forEach(d=>d.dispatchConditional()),this.actionsIn.Link.forEach(d=>d.dispatch()),this.actionsIn.Create.forEach(d=>d.dispatch()),this.actionsIn.Destroy.forEach(d=>d.dispatch()),this.actionsIn.Reset.forEach(d=>d.dispatch()),this.actionsOut.Transition.forEach(d=>d.pause()),this.actionsOut.Transition.forEach(d=>d.pause()),this.object.currentTransitionEvent=this,this.actionsIn.Transition.forEach(d=>d.play()),this.actionsIn.Animation.forEach(d=>d.play()),this.actionsOut.SwitchCamera.forEach(d=>d.pause()),this.actionsIn.SwitchCamera.forEach(d=>d.play()),this.actionsIn.SceneTransition.forEach(d=>d.dispatch()),this.actionsIn.SetVariable.forEach(d=>d.checkConditions()),this.actionsIn.SetVariable.forEach(d=>d.dispatch()),this.actionsIn.DynamicVariablePlay.forEach(d=>d.dispatch()))};let{condition:n}=t;if(!n.object)throw new Error("Missing property");let o=r.find(n.object);if(!o)throw new Error("Missing property");if(this.toObject=o,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.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Video.length||this.actionsOut.Create.length||this.actionsOut.Destroy.length||this.actionsOut.Transition.length||this.actionsOut.Animation.length||this.actionsOut.SwitchCamera.length||this.actionsOut.SceneTransition.length||this.actionsOut.SetVariable.length||this.actionsOut.DynamicVariablePlay.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Video.length||this.actionsOut.Create.length||this.actionsIn.Destroy.length||this.actionsIn.Transition.length||this.actionsIn.Animation.length||this.actionsIn.SwitchCamera.length||this.actionsIn.SceneTransition.length||this.actionsIn.SetVariable.length||this.actionsIn.DynamicVariablePlay.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},Xq=class extends ys{constructor(e,t){super(e),this.eventsPerConditions={Comparison:[],Distance:[],State:[]},this.hasVideoAction=!1;let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(s.data?.events.length){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="Conditional")try{let o;n.condition.type==="Comparison"||(n.condition.type==="Distance"?o=new Wq(a,n,s,i,r,t):n.condition.type==="State"&&(o=new qq(a,n,s,i,r,t))),o&&(this.eventsPerConditions[n.condition.type].push(o),(o.actionsIn.Video.length||o.actionsOut.Video.length)&&(this.hasVideoAction=!0))}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(e=>e.forEach(t=>t.disconnect()))}},Uh=new E,Ga=new E,On=new E,iS=new Er,Yq=.01,_t=new E,ui=new E,rS=new E,Xn=new it,jm=new _i,Qq=new me,Gm=new Ai,Go=new E,Ps=new E,Ho=.2;function Hm(e,t){!t||(t[0]<t[1]&&(e.x=Math.min(Math.max(e.x,t[0]),t[1])),t[2]<t[3]&&(e.y=Math.min(Math.max(e.y,t[2]),t[3])),t[4]<t[5]&&(e.z=Math.min(Math.max(e.z,t[4]),t[5])))}var Zq=function(){let e=new me;return(t,i,r)=>{let s=t.obj;e.copy(s.hiddenMatrix),s.parent!==null&&e.premultiply(s.parent.matrixWorld),e.invert(),s.position.copy(i),t.reference==="global"&&Hm(s.position,t.limits),s.position.applyMatrix4(e),t.reference==="parent"?Hm(s.position,t.limits):t.reference==="local"&&(Xn.copy(t.quat0).invert(),s.position.sub(t.position0),s.position.applyQuaternion(Xn),Hm(s.position,t.limits),Xn.invert(),s.position.applyQuaternion(Xn),s.position.add(t.position0)),e.multiply(r??s.matrixWorld).decompose(_t,s.quaternion,ui),s.updateMatrix(),s.hasNonUniformScale&&(s.updateMatrixWorld(),s.updateMatrixWorldSVD()),s instanceof yr&&Us(s.parent)&&s.invalidateDownstreamBooleanData(!0)}}(),Kq=class{constructor(e,t,i,r,s,a){this.object=e,this.data=t,this.dropDestIds=[],this.activeIdx=null,this.wasDragEventTriggered=!1,this.resetDampingFactor=this.data.resetSpeed===0?1:8/this.data.resetSpeed+1,this.snapDampingFactor=this.data.snapSpeed===0?1:8/this.data.snapSpeed+1,this.actionsDrag=rr(t,t.dragDropActions.drag,i,r,s,this.object),this.actionsDrop=rr(t,t.dragDropActions.drop,i,r,s,this.object);let n=[];this.data.objects.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(n.push(l),a[l.uuid]&&a[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&n.push(d)}))}),this.data.dropDestinations.forEach(o=>{let l=i.find(o);!l||l.data.visible!==!1&&(this.dropDestIds.push(l.uuid),a[l.uuid]&&a[l.uuid].forEach(h=>{let d=i.find(h);!d||d.data.visible!==!1&&this.dropDestIds.push(d.uuid)}))}),this.dragItems=n.map(o=>(this.data.planeMode==="locked"&&(o.userData.lockedPlane=!0),o.userData.worldPosition0=new E().setFromMatrixPosition(o.matrixWorld),{obj:o,fromPosition:new E().setFromMatrixPosition(o.matrixWorld),pointStart:new E,pointEnd:new E,paused:!0,currentDampingFactor:this.data.dampingFactor,reset:!1,position0:new E().copy(o.position),quat0:new it().copy(o.quaternion),snapped:!1,orientationMatrix:new me,limits:this.data.limits,reference:this.data.referenceFrame}))}get activeDragItem(){return this.activeIdx!==null?this.dragItems[this.activeIdx]:null}dispose(){Mi(this.actionsDrag),Mi(this.actionsDrop),this.dragItems.forEach(e=>{e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart),e.obj.recursiveBBoxNeedsUpdate=!0,e.obj.userData.lockedPlane=void 0,e.obj.position.copy(e.position0),e.obj.quaternion.copy(e.quat0),e.obj.updateMatrix()})}},Jq=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.lastDropDestination=null,this.dragTimeout=null,this.onPointerDown=r=>{if(Xe.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(this.lastDropDestination=null,n.length===0){this.activeEvent=null;return}for(let o of this.events){let l=0;for(let{obj:h,pointEnd:d,pointStart:c}of o.dragItems){if(h===n[0].object||h===n[0].object.object||ut.is(h)&&h.isAncestorOf(n[0].object.uuid)){if(o.activeIdx=l,o.activeDragItem.reset=!1,o.activeDragItem.currentDampingFactor=o.data.dampingFactor,o.activeDragItem.snapped=!1,o.data.cursor==="hand"&&this.setCursor("grabbing"),this.eventManager.controlsManager.usePhysics){o.activeDragItem.obj.rigidBody&&o.activeDragItem.obj.rigidBody.setBodyType(2,!0);let u=o.activeDragItem.obj;h.hasNonUniformScale&&h.updateMatrixWorldSVD(),(u.hasNonUniformScale?u.matrixWorldRigid:u.matrixWorld).decompose(_t,Xn,ui),jm.setFromQuaternion(Xn),u.prevR===void 0?(u.prevR=jm.clone(),u.prevT=_t.clone()):(u.prevR.copy(jm),u.prevT.copy(_t)),this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.push(o.activeDragItem.obj)}this.calcPlaneIntersectPos(h,c,o.data.plane,o.data.referenceFrame),d.copy(c),(this.eventManager.controlsManager.usePhysics&&h.data.physics?.rigidBody==="dynamic"||o.data.drop===!1||o.data.resetOnSnapFail===!1)&&o.activeDragItem.fromPosition.setFromMatrixPosition(o.activeDragItem.obj.matrixWorld),this.activeEvent=o,this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1);return}l++}}this.activeEvent=null},this.onPointerMove=r=>{if(Xe.length>1)return;this.eventContext.updateRaycaster(r);let{raycaster:s,page:a}=this.eventContext,n=a.raycastWithClones(s);if(Xe.length===0){let o=!1;for(let l of this.events){for(let{obj:h}of l.dragItems)if(h===n[0]?.object||h===n[0]?.object?.object||ut.is(h)&&h.isAncestorOf(n[0]?.object.uuid)){switch(o=!0,l.data.cursor){case"hand":this.setCursor("grab");break;case"move":this.setCursor("move");break;default:break}break}if(o)break}o||this.setCursor("default");return}if(this.activeEvent&&this.activeEvent.activeDragItem){let o=this.activeEvent.activeDragItem;o.snapped=!1;let l;if(this.activeEvent.data.drop&&(l=n.filter(h=>o.obj!==h.object&&!o.obj.isAncestorOf(h.object.uuid)&&!(h.object instanceof Pc)&&(this.activeEvent.data.dropOn==="all"||this.activeEvent.dropDestIds.some(d=>d===h.object.uuid||a.scene.find(d).isAncestorOf(h.object.uuid))))[0]),l){let h=rS.copy(l.face.normal).applyMatrix3(Gm.getNormalMatrix(l.object.matrixWorld));if(this.activeEvent.data.snapTo==="center")o.fromPosition.setFromMatrixPosition(l.object.matrixWorld);else if(this.activeEvent.data.snapTo==="surface"){if(o.fromPosition.copy(l.point),this.activeEvent.data.snapSurfaceMode==="bbox"){_t.copy(h).applyMatrix3(Gm.setFromMatrix4(o.obj.matrixWorld).transpose());let d=o.obj;_t.x>Ho?ui.x=-d.recursiveBBox.min.x:_t.x<-Ho&&(ui.x=-d.recursiveBBox.max.x),_t.y>Ho?ui.y=-d.recursiveBBox.min.y:_t.y<-Ho&&(ui.y=-d.recursiveBBox.max.y),_t.z>Ho?ui.z=-d.recursiveBBox.min.z:_t.z<-Ho&&(ui.z=-d.recursiveBBox.max.z),ui.applyMatrix3(Gm.invert())}else ui.copy(h).multiplyScalar(this.activeEvent.data.snapSurfaceOffset);o.fromPosition.add(ui)}this.activeEvent.data.autoOrient&&(_t.set(0,1,0).cross(h),_t.length()<1e-4&&_t.set(-1,0,0).cross(h),ui.crossVectors(rS,_t),o.orientationMatrix.makeBasis(_t,ui,h)),o.pointStart.copy(o.fromPosition),o.pointEnd.copy(o.pointStart),o.currentDampingFactor=this.activeEvent.snapDampingFactor,o.snapped=!0,this.lastDropDestination!==l.object&&(this.lastDropDestination=l.object,this.activeEvent.actionsDrop.Transition.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Animation.forEach(d=>{d.play()}),this.activeEvent.actionsDrop.Audio.forEach(d=>{d.dispatchGameControl("start")}),this.activeEvent.actionsDrop.Create.forEach(d=>{d.dispatchThrottled()}))}else o.orientationMatrix.makeRotationFromQuaternion(o.quat0),this.lastDropDestination=null,o.currentDampingFactor=this.activeEvent.data.dampingFactor,this.calcPlaneIntersectPos(o.obj,o.pointEnd,this.activeEvent.data.plane,this.activeEvent.data.referenceFrame),this.activeEvent.actionsDrop.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrop.Animation.forEach(h=>{h.stop()}),this.activeEvent.actionsDrop.Audio.forEach(h=>{h.dispatchGameControl("stop")});this.activeEvent.actionsDrag.Create.forEach(h=>{h.dispatchThrottled()}),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.checkConditions()),this.activeEvent.actionsDrag.SetVariable.forEach(h=>h.dispatch()),this.activeEvent.actionsDrag.DynamicVariablePlay.forEach(h=>h.dispatch()),this.activeEvent.wasDragEventTriggered===!1&&(this.activeEvent.wasDragEventTriggered=!0,this.activeEvent.actionsDrag.Transition.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.play()}),this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("start")})),this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>{!this.activeEvent||(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Audio.forEach(h=>{h.dispatchGameControl("stop")}),this.activeEvent.actionsDrag.Transition.forEach(h=>{h.stop(),h.object.currentState!==null&&h.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(h=>{h.stop()}))},500),this.updateDragItem(o),o.obj.dispatchEvent({type:"requestRender"})}},this.onPointerUp=r=>{if(this.activeEvent&&this.activeEvent.activeDragItem){this.activeEvent.data.cursor==="hand"&&this.setCursor("grab");let s=this.activeEvent.activeDragItem.obj.data.physics?.rigidBody==="dynamic";this.activeEvent.activeDragItem.snapped===!1&&this.activeEvent.data.drop&&this.activeEvent.data.resetOnSnapFail&&(this.eventManager.controlsManager.usePhysics===!1||!s)&&(this.activeEvent.activeDragItem.reset=this.activeEvent.data.resetOnSnapFail,this.activeEvent.activeDragItem.paused=!1,this.activeEvent.activeDragItem.currentDampingFactor=this.activeEvent.resetDampingFactor),this.eventManager.controlsManager.usePhysics&&s&&(this.eventManager.controlsManager.sharedGameControlGlobals.entitiesWithTransformAnim.pop(),this.activeEvent.activeDragItem.obj.rigidBody.setBodyType(0,!0),this.activeEvent.activeDragItem.paused=!0),this.activeEvent.wasDragEventTriggered===!0&&(this.activeEvent.wasDragEventTriggered=!1,this.activeEvent.actionsDrag.Transition.forEach(a=>{a.stop(),a.object.currentState!==null&&a.object.changeSelectedState(null,{scene:this.eventContext.page.scene,shared:this.eventContext.sharedAssets})}),this.activeEvent.actionsDrag.Animation.forEach(a=>{a.stop()}),this.activeEvent.actionsDrag.Audio.forEach(a=>{a.dispatchGameControl("stop")}),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.checkConditions()),this.activeEvent.actionsDrop.SetVariable.forEach(a=>a.dispatch()),this.activeEvent.actionsDrop.DynamicVariablePlay.forEach(a=>a.dispatch())),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0)}};let i={};e.page.traverseEntity(r=>{r.component&&(i[r.component.uuid]?i[r.component.uuid].push(r.uuid):i[r.component.uuid]=[r.uuid])}),e.page.traverseEntity(r=>{r.data?.events.filter(s=>s.data.type==="DragDrop"&&!s.data.disabled).forEach(s=>{this.events.push(new Kq(r,s.data,e.page,e.sharedAssets,t,i))})})}connect(){if(!this.events.length)return;this.domEventsNeeded.clear(),this.domEventsNeeded.add("pointerdown");let e=this.eventContext.domElement;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.domEventsNeeded.add("pointermove")}disconnect(){if(!this.events.length)return;this.domEventsNeeded.clear();let e=this.eventContext.domElement;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),this.events.forEach(t=>t.dispose())}setCursor(e){this.eventContext.domElement.style.cursor=e}onAnimationFrameDamping(){for(let e of this.events)for(let t of e.dragItems)t.paused||this.updateDragItem(t,!0)}calcPlaneIntersectPos(e,t,i,r){let{getCamera:s,raycaster:a}=this.eventContext;s().getWorldDirection(Ga),Ga.negate();let n=Xn.identity();switch(r==="parent"?Qq.multiplyMatrices(e.parent.matrixWorld,e.hiddenMatrix).decompose(_t,n,ui):r==="local"&&e.matrixWorld.decompose(_t,n,ui),i){case"x":_t.set(1,0,0).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"y":_t.set(0,1,0).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"z":_t.set(0,0,1).applyQuaternion(n),Go.copy(Ga).cross(_t),Ps.copy(_t).cross(Go);break;case"xy":Ps.set(0,0,1).applyQuaternion(n);break;case"yz":Ps.set(1,0,0).applyQuaternion(n);break;case"xz":Ps.set(0,1,0).applyQuaternion(n);break;case"adaptive":Ga.angleTo(ui.set(0,1,0))>Math.PI/6?(_t.crossVectors(ui.set(0,1,0),Ga),Ps.crossVectors(_t,ui)):Ps.set(0,1,0);break;default:Ps.copy(Ga);break}On.setFromMatrixPosition(e.matrixWorld);let o=e.userData.lockedPlane?e.userData.worldPosition0:On;if(iS.setFromNormalAndCoplanarPoint(Ps,o),!!a.ray.intersectPlane(iS,t)&&(i==="x"||i==="y"||i==="z")){let l=ui.subVectors(t,o).dot(_t);t.copy(o).addScaledVector(_t,l)}}updateDragItem(e,t=!1){On.setFromMatrixPosition(e.obj.matrixWorld),e.reset==="current"?Uh.subVectors(e.fromPosition,On).divideScalar(e.currentDampingFactor):e.reset==="original"?(Uh.subVectors(e.obj.userData.worldPosition0,On).divideScalar(e.currentDampingFactor),e.fromPosition.copy(e.obj.userData.worldPosition0),e.pointStart.copy(e.fromPosition),e.pointEnd.copy(e.pointStart)):Uh.subVectors(e.pointEnd,e.pointStart).add(e.fromPosition).sub(On).divideScalar(e.currentDampingFactor),e.paused=e.currentDampingFactor>1?Uh.length()<Yq:!0,(this.activeEvent&&this.activeEvent.data.dampingFactor===1||t)&&Zq(e,Uh.add(On),this.activeEvent?.data.drop&&this.activeEvent?.data.autoOrient?e.orientationMatrix:null),e.obj.dispatchEvent({type:"beginEvent",eventName:"DragDrop"}),this.eventManager.requestRender()}},Wo=new E,Wm=new E,la=new E,ha=new E,sS=new Er,$q=.01,eX={type:"requestRender"},tX=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}(),aS=function(){let e=new me;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 yr&&Us(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),iX=class{constructor(e,t,i,r,s){this.data=e,this.object=t,this.paused=!1,this.currentDampingFactor=1,this.snapComplete=!1,this.isReset=!1,this.worldPosition0=new E,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Lg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.resetDampingFactor=80/this.data.resetSpeed+1,this.object.getWorldPosition(this.worldPosition0),this.actions=rr(e,e.actions,i,r,s,t)}},rX=class extends ys{constructor(e,t){super(e),this.events=[],this.pairOfEventListeners=[],this.onMouseMove=r=>{if(!(Xe.length>1)){this.eventContext.updateRaycaster(r);for(let s of this.events)s.target===void 0&&this.updateSingleEvent(s)}},this.onMouseEnter=r=>{for(let s of this.events)s.target===void 0&&(s.isReset=!1,s.currentDampingFactor=s.data.dampingFactor)},this.onMouseLeave=r=>{for(let s of this.events)s.target===void 0&&(s.data.resetOnPointerLeave&&(s.isReset=!0,s.currentDampingFactor=s.resetDampingFactor),this.updateSingleEvent(s))},this.onTargetChange=r=>()=>{this.updateSingleEvent(r)};let{page:i}=this.eventContext;i.traverseEntity(r=>{let s=r.data?.events.find(a=>a.data.type==="Follow"&&!a.data.disabled);s&&(!i.data.globalPhysics.usePhysics||r.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new iX(s.data,r,i,e.sharedAssets,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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(),Pr&&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,Mi(i.actions)}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e,!0)}updateSingleEvent(e,t=!1){this.events.forEach(n=>{n.actions.Create.forEach(o=>{o.dispatchThrottled()})});let{plane:i,limitDistance:r,limitDistanceEnabled:s}=e.data;if(e.object.getWorldPosition(la),e.isReset)ha.copy(e.worldPosition0);else if(e.target)e.target.getWorldPosition(ha);else{let{getCamera:n,raycaster:o}=this.eventContext;if(i==="custom"?(n().getWorldDirection(Wm),Wm.negate(),Wo.copy(Wm)):i==="xy"?Wo.set(0,0,1):i==="xz"?Wo.set(0,1,0):i==="yz"&&Wo.set(1,0,0),sS.setFromNormalAndCoplanarPoint(Wo,la),!o.ray.intersectPlane(sS,ha))return}if(!e.isReset){if(ha.distanceTo(e.worldPosition0)>r&&s&&e.target)if(e.snapComplete=!1,e.data.snapDelay&&(e.delayFinished=!1,typeof window<"u"&&e.timeoutId!==null&&(window.clearTimeout(e.timeoutId),e.timeoutId=null)),e.wasOutside=!0,e.data.resetAfterDistanceLimit)ha.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&&(ha.x=la.x),e.data.enabledTranslation[1]===!1&&(ha.y=la.y),e.data.enabledTranslation[2]===!1&&(ha.z=la.z);let a=tX(la,ha,e.wasOutside?0:e.data.maxDelta);if(e.currentDampingFactor>1){let n=Wo.subVectors(a,la).divideScalar(e.currentDampingFactor);la.add(n),t&&aS(e.object,la),e.paused=n.length()<$q}else aS(e.object,a),e.paused=!0;e.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),e.object.dispatchEvent(eX)}},Fh=new E,ou=new E,Vh=new me,qo=new it,Ha=new it,jh=new E,Gh=new E,Ln=new E,ca=new E,qm=new Er,sX=1e-6,aX={type:"requestRender"},nX={type:"changeRotation"},nS=function(){let e=new me;return function(t,i){t.parent!==null?e.multiplyMatrices(t.parent.matrixWorld,t.hiddenMatrix):e.copy(t.hiddenMatrix),i.premultiply(YE(e).invert()),t.rotation.setFromRotationMatrix(i),t.updateMatrix(),t instanceof yr&&Us(t.parent)&&t.invalidateDownstreamBooleanData(!0)}}(),oX=class{constructor(e,t,i){this.object=t,this.paused=!1,this.currentDampingFactor=1,this.isReset=!1,this.worldQuaternion0=new it,this.timeoutId=null,this.delayFinished=!0,this.wasOutside=!1,this.data={...Rg.defaultData,...e,...e.resetOnPointerLeave===void 0&&{resetOnPointerLeave:!1}},e.target===void 0||e.target==="cursor"||(this.target=i.find(e.target)),this.data.dampingFactor&&(this.currentDampingFactor=this.data.dampingFactor),this.object.getWorldQuaternion(this.worldQuaternion0),this.resetDampingFactor=80/this.data.resetSpeed+1}},lX=class extends ys{constructor(e){super(e),this.events=[],this.pairOfEventListeners=[],this.pairOfUserEventListeners=[],this.onMouseMove=i=>{if(!(Xe.length>1)){this._lastMouseEvent=i,this.eventContext.updateRaycaster(i);for(let r of this.events)r.target===void 0&&this.updateSingleEvent(r)}},this.onMouseEnter=i=>{for(let r of this.events)r.target===void 0&&(r.isReset=!1,r.currentDampingFactor=r.data.dampingFactor)},this.onMouseLeave=i=>{for(let r of this.events)r.target===void 0&&(r.data.resetOnPointerLeave&&(r.isReset=!0,r.currentDampingFactor=r.resetDampingFactor),this.updateSingleEvent(r))},this.onScroll=i=>{if(this._lastMouseEvent){let r=new PointerEvent("pointermove",{clientX:this._lastMouseEvent.clientX,clientY:this._lastMouseEvent.clientY,bubbles:!0,cancelable:!0,view:window});this.eventContext.eventElement.dispatchEvent(r)}},this.onTargetChange=i=>()=>{this.updateSingleEvent(i)},this.createUserEventListener=i=>({eventName:r,target:s})=>{if(!r||!s)return;let a=Gc(r);a&&a==="LookAt"&&this.updateSingleEvent(i)};let{page:t}=this.eventContext;t.traverseEntity(i=>{let r=i.data?.events.find(s=>s.data.type==="LookAt"&&!s.data.disabled);r&&(!t.data.globalPhysics.usePhysics||i.dataPatched.physics?.rigidBody!=="dynamic")&&this.events.push(new oX(r.data,i,t))})}connect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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 a=this.onTargetChange(i),n=i.target;this.pairOfEventListeners.push([n,a]),n.addEventListener("requestRender",a)}let r=this.createUserEventListener(i),s=i.object;this.pairOfUserEventListeners.push([s,r]),s.addEventListener("userEvent",r)}}disconnect(){if(!this.events.length)return;let{domElement:e,eventElement:t}=this.eventContext;this.domEventsNeeded.clear(),Pr&&e.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove),e.removeEventListener("pointerenter",this.onMouseEnter),e.removeEventListener("pointerleave",this.onMouseLeave),t.removeEventListener("scroll",this.onScroll);for(let[i,r]of this.pairOfEventListeners)i.removeEventListener("requestRender",r);for(let[i,r]of this.pairOfUserEventListeners)i.removeEventListener("userEvent",r);for(let i of this.events)i.paused=!0,i.isReset=!1}onAnimationFrameDamping(){for(let e of this.events)e.paused||this.updateSingleEvent(e)}updateSingleEvent(e){let{tilt:t,axis:i,distance:r,plane:s,limitDistance:a,enabledRotation:n,limitDistanceEnabled:o}=e.data,{getCamera:l,raycaster:h}=this.eventContext,{object:d,target:c}=e;if(d.getWorldPosition(jh),!e.isReset)if(e.target)e.target.getWorldPosition(Gh);else{if(s==="custom"?(l().getWorldDirection(ou),ou.negate(),qm.setFromNormalAndCoplanarPoint(ou,jh)):(s==="xy"?Fh.set(0,0,1):s==="xz"?Fh.set(0,1,0):s==="yz"&&Fh.set(1,0,0),qm.setFromNormalAndCoplanarPoint(Fh,jh)),!h.ray.intersectPlane(qm,Gh))return;r>0&&(s==="custom"||s===void 0)&&Gh.addScaledVector(ou,r)}if(e.isReset||(c?t==="target"?Ln.copy(c.up).applyMatrix4(Vh.extractRotation(c.matrixWorld)).normalize():n.some(u=>u===!1)?(i==="x"?(ca.set(0,0,1),n[2]===!1&&ca.set(0,1,0)):i==="y"?(ca.set(1,0,0),n[0]===!1&&ca.set(0,0,1)):(ca.set(0,1,0),n[1]===!1&&ca.set(1,0,0)),Ln.copy(ca).applyQuaternion(e.worldQuaternion0).normalize()):Ln.set(0,1,0):s==="custom"?Ln.set(0,1,0):Ln.copy(Fh)),e.isReset)Ha.copy(e.worldQuaternion0);else if(jh.distanceTo(Gh)>a&&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)Ha.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;hX(Vh,Gh,jh,Ln,i,ca),Ha.setFromRotationMatrix(Vh),qo.setFromUnitVectors(ca.applyQuaternion(Ha),Ln),n.some(u=>u===!1)&&t!=="target"&&Ha.premultiply(qo).normalize()}e.currentDampingFactor>1?(d.updateWorldMatrix(!0,!1),qo.setFromRotationMatrix(YE(d.matrixWorld)),qo.slerp(Ha,1/e.currentDampingFactor),nS(d,Vh.makeRotationFromQuaternion(qo)),e.paused=8*(1-qo.dot(Ha))<sX):(nS(d,Vh.makeRotationFromQuaternion(Ha)),e.paused=!0),e.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),d.dispatchEvent(aX),d.dispatchEvent(nX)}},Nr=new E,di=new E,Zt=new E;function hX(e,t,i,r,s,a){let n=e.elements;Zt.subVectors(t,i),Zt.lengthSq()===0&&(Zt.z=1),Zt.normalize(),di.crossVectors(r,Zt),di.lengthSq()===0&&(Math.abs(r.z)===1?Zt.x+=1e-4:Zt.z+=1e-4,Zt.normalize(),di.crossVectors(r,Zt)),di.normalize(),Nr.crossVectors(Zt,di),s==="x"?a.z===1?[di,Nr,Zt]=[Zt,di,Nr]:(di.negate(),[di,Zt]=[Zt,di]):s==="y"?a.x===1?[di,Nr,Zt]=[Nr,Zt,di]:(di.negate(),[Nr,Zt]=[Zt,Nr]):a.x===1&&(di.negate(),[di,Nr]=[Nr,di]),n[0]=di.x,n[4]=Nr.x,n[8]=Zt.x,n[1]=di.y,n[5]=Nr.y,n[9]=Zt.y,n[2]=di.z,n[6]=Nr.z,n[10]=Zt.z}var cX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.entered=!1,this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatchEnter(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.playFromCurrent()),this.actions.Animation.forEach(e=>e.play()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.SwitchCamera.forEach(e=>e.playFromCurrent()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()))}dispatchLeave(){this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.reverseFromCurrent()),this.actions.SwitchCamera.forEach(e=>e.reverseFromCurrent()))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},dX=class extends ys{constructor(e,t){super(e),this.eventsPerObjects={},this.objects=[],this._prevObjects=[],this.onMouseDown=s=>{Xe.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onMouseUp=s=>{Xe.length>1||this.handleMouseHoverEvent(!0)},this.onMouseMove=s=>{Xe.length>1||(this.eventContext.updateRaycaster(s),this.handleMouseHoverEvent())},this.onUserEvent=({eventName:s,target:a,reverse:n})=>{if(!s||!a)return;let o=Gc(s);o&&o==="MouseHover"&&(a.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[a.uuid]?.forEach(l=>l.dispatchUserEvent(n)))};let{page:i,sharedAssets:r}=this.eventContext;i.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{id:a,data:n}of s.data.events)if(!n.disabled&&n.type==="MouseHover")try{let o=new cX(a,n,s,i,r,t);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(o):this.eventsPerObjects[s.uuid]=[o]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:e}=this.eventContext;this.domEventsNeeded.clear(),Pr&&(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(),Pr&&(e.removeEventListener("pointerdown",this.onMouseDown),e.removeEventListener("pointerup",this.onMouseUp)),e.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(t=>{t.forEach(i=>{i.disconnect()})}),this.objects.forEach(t=>{t.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(e=!1){let t=[];if(!e){let{stopRaycast:i,raycaster:r,page:s}=this.eventContext;if(i){let a=_u(r,s,this.objects);t=Vv(a)}else this.objects.forEach(a=>{vp(r,a)&&t.push(a)})}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}},uX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.scrollCounter=0,this.actions=rr(t,t.actions,r,s,a,i)}connect(){this.scrollCounter=0}disconnect(){Mi(this.actions)}dispatch(e){this.actions.Transition.forEach(r=>{r.object.currentTransitionEvent!==this&&(r.object.currentTransitionEvent=this,r.init())});let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(r=>r.seek(i)),this.actions.Animation.forEach(r=>r.seek(t)),this.actions.Create.forEach(r=>r.dispatchThrottled()),this.actions.SetVariable.forEach(r=>r.checkConditions()),this.actions.SetVariable.forEach(r=>r.dispatch()),this.actions.DynamicVariablePlay.forEach(r=>r.dispatch())}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},pX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.object=i,this.domElement=a,this.eventManager=n,this.scrollStart=0,this.scrollEnd=0,this.actions=rr(t,t.actions,r,s,n,i)}computeScrollBounds(){let e=this.domElement.getBoundingClientRect(),t=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||t.scrollTop,s=i.clientTop||t.clientTop||0,a=Math.round(e.top+r-s);if(this.data.startFrom==="enter"){let n=window.innerHeight,o=e.height,l=this.data.enterAnchor,h=l==="top"?n:l==="bottom"?n-o:n-o*.5;this.scrollStart=a-h}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=e,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){Mi(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return this.box===void 0||this.box.width===0&&this.box.height===0&&this.box.top===0&&this.box.bottom===0}computeScroll({x:e,y:t}){this.actions.Transition.forEach(s=>{s.object.currentTransitionEvent!==this&&(s.object.currentTransitionEvent=this,s.init())});let i=this.scrollEnd-this.scrollStart,r=Math.min(1,Math.max(0,(t-this.scrollStart)/i));this.actions.Transition.forEach(s=>s.seek(r)),this.actions.Animation.forEach(s=>s.seek(r)),this.actions.Create.forEach(s=>s.dispatchThrottled()),this.actions.SetVariable.forEach(s=>s.checkConditions()),this.actions.SetVariable.forEach(s=>s.dispatch()),this.actions.DynamicVariablePlay.forEach(s=>s.dispatch())}dispatch(e){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(e)}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch())}},fX=class extends ys{constructor(e,t){super(e),this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([n,o])=>{o.forEach(l=>l.handleResize())})},this.onScroll=n=>{if(!this.isInview)return;let o={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([l,h])=>{l.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:o}),h.forEach(d=>d.dispatch(o))})},this.onWheel=n=>{!this.isInview||n.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([o,l])=>{o.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:n.deltaY}),l.forEach(h=>h.dispatch(n.deltaY))})},this.onUserEvent=({eventName:n,target:o,reverse:l})=>{if(!n||!o)return;let h=Gc(n);h&&h==="Scroll"&&(o.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(o)?.forEach(d=>{d.dispatchUserEvent(l)}))};let{page:i,sharedAssets:r,domElement:s,isExport:a}=this.eventContext;i.traverseEntity(n=>{if(n.data?.events.length){for(let{id:o,data:l}of n.data.events)if(!l.disabled&&l.type==="Scroll")if(l.trigger==="load"||!a){let h=new uX(o,l,n,i,r,t);this.wheelEventsPerObject.has(n)?this.wheelEventsPerObject.get(n)?.push(h):this.wheelEventsPerObject.set(n,[h])}else{let h=new pX(o,l,n,i,r,s,t);this.scrollEventsPerObject.has(n)?this.scrollEventsPerObject.get(n)?.push(h):this.scrollEventsPerObject.set(n,[h])}}}),this.intersectionObserver=new IntersectionObserver(n=>{let o=n[0];o&&(this.isInview=o.isIntersecting)},{root:null})}connect(){this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.connect()),e.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(e=>e.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([e,t])=>{t.forEach(i=>i.disconnect()),e.removeEventListener("userEvent",this.onUserEvent)})}},mX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=rr(t,t.actions,r,s,a,i)}disconnect(){Mi(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()}),this.actions.Animation.forEach(e=>{e.play()}),this.actions.SwitchCamera.forEach(e=>{e.play()}),this.actions.SceneTransition.forEach(e=>{e.dispatch()}),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch()),this.actions.Create.forEach(e=>{e.dispatchFromStart()}),this.actions.Destroy.forEach(e=>{e.dispatchFromStart()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof qn?t.interaction.audioPlayer.play():t.interaction instanceof Bv&&t.interaction.dispatch())}),this.actions.Video.forEach(t=>{let i=t.interaction.data.triggerAfter??"autoplay";i===e&&(t.interaction instanceof El?t.interaction.play(i==="autoplay"):t.interaction instanceof Uv&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),e?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>t.playFromCurrent()),this.actions.Animation.forEach(t=>t.playFromCurrent()),this.actions.SwitchCamera.forEach(t=>t.playFromCurrent())),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.interaction instanceof qn?t.interaction.audioPlayer.play():t.interaction instanceof Bv&&t.interaction.dispatch()}),this.actions.Video.forEach(t=>{t.interaction instanceof El?t.interaction.play():t.interaction instanceof Uv&&t.interaction.dispatch()})}},gX=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.eventsPerObject=new Map,this.eventsAfterPerObject=new Map,this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("mouseDown")})})},this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("keyDown")})})},this.onAny=()=>{let{domElement:i,isExport:r}=this.eventContext;(r?document:i).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,a])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),a.forEach(n=>{n.dispatchAfter("any")})})},this.onSceneTransitionAudioVideoPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.actions.Audio.forEach(a=>{a.interaction instanceof qn&&a.interaction.audioPlayer.play()}),s.actions.Video.forEach(a=>{let n=a.interaction.data.triggerAfter??"autoplay";a.interaction instanceof El&&a.interaction.play(n==="autoplay")})})})},this.onPlay=()=>{[...this.eventsAfterPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>{s.dispatchAfter("autoplay")})})},this.onUserEvent=({eventName:i,target:r,reverse:s})=>{if(!i||!r)return;let a=Gc(i);a&&a==="Start"&&(r.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}),this.eventsAfterPerObject.get(r)?.forEach(n=>{n.dispatchUserEvent(s)}))}}connect(){let{sharedAssets:e,page:t}=this.eventContext;if(t.traverseEntity(i=>{if(i.data?.events.length)for(let{id:r,data:s}of i.data.events){if(s.disabled||s.type!=="Start")continue;let a=new mX(r,s,i,t,e,this.eventManager);(a.actions.Transition.length||a.actions.Animation.length||a.actions.SwitchCamera.length||a.actions.Create.length||a.actions.Destroy.length||a.actions.SceneTransition.length||a.actions.SetVariable.length||a.actions.DynamicVariablePlay.length)&&(this.eventsPerObject.has(i)?this.eventsPerObject.get(i)?.push(a):this.eventsPerObject.set(i,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a])),a.actions.Video.length&&(this.hasVideoAction=!0,this.eventsAfterPerObject.has(i)?this.eventsAfterPerObject.get(i)?.push(a):this.eventsAfterPerObject.set(i,[a]))}}),[...this.eventsAfterPerObject.values()].some(i=>i.length)){if(this.eventManager.activateCount===0){let{domElement:i,isExport:r}=this.eventContext,s=r?document:i;s.addEventListener("pointerdown",this.onMouseDown,{once:!0}),s.addEventListener("mousedown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),s.addEventListener("pointerdown",this.onAny),s.addEventListener("mousedown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([a,n])=>{a.addEventListener("userEvent",this.onUserEvent)})}else this.onSceneTransitionAudioVideoPlay();this.onPlay()}[...this.eventsPerObject.entries()].forEach(([i,r])=>{i.dispatchEvent({type:"beginEvent",eventName:"Start"}),r.forEach(s=>s.dispatch()),i.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(e=>e.length)){let{domElement:e,isExport:t}=this.eventContext,i=t?document:e;i.removeEventListener("pointerdown",this.onMouseDown),i.removeEventListener("mousedown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),i.removeEventListener("mousedown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([r,s])=>{r.removeEventListener("userEvent",this.onUserEvent),s.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([e,t])=>{e.removeEventListener("userEvent",this.onUserEvent),t.forEach(i=>i.disconnect())}),this.eventsPerObject.clear(),this.eventsAfterPerObject.clear()}},vX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.disabled=!1,this.alreadyPlayedNonTogglingActions=new Set,this.actions=rr(t,t.actions,r,s,a,i),this.target=t.target,this.useToggle=t.runMode==="Toggle"}disconnect(){Mi(this.actions)}dispatch(e){this.disabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this?(t.object.currentTransitionEvent=this,t.init()):this.data.runMode==="Once"&&this.alreadyPlayedNonTogglingActions.add(t)}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.actions.Transition.forEach(t=>{t.toggle()}),this.actions.Animation.forEach(t=>{t.toggle()})):(this.actions.Transition.forEach(t=>{this.alreadyPlayedNonTogglingActions.has(t)===!1&&t.play()}),this.actions.Animation.forEach(t=>{t.play()})),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(e??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}))}},yX=class extends ys{constructor(e,t,i,r,s){super(e),this.sharedVariables=t,this.eventManager=i,this.needsMouse=r,this.needsRaycast=s,this.dynamicVars=[],this.variablesToWatch=[],this.prevMouseProperty=null,this.prevRaycastProperty=null,this.pauseTime=0,this.events=[],this.onFrame=a=>{this.rafId=window.requestAnimationFrame(this.onFrame);let n=new Date,o=[],l=[];for(let c=0;c<this.propertiesToWatch.length;c++){let{objectId:u,property:p,prevValue:f}=this.propertiesToWatch[c],m=this.eventContext.scene.find(u),g=zg.propertyPaths[p];if(g[0]==="width"||g[0]==="height"||g[0]==="depth")m=m.geometry.userData.parameters[g[0]];else for(let v=0;v<g.length;v++)m=m[g[v]];f===null?this.propertiesToWatch[c].prevValue=m instanceof E?m.clone():m:(m instanceof E?!m.equals(f):f!==m)&&(l.push({objId:u,property:p}),m instanceof E?this.propertiesToWatch[c].prevValue.copy(m):this.propertiesToWatch[c].prevValue=m)}for(let c=0;c<this.variablesToWatch.length;c++){let{id:u,prevValue:p}=this.variablesToWatch[c],f=this.shared.getVariable(u);f!==p&&(o.push(u),this.variablesToWatch[c].prevValue=f)}for(let c=0;c<this.dynamicVars.length;c++){let{id:u,expectedTime:p,last:f,data:m,timerSeconds:g,startValue:v}=this.dynamicVars[c],y=1e3;if((m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&m.format==="number3decimal"?y=1:m.dynamicVariableType==="counter"?y=m.updateInterval:m.dynamicVariableType==="random"&&(y=m.isStatic?1/0:m.updateInterval),p===-1){this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y;continue}if(!((this.shared.getDynamicVariablePlayState(u)==="Stopped"||this.shared.getDynamicVariablePlayState(u)==="Restarted")&&(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime=a+y,m.dynamicVariableType==="counter"&&this.shared.getVariable(u)!==v&&(this.shared.updateVariable(u,v),this.eventManager.requestRender()),(m.dynamicVariableType==="timer"||m.dynamicVariableType==="stopwatch")&&this.dynamicVars[c].timerSeconds!==v&&(this.dynamicVars[c].timerSeconds=v,this.shared.updateVariable(u,ns.getFormattedTimerTime(v,m)),this.eventManager.requestRender()),this.shared.getDynamicVariablePlayState(u)==="Restarted"&&this.shared.setDynamicVariablePlayState(u,"Playing"),this.shared.getDynamicVariablePlayState(u)==="Stopped"))){if(this.shared.getDynamicVariablePlayState(u)==="Paused"){this.dynamicVars[c].deltaToExpectedTime===void 0&&(this.dynamicVars[c].deltaToExpectedTime=Math.max(this.dynamicVars[c].expectedTime-a,0)),this.dynamicVars[c].last=a-(y-this.dynamicVars[c].deltaToExpectedTime),this.dynamicVars[c].expectedTime=a+this.dynamicVars[c].deltaToExpectedTime;continue}else this.dynamicVars[c].deltaToExpectedTime=void 0;if(a>=p)if(this.dynamicVars[c].last=a,this.dynamicVars[c].expectedTime+=y,m.dynamicVariableType==="random"){let x=m.min+Math.random()*(m.max-m.min),b=m.decimals;x=Math.round(x*Math.pow(10,b))/Math.pow(10,b),this.shared.updateVariable(u,x),o.push(u),this.eventManager.requestRender()}else if(m.dynamicVariableType==="counter"){if(m.increment===0)continue;let x=this.shared.getVariable(u),b=this.shared.getDynamicVariableToggleIsForward(u)??!0,w=this.shared.getVariable(u)+m.increment*(b?1:-1);m.hasEnd&&(w=m.increment>0?Re.clamp(w,v,m.endValue):Re.clamp(w,m.endValue,v),w===v&&this.shared.setDynamicVariableToggleIsForward(u,void 0),m.repeat?w===m.endValue&&(w=v):(w===v||w===m.endValue)&&this.shared.setDynamicVariablePlayState(u,"Paused")),w!==x&&(o.push(u),this.shared.updateVariable(u,w),this.eventManager.requestRender())}else if(m.dynamicVariableType==="time")this.shared.updateVariable(u,Vw(n,m)),o.push(u),this.eventManager.requestRender();else{let x=Dr.isTextValue(m.endValue)?oS(m.endValue.textValue):m.endValue,b=this.shared.getDynamicVariableToggleIsForward(u)??!0,w=g+(a-f)/1e3*(m.dynamicVariableType==="timer"?-1:1)*(b?1:-1);w=Math.max(w,0),m.hasEnd&&(w=m.dynamicVariableType==="stopwatch"?Re.clamp(w,v,x):Re.clamp(w,x,v),w===v&&this.shared.setDynamicVariableToggleIsForward(u,void 0),m.repeat?Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1)&&(w=v):(Math.abs(w-v)<(m.format==="number3decimal"?1e-4:.1)||Math.abs(w-x)<(m.format==="number3decimal"?1e-4:.1))&&this.shared.setDynamicVariablePlayState(u,"Paused")),w!==g&&(o.push(u),this.dynamicVars[c].timerSeconds=w,this.shared.updateVariable(u,ns.getFormattedTimerTime(w,m)),this.eventManager.requestRender())}}}this.needsMouse&&this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,this.events.forEach(c=>{c.data.variableId==="mouseProperty"&&(c.dispatch(),this.eventManager.requestRender())}));let h=!1;this.shared.mouseProperty!==this.prevMouseProperty&&(this.prevMouseProperty=this.shared.mouseProperty,h=!0);let d=!1;this.shared.raycastProperty!==this.prevRaycastProperty&&(this.prevRaycastProperty=this.shared.raycastProperty,d=!0),this.events.forEach(c=>{(o.includes(c.data.variableId)||l.find(u=>u.objId===c.data.objectId&&u.property===c.data.property)||c.data.variableId==="mouseProperty"&&h||c.data.variableId==="raycastProperty"&&d)&&(c.dispatch(),this.eventManager.requestRender())})},this.onBlur=()=>{this.pause()},this.onFocus=()=>{this.resume()},e.page.traverseEntity(a=>{a.data?.events.filter(n=>n.data.type==="VariableChange"&&!n.data.disabled).forEach(n=>{this.events.push(new xX(a.uuid,n.data,a,e.page,e.sharedAssets,i))})}),this.propertiesToWatch=this.events.filter(a=>a.data.variableId==="objectProperty"&&a.data.objectId!==null).map(a=>({objectId:a.data.objectId,property:a.data.property,prevValue:null})),this.shared=e.sharedAssets,this.sharedVariables.forEach(({id:a,data:n})=>{if(!("dynamicVariableType"in n)){this.events.find(l=>l.data.variableId===a)&&this.variablesToWatch.push({id:a,prevValue:this.shared.getVariable(a)});return}let o;if(n.dynamicVariableType==="timer"||n.dynamicVariableType==="stopwatch"){let l;if(Dr.isTextValue(n.value)&&Array.isArray(n.value.textValue)){let h=n.value.textValue;h.length===3?l=h[2]+h[1]*60+h[0]*3600:l=h[1]+h[0]*60}else l=n.value;o=l,this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,timerSeconds:l,startValue:o})}else n.dynamicVariableType==="time"&&this.shared.updateVariable(a,Vw(new Date,n)),n.dynamicVariableType==="counter"&&(o=Dr.isTextValue(n.value)?oS(n.value.textValue):n.value),this.dynamicVars.push({id:a,last:-1,expectedTime:-1,data:n,startValue:o})})}pause(){this.pauseTime=Date.now()}resume(){let e=Date.now()-this.pauseTime;for(let t=0;t<this.dynamicVars.length;t++)this.dynamicVars[t].last+=e,this.dynamicVars[t].expectedTime+=e}connect(){this.rafId=window.requestAnimationFrame(this.onFrame),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus)}disconnect(){window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=void 0),this.events.forEach(e=>e.dispose())}},xX=class{constructor(e,t,i,r,s,a){this.id=e,this.data=t,this.object=i,this.actions=rr(t,t.actions,r,s,a,i)}dispatch(){let e=this.actions;e.Audio.forEach(t=>t.dispatchConditional()),e.Video.forEach(t=>t.dispatchConditional()),e.Create.forEach(t=>t.dispatch()),e.Destroy.forEach(t=>t.dispatch()),e.Reset.forEach(t=>t.dispatch()),e.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this),t.init()}),e.Transition.forEach(t=>t.play()),e.Animation.forEach(t=>t.play()),e.SwitchCamera.forEach(t=>t.play()),e.SceneTransition.forEach(t=>t.dispatch()),e.SetVariable.forEach(t=>t.checkConditions()),e.SetVariable.forEach(t=>t.dispatch()),e.DynamicVariablePlay.forEach(t=>t.dispatch())}dispose(){Mi(this.actions)}};function oS(e){return e.length===3?e[2]+e[1]*60+e[0]*3600:e[1]+e[0]*60}var bX="https://unpkg.com/@splinetool/runtime@0.9.497/build/",wX="https://unpkg.com/@splinetool/navmesh-wasm@0.9.497/build/",_X=`
6240
6240
  (async function() {
6241
6241
  const [wasmImport, wasmBinary] = await Promise.all([
6242
6242
  import('${bX}' + 'navmesh.js'),
@@ -6302,7 +6302,7 @@ onmessage = function(messageEvent) {
6302
6302
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
6303
6303
  </svg>
6304
6304
  `),_.addEventListener("pointerdown",()=>{this.gameControl.movementState.jump=1,this.requestRender()}),_.addEventListener("touchend",C=>C.preventDefault()),this.joysticks[p]=[void 0,f];return}let A={zone:f,mode:"static",position:x,size:m};v==="hide"&&(A.restOpacity=0);let S=aW.create(A);S.on("move",(_,M)=>{let C=this.gameControl;u==="pos"?M.force<.2?C.moveForce=0:(C.movementState.movePosZ=Math.sin(-M.angle.radian),C.movementState.movePosX=Math.cos(-M.angle.radian),M.force>1.2?C.movementState.run=1:C.movementState.run=0,M.force<.3?C.moveForce=(M.force-.2)/.1:C.moveForce=1):u==="rot"&&(M.force<.2?C.rotForce=0:(C.movementState.rotPosX=M.vector.y,C.movementState.rotPosY=-M.vector.x,M.force<.3?C.rotForce=(M.force-.2)/.1:C.rotForce=1)),this.requestRender()}),S.on("end",(_,M)=>{let C=this.gameControl;u==="pos"?(C.movementState.movePosZ=0,C.movementState.movePosX=0,C.moveForce=1):u==="rot"&&(C.movementState.rotPosX=0,C.movementState.rotPosY=0,C.rotForce=1)}),this.joysticks[p]=[S,f]}),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(u=>u.disabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new pt.World(new pt.Vector3(0,this.gravity,0)),this.events=new pt.EventQueue(!0);let e=[],t=[];if(this.page.traverseChildren(n=>{let o;if(n instanceof ds)if(n.objectForSample){if(n.objectForSample.dataPatched.physics.fusedBody)return;o=n.object}else return n.object.dataPatched.physics.fusedBody===!0&&n.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(n instanceof Ui)o=n.object;else if(o=n,o.dataPatched.cloner?.disabled===!1&&o.dataPatched.cloner?.hideBase&&o.dataPatched.physics?.fusedBody!==!0)return!0;let l=o.dataPatched,h;for(let g of l.events)g.data.disabled!==!0&&g.data.type==="GameControl"&&(h=g.data);if(!l.physics||(l.physics.enabled==="visibility"?!l.visible:!l.physics.enabled))return!0;n.updateMatrixWorldSVD();let d=yp(l),c=!1,u=o.userData.hasDestroy,p=o.userData.hasDrag,f=!1;for(let g of l.events)if(g.data.disabled!==!0){if(g.data.type==="Collision"){c=!0;let v=new vX(g.id,g.data,o,this.page,this.sharedAssets,this.eventManager);v.disabled=!0,this.collisionEvents.push(v),this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].every(y=>y.id!==g.id)?this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid].push(v):this.sharedGameControlGlobals.entityToCollisionEvents[o.uuid]=[v]}else if(g.data.type==="Follow"){f=!0;let v=g.data.target;n.traverseVisible(y=>{y.userData.isFollowingObj=v})}}l.physics.rigidBody==="dynamic"&&l.physics.fusedBody===!1&&(n.matrixWorldFusedFalse=n.matrixWorld.clone());let m=n.geometry;if(h!==void 0){let g=pt.RigidBodyDesc.kinematicPositionBased();(n.hasNonUniformScale?n.matrixWorldRigid:n.matrixWorld).decompose(si,ss,Wa),n.position0=si.clone().divideScalar(this.pixelsPerMeter),n.rotation0=ss.clone(),si.divideScalar(this.pixelsPerMeter),g.setTranslation(si.x,si.y,si.z).setRotation(ss);let v=this.sharedGameControlGlobals.rapierWorld.createRigidBody(g);n.rigidBody=v;let y;h.collider.type==="sphere"?y=pt.ColliderDesc.ball(h.collider.radius/this.pixelsPerMeter):h.collider.type==="capsule"?y=pt.ColliderDesc.capsule((h.collider.height/2-h.collider.radius)/this.pixelsPerMeter,h.collider.radius/this.pixelsPerMeter):y=pt.ColliderDesc.cuboid(h.collider.width/this.pixelsPerMeter/2,h.collider.height/this.pixelsPerMeter/2,h.collider.depth/this.pixelsPerMeter/2),y.setFrictionCombineRule(pt.CoefficientCombineRule.Average).setRestitutionCombineRule(pt.CoefficientCombineRule.Average).setDensity(l.physics.density).setFriction(l.physics.friction).setRestitution(l.physics.restitution);let x=this.sharedGameControlGlobals.rapierWorld.createCollider(y,v);this.sharedGameControlGlobals.colliderToEntity.set(x.handle,o),si.fromArray(h.collider.position).multiply(Wa.setFromMatrixScale(o.matrixWorld)).divideScalar(this.pixelsPerMeter),x.setTranslationWrtParent(si);let b=new it().setFromEuler(new _i().setFromVector3(new E().fromArray(h.collider.rotation)));x.setRotationWrtParent(b),x.setActiveEvents(pt.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(o,!0)}else l.physics.rigidBody==="dynamic"||d||f||u||p||c?(this.addRigidBody(n,o,{hasFollow:f,hasTransformAnim:d,hasDrag:p}),this.generateSensorColliderDescs(o,l.physics.fusedBody)):(m&&e.push(ya(m,n.matrixWorld)),l.physics.fusedBody&&n.traverseObject((g,v)=>{if(v===0)return;let y;if(g instanceof ds)if(g.objectForSample){if(g.objectForSample.dataPatched.physics.fusedBody)return;y=g.object}else return g.object.dataPatched.physics.fusedBody===!0&&g.object.dataPatched.physics.rigidBody==="dynamic"?!0:void 0;else if(g instanceof Ui)y=g.object;else if(y=g,y.dataPatched.cloner?.hideBase)return!0;let x=y.dataPatched;if(x.physics.enabled==="visibility"?!x.visible:!x.physics.enabled)return!0;let b=g.geometry;b?.getAttribute("position")!==void 0&&e.push(ya(b,g.matrixWorld))}),this.generateSensorColliderDescs(o,l.physics.fusedBody,t));if(l.physics?.fusedBody===!0||h)return!0}),e.length===0)return;let i=Hn(e);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let r=pt.RigidBodyDesc.fixed(),s=this.sharedGameControlGlobals.rapierWorld.createRigidBody(r),a=pt.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(pt.CoefficientCombineRule.Multiply).setRestitutionCombineRule(pt.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,s);for(let[n,o]of t){let l=this.sharedGameControlGlobals.rapierWorld.createCollider(n,s);this.sensorToTriggerEvent[l.handle]=o}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(e=>{for(let t of e.dataPatched.events)if(t.data.type==="Trigger"&&t.data.disabled!==!0){let i=new pS(t.id,t.data,e,this.page,this.sharedAssets,this.eventManager),r=new me().compose(as.fromArray(t.data.position),Qo.setFromEuler(fS.fromArray(t.data.rotation)),Jm);if(t.data.triggerZone==="box"){let s=new $t;s.min.fromArray(t.data.size).multiplyScalar(-.5),s.max.fromArray(t.data.size).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([s,r,e,i])}else this.sharedGameControlGlobals.triggers.push([t.data.radius,r,e,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(e=>e.disconnect()),this.sharedGameControlGlobals.triggers.forEach(e=>e[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(e=>{let t=e;t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0),t.position0&&(t.position0=void 0),t.rotation0&&(t.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let e of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(e,t,i){if(!this.isEnabled)return!0;let r=!0;if(this.orbitControls!==void 0&&this.orbitControls.needsUpdate&&(r=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,r=!1):this.initializationCounter===2&&this.gameControl&&(r=!this.gameControl.update(e,t,i)&&r),this.usePhysics===!1&&this.checkTrigger(),this.usePhysics){let s=.016666666666666666;if(e===0)r=this.stepPhysics()&&r;else{let a=e/1e3;a<s&&a>s*.55&&(a=s),this.accumulator+=a;let n=performance.now(),o=0,l=6;for(;this.accumulator>=s&&o<l&&(r=this.stepPhysics()&&r,this.accumulator-=s,o++,!(performance.now()-n>s*1e3)););this.accumulator=this.accumulator%s}}return r}stepPhysics(){for(let e of this.sharedGameControlGlobals.entitiesWithTransformAnim){(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).decompose(si,ss,Wa),Zm.setFromQuaternion(ss);let t=e;t.prevR===void 0?(t.prevR=Zm.clone(),t.prevT=si.clone()):(t.prevR.copy(Zm),t.prevT.copy(si)),e.rigidBody&&(e.rigidBody.setNextKinematicTranslation(si.divideScalar(this.pixelsPerMeter)),e.rigidBody.setNextKinematicRotation(ss))}return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(e,t,i){let r=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent,s;if(t.cloner){for(let a of t.cloner.children)if(a.rigidBody===r){s=a;break}}e.dispatch(s),t.dispatchEvent(jv)}updateUseWindowEvents(e){this.orbitControls?.updateUseWindowEvents(e)}generateSensorColliderDescs(e,t,i){let r=mS.copy(e.matrixWorld).invert();e.traverseEntity((s,a)=>{if(t===!1&&a===1)return!0;for(let n of s.dataPatched.events)if(n.data.type==="Trigger"&&n.data.disabled!==!0){let o=new pS(n.id,n.data,s,this.page,this.sharedAssets,this.eventManager),l;if(n.data.triggerZone==="box"?l=pt.ColliderDesc.cuboid(...n.data.size.map(h=>h/(2*this.pixelsPerMeter))):l=pt.ColliderDesc.ball(n.data.radius/this.pixelsPerMeter),l.setDensity(0).setSensor(!0).setActiveEvents(pt.ActiveEvents.COLLISION_EVENTS),as.fromArray(n.data.position),Qo.setFromEuler(fS.fromArray(n.data.rotation)),cu.compose(as,Qo,Jm).premultiply(s.matrixWorld),i?(cu.decompose(as,Qo,Km),l.setActiveCollisionTypes(pt.ActiveCollisionTypes.KINEMATIC_FIXED|pt.ActiveCollisionTypes.DYNAMIC_FIXED)):(cu.premultiply(r).decompose(as,Qo,Km),e.rigidBody.bodyType()===pt.RigidBodyType.Dynamic||(e.rigidBody.bodyType()===pt.RigidBodyType.Fixed?l.setActiveCollisionTypes(pt.ActiveCollisionTypes.KINEMATIC_FIXED|pt.ActiveCollisionTypes.DYNAMIC_FIXED):l.setActiveCollisionTypes(pt.ActiveCollisionTypes.KINEMATIC_KINEMATIC|pt.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),as.divideScalar(this.pixelsPerMeter),l.setTranslation(as.x,as.y,as.z),l.setRotation(Qo),i)i.push([l,o]);else{let h=this.sharedGameControlGlobals.rapierWorld.createCollider(l,e.rigidBody);this.sensorToTriggerEvent[h.handle]=o}}})}checkTrigger(){let e;for(let t=0;t<this.sharedGameControlGlobals.triggers.length;t++){let[i,r,s,a]=this.sharedGameControlGlobals.triggers[t];for(let n=0;n<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;n++){let o=this.sharedGameControlGlobals.entitiesWithTransformAnim[n];if(s===o||a.isValidTriggeringObject(ut.is(o)?o:o.object)===!1)continue;let l=mS.copy(s.matrixWorld).decompose(as,gS,Km).compose(as,gS,Jm).multiply(r),h=cu.copy(o.matrixWorld).invert().multiply(l);i instanceof $t?e=o.bvhGeometry.boundsTree.intersectsBox(i,h):($m.radius=i,$m.center.setFromMatrixPosition(h),e=o.bvhGeometry.boundsTree.intersectsSphere($m)),e?a.currentIntersectedObjects.indexOf(o)===-1&&(a.currentIntersectedObjects.push(o),a.dispatch(),s.dispatchEvent(UX)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(d=>d!==o)}}}};function jX(e){let t=this._clip.duration,i=this._clip.start??0,r=this.loop,s=this.time+e,a=this._loopCount,n=r===Wv;if(e===0)return a===-1?s:n&&(a&1)===1?t-(s-i):s;if(r===ES){a===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(s>=t)s=t;else if(s<0)s=0;else{this.time=s;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(a===-1&&(e>=0?(a=0,this._setEndings(!0,this.repetitions===0,n)):this._setEndings(this.repetitions===0,!0,n)),s>=t||s<i){let o=Math.floor((s-i)/(t-i));s-=(t-i)*o,a+=Math.abs(o);let l=this.repetitions-a;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n||(s=e>0?t:i,this.repetitions===1&&(s=t)),this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){let h=e<0;this._setEndings(h,!h,n)}else this._setEndings(!1,!1,n);this._loopCount=a,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=s;if(n&&(a&1)===1)return t-(s-i)}return s}var vS=!1,GX=class{constructor(e,t,i,r){this.scene=e,this.requestRender=t,this.updateDisplayProgress=i,this.animationInspectorState=r,this.clipIdToAction={},this.activeClip=null,this.needsUpdate=!1,this.addClip=s=>{s.data.type==="Empty"&&s.data.animations&&s.data.animations.forEach((a,n)=>{let o=a[0]+"/";if(Array.isArray(s.identity)?o+=s.identity[0]:o+=s.uuid,this.clipIdToAction[o])return;let l=ug.parse(JSON.parse(a[2]));s.animations[n]=l;let h=this.mixer.clipAction(l,s);vS===!1&&(Object.getPrototypeOf(h)._updateTime=jX,vS=!0),h.clampWhenFinished=!0,this.clipIdToAction[o]=h})},this.mixer=new s4(e),this.scene.traverseEntity(this.addClip)}deleteClip(e,t){let i=this.scene.find(t);if(!i)return;let r=i.animations.find(a=>a.uuid===e);if(!r)return;let s=this.clipIdToAction[e];!s||(s.stop(),this.mixer.uncacheClip(r),delete this.clipIdToAction[e],i.animations=i.animations.filter(a=>a.uuid!==e))}get isPlaying(){return Object.values(this.clipIdToAction).some(e=>e.isRunning())}playFromInspector(e){this.mixer.stopAllAction();let t=this.clipIdToAction[e];!t||(t.play(),this.activeClip=t.getClip(),this.requestRender())}onExitPlayMode(){Object.values(this.clipIdToAction).forEach(e=>{e.repetitions=1/0,e.loop=CS}),this.mixer.stopAllAction(),this.requestRender()}play(e){let t=e.clipId+"/"+e.object,i=this.clipIdToAction[t];if(i)return e&&(e.repeat>=0&&(i.repetitions=e.repeat+1),e.direction==="pingpong"&&e.repeat!==0&&(i.loop=Wv)),i.play(),i.paused=!1,this.requestRender(),i}resumeFromInspector(e){let t=this.clipIdToAction[e];!t||(t.play(),t.paused=!1,this.requestRender())}pauseFromInspector(e){let t=this.clipIdToAction[e];!t||(t.paused=!0)}stop(){this.mixer.stopAllAction(),this.requestRender()}update(e){if(this.needsUpdate)this.needsUpdate=!1;else if(this.isPlaying===!1||this.animationInspectorState?.isScrubbing)return;this.mixer.update(e/1e3),this.activeClip&&this.updateDisplayProgress(Math.round(this.mixer.time/this.activeClip.duration*this.maxFrames%this.maxFrames)),this.requestRender()}get maxFrames(){return this.activeClip?.tracks[0]?.times.length??0}setProgressFromInspector(e,t){if(!this.clipIdToAction[t])return;this.activeClip!==this.clipIdToAction[t].getClip()&&this.playFromInspector(t);let i=this.clipIdToAction[t].paused;this.clipIdToAction[t].paused=!1,this.mixer.setTime(Math.min(this.maxFrames?e/this.maxFrames:0,.9999)*this.activeClip.duration),this.requestRender(),i&&(this.clipIdToAction[t].paused=!0)}},eg=new WeakMap,HX=class extends a0{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,r){let s=new pg(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.decodeDracoFile(a,t).catch(r)},i,r)}decodeDracoFile(e,t,i,r){let s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!i};return this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(eg.has(e)){let o=eg.get(e);if(o.key===i)return o.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r,s=this.workerNextTaskID++,a=e.byteLength,n=this._getWorker(s,a).then(o=>(r=o,new Promise((l,h)=>{r._callbacks[s]={resolve:l,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(o=>this._createGeometry(o.geometry));return n.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),eg.set(e,{key:i,promise:n}),n}_createGeometry(e){let t=new Ue;e.index&&t.setIndex(new Ke(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let r=e.attributes[i],s=r.name,a=r.array,n=r.itemSize;t.setAttribute(s,new Ke(a,n))}return t}_loadLibrary(e,t){let i=new pg(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((r,s)=>{i.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(i=>{let r=i[0];e||(this.decoderConfig.wasmBinary=i[1]);let s=WX.toString(),a=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
6305
- `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function WX(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(d){e.onModuleLoaded=function(c){d({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(d=>{let c=d.draco,u=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,u,p,h),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(u)}});break}};function i(n,o,l,h){let d=h.attributeIDs,c=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)u=new n.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===n.POINT_CLOUD)u=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in d){let v=self[c[g]],y,x;if(h.useUniqueIDs)x=d[g],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,n[d[g]]),x===-1)continue;y=o.GetAttribute(u,x)}m.attributes.push(s(n,o,u,g,v,y))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,u)),n.destroy(u),m}function r(n,o,l){let h=l.num_faces()*3,d=h*4,c=n._malloc(d);o.GetTrianglesUInt32Array(l,d,c);let u=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:u,itemSize:1}}function s(n,o,l,h,d,c){let u=c.num_components(),p=l.num_points()*u,f=p*d.BYTES_PER_ELEMENT,m=a(n,d),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,g);let v=new d(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:u}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var an;function qX(){return an||(an=new HX,an.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),an.decoderPending}async function XX(e){if(an){let t={attributeIDs:an.defaultAttributeIDs,attributeTypes:an.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await an.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function YX(e,t){let[i,r]=o2(Ig.deserialize(new Uint8Array(e)));L2(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await qX();for(let a of s){let n=await XX(oi(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:d})=>{o[l]={array:h,itemSize:d,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var QX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=rr(i,t.actions,s,a,n,r)}disconnect(){Mi(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},ZX=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=Bg.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())}),this.eventContext.updateDomRect()},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i),e.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length))for(let{data:s}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:a,id:n})=>{try{let o=new QX(n,a,s,r,e,t,this.eventManager);this.breakpoints.push(o)}catch{}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},yS=Object.keys(JE).filter(e=>isNaN(Number(e))),KX=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=a=>{(a.touches.length>1||this.preventTouchScroll)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new Fq(this.eventContext),DynamicVariable:new yX(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new Xq(this.eventContext,this),Start:new gX(this.eventContext,this),Basic:new jq(this.eventContext,this,this.needsRaycast),MouseHover:new dX(this.eventContext,this),Scroll:new fX(this.eventContext,this),Follow:new rX(this.eventContext,this),DragDrop:new Jq(this.eventContext,this),LookAt:new lX(this.eventContext),Resize:new ZX(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),yS.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),yS.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},JX=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new k().copy(i),this._editorSize=new k().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=$X(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function $X(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var eY=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new $0(e.shared,t),this.scene=new ly(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof dn&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof er&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},tY=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 iY(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 dc(e){return e instanceof Tc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function rY(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof yr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof yr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Fi.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Fi.isMergable(l.material))return;a=Fi.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][dc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][dc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][dc(r)].push(l)}),i}function sY(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 aY(e,t){let i=rY(t,e),r=sY(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof yr&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&iY(n[g]);let m=Hn(n.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new ur(m,l[0].material);break}default:{g=new ur(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof yr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][dc(x)]&&i[x.material.uuid][dc(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[a++]=x}}}for(let u=0;u<a;u++)s[u].removeFromParent()}var nY=gn(WC(),1),oY=new k;function lY(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 _y=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=oY.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=E0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new tY({x:10,y:10})),BF(e)}async load(e,t,i){lY(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await YX(e);this._data=r,r.version&&(0,nY.default)(r.version,"0.9.496")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([o_(r)&&gj(),nH(r)&&pj(),Sc.physicsEnabled(r.scene.objects)&&FF(),t_(r)&&qG(),PX(r)&&kF()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new eY(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();aY(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}o_(r)&&this._scene.traverse(o=>{Us(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof ds&&o.pendingMediaLoad&&o.update()})});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),t_(r)&&FX(r)&&await Promise.all(a),this._scene.rewriteEventsBeforeGoToPlayMode(),by(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new B7({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new JX(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new kq(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new VX(o),this._animationControls=new GX(this._scene,this._requestRenderAutoMode),this._eventManager=new KX(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Dr.isTextValue(e)?Dr.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==rh&&!this._scene.isInvisibleObjects(t)&&!(t instanceof dn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof iC&&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},a=new gr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{Ex.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),zF(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof dn&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof dn||e instanceof ly?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Ex(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var Hp=window,Wp=Hp.ShadowRoot&&(Hp.ShadyCSS===void 0||Hp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Sy=Symbol(),rC=new WeakMap,Hc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Sy)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(Wp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=rC.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&rC.set(i,t))}return t}toString(){return this.cssText}},sC=e=>new Hc(typeof e=="string"?e:e+"",void 0,Sy),Ay=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new Hc(i,e,Sy)},My=(e,t)=>{Wp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Hp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},qp=Wp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return sC(i)})(e):e;var Ey,Xp=window,aC=Xp.trustedTypes,hY=aC?aC.emptyScript:"",nC=Xp.reactiveElementPolyfillSupport,Ty={toAttribute(e,t){switch(t){case Boolean:e=e?hY: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}},oC=(e,t)=>t!==e&&(t==t||e==e),Cy={attribute:!0,type:String,converter:Ty,reflect:!1,hasChanged:oC},Ia=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=Cy){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 a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Cy}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(qp(s))}else t!==void 0&&i.push(qp(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 My(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=Cy){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Ty).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:Ty;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||oC)(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,a)=>this[a]=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 a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.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){}};Ia.finalized=!0,Ia.elementProperties=new Map,Ia.elementStyles=[],Ia.shadowRootOptions={mode:"open"},nC?.({ReactiveElement:Ia}),((Ey=Xp.reactiveElementVersions)!==null&&Ey!==void 0?Ey:Xp.reactiveElementVersions=[]).push("1.6.0");var Py,Yp=window,lh=Yp.trustedTypes,lC=lh?lh.createPolicy("lit-html",{createHTML:e=>e}):void 0,bn=`lit$${(Math.random()+"").slice(9)}$`,mC="?"+bn,cY=`<${mC}>`,hh=document,qc=(e="")=>hh.createComment(e),Xc=e=>e===null||typeof e!="object"&&typeof e!="function",gC=Array.isArray,dY=e=>gC(e)||typeof e?.[Symbol.iterator]=="function",Wc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,hC=/-->/g,cC=/>/g,fo=RegExp(`>|[
6305
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){let a=s.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}};function WX(){let e,t;onmessage=function(n){let o=n.data;switch(o.type){case"init":e=o.decoderConfig,t=new Promise(function(d){e.onModuleLoaded=function(c){d({draco:c})},DracoDecoderModule(e)});break;case"decode":let l=o.buffer,h=o.taskConfig;t.then(d=>{let c=d.draco,u=new c.Decoder,p=new c.DecoderBuffer;p.Init(new Int8Array(l),l.byteLength);try{let f=i(c,u,p,h),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:o.id,error:f.message})}finally{c.destroy(p),c.destroy(u)}});break}};function i(n,o,l,h){let d=h.attributeIDs,c=h.attributeTypes,u,p,f=o.GetEncodedGeometryType(l);if(f===n.TRIANGULAR_MESH)u=new n.Mesh,p=o.DecodeBufferToMesh(l,u);else if(f===n.POINT_CLOUD)u=new n.PointCloud,p=o.DecodeBufferToPointCloud(l,u);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||u.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());let m={index:null,attributes:[]};for(let g in d){let v=self[c[g]],y,x;if(h.useUniqueIDs)x=d[g],y=o.GetAttributeByUniqueId(u,x);else{if(x=o.GetAttributeId(u,n[d[g]]),x===-1)continue;y=o.GetAttribute(u,x)}m.attributes.push(s(n,o,u,g,v,y))}return f===n.TRIANGULAR_MESH&&(m.index=r(n,o,u)),n.destroy(u),m}function r(n,o,l){let h=l.num_faces()*3,d=h*4,c=n._malloc(d);o.GetTrianglesUInt32Array(l,d,c);let u=new Uint32Array(n.HEAPF32.buffer,c,h).slice();return n._free(c),{array:u,itemSize:1}}function s(n,o,l,h,d,c){let u=c.num_components(),p=l.num_points()*u,f=p*d.BYTES_PER_ELEMENT,m=a(n,d),g=n._malloc(f);o.GetAttributeDataArrayForAllPoints(l,c,m,f,g);let v=new d(n.HEAPF32.buffer,g,p).slice();return n._free(g),{name:h,array:v,itemSize:u}}function a(n,o){switch(o){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}var an;function qX(){return an||(an=new HX,an.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),an.decoderPending}async function XX(e){if(an){let t={attributeIDs:an.defaultAttributeIDs,attributeTypes:an.defaultAttributeTypes,useUniqueIDs:!1},i;try{i=await an.decodeGeometry(new Int8Array(e).buffer,t)}catch(r){console.error(r)}if(i)return{index:i.index?{array:i.index.array}:void 0,attributes:Object.entries(i.attributes).map(([r,s])=>({name:r,itemSize:s.itemSize,array:s.array}))}}return null}async function YX(e,t){let[i,r]=o2(Ig.deserialize(new Uint8Array(e)));L2(i);let s=[];i.scene.objects.traverse((a,n)=>{n.type==="Mesh"&&n.geometry.type==="NonParametricGeometry"&&n.geometry.data.draco!==void 0&&s.push(n)}),s.length&&await qX();for(let a of s){let n=await XX(oi(a.geometry.data.draco));if(n){n.index&&(a.geometry.data.index={array:n.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};n.attributes.forEach(({name:l,array:h,itemSize:d})=>{o[l]={array:h,itemSize:d,type:"Float32Array",normalized:!1}}),a.geometry.data.attributes=o,a.geometry.data.draco=void 0}}return t&&t(i),r.result().data}var QX=class{constructor(e,t,i,r,s,a,n){this.id=e,this.data=t,this.dataEvent=i,this.object=r,this.stage=!1,this.actions=rr(i,t.actions,s,a,n,r)}disconnect(){Mi(this.actions)}dispatchIn(){this.actions.Audio.forEach(e=>e.dispatchBasic()),this.actions.Video.forEach(e=>e.dispatchBasic()),this.actions.Create.forEach(e=>e.dispatch()),this.actions.Destroy.forEach(e=>e.dispatch()),this.actions.Reset.forEach(e=>e.dispatch()),this.actions.Link.forEach(e=>e.dispatch()),this.actions.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this,e.init())}),this.actions.Transition.forEach(e=>e.toggle()),this.actions.Animation.forEach(e=>e.play()),this.actions.SwitchCamera.forEach(e=>e.play()),this.actions.SceneTransition.forEach(e=>e.dispatch()),this.actions.SetVariable.forEach(e=>e.checkConditions()),this.actions.SetVariable.forEach(e=>e.dispatch()),this.actions.DynamicVariablePlay.forEach(e=>e.dispatch())}dispatchOut(){this.actions.Transition.forEach(e=>{e.toggle()})}},ZX=class extends ys{constructor(e,t){super(e),this.eventManager=t,this.breakpoints=[],this.resize=(i,r)=>{this.breakpoints.forEach(s=>{let a=Bg.deviceToSize(s.data.size),n=s.dataEvent.orientation==="horizontal"?i:r,o;switch(s.data.operator){case"<":o=n<a[0];break;case">":o=n>a[0];break;case"<>":o=n>a[0]&&n<a[1];break}s.stage!==o&&(s.stage=o,s.stage?s.dispatchIn():s.dispatchOut())}),this.eventContext.updateDomRect()},this.onResizeObserver=new ResizeObserver(i=>{for(let r of i){let{width:s,height:a}=r.contentRect;this.resize(s,a)}})}connect(){let{page:e,sharedAssets:t,domElement:i}=this.eventContext;this.onResizeObserver.observe(i),e.traverseEntity(r=>{if(!(!r.visible||!r.data?.events.length))for(let{data:s}of r.data.events)s.disabled||s.type==="Resize"&&s.breakpoints.forEach(({data:a,id:n})=>{try{let o=new QX(n,a,s,r,e,t,this.eventManager);this.breakpoints.push(o)}catch{}})})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(e=>{e.disconnect()}),this.breakpoints=[]}},yS=Object.keys(JE).filter(e=>isNaN(Number(e))),KX=class{constructor(e,t,i,r,s){this.publish=e,this.controlsManager=t,this.animationControls=i,this.eventContext=r,this.sharedVariables=s,this.isEnabled=!1,this.activateCount=0,this.needsMouse=!1,this.needsRaycast=!1,this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0},this.onTouchMovePreventScroll=a=>{(a.touches.length>1||this.preventTouchScroll)&&a.preventDefault()},this.onMouseWheelPreventScroll=a=>{this.preventScroll&&a.preventDefault()},this.onMouseMove=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:a.buttons>0}},this.onMouseDown=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!0}},this.onMouseUp=a=>{this.eventContext.sharedAssets.mouseProperty={...this.getMousePosition(a),pressed:!1}},this.getMousePosition=a=>{let{domRect:n}=this.eventContext,{pageX:o,pageY:l}=a.touches?.length>0?a.touches[0]:a;return{x:o-(n.left+window.scrollX),y:l-(n.top+window.scrollY)}},this.stopRaycast=e.stopRaycast,this.preventScroll=e.preventScroll,this.preventTouchScroll=e.preventTouchScroll,this.hideCursor=e.hideCursor,this.requestRender=r.requestRender}activate(){if(this.isEnabled)return;this.isEnabled=!0,this.initializeActionsDependentStates(),this.needsMouse&&(this.eventContext.domElement.addEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.addEventListener("pointerdown",this.onMouseDown)),this.handlers={Spline:new Fq(this.eventContext),DynamicVariable:new yX(this.eventContext,this.sharedVariables,this,this.needsMouse,this.needsRaycast),Conditional:new Xq(this.eventContext,this),Start:new gX(this.eventContext,this),Basic:new jq(this.eventContext,this,this.needsRaycast),MouseHover:new dX(this.eventContext,this),Scroll:new fX(this.eventContext,this),Follow:new rX(this.eventContext,this),DragDrop:new Jq(this.eventContext,this),LookAt:new lX(this.eventContext),Resize:new ZX(this.eventContext,this)};let{page:e,domElement:t,eventElement:i}=this.eventContext;this.hideCursor&&(t.style.cursor="none"),e.traverseEntity(r=>{r.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(r=>r.connect()),yS.forEach(r=>{(Object.values(this.handlers).some(s=>s.domEventsNeeded.has(r))||r==="pointerdown"&&this.controlsManager.navigationMeshWrapper)&&(t.addEventListener(r,this.onResetRaycaster),i.addEventListener(r,this.onResetRaycaster))}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll),this.activateCount++}deactivate(){if(!this.isEnabled)return;this.isEnabled=!1,this.eventContext.domElement.removeEventListener("pointermove",this.onMouseMove),this.eventContext.domElement.removeEventListener("pointerdown",this.onMouseDown),this.eventContext.domElement.removeEventListener("pointerup",this.onMouseUp),this.eventContext.sharedAssets.mouseProperty=null,this.eventContext.sharedAssets.raycastProperty=null;let{page:e,domElement:t}=this.eventContext;t.style.cursor="",Object.values(this.handlers).forEach(i=>i.disconnect()),this.controlsManager.gameControl?.disposeActions(),this.controlsManager.disconnectEvents(),e.traverseEntity(i=>{i.removeEventListener("requestRender",this.requestRender),i.destroyedInAction=!1}),yS.forEach(i=>{t.removeEventListener(i,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll),this.animationControls.onExitPlayMode()}get isPaused(){return this.isEnabled}pause(){this.deactivate()}resume(){this.activate()}reset(){this.deactivate(),this.activate(),this.controlsManager.page.updateMatrixWorld(!0),this.controlsManager.rebuildBVH()}updateUseWindowEvents(e){let t=this.isEnabled;t&&this.deactivate(),this.eventContext.useWindowEvents=e,t&&this.activate()}initializeActionsDependentStates(){let e=this.eventContext.sharedAssets;e.resetDynamicVariablePlayState();let t=i=>{if(i.data.type==="Conditional"&&(i.data.ifActions.forEach(t),i.data.elseActions.forEach(t)),i.data.type==="Conditional"||i.data.type==="SetVariable")for(let r of i.data.type==="Conditional"?i.data.condition:i.data.expression)"id"in r&&Array.isArray(r.id)&&(r.id[0]==="mouse"&&(this.needsMouse=!0),r.id[0]==="raycast"&&(this.needsRaycast=!0));i.data.type==="DynamicVariablePlay"&&i.data.variableId!==""&&(i.data.mode==="Play"||i.data.mode==="PlayPause"||i.data.mode==="Toggle")&&e.setDynamicVariablePlayState(i.data.variableId,"Stopped")};this.eventContext.page.traverseEntity(i=>{if(i.data?.events.length){for(let r of i.data.events)if(!r.data.disabled)if(r.data.type==="VariableChange"&&(r.data.variableId==="mouseProperty"&&(this.needsMouse=!0),r.data.variableId==="raycastProperty"&&(this.needsRaycast=!0)),r.data.type==="Conditional")for(let s of["inActions","outActions"])r.data[s].forEach(t);else if(r.data.type==="DragDrop")for(let s of["drag","drop"])r.data.dragDropActions[s].forEach(t);else if(r.data.type==="GameControl")for(let s of["idle","move","jump","run"])r.data.gameActions[s].forEach(t);else if(r.data.type==="Resize")for(let s of r.data.breakpoints)s.data.actions.forEach(t);else r.data.type==="LookAt"||r.data.actions.forEach(t)}})}},JX=class{constructor(e,t,i,r,s){this._aspect=1,this.enableResponsive=!1,this._renderer=e,this._camera=t,this._frameSize=new k().copy(i),this._editorSize=new k().copy(r),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,i=this._editorSize.y;this._aspect=e/t,t<=i&&(this._camera.zoom*=i/t),this._renderer.setViewport(0,0,e,t)}updateCamera(e=!0){if(this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let t=this._frameSize.y,i=this._editorSize.y,r=this._fov;if(e&&t>i){let s=$X(t,1080,2160,1,15)/100;r*=t/i,r*=1-s}this._camera.aspect=this._aspect,this._camera.fov=r,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y,this.enableResponsive)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t,this.enableResponsive),this._camera.updateProjectionMatrix())}};function $X(e,t,i,r,s){return(e-t)/(i-t)*(s-r)+r}var eY=class{get sharedAssets(){return this.shared}constructor(e,t={}){this.shared=new $0(e.shared,t),this.scene=new ly(e.scene,this.sharedAssets),this.shared.setEntityOpContext({scene:this.scene,shared:this.shared})}reset(e,t){this.scene.clearScene(),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}resetPersonalCameraFromDocumentData(){for(let e of this.scene.children)e instanceof dn&&e.personalCamera.updateState(e.data.camera,{scene:this.scene,shared:this.shared})}dispose(){this.scene.dispose(),this.shared.dispose()}gc(){this.shared.geometryCache.startGc(),this.shared.geometryCache2.startGc(),this.scene.traverseEntity(e=>{e instanceof er&&e.markGeometryAsReachable(this.shared)}),this.shared.geometryCache.endGc(),this.shared.geometryCache2.endGc()}},tY=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 iY(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 dc(e){return e instanceof Tc?"SubdivObject":e.geometry.type==="NonParametricGeometry"?"NonParametric":"Mesh"}function rY(e,t){let i={};return e.traverseEntity(r=>{if(!r.visible||!(r instanceof yr)||r.type!=="Mesh"||Array.isArray(r.material)||r.states&&Object.keys(r.states).length)return;let s=r.parent;for(;s;){if(s instanceof yr&&r.states&&Object.keys(r.states).length)return;s=s.parent}let a=r.material.uuid,n=t.shared.materials[a];if(n){if(!Fi.isMergable(n))return}else{let l=t.scene.objects.get(r.uuid)?.data;if(l&&"material"in l&&typeof l.material!="string"){if(!Fi.isMergable(l.material))return;a=Fi.getHash(l.material)}}i[a]||(i[a]={});let o=i[a][dc(r)];if(o){if(o.push(r),r.cloner)for(let l of r.cloner.children)o.push(l)}else if(i[a][dc(r)]=[r],r.cloner)for(let l of r.cloner.children)i[a][dc(r)].push(l)}),i}function sY(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 aY(e,t){let i=rY(t,e),r=sY(i),s=new Array(r),a=0,n=new Array(r),o=0,l=new Array(r),h=0,d=new Array(r),c=0;for(let[u,p]of Object.entries(i))for(let f of Object.values(p)){if(o=0,h=0,f.forEach(g=>{g instanceof yr&&(n[o++]=g.geometry.clone(),l[h++]=g)}),h<2)continue;for(let g=0;g<h;g++)l[g].updateWorldMatrix(!0,!1),n[g].applyMatrix4(l[g].matrixWorld),l[g].matrixWorld.determinant()<0&&iY(n[g]);let m=Hn(n.slice(0,o),!1);if(m){let g;switch(u){case"SubdivObject":{console.warn("Turning subdiv object into mesh"),g=new ur(m,l[0].material);break}default:{g=new ur(m,l[0].material);break}}g.castShadow=l[0].castShadow,g.receiveShadow=l[0].receiveShadow,t.add(g);let v=y=>{c=0;for(let x of y)x.children&&v(x.children),x instanceof yr&&(Array.isArray(x.material)||i[x.material.uuid]&&i[x.material.uuid][dc(x)]&&i[x.material.uuid][dc(x)].length>1||(d[c++]=x));for(let x=0;x<c;x++)t.attach(d[x])};for(let y=0;y<h;y++){let x=l[y];v(x.children),s[a++]=x}}}for(let u=0;u<a;u++)s[u].removeFromParent()}var nY=gn(WC(),1),oY=new k;function lY(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 _y=class{constructor(e,{renderOnDemand:t,renderMode:i="auto"}={}){this._viewportMode=1,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._proxyObjectCache=new Map,this._variablesCache=new Map,this._isPaused=!1,this._renderRequested=!1,this._skipRender=!1,this.time=performance.now(),this.dt=0,this.currentTAAFrame=0,this.disposed=!1,this._requestRenderAutoMode=()=>{this._skipRender=!1},this.requestRender=()=>{this._renderRequested=!0},this.render=r=>{if(this.time=r,this._lastTime&&(this.dt=this.time-this._lastTime),this._lastTime=this.time,this._perfs?.start(),!this._renderer){this._perfs?.end();return}if(!this._isPaused&&(this.renderMode==="manual"&&!this._renderRequested||this.renderMode==="auto"&&this._skipRender)){this._perfs?.end();return}if(this._renderRequested=!1,this._skipRender=!0,this._controls&&(this._skipRender=this._controls.update(this.dt)),this._eventManager&&(this._eventManager.handlers?.Start.hasVideoAction||this._eventManager.handlers?.Basic.hasVideoAction||this._eventManager.handlers?.Conditional.hasVideoAction)&&(this._skipRender=!1),this._animationControls?.update(this.dt),this._skipRender?(this.currentTAAFrame++,this.currentTAAFrame<32?this._skipRender=!1:this.currentTAAFrame=0):this.currentTAAFrame=0,this._scene&&this._scene.activeCamera!==this._camera&&(this._camera=this._scene.activeCamera),this._eventManager?.isEnabled&&((this._eventManager.handlers?.Follow).onAnimationFrameDamping(),(this._eventManager.handlers?.LookAt).onAnimationFrameDamping(),(this._eventManager.handlers?.DragDrop).onAnimationFrameDamping()),this._scene&&this._camera){if(this._scene.pathConstraints.applyConstraints(this._scene),this._renderer.sceneTransitionTimeRemaining>0){this._renderer.sceneTransitionTimeRemaining-=this.dt;let s=1-this._renderer.sceneTransitionTimeRemaining/this._renderer.sceneTransitionDuration;this._renderer.pipeline.sceneTransitionPass.uniforms.mixRatio.value=s,this._skipRender=!1}else this._renderer.pipeline.sceneTransitionFromTexture=null;this._renderer.renderSplineScene(this._scene,this._camera)}this.canvas.dispatchEvent(this._renderedEvent),this._perfs?.end()},this._resize=()=>{if(this._renderer){if(this._viewportMode===1&&this._frameView&&(this._frameView.frameSize=oY.set(this._viewportWidth,this._viewportHeight)),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._camera=this._scene?.activeCamera,this._scene?.updateViewPlaneSize(this._frameView?.frameSize?.x??this._viewportWidth,this._frameView?.frameSize?.y??this._viewportHeight,this._frameView?.enableResponsive??!1),this._camera){let r=Object.values(this._data?.frames??{})[0].preset??"fullscreen";this._frameView?.setCamera(this._camera),this._frameView?.updateCamera(r!=="fullscreen"),this._camera.cameraType==="PerspectiveCamera"&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()}this._requestRenderAutoMode()}},this._debouncedResize=E0(this._resize,10),this.canvas=e,this.renderMode=t?"auto":i,this._renderedEvent=new CustomEvent("rendered",{bubbles:!0}),Object.defineProperty(this._renderedEvent,"target",{writable:!1,value:this}),window.location.search.includes("perfs")&&(this._perfs=new tY({x:10,y:10})),BF(e)}async load(e,t,i){lY(e),this.disposed=!1;let r=await(await fetch(e,i)).arrayBuffer();await this.start(r,{variables:t})}async start(e,{interactive:t=!0,variables:i}={}){if(this.disposed)return;let r=await YX(e);this._data=r,r.version&&(0,nY.default)(r.version,"0.9.497")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/runtime to the latest version."),await Promise.all([o_(r)&&gj(),nH(r)&&pj(),Sc.physicsEnabled(r.scene.objects)&&FF(),t_(r)&&qG(),PX(r)&&kF()].filter(Boolean)),this._eventManager?.deactivate(),this._controls?.deactivate(),this._scene?.dispose();let s=new eY(r);if(s.resetPersonalCameraFromDocumentData(),this._scene=s.scene,this._sharedAssetsManager=s.sharedAssets,this._camera=this._scene.activeCamera,window.location.search.includes("merge-geometries")){let o=performance.now();aY(r,s.scene);let l=performance.now();console.log("Merged geometries in ",l-o," ms")}o_(r)&&this._scene.traverse(o=>{Us(o)&&o.recomputeBoolean()}),this._sharedAssetsManager.setRequestRender(()=>{this._requestRenderAutoMode(),this._scene?.traverse(o=>{o instanceof ds&&o.pendingMediaLoad&&o.update()})});let a=Object.keys(r.shared.fonts).map(o=>this._sharedAssetsManager.getFont(o).loadingPromise);Promise.all(a).then(()=>{s.scene.markNeedsUpdateRendererDirty(),this._requestRenderAutoMode()}),t_(r)&&FX(r)&&await Promise.all(a),this._scene.rewriteEventsBeforeGoToPlayMode(),by(this._scene.activePage,this._sharedAssetsManager),this._renderer||(this._renderer=new B7({canvas:this.canvas,antialias:!1,alpha:!0,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._renderer.hdTransmission=r.scene.publish.hdTransmission===!0,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.pipeline.addEventListener("smaaloaded",this._requestRenderAutoMode)),r.scene.blueNoiseTextureData!==void 0&&this._renderer.pipeline.updateBlueNoiseTexture(r.scene.blueNoiseTextureData);let n=Object.values(r.frames)[0];if(this._frameView?this._frameView.setCamera(this._camera):(n.preset==="fullscreen"?(this._viewportMode=1,this.canvas.style.display="block",this.canvas.parentElement&&(this._viewportWidth=this.canvas.parentElement.clientWidth||300,this.canvas.style.width="100%"),this.canvas.parentElement&&(this._viewportHeight=this.canvas.parentElement.clientHeight||150,this.canvas.style.height="100%")):(this._viewportMode=2,this._viewportWidth=n.size[0],this._viewportHeight=n.size[1],this.canvas.style.width=`${this._viewportWidth}px`,this.canvas.style.height=`${this._viewportHeight}px`),this._renderer.setSize(this._viewportWidth,this._viewportHeight,!1),this._frameView=new JX(this._renderer,this._camera,new k(this._viewportWidth,this._viewportHeight),new k(window.innerWidth,window.innerHeight)),this._frameView.enableResponsive=(n.allowResponsive??!1)&&n.preset==="fullscreen"),t){let o=new kq(this._renderer,this.data.scene.publish,this._scene,()=>this._scene.activeCamera,this._sharedAssetsManager,this._requestRenderAutoMode,!0,n);this._scene.updateMatrixWorld(!0),this._controls=new VX(o),this._animationControls=new GX(this._scene,this._requestRenderAutoMode),this._eventManager=new KX(r.scene.publish,this._controls,this._animationControls,o,r.shared.variables),this._eventManager.activate(),this._controls.activate(this._eventManager)}this._resize(),i!==void 0&&this.setVariables(i),this.dt===0&&(this.render(performance.now()),setTimeout(()=>{this._renderer?.setAnimationLoop(this.render)},0)),this._resizeObserverTimeout=setTimeout(()=>{!this._resizeObserver&&this.canvas.parentElement&&(this._resizeObserver=new ResizeObserver(()=>{this._viewportWidth=this.canvas.clientWidth,this._viewportHeight=this.canvas.clientHeight,this._debouncedResize()}),this._resizeObserver.observe(this.canvas.parentElement))},300)}setVariables(e){if(this._data!==void 0){let t=Object.entries(e);for(let[i,r]of t)this.setVariable(i,r)}}setVariable(e,t){let i=this._getVariableByName(e);if(i&&!("dynamicVariableType"in i.data)){let r=t;typeof i.data.value=="number"?r=typeof t=="number"?t:typeof t=="boolean"?t===!0?1:0:parseFloat(t):typeof i.data.value=="boolean"?r=typeof t=="number"?!!t:typeof t=="boolean"?t:t.toLocaleLowerCase()==="false"?!1:!!t:typeof i.data.value!="string"&&i.data.value.textValue!==void 0&&(r=t.toString());let s=typeof r=="string"?{textValue:r}:r;this._sharedAssetsManager?.updateVariable(i.id,s),this.requestRender(),this._requestRenderAutoMode()}else i===void 0?console.warn(`No variable named ${e} was found in your Spline file. Make sure to create it from Spline editor.`):"dynamicVariableType"in i.data&&console.warn(`Dynamic variables like ${e} cannot be updated from code.`)}getVariables(){let e={};return this._data&&this._data.shared.variables.forEach(t=>{e[t.data.name]===void 0&&(e[t.data.name]=this._getVariableValue(this._sharedAssetsManager.getVariable(t.id)))}),e}getVariable(e){let t=this._getVariableByName(e);if(t){let i=this._sharedAssetsManager.getVariable(t.id);return this._getVariableValue(i)}}_getVariableValue(e){return typeof e!="string"&&Dr.isTextValue(e)?Dr.getDisplayedValue(e):e}_getVariableByName(e){if(this._data){if(this._variablesCache.has(e))return this._variablesCache.get(e);let t=this._data.shared.variables.find(i=>i.data.name===e);return t&&this._variablesCache.set(e,t),t}}findObjectById(e){let t=this._scene?.getObjectByProperty("uuid",e);return this._createProxyObject(t)}findObjectByName(e){let t=this._scene?.getObjectByName(e);return this._createProxyObject(t)}getAllObjects(){let e=[];return this._scene?.traverseEntity(t=>{if(t.uuid!==rh&&!this._scene.isInvisibleObjects(t)&&!(t instanceof dn)){let i=this._createProxyObject(t);i&&e.push(i)}}),e}getSplineEvents(){return(this._eventManager?.handlers?.Spline).splineEvents}emitEvent(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEvent(e)}emitEventReverse(e,t){(this.findObjectById(t)||this.findObjectByName(t))?.emitEventReverse(e)}addEventListener(e,t){this.canvas.addEventListener(e,t)}removeEventListener(e,t){this.canvas.removeEventListener(e,t)}setZoom(e){this._controls?.orbitControls instanceof iC&&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},a=new gr(t,i,r,s);try{a.setStyle(e)}catch{console.error("This is not a valid css color",e)}this._scene?.activePage.setBackgroundColor(a),this._requestRenderAutoMode()}dispose(){this.disposed=!0,this._eventManager?.deactivate(),this._scene?.dispose(),this._sharedAssetsManager?.dispose(),this._proxyObjectCache.forEach(e=>{Ex.unsubscribe(e)}),this._variablesCache.clear(),this._renderer?.setAnimationLoop(null),this._renderer?.dispose(),this._renderer=void 0,this._sharedAssetsManager?.dispose(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeObserverTimeout!==void 0&&clearTimeout(this._resizeObserverTimeout),this.canvas.style.width="",this.canvas.style.height="",this.canvas.removeAttribute("width"),this.canvas.removeAttribute("height"),this._frameView&&(this._frameView=void 0),this._controls?.deactivate(),zF(this.canvas)}get isStopped(){return this._isPaused}stop(){this._isPaused||(this._renderer?.setAnimationLoop(null),this._isPaused=!0,this._eventManager?.pause(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!1))}play(){!this._isPaused||(this._isPaused=!1,this._eventManager?.resume(),this._controls?.orbitControls&&(this._controls.orbitControls.enabled=!0),this._renderer?.setAnimationLoop(this.render))}setGlobalEvents(e){this._eventManager?.updateUseWindowEvents(e)}get data(){return this._data}_createProxyObject(e){if(e==null)return;if(this._proxyObjectCache.has(e.uuid))return this._proxyObjectCache.get(e.uuid);let t;e.traverseAncestors(s=>{s instanceof dn&&(t=s.name)});let i={name:e.name,uuid:e.uuid,visible:e.visible,intensity:e.intensity,position:e.position,rotation:e.rotation,scale:e.scale,type:e.data.type,page:t,parentUuid:e.parent instanceof dn||e instanceof ly?void 0:e.parent?.uuid,emitEvent(s){e.dispatchEvent({type:"userEvent",eventName:s})},emitEventReverse(s){e.dispatchEvent({type:"userEvent",eventName:s,reverse:!0})}},r=Ex(i,(s,a)=>{typeof e[s]!="object"&&Object.getOwnPropertyDescriptor(e,s)?.writable&&(e[s]=a),this._requestRenderAutoMode(),e.updateMatrix()});return this._proxyObjectCache.set(e.uuid,r),r}};var Hp=window,Wp=Hp.ShadowRoot&&(Hp.ShadyCSS===void 0||Hp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Sy=Symbol(),rC=new WeakMap,Hc=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Sy)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(Wp&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=rC.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&rC.set(i,t))}return t}toString(){return this.cssText}},sC=e=>new Hc(typeof e=="string"?e:e+"",void 0,Sy),Ay=(e,...t)=>{let i=e.length===1?e[0]:t.reduce((r,s,a)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+e[a+1],e[0]);return new Hc(i,e,Sy)},My=(e,t)=>{Wp?e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet):t.forEach(i=>{let r=document.createElement("style"),s=Hp.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=i.cssText,e.appendChild(r)})},qp=Wp?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return sC(i)})(e):e;var Ey,Xp=window,aC=Xp.trustedTypes,hY=aC?aC.emptyScript:"",nC=Xp.reactiveElementPolyfillSupport,Ty={toAttribute(e,t){switch(t){case Boolean:e=e?hY: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}},oC=(e,t)=>t!==e&&(t==t||e==e),Cy={attribute:!0,type:String,converter:Ty,reflect:!1,hasChanged:oC},Ia=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=Cy){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 a=this[t];this[i]=s,this.requestUpdate(t,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Cy}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(qp(s))}else t!==void 0&&i.push(qp(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 My(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=Cy){var s;let a=this.constructor._$Ep(t,r);if(a!==void 0&&r.reflect===!0){let n=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:Ty).toAttribute(i,r.type);this._$El=t,n==null?this.removeAttribute(a):this.setAttribute(a,n),this._$El=null}}_$AK(t,i){var r;let s=this.constructor,a=s._$Ev.get(t);if(a!==void 0&&this._$El!==a){let n=s.getPropertyOptions(a),o=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?n.converter:Ty;this._$El=a,this[a]=o.fromAttribute(i,n.type),this._$El=null}}requestUpdate(t,i,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||oC)(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,a)=>this[a]=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 a;return(a=s.hostUpdate)===null||a===void 0?void 0:a.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){}};Ia.finalized=!0,Ia.elementProperties=new Map,Ia.elementStyles=[],Ia.shadowRootOptions={mode:"open"},nC?.({ReactiveElement:Ia}),((Ey=Xp.reactiveElementVersions)!==null&&Ey!==void 0?Ey:Xp.reactiveElementVersions=[]).push("1.6.0");var Py,Yp=window,lh=Yp.trustedTypes,lC=lh?lh.createPolicy("lit-html",{createHTML:e=>e}):void 0,bn=`lit$${(Math.random()+"").slice(9)}$`,mC="?"+bn,cY=`<${mC}>`,hh=document,qc=(e="")=>hh.createComment(e),Xc=e=>e===null||typeof e!="object"&&typeof e!="function",gC=Array.isArray,dY=e=>gC(e)||typeof e?.[Symbol.iterator]=="function",Wc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,hC=/-->/g,cC=/>/g,fo=RegExp(`>|[
6306
6306
  \f\r](?:([^\\s"'>=/]+)([
6307
6307
  \f\r]*=[
6308
6308
  \f\r]*(?:[^